public class ImageResource extends java.lang.Object
svg
is not null
and in the latter case,
baseImage
is not null
.Modifier and Type | Field and Description |
---|---|
private java.awt.Image |
baseImage |
static java.awt.Dimension |
DEFAULT_DIMENSION
Use this dimension to request original file dimension.
|
private java.util.Map<java.awt.Dimension,java.awt.Image> |
imgCache
Caches the image data for resized versions of the same image.
|
protected java.util.List<ImageOverlay> |
overlayInfo
ordered list of overlay images
|
private SVGDiagram |
svg
SVG diagram information in case of SVG vector image.
|
Constructor and Description |
---|
ImageResource(java.awt.Image img)
Constructs a new
ImageResource from an image. |
ImageResource(ImageResource res,
java.util.List<ImageOverlay> overlayInfo)
Constructs a new
ImageResource from another one and sets overlays. |
ImageResource(SVGDiagram svg)
Constructs a new
ImageResource from SVG data. |
Modifier and Type | Method and Description |
---|---|
javax.swing.ImageIcon |
getImageIcon()
Returns the image icon at default dimension.
|
void |
getImageIcon(javax.swing.AbstractAction a)
Set both icons of an Action
|
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.
|
private java.util.Map<java.awt.Dimension,java.awt.Image> imgCache
private SVGDiagram svg
public static final java.awt.Dimension DEFAULT_DIMENSION
protected java.util.List<ImageOverlay> overlayInfo
private java.awt.Image baseImage
public ImageResource(java.awt.Image img)
ImageResource
from an image.img
- the imagepublic ImageResource(SVGDiagram svg)
ImageResource
from SVG data.svg
- SVG datapublic ImageResource(ImageResource res, java.util.List<ImageOverlay> overlayInfo)
ImageResource
from another one and sets overlays.res
- the existing resourceoverlayInfo
- the overlay to applypublic javax.swing.ImageIcon getImageIcon()
public void getImageIcon(javax.swing.AbstractAction a)
a
- The action for the iconspublic javax.swing.ImageIcon getImageIcon(java.awt.Dimension dim)
dim
- The requested dimensions. Use (-1,-1) for the original size
and (width, -1) to set the width, but otherwise scale the image
proportionally.public javax.swing.ImageIcon getImageIconBounded(java.awt.Dimension maxSize)
maxSize
- The maximum size. One of the dimensions (width or height) can be -1,
which means it is not bounded.