com.tensegrity.gui.swing.icon
Class Icon

java.lang.Object
  extended byjavax.swing.ImageIcon
      extended bycom.tensegrity.gui.swing.icon.Icon
All Implemented Interfaces:
javax.accessibility.Accessible, javax.swing.Icon, java.io.Serializable
Direct Known Subclasses:
CloseIcon, PopupIcon, TriangleIcon, VisualGraphObjectIcon

public class Icon
extends javax.swing.ImageIcon

ImageIcon extension. This allows copying of icons. Constructing an Icon with an URL is forbidden.

Version:
$Id: Icon.java,v 1.16 2006/06/08 12:15:29 MichaelKegel Exp $
Author:
Gilles Iachelini
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.ImageIcon
javax.swing.ImageIcon.AccessibleImageIcon
 
Field Summary
static Icon EMPTYICON_16x15
          An Empty icon with color.
 
Fields inherited from class javax.swing.ImageIcon
component, tracker
 
Constructor Summary
Icon(java.awt.Image image)
          Creates a new icon based on the given Image parameter.
Icon(java.awt.Image image, boolean useFilteredImage)
          Creates a new Icon based on the given Image parameter.
Icon(int width, int height)
          Creates a new Icon with the given width and height.
 
Method Summary
static java.awt.Image filter(java.awt.Image image)
          Filters the given image according to the internal Icon#scale field.
 java.awt.Color getColor()
          The method getColor returns the value of the color field.
 java.awt.Graphics2D getGraphics()
          Method getGraphics returns the Graphics2D instance of the internal Image.
 int getHeight()
          Method getHeight returns the height of the Icon.
 java.awt.Image getImage()
           
 java.awt.Dimension getSize()
          Method getSize returns the size of this Icon.
 int getWidth()
          Method getWidth returns the width of this icon.
 void paint(java.awt.Component c, java.awt.Graphics g, int x, int y)
          Method paint paints the icon on the given component with the given graphics instance at the specific position.
 void paintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y)
           
 void setColor(java.awt.Color color)
          The method setColor sets a color field, which can be used to draw the icon.
 void setImage(java.awt.Image image)
           
 
Methods inherited from class javax.swing.ImageIcon
getAccessibleContext, getDescription, getIconHeight, getIconWidth, getImageLoadStatus, getImageObserver, loadImage, setDescription, setImageObserver, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTYICON_16x15

public static final Icon EMPTYICON_16x15
An Empty icon with color. Used as place holder.

Constructor Detail

Icon

public Icon(java.awt.Image image)
Creates a new icon based on the given Image parameter. This icon will be represented by filtered version whenever the enclosing swing context switches to the TensegrityLookAndFeel. See ColorFilter for more details. Use the Icon(Image, boolean) constructor with false to create a "normal" icon.

Parameters:
image - Image instance to create the icon from.
See Also:
ImageIcon.ImageIcon(Image)

Icon

public Icon(java.awt.Image image,
            boolean useFilteredImage)
Creates a new Icon based on the given Image parameter. If the parameter useFilteredImage is set to true a filtered image will be created to represent this icon in the TensegrityLookAndFeel.

Parameters:
image - Image instance to create the icon from.
useFilteredImage - set to true to let this class create a filtered version of the parameter image.

Icon

public Icon(int width,
            int height)
Creates a new Icon with the given width and height.

Parameters:
width - the width of the icon.
height - the height of the icon.
Method Detail

setImage

public void setImage(java.awt.Image image)

getGraphics

public java.awt.Graphics2D getGraphics()
Method getGraphics returns the Graphics2D instance of the internal Image.

Returns:
Graphics2D theGraphics2D instance from the internal image.

getHeight

public int getHeight()
Method getHeight returns the height of the Icon.

Returns:
int the height in pixel.

getSize

public java.awt.Dimension getSize()
Method getSize returns the size of this Icon.

Returns:
Dimension the size of this icon.

getWidth

public int getWidth()
Method getWidth returns the width of this icon.

Returns:
int the width in pixel.,

paint

public void paint(java.awt.Component c,
                  java.awt.Graphics g,
                  int x,
                  int y)
Method paint paints the icon on the given component with the given graphics instance at the specific position.

Parameters:
c - the component to draw on.
g - the graphics to use.
x - the horizontal position.
y - the vertical position.

getColor

public java.awt.Color getColor()
The method getColor returns the value of the color field. An implementation of this Icon class must no use this field.

Returns:
Color the color field.

paintIcon

public void paintIcon(java.awt.Component c,
                      java.awt.Graphics g,
                      int x,
                      int y)

setColor

public void setColor(java.awt.Color color)
The method setColor sets a color field, which can be used to draw the icon.

Parameters:
color - void

getImage

public java.awt.Image getImage()

filter

public static java.awt.Image filter(java.awt.Image image)
Filters the given image according to the internal Icon#scale field.

Parameters:
image - the image to filter.
Returns:
the filtered image.


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.