use of org.jdesktop.swingx.graphics.ShadowRenderer in project intellij-community by JetBrains.
the class ShadowBorderPainter method createShadow.
public static Shadow createShadow(Image source, int x, int y, boolean paintSource, int shadowSize) {
source = ImageUtil.toBufferedImage(source);
final float w = source.getWidth(null);
final float h = source.getHeight(null);
float ratio = w / h;
float deltaX = shadowSize;
float deltaY = shadowSize / ratio;
final Image scaled = source.getScaledInstance((int) (w + deltaX), (int) (h + deltaY), Image.SCALE_SMOOTH);
final BufferedImage s = GraphicsUtilities.createCompatibleTranslucentImage(scaled.getWidth(null), scaled.getHeight(null));
final Graphics2D graphics = (Graphics2D) s.getGraphics();
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
graphics.drawImage(scaled, 0, 0, null);
final BufferedImage shadow = new ShadowRenderer(shadowSize, .25f, Gray.x00).createShadow(s);
if (paintSource) {
final Graphics imgG = shadow.getGraphics();
final double d = shadowSize * 0.5;
imgG.drawImage(source, (int) (shadowSize + d), (int) (shadowSize + d / ratio), null);
}
return new Shadow(shadow, x - shadowSize - 5, y - shadowSize + 2);
}
use of org.jdesktop.swingx.graphics.ShadowRenderer in project intellij-community by JetBrains.
the class SheetController method initShadowImage.
private void initShadowImage() {
final BufferedImage mySheetStencil = GraphicsUtilities.createCompatibleTranslucentImage(SHEET_WIDTH, SHEET_HEIGHT);
Graphics2D g2 = mySheetStencil.createGraphics();
g2.setColor(new JBColor(Gray._255, Gray._0));
g2.fillRect(0, 0, SHEET_WIDTH, SHEET_HEIGHT);
g2.dispose();
ShadowRenderer renderer = new ShadowRenderer();
renderer.setSize(SHADOW_BORDER);
renderer.setOpacity(.80f);
renderer.setColor(new JBColor(JBColor.BLACK, Gray._10));
myShadowImage = renderer.createShadow(mySheetStencil);
}
Aggregations