uk.ac.starlink.ttools.plot
Class PictureImageIcon

java.lang.Object
  extended by uk.ac.starlink.ttools.plot.PictureImageIcon
All Implemented Interfaces:
Icon

public class PictureImageIcon
extends Object
implements Icon

Adapter 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
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
 void cacheImage(GraphicsConfiguration gc, Color bg)
          Forces creation of a cached image for display.
static BufferedImage createImage(Picture picture, GraphicsConfiguration gc, Color bg, Integer transparency)
          Creates an image containing the graphic content of this icon, suitable for caching or painting to a graphics context.
 int getIconHeight()
           
 int getIconWidth()
           
 void paintIcon(Component c, Graphics g, int x, int y)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PictureImageIcon

public PictureImageIcon(Picture picture,
                        boolean caching,
                        int transparency)
Constructs an icon with specific transparency characteristics.

Parameters:
picture - picture to paint
caching - true iff painted image is cached rather than just drawn off-screen every time
transparency - 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 paint
caching - true iff painted image is cached rather than just drawn off-screen every time
Method Detail

getIconWidth

public int getIconWidth()
Specified by:
getIconWidth in interface Icon

getIconHeight

public int getIconHeight()
Specified by:
getIconHeight in interface Icon

paintIcon

public void paintIcon(Component c,
                      Graphics g,
                      int x,
                      int y)
Specified by:
paintIcon in interface Icon

cacheImage

public void cacheImage(GraphicsConfiguration gc,
                       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 displayed
bg - background colour for image; null is legal but may lead to unpredictable effects.

createImage

public static BufferedImage createImage(Picture picture,
                                        GraphicsConfiguration gc,
                                        Color bg,
                                        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 image
gc - graphics config in which this icon will be displayed
bg - 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


Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.