jview
Class CircleIcon

java.lang.Object
  extended by jview.CircleIcon
All Implemented Interfaces:
Icon

public class CircleIcon
extends Object
implements Icon

A icon that displays itself as a filled circle, color depending on its state. The outline of the circle is drawn in the current color, if not specified. This icon is also a toggle.


Nested Class Summary
static class CircleIcon.Label
          Constructs labels with this icon and displays them.
 
Field Summary
static int DEFHEIGHT
          The default icon height in pixel.
static int DEFWIDTH
          The default icon width in pixel.
private  int height
          The icon height.
private  Color off
          The off color.
private  Color on
          The on color.
private  Color outline
          The outl;ine color.
private  Component parent
          The parent component for redraws if the state changes.
private  Boolean state
          State of the icon.
private  int width
          The icon width.
 
Constructor Summary
CircleIcon(Color red, Color green)
          Constructs a new circular icon with the specified on and off color and the default size.
CircleIcon(Color red, Color green, boolean init)
          Constructs a new circular icon with the specified on and off color and the default size.
CircleIcon(Color red, Color green, int w, int h)
          Constructs a new circular icon with the specified on and off color and the given size.
CircleIcon(Color red, Color green, int w, int h, boolean init)
          Constructs a new circular icon with the specified on and off color and the given size.
 
Method Summary
 int getIconHeight()
          Returns the icon height.
 int getIconWidth()
          Returns the icon width.
 boolean getState()
          Gets the state of the icon.
 void paintIcon(Component c, Graphics g, int x, int y)
          Paints the icon.
 void setOutlineColor(Color out)
          Sets the outline color.
 void setState(boolean on)
          Sets the state of the icon.
 boolean toggle()
          Toggles the state of the icon.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFWIDTH

public static final int DEFWIDTH
The default icon width in pixel.

See Also:
Constant Field Values

DEFHEIGHT

public static final int DEFHEIGHT
The default icon height in pixel.

See Also:
Constant Field Values

width

private int width
The icon width.


height

private int height
The icon height.


on

private Color on
The on color.


off

private Color off
The off color.


outline

private Color outline
The outl;ine color.


state

private Boolean state
State of the icon. Once set, only on/off is displayed.


parent

private Component parent
The parent component for redraws if the state changes.

Constructor Detail

CircleIcon

public CircleIcon(Color red,
                  Color green)
Constructs a new circular icon with the specified on and off color and the default size.


CircleIcon

public CircleIcon(Color red,
                  Color green,
                  boolean init)
Constructs a new circular icon with the specified on and off color and the default size.


CircleIcon

public CircleIcon(Color red,
                  Color green,
                  int w,
                  int h,
                  boolean init)
Constructs a new circular icon with the specified on and off color and the given size.


CircleIcon

public CircleIcon(Color red,
                  Color green,
                  int w,
                  int h)
Constructs a new circular icon with the specified on and off color and the given size.

Method Detail

getIconWidth

public int getIconWidth()
Returns the icon width.

Specified by:
getIconWidth in interface Icon

getIconHeight

public int getIconHeight()
Returns the icon height.

Specified by:
getIconHeight in interface Icon

paintIcon

public void paintIcon(Component c,
                      Graphics g,
                      int x,
                      int y)
Paints the icon. The graphics object is returned in the same state as prior to the call.

Specified by:
paintIcon in interface Icon
Parameters:
x - the X coordinate of the icon's top-left corner.
y - the Y coordinate of the icon's top-left corner

setOutlineColor

public void setOutlineColor(Color out)
Sets the outline color. If called with null, the outline color is restored to be the default drawing color.


toggle

public boolean toggle()
Toggles the state of the icon. If it was painted already, issue a repaint of the parent component.

Returns:
The new icon state.

setState

public void setState(boolean on)
Sets the state of the icon.


getState

public boolean getState()
Gets the state of the icon. If the state was never set, false is returned.