APIdia Launch Partner
Top Description Fields Constructors Methods
sun.java2d

public abstract Class SunGraphicsEnvironment

extends GraphicsEnvironment
implements DisplayChangedListener
Class Inheritance
All Implemented Interfaces
sun.awt.DisplayChangedListener, java.util.EventListener
Known Direct Subclasses
sun.awt.X11GraphicsEnvironment
Imports
java.awt.AWTError, .Color, .Dimension, .Font, .Graphics2D, .GraphicsConfiguration, .GraphicsDevice, .GraphicsEnvironment, .Insets, .Point, .Rectangle, .Toolkit, java.awt.geom.AffineTransform, java.awt.image.BufferedImage, java.awt.peer.ComponentPeer, java.util.Locale, .TreeMap, sun.awt.DisplayChangedListener, .SunDisplayChanger, sun.font.FontManager, .FontManagerFactory, .FontManagerForSGE, sun.java2d.pipe.Region

This is an implementation of a GraphicsEnvironment object for the default local GraphicsEnvironment.
See Also
GraphicsDevice, GraphicsConfiguration

Field Summary

Modifier and TypeField and Description
private static final double
private final Font
defaultFont

Establish the default font to be used by SG2D.

protected SunDisplayChanger
protected GraphicsDevice[]
private static final boolean

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addDisplayChangedListener(DisplayChangedListener client)

Add a DisplayChangeListener to be notified when the display settings are changed.

public Graphics2D
createGraphics(BufferedImage img)

Implements abstract java.awt.GraphicsEnvironment.createGraphics.

Returns a Graphics2D object for rendering into the given BufferedImage.

public void
displayChanged()

Implements sun.awt.DisplayChangedListener.displayChanged.

From the DisplayChangedListener interface; called when the display mode has been changed.

public Font[]
getAllFonts()

Implements abstract java.awt.GraphicsEnvironment.getAllFonts.

Returns all fonts available in this environment.

public String[]
getAvailableFontFamilyNames(Locale requestedLocale)

Implements abstract java.awt.GraphicsEnvironment.getAvailableFontFamilyNames.

Returns an array containing the names of all font families in this GraphicsEnvironment localized for the specified locale.

public String[]
getAvailableFontFamilyNames()

Implements abstract java.awt.GraphicsEnvironment.getAvailableFontFamilyNames.

Returns an array containing the names of all font families in this GraphicsEnvironment localized for the default locale, as returned by Locale.getDefault().

public static double
public GraphicsDevice
getDefaultScreenDevice()

Implements abstract java.awt.GraphicsEnvironment.getDefaultScreenDevice.

Returns the default screen graphics device.

public static FontManagerForSGE
public static Rectangle

Returns:

the bounds of the area covered by this GraphicsConfiguration in device space (pixels)
getGCDeviceBounds
(GraphicsConfiguration
the graphics configuration which bounds are requested
config
)

Returns the bounds of the graphics configuration in device space.

public static GraphicsConfiguration

Returns:

the graphics configuration
getGraphicsConfigurationAtPoint
(GraphicsConfiguration
the default configuration which is checked in the first place
current
,
double
the x coordinate of the given point
x
,
double
the y coordinate of the given point
y
)

Returns the graphics configuration which bounds contain the given point.

protected abstract int

Returns:

the number of screen devices of this graphics environment
getNumScreens
()

Returns the number of screen devices of this graphics environment.

public static double
getScaleFactor(String propertyName)

public synchronized GraphicsDevice[]
getScreenDevices()

Implements abstract java.awt.GraphicsEnvironment.getScreenDevices.

Returns an array of all of the screen devices.

public static Rectangle
getUsableBounds(GraphicsDevice gd)

Return the bounds of a GraphicsDevice, less its screen insets.

public abstract boolean

Returns:

true when the display is local, false for remote displays
isDisplayLocal
()

Returns true when the display is local, false for remote displays.

public boolean

Returns:

true if flip strategy should be used, false otherwise
isFlipStrategyPreferred
(ComponentPeer peer)

Returns true if FlipBufferStrategy with COPIED buffer contents is preferred for this peer's GraphicsConfiguration over BlitBufferStrategy, false otherwise.

public static boolean
protected abstract GraphicsDevice

Returns:

the created screen device
makeScreenDevice
(int
the number of the screen to create
screennum
)

Create and return the screen device with the specified number.

public void
paletteChanged()

Implements sun.awt.DisplayChangedListener.paletteChanged.

Part of the DisplayChangedListener interface: propagate this event to listeners

public void
removeDisplayChangedListener(DisplayChangedListener client)

Remove a DisplayChangeListener from Win32GraphicsEnvironment

public static Point

Returns:

the point which uses device space (pixels)
toDeviceSpace
(int
coordinate in the user's space
x
,
int
coordinate in the user's space
y
)

Converts coordinates from the user's space to the device space using appropriate device transformation.

public static Rectangle

Returns:

