Package uk.ac.starlink.ttools.plot
Class PictureImageIcon
- java.lang.Object
-
- uk.ac.starlink.ttools.plot.PictureImageIcon
-
- All Implemented Interfaces:
javax.swing.Icon
public class PictureImageIcon extends java.lang.Object implements javax.swing.IconAdapter class that makes a Picture usable as an Icon, suitable for use in a pixel (non-vector) context. Rendering is done to an off-screen volatile image for performance. This rendered image is optionally cached for subsequent use.- Since:
- 25 Jan 2012
- Author:
- Mark Taylor
-
-
Constructor Summary
Constructors Constructor Description PictureImageIcon(Picture picture, boolean caching)Constructs an icon with default transparency.PictureImageIcon(Picture picture, boolean caching, int transparency)Constructs an icon with specific transparency characteristics.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcacheImage(java.awt.GraphicsConfiguration gc, java.awt.Color bg)Forces creation of a cached image for display.static java.awt.image.BufferedImagecreateImage(Picture picture, java.awt.GraphicsConfiguration gc, java.awt.Color bg, java.lang.Integer transparency)Creates an image containing the graphic content of this icon, suitable for caching or painting to a graphics context.intgetIconHeight()intgetIconWidth()voidpaintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y)
-
-
-
Constructor Detail
-
PictureImageIcon
public PictureImageIcon(Picture picture, boolean caching, int transparency)
Constructs an icon with specific transparency characteristics.- Parameters:
picture- picture to paintcaching- true iff painted image is cached rather than just drawn off-screen every timetransparency- transparency mode- See Also:
Transparency.OPAQUE,Transparency.BITMASK,Transparency.TRANSLUCENT
-
PictureImageIcon
public PictureImageIcon(Picture picture, boolean caching)
Constructs an icon with default transparency.- Parameters:
picture- picture to paintcaching- true iff painted image is cached rather than just drawn off-screen every time
-
-
Method Detail
-
getIconWidth
public int getIconWidth()
- Specified by:
getIconWidthin interfacejavax.swing.Icon
-
getIconHeight
public int getIconHeight()
- Specified by:
getIconHeightin interfacejavax.swing.Icon
-
paintIcon
public void paintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y)- Specified by:
paintIconin interfacejavax.swing.Icon
-
cacheImage
public void cacheImage(java.awt.GraphicsConfiguration gc, java.awt.Color bg)Forces creation of a cached image for display. If this is not called explicitly then in caching mode a cached image will be created when this icon is first painted.- Parameters:
gc- graphics config in which this icon will be displayedbg- background colour for image; null is legal but may lead to unpredictable effects.
-
createImage
public static java.awt.image.BufferedImage createImage(Picture picture, java.awt.GraphicsConfiguration gc, java.awt.Color bg, java.lang.Integer transparency)
Creates an image containing the graphic content of this icon, suitable for caching or painting to a graphics context.- Parameters:
picture- picture to paint on the imagegc- graphics config in which this icon will be displayedbg- background colour for image; null is legal but may lead to unpredictable effects.transparency- integer value of Transparency code, or null- Returns:
- image containing picture graphics
-
-