use of java.awt.GraphicsConfiguration in project processing by processing.
the class EditorState method defaultConfig.
GraphicsConfiguration defaultConfig() {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice device = ge.getDefaultScreenDevice();
GraphicsConfiguration config = device.getDefaultConfiguration();
// deviceName = device.getIDstring();
deviceBounds = config.getBounds();
return config;
}
use of java.awt.GraphicsConfiguration in project processing by processing.
the class EditorState method checkConfig.
/**
* Returns a GraphicsConfiguration so that a new Editor Frame can be
* constructed. First tries to match the bounds for this state information
* to an existing config (nominally, a display) and if that doesn't work,
* then returns the default configuration/default display.
*/
GraphicsConfiguration checkConfig() {
if (deviceBounds != null) {
GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] screenDevices = graphicsEnvironment.getScreenDevices();
for (GraphicsDevice device : screenDevices) {
GraphicsConfiguration[] configurations = device.getConfigurations();
for (GraphicsConfiguration config : configurations) {
// if (config.getDevice().getIDstring().equals(deviceName)) {
if (config.getBounds().equals(deviceBounds)) {
return config;
}
}
}
}
// otherwise go to the default config
return defaultConfig();
}
use of java.awt.GraphicsConfiguration in project processing by processing.
the class PSurfaceAWT method getDisplaySpan.
//public void initImage(PGraphics gr, int wide, int high) {
/*
@Override
public void initImage(PGraphics graphics) {
GraphicsConfiguration gc = canvas.getGraphicsConfiguration();
// If not realized (off-screen, i.e the Color Selector Tool), gc will be null.
if (gc == null) {
System.err.println("GraphicsConfiguration null in initImage()");
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
gc = ge.getDefaultScreenDevice().getDefaultConfiguration();
}
// Formerly this was broken into separate versions based on offscreen or
// not, but we may as well create a compatible image; it won't hurt, right?
int wide = graphics.width * graphics.pixelFactor;
int high = graphics.height * graphics.pixelFactor;
graphics.image = gc.createCompatibleImage(wide, high);
}
*/
// @Override
// public Component getComponent() {
// return canvas;
// }
// @Override
// public void setSmooth(int level) {
// }
/*
private boolean checkRetina() {
if (PApplet.platform == PConstants.MACOSX) {
// This should probably be reset each time there's a display change.
// A 5-minute search didn't turn up any such event in the Java 7 API.
// Also, should we use the Toolkit associated with the editor window?
final String javaVendor = System.getProperty("java.vendor");
if (javaVendor.contains("Oracle")) {
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice device = env.getDefaultScreenDevice();
try {
Field field = device.getClass().getDeclaredField("scale");
if (field != null) {
field.setAccessible(true);
Object scale = field.get(device);
if (scale instanceof Integer && ((Integer)scale).intValue() == 2) {
return true;
}
}
} catch (Exception ignore) { }
}
}
return false;
}
*/
/** Get the bounds rectangle for all displays. */
static Rectangle getDisplaySpan() {
Rectangle bounds = new Rectangle();
GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
for (GraphicsDevice device : environment.getScreenDevices()) {
for (GraphicsConfiguration config : device.getConfigurations()) {
Rectangle2D.union(bounds, config.getBounds(), bounds);
}
}
return bounds;
}
use of java.awt.GraphicsConfiguration in project jdk8u_jdk by JetBrains.
the class FontPanel method getDefaultLCDContrast.
static Integer getDefaultLCDContrast() {
if (defaultContrast == null) {
GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
Graphics2D g2d = (Graphics2D) (gc.createCompatibleImage(1, 1).getGraphics());
defaultContrast = (Integer) g2d.getRenderingHint(RenderingHints.KEY_TEXT_LCD_CONTRAST);
}
return defaultContrast;
}
use of java.awt.GraphicsConfiguration in project jdk8u_jdk by JetBrains.
the class TranslucentWindowPainter method createInstance.
/**
* Creates an instance of the painter for particular peer.
*/
public static TranslucentWindowPainter createInstance(WWindowPeer peer) {
GraphicsConfiguration gc = peer.getGraphicsConfiguration();
if (!forceSW && gc instanceof AccelGraphicsConfig) {
String gcName = gc.getClass().getSimpleName();
AccelGraphicsConfig agc = (AccelGraphicsConfig) gc;
// (those have higher transfer rate from gpu to cpu)
if ((agc.getContextCapabilities().getCaps() & CAPS_PS30) != 0 || forceOpt) {
// a pipeline isn't enabled
if (gcName.startsWith("D3D")) {
return new VIOptD3DWindowPainter(peer);
} else if (forceOpt && gcName.startsWith("WGL")) {
// unless forced
return new VIOptWGLWindowPainter(peer);
}
}
}
return new BIWindowPainter(peer);
}
Aggregations