Search in sources :

Example 46 with GraphicsConfiguration

use of java.awt.GraphicsConfiguration in project spf4j by zolyfarkas.

the class StackPanelBase method paintComponent.

@Override
public final void paintComponent(final Graphics g) {
    super.paintComponent(g);
    Dimension size = getSize();
    Insets insets = getInsets();
    Rectangle2D available = new Rectangle2D.Double(insets.left, insets.top, size.getWidth() - insets.left - insets.right, size.getHeight() - insets.top - insets.bottom);
    Graphics2D g2 = (Graphics2D) g.create();
    try {
        double rowHeight = g2.getFont().getStringBounds("ROOT", g2.getFontRenderContext()).getHeight();
        GraphicsConfiguration gc = g2.getDeviceConfiguration();
        BufferedImage img = gc.createCompatibleImage((int) available.getWidth(), (int) available.getHeight(), Transparency.TRANSLUCENT);
        double width = available.getWidth();
        samplesRTree.clear();
        Graphics2D gr = img.createGraphics();
        gr.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        int height = paint(gr, width, rowHeight);
        g2.drawImage(img, insets.left, insets.top, this);
        final Dimension dimension = new Dimension((int) size.getWidth(), height + 10);
        setPreferredSize(dimension);
        setSize(dimension);
    } finally {
        g2.dispose();
    }
}
Also used : Insets(java.awt.Insets) Rectangle2D(java.awt.geom.Rectangle2D) Dimension(java.awt.Dimension) BufferedImage(java.awt.image.BufferedImage) Point(java.awt.Point) Graphics2D(java.awt.Graphics2D) GraphicsConfiguration(java.awt.GraphicsConfiguration)

Example 47 with GraphicsConfiguration

use of java.awt.GraphicsConfiguration in project cytoscape-impl by cytoscape.

the class CreditScreen method centerDialogSize.

protected void centerDialogSize(JDialog dialog) {
    Dimension screen_size = Toolkit.getDefaultToolkit().getScreenSize();
    GraphicsConfiguration configuration = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
    Insets screen_insets = Toolkit.getDefaultToolkit().getScreenInsets(configuration);
    screen_size.width -= screen_insets.left;
    screen_size.width -= screen_insets.right;
    screen_size.height -= screen_insets.top;
    screen_size.height -= screen_insets.bottom;
    Dimension frame_size = dialog.getSize();
    frame_size.width = (int) (screen_size.width * .75);
    frame_size.height = (int) (screen_size.height * .75);
    dialog.setSize(frame_size);
}
Also used : Insets(java.awt.Insets) Dimension(java.awt.Dimension) GraphicsConfiguration(java.awt.GraphicsConfiguration)

Example 48 with GraphicsConfiguration

use of java.awt.GraphicsConfiguration in project cytoscape-impl by cytoscape.

the class BirdsEyeView method updateSubgraph.

public void updateSubgraph(List<CyNode> nodes, List<CyEdge> edges) {
    // System.out.println("BirdsEyeView: updateSubgraph with "+nodes.size()+" nodes and "+edges.size()+" edges");
    try {
        if (networkImage == null) {
            // System.out.println("BirdsEyeView: updateSubgraph creating network image");
            final GraphicsConfiguration gc = getGraphicsConfiguration();
            if (gc != null)
                networkImage = gc.createCompatibleVolatileImage(imageWidth, imageHeight, VolatileImage.OPAQUE);
        }
        // Now draw the network
        viewModel.drawSnapshot(networkImage, new BirdsEyeViewLOD(viewModel.getGraphLOD()), viewModel.getBackgroundPaint(), m_extents[0], m_extents[1], m_myXCenter, m_myYCenter, m_myScaleFactor, nodes, edges);
    } catch (Exception e) {
        logger.error("Error updating subgraph", e);
    }
    boundChanged = false;
    imageUpdated = false;
    imageDirty = true;
    repaint();
}
Also used : GraphicsConfiguration(java.awt.GraphicsConfiguration)

Example 49 with GraphicsConfiguration

use of java.awt.GraphicsConfiguration in project Spark by igniterealtime.

the class GraphicUtils method getScreenBounds.

/**
 * Returns the ScreenBounds
 *
 * @return Array of {@link Rectangle}'s
 */
public static Rectangle[] getScreenBounds() {
    GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
    final GraphicsDevice[] screenDevices = graphicsEnvironment.getScreenDevices();
    Rectangle[] screenBounds = new Rectangle[screenDevices.length];
    for (int i = 0; i < screenDevices.length; i++) {
        GraphicsDevice screenDevice = screenDevices[i];
        final GraphicsConfiguration defaultConfiguration = screenDevice.getDefaultConfiguration();
        screenBounds[i] = defaultConfiguration.getBounds();
    }
    return screenBounds;
}
Also used : GraphicsDevice(java.awt.GraphicsDevice) Rectangle(java.awt.Rectangle) GraphicsEnvironment(java.awt.GraphicsEnvironment) Point(java.awt.Point) GraphicsConfiguration(java.awt.GraphicsConfiguration)

Example 50 with GraphicsConfiguration

use of java.awt.GraphicsConfiguration in project blue by kunstmusik.

the class BumpBuffer method paintIcon.

@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
    GraphicsConfiguration gc = (g instanceof Graphics2D) ? ((Graphics2D) g).getDeviceConfiguration() : null;
    buffer = getBuffer(gc, topColor, shadowColor, backColor);
    int bufferWidth = buffer.getImageSize().width;
    int bufferHeight = buffer.getImageSize().height;
    int iconWidth = getIconWidth();
    int iconHeight = getIconHeight();
    int x2 = x + iconWidth;
    int y2 = y + iconHeight;
    int savex = x;
    while (y < y2) {
        int h = Math.min(y2 - y, bufferHeight);
        for (x = savex; x < x2; x += bufferWidth) {
            int w = Math.min(x2 - x, bufferWidth);
            g.drawImage(buffer.getImage(), x, y, x + w, y + h, 0, 0, w, h, null);
        }
        y += bufferHeight;
    }
}
Also used : GraphicsConfiguration(java.awt.GraphicsConfiguration) Graphics2D(java.awt.Graphics2D)

Aggregations

GraphicsConfiguration (java.awt.GraphicsConfiguration)134 GraphicsEnvironment (java.awt.GraphicsEnvironment)55 BufferedImage (java.awt.image.BufferedImage)46 Rectangle (java.awt.Rectangle)43 GraphicsDevice (java.awt.GraphicsDevice)38 Graphics2D (java.awt.Graphics2D)33 VolatileImage (java.awt.image.VolatileImage)31 Point (java.awt.Point)29 Dimension (java.awt.Dimension)21 Insets (java.awt.Insets)16 File (java.io.File)16 Graphics (java.awt.Graphics)13 IOException (java.io.IOException)13 Frame (java.awt.Frame)11 JFrame (javax.swing.JFrame)8 HeadlessException (java.awt.HeadlessException)7 Window (java.awt.Window)7 ImageIcon (javax.swing.ImageIcon)7 Color (java.awt.Color)6 AffineTransform (java.awt.geom.AffineTransform)6