templates.diagram
Class SimpleIcon

java.lang.Object
  extended by templates.diagram.SimpleIcon
All Implemented Interfaces:
javax.swing.Icon, EntityIcon

public class SimpleIcon
extends java.lang.Object
implements EntityIcon

Simple implementation of the EntityIcon interface. The icon is either rectangular or oval (depending on the type of rendered component), with uniform background, containing the "tag" of the component.

Author:
Lenko Grigorov

Field Summary
protected  java.awt.Color bgColor
          Background color of the icon.
protected  int deltaX
          The displacement of the text inside the icon, in the X direction.
protected  int deltaY
          The displacement of the text inside the icon, in the Y direction.
protected static java.awt.Stroke FAT_LINE_STROKE
          Line stroke for the border of the icon.
protected  java.awt.Color fgColor
          Color of the text inside the icon (if any).
protected  boolean flag
          Is the icon "flagged".
protected  int flaggedDeltaX
          The displacement of the text inside the icon when it is "flagged", in the X direction.
protected  int flaggedDeltaY
          The displacement of the text inside the icon when it is "flagged", in the Y direction.
protected  int flaggedH
          Height of the icon when it is "flagged".
protected  java.lang.String flaggedTag
          Text inside the icon when it is "flagged".
protected  int flaggedW
          Width of the icon when it is "flagged".
protected  int h
          Height of the icon.
protected  boolean isModule
          Does the icon represent a module (true) or a channel (false).
protected static int SPACING
          Space to be added between the icon border and the text inside the icon (if any), in pixels.
protected  java.lang.String tag
          Text inside the icon.
protected  int w
          Width of the icon.
 
Fields inherited from interface templates.utils.EntityIcon
BOX_DISTANCE
 
Constructor Summary
SimpleIcon()
          Construct a simple icon with default attributes.
SimpleIcon(java.lang.String tag, java.awt.Color color, java.awt.Graphics context)
          Construct a simple icon with the given parameters.
 
Method Summary
 SimpleIcon clone()
          Create a clone of this icon.
 java.awt.Color getColor()
          Retrieve the background color of the icon.
 int getIconHeight()
           
 int getIconWidth()
           
 java.lang.String getTag()
          Retrieve the text rendered inside the icon.
 boolean isFlagged()
          Check if the icon is "flagged".
 void paintIcon(java.awt.Component arg0, java.awt.Graphics g, int x, int y)
           
 void paintIcon(java.awt.Graphics g, int x, int y, java.awt.Color color)
          Render the icon in the given graphics context according to the given parameters.
 void setColor(java.awt.Color color)
          Set the background color of the icon.
 void setFlagged(boolean b)
          Specify if the icon has to be "flagged".
 void setIsModule(boolean b)
          Specify the type of icon to be painted.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FAT_LINE_STROKE

protected static final java.awt.Stroke FAT_LINE_STROKE
Line stroke for the border of the icon.


SPACING

protected static final int SPACING
Space to be added between the icon border and the text inside the icon (if any), in pixels.

See Also:
Constant Field Values

bgColor

protected java.awt.Color bgColor
Background color of the icon.


fgColor

protected java.awt.Color fgColor
Color of the text inside the icon (if any).


tag

protected java.lang.String tag
Text inside the icon. Can be the empty string.


flaggedTag

protected java.lang.String flaggedTag
Text inside the icon when it is "flagged". Can be the empty string.


w

protected int w
Width of the icon.


flaggedW

protected int flaggedW
Width of the icon when it is "flagged".


h

protected int h
Height of the icon.


flaggedH

protected int flaggedH
Height of the icon when it is "flagged".


deltaY

protected int deltaY
The displacement of the text inside the icon, in the Y direction.


flaggedDeltaY

protected int flaggedDeltaY
The displacement of the text inside the icon when it is "flagged", in the Y direction.


deltaX

protected int deltaX
The displacement of the text inside the icon, in the X direction.


flaggedDeltaX

protected int flaggedDeltaX
The displacement of the text inside the icon when it is "flagged", in the X direction.


isModule

protected boolean isModule
Does the icon represent a module (true) or a channel (false).


flag

protected boolean flag
Is the icon "flagged".

Constructor Detail

SimpleIcon

public SimpleIcon(java.lang.String tag,
                  java.awt.Color color,
                  java.awt.Graphics context)
Construct a simple icon with the given parameters.

Parameters:
tag - the text inside the icon (can be the empty string)
color - the background color of the icon
context - the graphical context to be used for font metrics information

SimpleIcon

public SimpleIcon()
Construct a simple icon with default attributes.

Method Detail

getIconHeight

public int getIconHeight()
Specified by:
getIconHeight in interface javax.swing.Icon

getIconWidth

public int getIconWidth()
Specified by:
getIconWidth in interface javax.swing.Icon

paintIcon

public void paintIcon(java.awt.Component arg0,
                      java.awt.Graphics g,
                      int x,
                      int y)
Specified by:
paintIcon in interface javax.swing.Icon

paintIcon

public void paintIcon(java.awt.Graphics g,
                      int x,
                      int y,
                      java.awt.Color color)
Description copied from interface: EntityIcon
Render the icon in the given graphics context according to the given parameters.

Specified by:
paintIcon in interface EntityIcon
Parameters:
g - the graphics context where the icon has to be rendered
x - the location of the icon on the horizontal axis
y - the location of the icon on the vertical axis
color - the color to be used for the border of the icon

clone

public SimpleIcon clone()
Description copied from interface: EntityIcon
Create a clone of this icon.

Specified by:
clone in interface EntityIcon
Overrides:
clone in class java.lang.Object
Returns:
the clone of this icon

setIsModule

public void setIsModule(boolean b)
Description copied from interface: EntityIcon
Specify the type of icon to be painted.

Specified by:
setIsModule in interface EntityIcon
Parameters:
b - specify true for an icon for template components of type module, specify false for an icon for template components of type channel

getColor

public java.awt.Color getColor()
Description copied from interface: EntityIcon
Retrieve the background color of the icon.

Specified by:
getColor in interface EntityIcon
Returns:
the background color of the icon

isFlagged

public boolean isFlagged()
Description copied from interface: EntityIcon
Check if the icon is "flagged".

Specified by:
isFlagged in interface EntityIcon
Returns:
true if the icon is "flagged"; false otherwise

setColor

public void setColor(java.awt.Color color)
Description copied from interface: EntityIcon
Set the background color of the icon.

Specified by:
setColor in interface EntityIcon
Parameters:
color - the new background color of the icon

setFlagged

public void setFlagged(boolean b)
Description copied from interface: EntityIcon
Specify if the icon has to be "flagged".

Specified by:
setFlagged in interface EntityIcon
Parameters:
b - specify true if the icon has to be "flagged", specify false otherwise

getTag

public java.lang.String getTag()
Description copied from interface: EntityIcon
Retrieve the text rendered inside the icon.

Specified by:
getTag in interface EntityIcon
Returns:
the text rendered inside the icon