the rectangle which uses device space (pixels)
toDeviceSpace
(GraphicsConfiguration
the graphics configuration to be used for transformation
gc
,
int
coordinate in the user's space
x
,
int
coordinate in the user's space
y
,
int
the width in the user's space
w
,
int
the height in the user's space
h
)

Converts coordinates (x, y) and the size (w, h) from the user's space to the device space using passed graphics configuration.

public static Point

Returns:

the point which uses device space (pixels)
toDeviceSpaceAbs
(int
absolute coordinate in the user's space
x
,
int
absolute coordinate in the user's space
y
)

Converts absolute coordinates from the user's space to the device space using appropriate device transformation.

public static Rectangle

Returns:

the rectangle which uses device space (pixels)
toDeviceSpaceAbs
(Rectangle
the rectangle in the user's space
rect
)

Converts the rectangle from the user's space to the device space using appropriate device transformation.

public static Rectangle

Returns:

the rectangle which uses device space (pixels)
toDeviceSpaceAbs
(GraphicsConfiguration
the graphics configuration to be used for transformation
gc
,
int
absolute coordinate in the user's space
x
,
int
absolute coordinate in the user's space
y
,
int
the width in the user's space
w
,
int
the height in the user's space
h
)

Converts absolute coordinates (x, y) and the size (w, h) from the user's space to the device space using passed graphics configuration.

public static Dimension

Returns:

the size in the user's space
toUserSpace
(GraphicsConfiguration
the graphics configuration to be used for transformation
gc
,
int
the width in the device space
w
,
int
the height in the device space
h
)

Converts the size (w, h) from the device space to the user's space using passed graphics configuration.

public static void
Inherited from java.awt.GraphicsEnvironment:
getCenterPointgetLocalGraphicsEnvironmentgetMaximumWindowBoundsisHeadlessisHeadlessInstancepreferLocaleFontspreferProportionalFontsregisterFont

Field Detail

debugScaleback to summary
private static final double debugScale
defaultFontback to summary
private final Font defaultFont

Establish the default font to be used by SG2D.

displayChangerback to summary
protected SunDisplayChanger displayChanger
screensback to summary
protected GraphicsDevice[] screens
uiScaleEnabledback to summary
private static final boolean uiScaleEnabled

Constructor Detail

SunGraphicsEnvironmentback to summary
public SunGraphicsEnvironment()

Method Detail

addDisplayChangedListenerback to summary
public void addDisplayChangedListener(DisplayChangedListener client)

Add a DisplayChangeListener to be notified when the display settings are changed.

createGraphicsback to summary
public Graphics2D createGraphics(BufferedImage img)

Implements abstract java.awt.GraphicsEnvironment.createGraphics.

Returns a Graphics2D object for rendering into the given BufferedImage.

Exceptions
NullPointerException:
if BufferedImage argument is null
displayChangedback to summary
public void displayChanged()

Implements sun.awt.DisplayChangedListener.displayChanged.

From the DisplayChangedListener interface; called when the display mode has been changed.

getAllFontsback to summary
public Font[] getAllFonts()

Implements abstract java.awt.GraphicsEnvironment.getAllFonts.

Returns all fonts available in this environment.

getAvailableFontFamilyNamesback to summary
public String[] getAvailableFontFamilyNames(Locale requestedLocale)

Implements abstract java.awt.GraphicsEnvironment.getAvailableFontFamilyNames.

Doc from java.awt.GraphicsEnvironment.getAvailableFontFamilyNames.

Returns an array containing the names of all font families in this GraphicsEnvironment localized for the specified locale.

Typical usage would be for presentation to a user for selection of a particular family name. An application can then specify this name when creating a font, in conjunction with a style, such as bold or italic, giving the font system flexibility in choosing its own best match among multiple fonts in the same font family.

getAvailableFontFamilyNamesback to summary
public String[] getAvailableFontFamilyNames()

Implements abstract java.awt.GraphicsEnvironment.getAvailableFontFamilyNames.

Doc from java.awt.GraphicsEnvironment.getAvailableFontFamilyNames.

Returns an array containing the names of all font families in this GraphicsEnvironment localized for the default locale, as returned by Locale.getDefault().

Typical usage would be for presentation to a user for selection of a particular family name. An application can then specify this name when creating a font, in conjunction with a style, such as bold or italic, giving the font system flexibility in choosing its own best match among multiple fonts in the same font family.

getDebugScaleback to summary
public static double getDebugScale()
getDefaultScreenDeviceback to summary
public GraphicsDevice getDefaultScreenDevice()

Implements abstract java.awt.GraphicsEnvironment.getDefaultScreenDevice.

Returns the default screen graphics device.

getFontManagerForSGEback to summary
public static FontManagerForSGE getFontManagerForSGE()
getGCDeviceBoundsback to summary
public static Rectangle getGCDeviceBounds(GraphicsConfiguration config)

Returns the bounds of the graphics configuration in device space.

Parameters
config:GraphicsConfiguration

the graphics configuration which bounds are requested

Returns:Rectangle

the bounds of the area covered by this GraphicsConfiguration in device space (pixels)

