use of org.intellij.images.editor.ImageDocument in project intellij-community by JetBrains.
the class ImageComponentUI method paint.
@Override
public void paint(Graphics g, JComponent c) {
ImageComponent ic = (ImageComponent) c;
if (ic != null) {
ImageDocument document = ic.getDocument();
BufferedImage image = document.getValue();
if (image != null) {
if (ic.isFileSizeVisible())
paintBorder(g, ic);
Dimension size = ic.getCanvasSize();
Graphics igc = g.create(2, 2, size.width, size.height);
// Transparency chessboard
if (ic.isTransparencyChessboardVisible() && image.getTransparency() != Transparency.OPAQUE) {
paintChessboard(igc, ic);
}
paintImage(igc, ic);
// Grid
if (ic.isGridVisible()) {
paintGrid(igc, ic);
}
igc.dispose();
}
}
}
use of org.intellij.images.editor.ImageDocument in project intellij-community by JetBrains.
the class ImageComponentUI method paintImage.
private static void paintImage(Graphics g, ImageComponent ic) {
ImageDocument document = ic.getDocument();
Dimension size = ic.getCanvasSize();
Graphics2D g2d = (Graphics2D) g;
RenderingHints oldHints = g2d.getRenderingHints();
BufferedImage image = ic.getDocument().getValue();
Image renderer = document.getValue();
if (size.width > image.getWidth() && size.height > image.getHeight()) {
// disable any kind of source image manipulation when resizing
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
} else {
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
}
g.drawImage(renderer, 0, 0, size.width, size.height, ic);
g2d.setRenderingHints(oldHints);
}
Aggregations