org.openflow.gui.drawables
Class Node

java.lang.Object
  extended by org.pzgui.AbstractDrawable
      extended by org.pzgui.layout.AbstractLayoutable
          extended by org.openflow.gui.drawables.Node
All Implemented Interfaces:
Drawable, Layoutable, Vertex<Link>
Direct Known Subclasses:
NodeWithPorts, SimpleNode

public abstract class Node
extends AbstractLayoutable
implements Vertex<Link>

Information about a node in the topology.

Author:
David Underhill

Field Summary
static double OUTLINE_RATIO
          ratio to use when outlining the shape
static boolean SHOW_NAMES
          whether to draw names on nodes
 
Constructor Summary
Node(java.lang.String name, int x, int y, Icon icon)
           
 
Method Summary
 boolean contains(int x, int y)
          returns true if the area described by getIcon() contains x, y
protected  void drawFailed(java.awt.Graphics2D gfx)
          draw an "X" over the node to indicate failure
protected  void drawName(java.awt.Graphics2D gfx, int x, int y)
          draws the name of the object centered at the specified x coordinate
 void drawObject(java.awt.Graphics2D gfx)
          Draws this object using the Icon specified by getIcon() at its current location as specified by getX() and getY().
 void drawOutline(java.awt.Graphics2D gfx, java.awt.Paint outlineColor, double ratio)
          Draw an outline around the object.
abstract  java.lang.String getDebugName()
          gets a debug version of the node's name
 int getHeight()
          The height of this node
 Icon getIcon()
          get how this node is visually represented
 java.lang.String getName()
          gets the name of the node
 int getWidth()
          The width of this node
 boolean isFailed()
           
 boolean isOff()
           
protected  boolean isWithin(int x, int y, java.awt.Dimension sz)
          Returns true if the object of size sz contains the location x, y
 void setFailed(boolean b)
           
 void setIcon(Icon icon)
          set how this node is visually represented
 void setName(java.lang.String name)
          sets the node's name
 void setOff(boolean b)
           
 java.lang.String toString()
          returns the name of the node
 
Methods inherited from class org.pzgui.layout.AbstractLayoutable
canPositionChange, drag, getPos, getX, getY, hasPositionChanged, setCanPositionChange, setPos, setXPos, setYPos, unsetPositionChanged
 
Methods inherited from class org.pzgui.AbstractDrawable
drawBeforeObject, isDrawn, isHovered, isSelected, setHovered, setSelected, unsetDrawn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.pzgui.layout.Vertex
getEdges
 
Methods inherited from interface org.pzgui.Drawable
drag, drawBeforeObject, isDrawn, isHovered, isSelected, setHovered, setSelected, unsetDrawn
 
Methods inherited from interface org.pzgui.layout.Layoutable
canPositionChange, getID, getPos, getX, getY, hasPositionChanged, setCanPositionChange, setPos, setXPos, setYPos, unsetPositionChanged
 

Field Detail

SHOW_NAMES

public static boolean SHOW_NAMES
whether to draw names on nodes


OUTLINE_RATIO

public static final double OUTLINE_RATIO
ratio to use when outlining the shape

See Also:
Constant Field Values
Constructor Detail

Node

public Node(java.lang.String name,
            int x,
            int y,
            Icon icon)
Method Detail

getName

public java.lang.String getName()
gets the name of the node


getDebugName

public abstract java.lang.String getDebugName()
gets a debug version of the node's name


setName

public void setName(java.lang.String name)
sets the node's name


drawName

protected final void drawName(java.awt.Graphics2D gfx,
                              int x,
                              int y)
draws the name of the object centered at the specified x coordinate


drawObject

public void drawObject(java.awt.Graphics2D gfx)
Draws this object using the Icon specified by getIcon() at its current location as specified by getX() and getY(). The name is drawn below the object.

Specified by:
drawObject in interface Drawable
Specified by:
drawObject in class AbstractDrawable

drawFailed

protected void drawFailed(java.awt.Graphics2D gfx)
draw an "X" over the node to indicate failure


drawOutline

public void drawOutline(java.awt.Graphics2D gfx,
                        java.awt.Paint outlineColor,
                        double ratio)
Draw an outline around the object.

Parameters:
gfx - where to draw
outlineColor - color of the outline
ratio - how big to make the outline

getIcon

public Icon getIcon()
get how this node is visually represented


setIcon

public void setIcon(Icon icon)
set how this node is visually represented


isOff

public boolean isOff()

setOff

public void setOff(boolean b)

isFailed

public boolean isFailed()

setFailed

public void setFailed(boolean b)

getHeight

public int getHeight()
The height of this node

Specified by:
getHeight in interface Layoutable

getWidth

public int getWidth()
The width of this node

Specified by:
getWidth in interface Layoutable

isWithin

protected boolean isWithin(int x,
                           int y,
                           java.awt.Dimension sz)
Returns true if the object of size sz contains the location x, y


contains

public boolean contains(int x,
                        int y)
returns true if the area described by getIcon() contains x, y

Specified by:
contains in interface Drawable
Overrides:
contains in class AbstractLayoutable

toString

public java.lang.String toString()
returns the name of the node

Overrides:
toString in class java.lang.Object