Search in sources :

Example 46 with GraphicsEnvironment

use of java.awt.GraphicsEnvironment in project jdk8u_jdk by JetBrains.

the class CGLSurfaceData method getGC.

public static CGLGraphicsConfig getGC(CPlatformView pView) {
    if (pView != null) {
        return (CGLGraphicsConfig) pView.getGraphicsConfiguration();
    } else {
        // REMIND: this should rarely (never?) happen, but what if
        // default config is not CGL?
        GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice gd = env.getDefaultScreenDevice();
        return (CGLGraphicsConfig) gd.getDefaultConfiguration();
    }
}
Also used : GraphicsDevice(java.awt.GraphicsDevice) GraphicsEnvironment(java.awt.GraphicsEnvironment)

Example 47 with GraphicsEnvironment

use of java.awt.GraphicsEnvironment in project eweb4j-framework by laiweiwei.

the class FileUtil method toBufferedImage.

private static BufferedImage toBufferedImage(Image image) {
    if (image instanceof BufferedImage) {
        return (BufferedImage) image;
    }
    // This code ensures that all the pixels in the image are loaded
    image = new ImageIcon(image).getImage();
    // Determine if the image has transparent pixels; for this method's
    // implementation, see e661 Determining If an Image Has Transparent
    // Pixels
    // boolean hasAlpha = hasAlpha(image);
    // Create a buffered image with a format that's compatible with the
    // screen
    BufferedImage bimage = null;
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    try {
        // Determine the type of transparency of the new buffered image
        int transparency = Transparency.OPAQUE;
        /*
			 * if (hasAlpha) { transparency = Transparency.BITMASK; }
			 */
        // Create the buffered image
        GraphicsDevice gs = ge.getDefaultScreenDevice();
        GraphicsConfiguration gc = gs.getDefaultConfiguration();
        bimage = gc.createCompatibleImage(image.getWidth(null), image.getHeight(null), transparency);
    } catch (HeadlessException e) {
    // The system does not have a screen
    }
    if (bimage == null) {
        // Create a buffered image using the default color model
        int type = BufferedImage.TYPE_INT_RGB;
        // int type = BufferedImage.TYPE_3BYTE_BGR;//by wang
        /*
			 * if (hasAlpha) { type = BufferedImage.TYPE_INT_ARGB; }
			 */
        bimage = new BufferedImage(image.getWidth(null), image.getHeight(null), type);
    }
    // Copy image to buffered image
    Graphics g = bimage.createGraphics();
    // Paint the image onto the buffered image
    g.drawImage(image, 0, 0, null);
    g.dispose();
    return bimage;
}
Also used : Graphics(java.awt.Graphics) ImageIcon(javax.swing.ImageIcon) GraphicsDevice(java.awt.GraphicsDevice) HeadlessException(java.awt.HeadlessException) GraphicsEnvironment(java.awt.GraphicsEnvironment) BufferedImage(java.awt.image.BufferedImage) GraphicsConfiguration(java.awt.GraphicsConfiguration)

Example 48 with GraphicsEnvironment

use of java.awt.GraphicsEnvironment in project bigbluebutton by bigbluebutton.

the class WindowlessFrame method centerOnScreen.

public final void centerOnScreen() {
    Toolkit kit = mLeftBorder.getToolkit();
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gs = ge.getScreenDevices();
    Insets in = kit.getScreenInsets(gs[0].getDefaultConfiguration());
    Dimension d = kit.getScreenSize();
    int maxWidth = (d.width - in.left - in.right);
    int maxHeight = (d.height - in.top - in.bottom);
    setLocation((int) (maxWidth - mOverallSize.width) / 2, (int) (maxHeight - mOverallSize.height) / 2);
}
Also used : GraphicsDevice(java.awt.GraphicsDevice) Insets(java.awt.Insets) Toolkit(java.awt.Toolkit) Dimension(java.awt.Dimension) GraphicsEnvironment(java.awt.GraphicsEnvironment) Point(java.awt.Point) GradientPaint(java.awt.GradientPaint)

Example 49 with GraphicsEnvironment

use of java.awt.GraphicsEnvironment in project google-analytics-java by brsanthu.

the class AwtRequestParameterDiscoverer method discoverParameters.

@Override
public DefaultRequest discoverParameters(GoogleAnalyticsConfig config, DefaultRequest request) {
    super.discoverParameters(config, request);
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    if (isEmpty(request.screenResolution())) {
        Dimension screenSize = toolkit.getScreenSize();
        request.screenResolution(((int) screenSize.getWidth()) + "x" + ((int) screenSize.getHeight()) + ", " + toolkit.getScreenResolution() + " dpi");
    }
    if (isEmpty(request.screenColors())) {
        GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice[] graphicsDevices = graphicsEnvironment.getScreenDevices();
        StringBuilder sb = new StringBuilder();
        for (GraphicsDevice graphicsDevice : graphicsDevices) {
            if (sb.length() != 0) {
                sb.append(", ");
            }
            sb.append(graphicsDevice.getDisplayMode().getBitDepth());
        }
        request.screenColors(sb.toString());
    }
    return request;
}
Also used : GraphicsDevice(java.awt.GraphicsDevice) Toolkit(java.awt.Toolkit) Dimension(java.awt.Dimension) GraphicsEnvironment(java.awt.GraphicsEnvironment)

Example 50 with GraphicsEnvironment

use of java.awt.GraphicsEnvironment in project smile by haifengl.

the class FontChooser method getFontFamilies.

private String[] getFontFamilies() {
    if (fontFamilyNames == null) {
        GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
        fontFamilyNames = env.getAvailableFontFamilyNames();
    }
    return fontFamilyNames;
}
Also used : GraphicsEnvironment(java.awt.GraphicsEnvironment)

Aggregations

GraphicsEnvironment (java.awt.GraphicsEnvironment)93 GraphicsDevice (java.awt.GraphicsDevice)46 GraphicsConfiguration (java.awt.GraphicsConfiguration)44 BufferedImage (java.awt.image.BufferedImage)24 VolatileImage (java.awt.image.VolatileImage)21 Dimension (java.awt.Dimension)17 Graphics2D (java.awt.Graphics2D)17 Point (java.awt.Point)12 Font (java.awt.Font)11 Rectangle (java.awt.Rectangle)11 Insets (java.awt.Insets)7 File (java.io.File)7 Frame (java.awt.Frame)6 Toolkit (java.awt.Toolkit)6 AffineTransform (java.awt.geom.AffineTransform)6 HeadlessException (java.awt.HeadlessException)5 Color (java.awt.Color)3 Container (java.awt.Container)3 DisplayMode (java.awt.DisplayMode)3 GradientPaint (java.awt.GradientPaint)3