• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java GraphicsUtilities类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.jdesktop.swingx.graphics.GraphicsUtilities的典型用法代码示例。如果您正苦于以下问题:Java GraphicsUtilities类的具体用法?Java GraphicsUtilities怎么用?Java GraphicsUtilities使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



GraphicsUtilities类属于org.jdesktop.swingx.graphics包,在下文中一共展示了GraphicsUtilities类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: paint

import org.jdesktop.swingx.graphics.GraphicsUtilities; //导入依赖的package包/类
/**
 * Overriden paint method to take into account the alpha setting
 * @param g
 */
@Override
public void paint(Graphics g) {
    float a = getAlpha();
    if (a == 1) {
        super.paint(g);
    } else {
        //the component is translucent, so we need to render to
        //an intermediate image before painting
        BufferedImage img = GraphicsUtilities.createCompatibleTranslucentImage(getWidth(), getHeight());
        Graphics2D gfx = img.createGraphics();
        super.paint(gfx);
        gfx.dispose();
        Graphics2D g2d = (Graphics2D)g;
        Composite oldComp = g2d.getComposite();
        Composite alphaComp = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, a);
        g2d.setComposite(alphaComp);
        g2d.drawImage(img, null, 0, 0);
        g2d.setComposite(oldComp);
    }
}
 
开发者ID:freeseawind,项目名称:littleluck,代码行数:25,代码来源:JXPanel.java


示例2: filter

import org.jdesktop.swingx.graphics.GraphicsUtilities; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public BufferedImage filter(BufferedImage src, BufferedImage dst) {
    if (dst == null) {
        dst = createCompatibleDestImage(src, null);
    }

    int width = src.getWidth();
    int height = src.getHeight();

    int[] pixels = new int[width * height];
    GraphicsUtilities.getPixels(src, 0, 0, width, height, pixels);
    mixColor(pixels);
    GraphicsUtilities.setPixels(dst, 0, 0, width, height, pixels);

    return dst;
}
 
开发者ID:teddyted,项目名称:iSeleda,代码行数:20,代码来源:ColorTintFilter.java


示例3: filter

import org.jdesktop.swingx.graphics.GraphicsUtilities; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public BufferedImage filter(BufferedImage src, BufferedImage dst) {
    int width = src.getWidth();
    int height = src.getHeight();

    if (dst == null) {
        dst = createCompatibleDestImage(src, null);
    }

    int[] srcPixels = new int[width * height];
    int[] dstPixels = new int[width * height];

    GraphicsUtilities.getPixels(src, 0, 0, width, height, srcPixels);
    // horizontal pass
    blur(srcPixels, dstPixels, width, height, radius);
    // vertical pass
    //noinspection SuspiciousNameCombination
    blur(dstPixels, srcPixels, height, width, radius);
    // the result is now stored in srcPixels due to the 2nd pass
    GraphicsUtilities.setPixels(dst, 0, 0, width, height, srcPixels);

    return dst;
}
 
开发者ID:teddyted,项目名称:iSeleda,代码行数:27,代码来源:FastBlurFilter.java


示例4: filter

import org.jdesktop.swingx.graphics.GraphicsUtilities; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public BufferedImage filter(BufferedImage src, BufferedImage dst) {
    int width = src.getWidth();
    int height = src.getHeight();

    if (dst == null) {
        dst = createCompatibleDestImage(src, null);
    }

    int[] srcPixels = new int[width * height];
    int[] dstPixels = new int[width * height];

    GraphicsUtilities.getPixels(src, 0, 0, width, height, srcPixels);
    for (int i = 0; i < iterations; i++) {
        // horizontal pass
        FastBlurFilter.blur(srcPixels, dstPixels, width, height, radius);
        // vertical pass
        FastBlurFilter.blur(dstPixels, srcPixels, height, width, radius);
    }
    // the result is now stored in srcPixels due to the 2nd pass
    GraphicsUtilities.setPixels(dst, 0, 0, width, height, srcPixels);

    return dst;
}
 
