javax.swing.ImageIcon#getImageLoadStatus ( )源码实例Demo

下面列出了javax.swing.ImageIcon#getImageLoadStatus ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

public BasemapLayer(Layer layer, String thumbnailFilename) {
    this.layer = layer;
    if (null == thumbnailFilename) {
        thumbnail = null;
    } else {
        ImageIcon imageIcon = new ImageIcon(thumbnailFilename);
        thumbnail = MediaTracker.COMPLETE == imageIcon.getImageLoadStatus() ? imageIcon : null;
    }
}
 
源代码2 项目: pdfxtk   文件: JavaImageFactory.java
public iiuf.xmillum.Image getImage(URL imageURL) throws IOException {
  ImageIcon icon = new ImageIcon(imageURL);
  if (icon.getImageLoadStatus() == MediaTracker.ERRORED) {
    context.setStatus("Unable to load image "+imageURL);
    return null;
  }
  return new JavaImage(icon.getImage());
}
 
源代码3 项目: megamek   文件: MegamekBorder.java
/**
 * Paints an edge for the border given a list of icons to paint.  We need
 * to know whether each icon should be tiled, how many tiled icons there 
 * are and how much space (width/height) needs to be filled by tiled icons.
 * 
 * @param c  The Component to pain on
 * @param g  The Graphics object to paint with 
 * @param isLeftRight Are we drawing a left or right edge?
 * @param icons The ImageIcons to draw
 * @param shouldTile  Denotes whether each icon should be tiled or not
 * @param numTiledIcons The number of tiled icons we have to draw with
 * @param staticSpace How much space needs to be filled with tiledi cons
 */
private void paintEdge(Component c, Graphics g, ArrayList<ImageIcon> icons, 
        int x, int y, int width, int height, boolean isLeftRight,
        ArrayList<Boolean> shouldTile, int numTiledIcons, int staticSpace){       
    g = g.create(x, y, width, height);
    
    // Determine how much width/height a tiled icons will get to consume
    int tiledWidth = isLeftRight ? width :
            (int)((width - staticSpace + 0.0) / numTiledIcons + 0.5);
    int tiledHeight = isLeftRight ? (int) ((height - staticSpace + 0.0)
            / numTiledIcons + 0.5) : height;
    
    x = 0; 
    y = 0;
    
    // Draw each icon
    for (int i = 0; i < icons.size(); i++){
        ImageIcon icon = icons.get(i);
        if (icon.getImageLoadStatus() != MediaTracker.COMPLETE){
            return;
        }
        if (shouldTile.get(i)){
            // Tile icons that should be tiled
            paintTiledIcon(c,g,icon,x,y,tiledWidth,tiledHeight);
            if (isLeftRight){
                y += tiledHeight;
            } else {
                x += tiledWidth;
            }
        } else {
            // Draw static icons once
            icons.get(i).paintIcon(c, g, x, y);
            if (isLeftRight){
                y+= icon.getIconHeight();
            } else {
                x+= icon.getIconWidth();
            }
        }
    }
    g.dispose();
}