org.openstreetmap.josm.tools
Class ImageResource

java.lang.Object
  extended by org.openstreetmap.josm.tools.ImageResource

 class ImageResource
extends java.lang.Object

Holds data for one particular image. It can be backed by a svg or raster image. In the first case, 'svg' is not null and in the latter case, 'imgCache' has at least one entry for the key DEFAULT_DIMENSION.


Field Summary
static java.awt.Dimension DEFAULT_DIMENSION
           
private  java.util.HashMap<java.awt.Dimension,java.awt.image.BufferedImage> imgCache
          Caches the image data for resized versions of the same image.
private  SVGDiagram svg
           
 
Constructor Summary
ImageResource(java.awt.image.BufferedImage img)
           
ImageResource(SVGDiagram svg)
           
 
Method Summary
 javax.swing.ImageIcon getImageIcon()
           
 javax.swing.ImageIcon getImageIcon(java.awt.Dimension dim)
          Get an ImageIcon object for the image of this resource
 javax.swing.ImageIcon getImageIconBounded(java.awt.Dimension maxSize)
          Get image icon with a certain maximum size.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

imgCache

private java.util.HashMap<java.awt.Dimension,java.awt.image.BufferedImage> imgCache
Caches the image data for resized versions of the same image.


svg

private SVGDiagram svg

DEFAULT_DIMENSION

public static final java.awt.Dimension DEFAULT_DIMENSION
Constructor Detail

ImageResource

public ImageResource(java.awt.image.BufferedImage img)

ImageResource

public ImageResource(SVGDiagram svg)
Method Detail

getImageIcon

public javax.swing.ImageIcon getImageIcon()

getImageIcon

public javax.swing.ImageIcon getImageIcon(java.awt.Dimension dim)
Get an ImageIcon object for the image of this resource

Parameters:
dim - The requested dimensions. Use (-1,-1) for the original size and (width, -1) to set the width, but otherwise scale the image proportionally.

getImageIconBounded

public javax.swing.ImageIcon getImageIconBounded(java.awt.Dimension maxSize)
Get image icon with a certain maximum size. The image is scaled down to fit maximum dimensions. (Keeps aspect ratio)

Parameters:
maxSize - The maximum size. One of the dimensions (widht or height) can be -1, which means it is not bounded.


JOSM