Copyright 2012-02-25 Werner Randelshofer

ch.randelshofer.gui
Class PolygonIcon

java.lang.Object
  extended by ch.randelshofer.gui.PolygonIcon
All Implemented Interfaces:
javax.swing.Icon

public class PolygonIcon
extends java.lang.Object
implements javax.swing.Icon

An Icon which is composed of java.awt.Polygon's.

Version:
1.4 2003-04-21 Method setFillPolygon add.
1.3.2 2001-08-14 Comments added.
1.3.1 2001-08-02 Method setFillColor added.
1.3 2001-07-24 Upgraded for JDK 1.3.
1.2 2001-02-27 When the component is disabled, the polygon is drawn in gray.
1999-05-13 Polygons are stroked and filled to provide better visual compatibility on various Java VM's.
1999-05-02 Support added for array of polygons.
1999-02-14 Created.
Author:
Werner Randelshofer, Hausmatt 10, CH-6405 Immensee, Switzerland

Constructor Summary
PolygonIcon(java.awt.Polygon[] p, java.awt.Dimension size)
          Creates a new icon.
PolygonIcon(java.awt.Polygon p, java.awt.Dimension size)
          Creates a new icon.
 
Method Summary
 int getIconHeight()
          Gets the height of the icon.
 int getIconWidth()
          Gets the width of the icon.
 void paintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y)
          Draws the icon at the specified location.
 void setFillColor(java.awt.Color color)
          Sets the fill color of the polygons.
 void setFilled(boolean b)
           
 void setForeground(java.awt.Color color)
          Sets the foreground color of the polygons.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PolygonIcon

public PolygonIcon(java.awt.Polygon[] p,
                   java.awt.Dimension size)
Creates a new icon.

Parameters:
p - An Array of polygons.
size - The fixed width/height of the icon.

PolygonIcon

public PolygonIcon(java.awt.Polygon p,
                   java.awt.Dimension size)
Creates a new icon.

Parameters:
p - The polygon.
size - The fixed width/height of the icon.
Method Detail

setFillColor

public void setFillColor(java.awt.Color color)
Sets the fill color of the polygons.

Parameters:
color - The fill color. If this is null, the polygons are filled with the foreground color.

setFilled

public void setFilled(boolean b)

setForeground

public void setForeground(java.awt.Color color)
Sets the foreground color of the polygons.

Parameters:
color - The foreground color. If this is null, the polygons are filled with the foreground color of the Component hosting the icon.

paintIcon

public void paintIcon(java.awt.Component c,
                      java.awt.Graphics g,
                      int x,
                      int y)
Draws the icon at the specified location. Icon implementations may use the Component argument to get properties useful for painting, e.g. the foreground or background color.

Specified by:
paintIcon in interface javax.swing.Icon

getIconWidth

public int getIconWidth()
Gets the width of the icon.

Specified by:
getIconWidth in interface javax.swing.Icon
Returns:
The fixed width of the icon.

getIconHeight

public int getIconHeight()
Gets the height of the icon.

Specified by:
getIconHeight in interface javax.swing.Icon
Returns:
The fixed height of the icon.

Copyright 2012-02-25 Werner Randelshofer