当前位置: 首页>>代码示例>>Java>>正文


Java Image.flush方法代码示例

本文整理汇总了Java中java.awt.Image.flush方法的典型用法代码示例。如果您正苦于以下问题:Java Image.flush方法的具体用法?Java Image.flush怎么用?Java Image.flush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Image的用法示例。


在下文中一共展示了Image.flush方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resetSplashPreview

import java.awt.Image; //导入方法依赖的package包/类
private void resetSplashPreview() throws NumberFormatException {
    Image oldImage = splashImage.image;
    if (null != oldImage)
        oldImage.flush();
    splashImage.setSplashImageIcon(splashSource);
    Rectangle tRectangle = (Rectangle)runningTextBounds.getValue();
    Rectangle pRectangle = (Rectangle)progressBarBounds.getValue();
    splashImage.setTextColor(textColor.getColor());
    splashImage.setColorBar(barColor.getColor());
    splashImage.setColorEdge(edgeColor.getColor());
    splashImage.setColorEdge(cornerColor.getColor());
    splashImage.setFontSize(((Number)fontSize.getValue()).intValue());
    splashImage.setRunningTextBounds(tRectangle);
    splashImage.setProgressBarBounds(pRectangle);
    splashImage.setProgressBarEnabled(progressBarEnabled.isSelected());
    splashImage.resetSteps();
    splashImage.setText(NbBundle.getMessage(getClass(),"TEXT_SplashSample")); //NOI18N
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:SplashBrandingPanel.java

示例2: toBufferedImage

import java.awt.Image; //导入方法依赖的package包/类
/** The method creates a BufferedImage which represents the same Image as the
 * parameter but consumes less memory.
 */
static final Image toBufferedImage(Image img) {
    // load the image
    new javax.swing.ImageIcon(img, "");

    if (img.getHeight(null)*img.getWidth(null) > 24*24) {
        return img;
    }
    java.awt.image.BufferedImage rep = createBufferedImage(img.getWidth(null), img.getHeight(null));
    java.awt.Graphics g = rep.createGraphics();
    g.drawImage(img, 0, 0, null);
    g.dispose();
    img.flush();

    return rep;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:ImageUtilities.java

示例3: draw

import java.awt.Image; //导入方法依赖的package包/类
private static void draw(Shape clip, Shape to, Image vi, BufferedImage bi,
                         int scale) {
    Graphics2D big = bi.createGraphics();
    big.setComposite(AlphaComposite.Src);
    big.setClip(clip);
    Rectangle toBounds = to.getBounds();
    int x1 = toBounds.x;

    int y1 = toBounds.y;
    int x2 = x1 + toBounds.width;
    int y2 = y1 + toBounds.height;
    big.drawImage(vi, x1, y1, x2, y2, 0, 0, toBounds.width / scale,
                  toBounds.height / scale, null);
    big.dispose();
    vi.flush();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:IncorrectClipSurface2SW.java

示例4: toBufferedImage

import java.awt.Image; //导入方法依赖的package包/类
private BufferedImage toBufferedImage(Image image) {
    if (image instanceof BufferedImage) {
        return (BufferedImage) image;
    }
    BufferedImage buffer = new BufferedImage(image.getWidth(null), image.getHeight(null), 2);
    Graphics2D g = buffer.createGraphics();
    g.drawImage(image, null, null);
    image.flush();
    return buffer;
}
 
开发者ID:me4502,项目名称:AdvancedServerListIcons,代码行数:11,代码来源:ImageHandler.java

示例5: toBufferedImage

import java.awt.Image; //导入方法依赖的package包/类
static final BufferedImage toBufferedImage(Image img) {
    // load the image
    new javax.swing.ImageIcon(img, "");

    java.awt.image.BufferedImage rep = createBufferedImage(img.getWidth(null), img.getHeight(null));
    java.awt.Graphics g = rep.createGraphics();
    g.drawImage(img, 0, 0, null);
    g.dispose();
    img.flush();

    return rep;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:DecorableTest.java

示例6: toBufferedImage

import java.awt.Image; //导入方法依赖的package包/类
private static final BufferedImage toBufferedImage(Image img) {
    // load the image
    new ImageIcon(img);
    BufferedImage rep = createBufferedImage(img.getWidth(null), img.getHeight(null));
    Graphics g = rep.createGraphics();
    g.drawImage(img, 0, 0, null);
    g.dispose();
    img.flush();
    return rep;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:PropertyMarkingTest.java

示例7: toBufferedImage

import java.awt.Image; //导入方法依赖的package包/类
private static final BufferedImage toBufferedImage(Image img) {
    // load the image
    new javax.swing.ImageIcon(img);
    java.awt.image.BufferedImage rep = createBufferedImage(img.getWidth(null), img.getHeight(null));
    java.awt.Graphics g = rep.createGraphics();
    g.drawImage(img, 0, 0, null);
    g.dispose();
    img.flush();
    return rep;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:ComboTest.java

示例8: getScaledImageIcon

import java.awt.Image; //导入方法依赖的package包/类
public static ImageIcon getScaledImageIcon(String path, int w, int h) {
    Image img = new ImageIcon("tmp.png").getImage();
    img.flush();
    
    int x = img.getWidth(null);
    int y = img.getHeight(null);
    double scale = Math.min((double) (w) / x, (double) (h) / y);
    x = (int) (x * scale);
    y = (int) (y * scale);
    return new ImageIcon(img.getScaledInstance(x, y, Image.SCALE_SMOOTH));
}
 
开发者ID:xehoth,项目名称:VisualGraphviz,代码行数:12,代码来源:Tools.java

示例9: paint

import java.awt.Image; //导入方法依赖的package包/类
@Override
public void paint(
  PaintContext context,
  Graphics     g,
  int          x,
  int          y,
  int          width,
  int          height
  )
{
  // On X servers with limited color capacities, we have problems with
  // getting the background color of the offscreen image to match the
  // actual background color of the destination BufferedImage.  The
  // problem is that when the X server runs out of colors, it uses a
  // near match - which might not be the background color that we want.
  // The result is that the area behind the text may have a different
  // background color than the rest of the image.  (eg. in buttons, the
  // bounding box of the text has a white background, while the rest of
  // the button content is the light off-white specified by BLAF.)
  //
  // To work around this problem, we convert background pixels to
  // transparent before drawing the offscreen buffer.  However, we
  // can't simply filter on pixels where the rgb value is equal to
  // our desired background rgb value - as the actual rgb value is
  // picked by the X server.  So, we've got a real hack here...
  //
  // We make the offscreen buffer one pixel taller than needed.
  // We fill this entire area, including the extra pixel scan line
  // at the top, with the background color.  Then, we draw the content
  // starting at y=1.  So, when we get around to filtering the background,
  // we know that the pixels at y=0 are the background color - all pixel
  // values which match the value at 0, 0 are filtered to transparent.
  // Yeah, I know this is insane.  Feel free to rip this out if you've
  // got a better solution.

  // Create the offscreen buffer.  We make it one pixel taller than
  // necessary.  We want the top scan line to be filled with the background
  // color, but without any actual content, so that we can use it later
  // (during transparency filtering) to get the real background color.
  BufferedImage buffer = _createOffscreenBuffer(context, width, height + 1);

  if (buffer == null)
  {
    super.paint(context, g, x, y, width, height);
    return;
  }

  // If we've got a buffer, use it's graphics object for rendering
  // our wrapped painter
  Graphics offscreenG = _getInitializedGraphics(context, buffer);

  // Fill in the background - including the extra 1 pixel at the top
  offscreenG.setColor(context.getPaintBackground());
  offscreenG.fillRect(0, 0, width, height + 1);

  // Reset for text rendering
  offscreenG.setColor(g.getColor());
  offscreenG.translate(-x, -y);

  // Render the wrapped painter into the offscreen buffer.  We offset
  // the y coordinate by one so that no content will be rendered into
  // the top pixel.
  super.paint(context, offscreenG, x, y + 1, width, height);

  // Filter out the background
  Image transparentImage = ImageUtils.createFilteredImage(buffer,
                             new TransparencyFilter());
  ImageUtils.loadImage(transparentImage);

  // Now, render the transparent image into the original in Graphics object
  g.drawImage(transparentImage,
              x, y, x+width, y+height, 0, 1, width, height + 1, this);

  // Clean up
  offscreenG.dispose();
  transparentImage.flush();
  buffer.flush();
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:79,代码来源:OffscreenWrappingPainter.java

示例10: setImage

import java.awt.Image; //导入方法依赖的package包/类
/**
 * Sets the cached image for the specified constraints.
 *
 * @param image  The image to store in cache
 * @param config The graphics configuration, needed if cached image is a Volatile Image. Used as part of cache key
 * @param w      The image width, used as part of cache key
 * @param h      The image height, used as part of cache key
 * @param args   Other arguments to use as part of the cache key
 * @return true if the image could be cached or false if the image is too big
 */
public boolean setImage(Image image, GraphicsConfiguration config, int w, int h, Object... args) {
    if (!isImageCachable(w, h)) return false;
    int hash = hash(config, w, h, args);
    lock.writeLock().lock();
    try {
        PixelCountSoftReference ref = map.get(hash);
        // check if currently in map
        if (ref != null && ref.get() == image) {
            return true;
        }
        // clear out old
        if (ref != null) {
            currentPixelCount -= ref.pixelCount;
            map.remove(hash);
        }
        // add new image to pixel count
        int newPixelCount = image.getWidth(null) * image.getHeight(null);
        currentPixelCount += newPixelCount;
        // clean out lost references if not enough space
        if (currentPixelCount > maxPixelCount) {
            while ((ref = (PixelCountSoftReference)referenceQueue.poll()) != null){
                //reference lost
                map.remove(ref.hash);
                currentPixelCount -= ref.pixelCount;
            }
        }
        // remove old items till there is enough free space
        if (currentPixelCount > maxPixelCount) {
            Iterator<Map.Entry<Integer, PixelCountSoftReference>> mapIter = map.entrySet().iterator();
            while ((currentPixelCount > maxPixelCount) && mapIter.hasNext()) {
                Map.Entry<Integer, PixelCountSoftReference> entry = mapIter.next();
                mapIter.remove();
                Image img = entry.getValue().get();
                if (img != null) img.flush();
                currentPixelCount -= entry.getValue().pixelCount;
            }
        }
        // finaly put new in map
        map.put(hash, new PixelCountSoftReference(image, referenceQueue, newPixelCount,hash, config, w, h, args));
        return true;
    } finally {
        lock.writeLock().unlock();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:55,代码来源:ImageCache.java

示例11: destroyBackBuffer

import java.awt.Image; //导入方法依赖的package包/类
@Override
public void destroyBackBuffer(final Image backBuffer) {
    if (backBuffer != null) {
        backBuffer.flush();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:7,代码来源:CGLGraphicsConfig.java


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