本文整理匯總了Java中org.jdesktop.swingx.graphics.ShadowRenderer類的典型用法代碼示例。如果您正苦於以下問題:Java ShadowRenderer類的具體用法?Java ShadowRenderer怎麽用?Java ShadowRenderer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ShadowRenderer類屬於org.jdesktop.swingx.graphics包,在下文中一共展示了ShadowRenderer類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createShadow
import org.jdesktop.swingx.graphics.ShadowRenderer; //導入依賴的package包/類
public static Shadow createShadow(Image source, int x, int y, boolean paintSource, int shadowSize) {
int size = shadowSize;
final float w = source.getWidth(null);
final float h = source.getHeight(null);
float ratio = w / h;
float deltaX = size;
float deltaY = size / 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(size, .25f, Color.black).createShadow(s);
if (paintSource) {
final Graphics imgG = shadow.getGraphics();
final double d = size * 0.5;
imgG.drawImage(source, (int)(size + d), (int)(size + d / ratio), null);
}
return new Shadow(shadow, x - size - 5, y - size + 2);
}
示例2: initShadowImage
import org.jdesktop.swingx.graphics.ShadowRenderer; //導入依賴的package包/類
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);
}