當前位置: 首頁>>代碼示例>>Java>>正文


Java ShadowRenderer類代碼示例

本文整理匯總了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);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:26,代碼來源:ShadowBorderPainter.java

示例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);
  }
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:16,代碼來源:SheetController.java


注:本文中的org.jdesktop.swingx.graphics.ShadowRenderer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。