开发者ID:teddyted,项目名称:iSeleda,代码行数:28,代码来源:StackBlurFilter.java


示例5: createShadow

import org.jdesktop.swingx.graphics.GraphicsUtilities; //导入依赖的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


示例6: getStaticImage

import org.jdesktop.swingx.graphics.GraphicsUtilities; //导入依赖的package包/类
/**
 * This method is used to show an image during message showing
 * @return image to show
 */
Image getStaticImage() {
  final JFrame myOffScreenFrame = new JFrame() ;
  myOffScreenFrame.add(mySheetPanel);
  myOffScreenFrame.getRootPane().setDefaultButton(myDefaultButton);

  final BufferedImage image = (SystemInfo.isJavaVersionAtLeast("1.7")) ?
                              UIUtil.createImage(SHEET_NC_WIDTH, SHEET_NC_HEIGHT, BufferedImage.TYPE_INT_ARGB) :
                              GraphicsUtilities.createCompatibleTranslucentImage(SHEET_NC_WIDTH, SHEET_NC_HEIGHT);

  Graphics g = image.createGraphics();
  mySheetPanel.paint(g);

  g.dispose();

  myOffScreenFrame.dispose();
  return image;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:SheetController.java


示例7: getTransferData

import org.jdesktop.swingx.graphics.GraphicsUtilities; //导入依赖的package包/类
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
    //log.fine("doing get trans data: " + flavor);
    if(flavor == DataFlavor.imageFlavor) {
        return img;
    }
    if(flavor == DataFlavor.javaFileListFlavor) {
        if(files == null) {
            files = new ArrayList<File>();
            File file = File.createTempFile(exportName,"."+exportFormat);
            //log.fine("writing to: " + file);
            ImageIO.write(GraphicsUtilities.convertToBufferedImage(img),exportFormat,file);
            files.add(file);
        }
        //log.fine("returning: " + files);
        return files;
    }
    return null;
}
 
开发者ID:sing-group,项目名称:aibench-project,代码行数:19,代码来源:JXImageView.java


示例8: getSubImage

import org.jdesktop.swingx.graphics.GraphicsUtilities; //导入依赖的package包/类
/**
 * Returns a new BufferedImage that represents a subregion of the given
 * BufferedImage.  (Note that this method does not use
 * BufferedImage.getSubimage(), which will defeat image acceleration
 * strategies on later JDKs.)
 */
private BufferedImage getSubImage(BufferedImage img,
                                  int x, int y, int w, int h) {
    BufferedImage ret = GraphicsUtilities.createCompatibleTranslucentImage(w, h);
    Graphics2D g2 = ret.createGraphics();
    
    try {
        g2.drawImage(img,
                     0, 0, w, h,
                     x, y, x+w, y+h,
                     null);
    } finally {
        g2.dispose();
    }
    
    return ret;
}
 
开发者ID:sing-group,项目名称:aibench-project,代码行数:23,代码来源:DropShadowBorder.java


示例9: filter

import org.jdesktop.swingx.graphics.GraphicsUtilities; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@SuppressWarnings({ "SuspiciousNameCombination" })
@Override
public BufferedImage filter(BufferedImage src, BufferedImage dst) {
    int width = src.getWidth();
    int height = src.getHeight();

    if (dst == null) {
        dst = createCompatibleDestImage(src, null);
    }

    int[] srcPixels = new int[width * height];
    int[] dstPixels = new int[width * height];

    float[] kernel = createGaussianKernel(radius);

    GraphicsUtilities.getPixels(src, 0, 0, width, height, srcPixels);
    // horizontal pass
    blur(srcPixels, dstPixels, width, height, kernel, radius);
    // vertical pass
    blur(dstPixels, srcPixels, height, width, kernel, radius);
    // the result is now stored in srcPixels due to the 2nd pass
    GraphicsUtilities.setPixels(dst, 0, 0, width, height, srcPixels);

    return dst;
}
 