getGraphicsConfigurationAtPointback to summary
public static GraphicsConfiguration getGraphicsConfigurationAtPoint(GraphicsConfiguration current, double x, double y)

Returns the graphics configuration which bounds contain the given point.

Parameters
current:GraphicsConfiguration

the default configuration which is checked in the first place

x:double

the x coordinate of the given point

y:double

the y coordinate of the given point

Returns:GraphicsConfiguration

the graphics configuration

getNumScreensback to summary
protected abstract int getNumScreens()

Returns the number of screen devices of this graphics environment.

Returns:int

the number of screen devices of this graphics environment

getScaleFactorback to summary
public static double getScaleFactor(String propertyName)
getScreenDevicesback to summary
public synchronized GraphicsDevice[] getScreenDevices()

Implements abstract java.awt.GraphicsEnvironment.getScreenDevices.

Returns an array of all of the screen devices.

getUsableBoundsback to summary
public static Rectangle getUsableBounds(GraphicsDevice gd)

Return the bounds of a GraphicsDevice, less its screen insets. See also java.awt.GraphicsEnvironment.getUsableBounds();

isDisplayLocalback to summary
public abstract boolean isDisplayLocal()

Returns true when the display is local, false for remote displays.

Returns:boolean

true when the display is local, false for remote displays

isFlipStrategyPreferredback to summary
public boolean isFlipStrategyPreferred(ComponentPeer peer)

Returns true if FlipBufferStrategy with COPIED buffer contents is preferred for this peer's GraphicsConfiguration over BlitBufferStrategy, false otherwise. The reason FlipBS could be preferred is that in some configurations an accelerated copy to the screen is supported (like Direct3D 9)

Returns:boolean

true if flip strategy should be used, false otherwise

isUIScaleEnabledback to summary
public static boolean isUIScaleEnabled()
makeScreenDeviceback to summary
protected abstract GraphicsDevice makeScreenDevice(int screennum)

Create and return the screen device with the specified number. The device with number 0 will be the default device (returned by getDefaultScreenDevice().

Parameters
screennum:int

the number of the screen to create

Returns:GraphicsDevice

the created screen device

paletteChangedback to summary
public void paletteChanged()

Implements sun.awt.DisplayChangedListener.paletteChanged.

Part of the DisplayChangedListener interface: propagate this event to listeners

removeDisplayChangedListenerback to summary
public void removeDisplayChangedListener(DisplayChangedListener client)

Remove a DisplayChangeListener from Win32GraphicsEnvironment

toDeviceSpaceback to summary
public static Point toDeviceSpace(int x, int y)

Converts coordinates from the user's space to the device space using appropriate device transformation.

Parameters
x:int

coordinate in the user's space

y:int

coordinate in the user's space

Returns:Point

the point which uses device space (pixels)

toDeviceSpaceback to summary
public static Rectangle toDeviceSpace(GraphicsConfiguration gc, int x, int y, int w, int h)

Converts coordinates (x, y) and the size (w, h) from the user's space to the device space using passed graphics configuration.

Parameters
gc:GraphicsConfiguration

the graphics configuration to be used for transformation

x:int

coordinate in the user's space

y:int

coordinate in the user's space

w:int

the width in the user's space

h:int

the height in the user's space

Returns:Rectangle

the rectangle which uses device space (pixels)

toDeviceSpaceAbsback to summary
public static Point toDeviceSpaceAbs(int x, int y)

Converts absolute coordinates from the user's space to the device space using appropriate device transformation.

Parameters
x:int

absolute coordinate in the user's space

y:int

absolute coordinate in the user's space

Returns:Point

the point which uses device space (pixels)

toDeviceSpaceAbsback to summary
public static Rectangle toDeviceSpaceAbs(Rectangle rect)

Converts the rectangle from the user's space to the device space using appropriate device transformation.

Parameters
rect:Rectangle

the rectangle in the user's space

Returns:Rectangle

the rectangle which uses device space (pixels)

toDeviceSpaceAbsback to summary
public static Rectangle toDeviceSpaceAbs(GraphicsConfiguration gc, int x, int y, int w, int h)

Converts absolute coordinates (x, y) and the size (w, h) from the user's space to the device space using passed graphics configuration.

Parameters
gc:GraphicsConfiguration

the graphics configuration to be used for transformation

x:int

absolute coordinate in the user's space

y:int

absolute coordinate in the user's space

w:int

the width in the user's space

h:int

the height in the user's space

Returns:Rectangle

the rectangle which uses device space (pixels)

toUserSpaceback to summary
public static Dimension toUserSpace(GraphicsConfiguration gc, int w, int h)

Converts the size (w, h) from the device space to the user's space using passed graphics configuration.

Parameters
gc:GraphicsConfiguration

the graphics configuration to be used for transformation

w:int

the width in the device space

h:int

the height in the device space

Returns:Dimension

the size in the user's space

useAlternateFontforJALocalesback to summary
public static void useAlternateFontforJALocales()

Deprecated

Annotations
@Deprecated