com.isti.util.gui
Class SymbolIcon

java.lang.Object
  extended by com.isti.util.gui.SymbolIcon
All Implemented Interfaces:
SymbolConstants, javax.swing.Icon

public class SymbolIcon
extends java.lang.Object
implements javax.swing.Icon, SymbolConstants

Class SymbolIcon is a icon that is a symbol. The symbol may be a filled circle, an empty circle, or a character; all with a given color.


Field Summary
protected static java.awt.Font symFontBold
           
protected static java.awt.Font symFontPlain
           
 
Fields inherited from interface com.isti.util.gui.SymbolConstants
CIRCLE_SYMBOL_OBJECT, RECTANGLE_SYMBOL_OBJECT, TRIANGLE_SYMBOL_OBJECT
 
Constructor Summary
SymbolIcon()
           
 
Method Summary
 void clearSymbolChar()
          Clears any character symbol in use, making a circle symbol be used instead.
protected static java.awt.Polygon createTriangle(int x, int y, int width)
          Creates a triangle.
 int getIconHeight()
          Returns the icon's height.
 int getIconWidth()
          Returns the icon's width.
 java.lang.String getLabelText()
          Get the label text.
 boolean isCharSymbol()
          Gets a flag indicating whether or not a character symbol is in use.
 void paintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y)
          Draw the icon at the specified location.
protected  void paintSymbol(java.awt.Component c, java.awt.Graphics g, int x, int y, boolean fillFlag)
          Paints the symbol.
 void setBoldFlag(boolean flgVal)
          Sets whether or not the the character symbol is displayed using a bold font.
 java.awt.Color setColorObj(java.awt.Color colorObj)
          Sets the color for the symbol.
 java.awt.Color setColorObj(int colorRGB)
          Sets the color for the symbol.
 void setFillFlag(boolean flgVal)
          Sets whether or not the the object symbol is filled.
 void setLabelText(java.lang.String labelText)
          Set the label text.
 void setOutlineColorObj(java.awt.Color colorObj)
          Sets the outline color to be used for filled symbols.
 void setSymbolChar(char symbolChar)
          Sets the character symbol to be used.
 void setSymbolObject(int symbolObj)
          Sets the object symbol to be used.
protected  void setupSymbol(java.awt.Graphics g)
          Setup the symbol if needed.
protected  java.lang.String symbolCharToString(char symbolChar)
          Converts the given symbol character to a displayable, single-character string.
 java.lang.String toString()
          Return the label text.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

symFontBold

protected static final java.awt.Font symFontBold

symFontPlain

protected static final java.awt.Font symFontPlain
Constructor Detail

SymbolIcon

public SymbolIcon()
Method Detail

clearSymbolChar

public void clearSymbolChar()
Clears any character symbol in use, making a circle symbol be used instead.


getIconHeight

public int getIconHeight()
Returns the icon's height.

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

getIconWidth

public int getIconWidth()
Returns the icon's width.

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

getLabelText

public java.lang.String getLabelText()
Get the label text.

Returns:
the label text.

isCharSymbol

public boolean isCharSymbol()
Gets a flag indicating whether or not a character symbol is in use.

Returns:
true if a character symbol is in use, false if a object symbol is in use.

paintIcon

public void paintIcon(java.awt.Component c,
                      java.awt.Graphics g,
                      int x,
                      int y)
Draw 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
Parameters:
c - the component to which the icon is added.
g - graphics object to use.
x - the X coordinate of the icon's top-left corner.
y - the Y coordinate of the icon's top-left corner.
fillFlag - true if the circle is to be filled; false if not.

paintSymbol

protected void paintSymbol(java.awt.Component c,
                           java.awt.Graphics g,
                           int x,
                           int y,
                           boolean fillFlag)
Paints the symbol.

Parameters:
g - graphics object to use.
c - the component to which the icon is added.
x - the X coordinate of the icon's top-left corner.
y - the Y coordinate of the icon's top-left corner.
fillFlag - true if the circle is to be filled; false if not.

setBoldFlag

public void setBoldFlag(boolean flgVal)
Sets whether or not the the character symbol is displayed using a bold font.

Parameters:
flgVal - true for bold, false for normal font.

setColorObj

public java.awt.Color setColorObj(java.awt.Color colorObj)
Sets the color for the symbol.

Parameters:
colorObj - the color to use.
Returns:
the color.

setColorObj

public java.awt.Color setColorObj(int colorRGB)
Sets the color for the symbol.

Parameters:
colorRGB - the color RGB to use.
Returns:
the color.

setFillFlag

public void setFillFlag(boolean flgVal)
Sets whether or not the the object symbol is filled.

Parameters:
flgVal - true if the object is to be filled; false if not.

setLabelText

public void setLabelText(java.lang.String labelText)
Set the label text.

Parameters:
labelText - the label text.

setOutlineColorObj

public void setOutlineColorObj(java.awt.Color colorObj)
Sets the outline color to be used for filled symbols.

Parameters:
colorObj - the color for the symbol outline, or null for no outline.

setSymbolChar

public void setSymbolChar(char symbolChar)
Sets the character symbol to be used.

Parameters:
symbolChar - the character symbol to use, or '(char)0' to have no character symbol (and use circle symbol instead).

setSymbolObject

public void setSymbolObject(int symbolObj)
Sets the object symbol to be used.

Parameters:
symbolObj - the object symbol to use.

setupSymbol

protected void setupSymbol(java.awt.Graphics g)
Setup the symbol if needed.

Parameters:
g - graphics object to use.

symbolCharToString

protected java.lang.String symbolCharToString(char symbolChar)
Converts the given symbol character to a displayable, single-character string.

Parameters:
symbolChar - the character to use.
Returns:
A new String.

toString

public java.lang.String toString()
Return the label text.

Overrides:
toString in class java.lang.Object
Returns:
the label text.

createTriangle

protected static java.awt.Polygon createTriangle(int x,
                                                 int y,
                                                 int width)
Creates a triangle.

Parameters:
x - the x coordinate of the triangle to be drawn.
y - the y coordinate of the triangle to be drawn.
width - the width of the triangle to be drawn.
Returns:
the triangle.