开发者ID:sing-group,项目名称:aibench-project,代码行数:29,代码来源:GaussianBlurFilter.java


示例10: getStaticImage

import org.jdesktop.swingx.graphics.GraphicsUtilities; //导入依赖的package包/类
/**
 * This method is used to show an image during message showing
 * @return image to show
 */
Image getStaticImage() {
  final JFrame myOffScreenFrame = new JFrame() ;
  myOffScreenFrame.add(mySheetPanel);
  myOffScreenFrame.getRootPane().setDefaultButton(myDefaultButton);

  final BufferedImage image = (SystemInfo.isJavaVersionAtLeast("1.7")) ?
                              UIUtil.createImage(SHEET_NC_WIDTH, SHEET_NC_HEIGHT, BufferedImage.TYPE_INT_ARGB) :
                              GraphicsUtilities.createCompatibleTranslucentImage(SHEET_NC_WIDTH, SHEET_NC_HEIGHT);

  Graphics g = image.createGraphics();
  mySheetPanel.paint(g);

  g.dispose();

  myOffScreenFrame.remove(mySheetPanel);

  myOffScreenFrame.dispose();
  return image;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:24,代码来源:SheetController.java


示例11: matchLabelBorderToButtons

import org.jdesktop.swingx.graphics.GraphicsUtilities; //导入依赖的package包/类
private void matchLabelBorderToButtons() {
    Insets insets = new Insets(4, 6, 4, 6);
    Dimension buttonSize = prevButton.getPreferredSize();
    prevButton.setSize(buttonSize);

    BufferedImage image = GraphicsUtilities.
            createCompatibleTranslucentImage(
                 buttonSize.width, buttonSize.height);
    prevButton.paint(image.getGraphics());
    BufferedImage labelTopImage = GraphicsUtilities.
            createCompatibleTranslucentImage(
                 buttonSize.width - insets.left - insets.right,
                 insets.top);
    labelTopImage.getGraphics().drawImage(image, 0, 0,
            buttonSize.width - insets.left - insets.right,
            insets.top,
            insets.left, 0,
            buttonSize.width - insets.right, insets.top,
            null,
            null);

    BufferedImage labelBottomImage = GraphicsUtilities.createCompatibleTranslucentImage(buttonSize.width - insets.left - insets.right,
            insets.bottom);
    labelBottomImage.getGraphics().drawImage(image, 0, 0,
            buttonSize.width - insets.left - insets.right, insets.top,
            insets.left, buttonSize.height - insets.bottom,
            buttonSize.width - insets.right, buttonSize.height,
            null,
            null);

    statusLabel.setBorder(new CenterLabelBorder(labelTopImage, labelBottomImage));
    needLabelBorder = false;
}
 
开发者ID:freeseawind,项目名称:littleluck,代码行数:34,代码来源:SnippetNavigator.java


示例12: initShadowImage

import org.jdesktop.swingx.graphics.GraphicsUtilities; //导入依赖的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


示例13: doPaint

import org.jdesktop.swingx.graphics.GraphicsUtilities; //导入依赖的package包/类
protected void doPaint(Graphics2D g, T component, int width, int height) {
    RectangularShape shape = calculateShape(width, height);
    switch (getStyle()) {
    case BOTH:
        drawBackground(g,shape,width,height);
        drawBorder(g,shape,width,height);
        break;
    case FILLED:
        drawBackground(g,shape,width,height);
        break;
    case OUTLINE:
        drawBorder(g,shape,width,height);
        break;
    case NONE:
        break;
    }

    // background
    // border
    // leave the clip to support masking other painters
    GraphicsUtilities.mergeClip(g,shape);
    /*
    Area area = new Area(g.getClip());
    area.intersect(new Area(shape));//new Rectangle(0,0,width,height)));
    g.setClip(area);*/
    //g.setClip(shape);
}
 
开发者ID:sing-group,项目名称:aibench-project,代码行数:28,代码来源:RectanglePainter.java


示例14: loadFromResource

import org.jdesktop.swingx.graphics.GraphicsUtilities; //导入依赖的package包/类
protected Icon loadFromResource(String name) {
  URL url = baseClass.getResource("resources/images/" + name);
  if (url == null)
    return null;
  try {
    BufferedImage image = ImageIO.read(url);
    if (image.getHeight() > 30) {
      image = GraphicsUtilities.createThumbnail(image, 16);
    }
    return new ImageIcon(image);
  } catch (IOException e) {
  }
  return null;
}
 
开发者ID:gigony,项目名称:GUITester-core,代码行数:15,代码来源:LazyLoadingIconValue.java


示例15: getBufferedImage

import org.jdesktop.swingx.graphics.GraphicsUtilities; //导入依赖的package包/类
public BufferedImage getBufferedImage(Integer width, Integer height) {
    if(bufferedImagesTable == null) { bufferedImagesTable = new Hashtable<>(); }
    String imageSize = width+"x"+height;
    if(bufferedImagesTable.containsKey(imageSize)) {
        return bufferedImagesTable.get(imageSize);
    } else {
        //System.out.println("Nuevo caché: "+width+", "+height);
        return bufferedImagesTable.put(imageSize, GraphicsUtilities.createCompatibleImage(width, height));
    }
}
 
开发者ID:ZooMMX,项目名称:Omoikane,代码行数:11,代码来源:FrostedGlassDesktopPane.java


示例16: paint

import org.jdesktop.swingx.graphics.GraphicsUtilities; //导入依赖的package包/类
/**
 * @inheritDoc
 */
public final void paint(Graphics2D g, T obj, int width, int height) {
    if (g == null) {
        throw new NullPointerException("The Graphics2D must be supplied");
    }

    if (!isVisible() || width < 1 || height < 1) {
        return;
    }

    configureGraphics(g);

    //paint to a temporary image if I'm caching, or if there are filters to apply
    if (shouldUseCache() || filters.length > 0) {
        validate(obj);
        BufferedImage cache = cachedImage == null ? null : cachedImage.get();
        boolean invalidCache = null == cache ||
                cache.getWidth() != width ||
                cache.getHeight() != height;

        if (cacheCleared || invalidCache || isDirty()) {
            //rebuild the cacheable. I do this both if a cacheable is needed, and if any
            //filters exist. I only *save* the resulting image if caching is turned on
            if (invalidCache) {
                cache = GraphicsUtilities.createCompatibleTranslucentImage(width, height);
            }
            Graphics2D gfx = cache.createGraphics();

            try {
                gfx.setClip(0, 0, width, height);

                if (!invalidCache) {
                    // If we are doing a repaint, but we didn't have to
                    // recreate the image, we need to clear it back
                    // to a fully transparent background.
                    Composite composite = gfx.getComposite();
                    gfx.setComposite(AlphaComposite.Clear);
                    gfx.fillRect(0, 0, width, height);
                    gfx.setComposite(composite);
                }

                configureGraphics(gfx);
                doPaint(gfx, obj, width, height);
            } finally {
                gfx.dispose();
            }

            for (BufferedImageOp f : getFilters()) {
                cache = f.filter(cache, null);
            }

            //only save the temporary image as the cacheable if I'm caching
            if (shouldUseCache()) {
                cachedImage = new SoftReference<BufferedImage>(cache);
                cacheCleared = false;
            }
        }

        g.drawImage(cache, 0, 0, null);
    } else {
        //can't use the cacheable, so just paint
        doPaint(g, obj, width, height);
    }

    //painting has occured, so restore the dirty bit to false
    setDirty(false);
}
 
开发者ID:teddyted,项目名称:iSeleda,代码行数:70,代码来源:AbstractPainter.java


示例17: convertToBufferedImage

import org.jdesktop.swingx.graphics.GraphicsUtilities; //导入依赖的package包/类
/**
 * @deprecated Use {@link GraphicsUtilities#convertToBufferedImage(Image)} instead
 */
@Deprecated
public static BufferedImage convertToBufferedImage(Image img) {
    return GraphicsUtilities.convertToBufferedImage(img);
}
 
开发者ID:sing-group,项目名称:aibench-project,代码行数:8,代码来源:PaintUtils.java


示例18: loadCompatibleImage

import org.jdesktop.swingx.graphics.GraphicsUtilities; //导入依赖的package包/类
/**
 * @deprecated Use {@link GraphicsUtilities#loadCompatibleImage(InputStream)} instead
 */
@Deprecated
public static BufferedImage loadCompatibleImage(InputStream in) throws IOException {
    return GraphicsUtilities.loadCompatibleImage(in);
}
 
开发者ID:sing-group,项目名称:aibench-project,代码行数:8,代码来源:PaintUtils.java


示例19: toCompatibleImage

import org.jdesktop.swingx.graphics.GraphicsUtilities; //导入依赖的package包/类
/**
 * @deprecated (pre-0.9.6) use {@link GraphicsUtilities#toCompatibleImage(BufferedImage)}
 */
@Deprecated
public static BufferedImage toCompatibleImage(BufferedImage image) {
    return GraphicsUtilities.toCompatibleImage(image);
}
 
开发者ID:sing-group,项目名称:aibench-project,代码行数:8,代码来源:PaintUtils.java


示例20: paint

import org.jdesktop.swingx.graphics.GraphicsUtilities; //导入依赖的package包/类
/**
 * @inheritDoc
 */
public final void paint(Graphics2D g, T obj, int width, int height) {
    if (g == null) {
        throw new NullPointerException("The Graphics2D must be supplied");
    }

    if(!isVisible() || width < 1 || height < 1) {
        return;
    }

    configureGraphics(g);

    //paint to a temporary image if I'm caching, or if there are filters to apply
    if (shouldUseCache() || filters.length > 0) {
        validate(obj);
        BufferedImage cache = cachedImage == null ? null : cachedImage.get();
        boolean invalidCache = null == cache || 
                                    cache.getWidth() != width || 
                                    cache.getHeight() != height;

        if (cacheCleared || invalidCache || isDirty()) {
            //rebuild the cacheable. I do this both if a cacheable is needed, and if any
            //filters exist. I only *save* the resulting image if caching is turned on
            if (invalidCache) {
                cache = GraphicsUtilities.createCompatibleTranslucentImage(width, height);
            }
            Graphics2D gfx = cache.createGraphics();
            
            try {
                gfx.setClip(0, 0, width, height);

                if (!invalidCache) {
                    // If we are doing a repaint, but we didn't have to
                    // recreate the image, we need to clear it back
                    // to a fully transparent background.
                    Composite composite = gfx.getComposite();
                    gfx.setComposite(AlphaComposite.Clear);
                    gfx.fillRect(0, 0, width, height);
                    gfx.setComposite(composite);
                }

                configureGraphics(gfx);
                doPaint(gfx, obj, width, height);
            } finally {
                gfx.dispose();
            }

            for (BufferedImageOp f : getFilters()) {
                cache = f.filter(cache, null);
            }

            //only save the temporary image as the cacheable if I'm caching
            if (shouldUseCache()) {
                cachedImage = new SoftReference<BufferedImage>(cache);
                cacheCleared = false;
            }
        }

        g.drawImage(cache, 0, 0, null);
    } else {
        //can't use the cacheable, so just paint
        doPaint(g, obj, width, height);
    }

    //painting has occured, so restore the dirty bit to false
    setDirty(false);
}
 
开发者ID:sing-group,项目名称:aibench-project,代码行数:70,代码来源:AbstractPainter.java



注:本文中的org.jdesktop.swingx.graphics.GraphicsUtilities类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ECPointUtil类代码示例发布时间:2022-05-22
下一篇:
Java MatrixDcMotorController类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap