org.opensourcephysics.cabrillo.tracker
Class ShapeIcon

java.lang.Object
  extended by org.opensourcephysics.cabrillo.tracker.ShapeIcon
All Implemented Interfaces:
javax.swing.Icon

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

This Icon centers and fills the shape specified in its constructor.

Author:
Douglas Brown

Constructor Summary
ShapeIcon(java.awt.Shape shape, int width, int height)
          Constructs a ShapeIcon.
ShapeIcon(java.awt.Shape shape, java.awt.Shape decoration, int width, int height)
          Constructs a ShapeIcon.
 
Method Summary
 int getIconHeight()
          Gets the icon height.
 int getIconWidth()
          Gets the icon width.
 void paintIcon(java.awt.Component c, java.awt.Graphics _g, int x, int y)
          Paints the icon.
 void setColor(java.awt.Color color)
          Sets the color.
 void setColor(java.awt.Color color, java.awt.Color decorationColor)
          Sets the colors.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShapeIcon

public ShapeIcon(java.awt.Shape shape,
                 java.awt.Shape decoration,
                 int width,
                 int height)
Constructs a ShapeIcon.

Parameters:
shape - the shape to draw
decoration - a decorating shape to draw
width - width of the icon
height - height of the icon

ShapeIcon

public ShapeIcon(java.awt.Shape shape,
                 int width,
                 int height)
Constructs a ShapeIcon.

Parameters:
shape - the shape to draw
width - width of the icon
height - height of the icon
Method Detail

setColor

public void setColor(java.awt.Color color)
Sets the color.

Parameters:
color - the desired color

setColor

public void setColor(java.awt.Color color,
                     java.awt.Color decorationColor)
Sets the colors.

Parameters:
color - the desired color
decorationColor - the desired decoration color

getIconWidth

public int getIconWidth()
Gets the icon width.

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

getIconHeight

public int getIconHeight()
Gets the icon height.

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

paintIcon

public void paintIcon(java.awt.Component c,
                      java.awt.Graphics _g,
                      int x,
                      int y)
Paints the icon.

Specified by:
paintIcon in interface javax.swing.Icon
Parameters:
c - the component on which it is painted
_g - the graphics context
x - the x coordinate of the icon
y - the y coordinate of the icon