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();
}
}
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);
}
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();
}
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;
}
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;
}
}
Aggregations