edu.colorado.cs.ns2.graphics
Class RectDrawable

java.lang.Object
  extended by edu.colorado.cs.ns2.graphics.RectDrawable
All Implemented Interfaces:
Drawable, java.io.Serializable

public class RectDrawable
extends java.lang.Object
implements Drawable, java.io.Serializable

This class represents Nodes as drawn on the Screen.

Author:
Kevin Bauer, Pushkar Sambhoos.
See Also:
Serialized Form

Field Summary
private  int HEIGHT
          The default shape height.
private  int myHeight
          The shape's height.
private  int myWidth
          The shape's width.
private  int myX
          The shape's X-coordainte.
private  int myY
          The shape's Y-coordinate.
private  boolean selected
          True if this node is selected with the mouse.
private static long serialVersionUID
          Generated version UID.
private  NsNode theNode
          A reference to the NS2 node that this shape represents graphically.
private  int WIDTH
          The default shape width.
 
Constructor Summary
RectDrawable(int x, int y, NsNode node)
          Default constructor.
 
Method Summary
 void drawSelf(java.awt.Graphics g, boolean clear)
          Draws a Node on the Screen
 NsNode getNsNode()
          Get the NsNode Simulation object associated with this Node.
 java.awt.Point getPoint()
          Get Point Representing the co-ordinates of the location of the Node.
 boolean isSelected()
          Checks if the current Node is selected.
 void move(int dX, int dY)
          Changes the coodinates of the location of Node.
 void setSelected()
          Sets the selected flag on the Node.
 void setUnSelected()
          Resets the selected flag on the Node.
 boolean within(int X, int Y)
          Checks to see if (X,Y) lies within the shape.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Generated version UID.

See Also:
Constant Field Values

myX

private int myX
The shape's X-coordainte.


myY

private int myY
The shape's Y-coordinate.


myWidth

private int myWidth
The shape's width.


myHeight

private int myHeight
The shape's height.


theNode

private NsNode theNode
A reference to the NS2 node that this shape represents graphically.


selected

private boolean selected
True if this node is selected with the mouse.


WIDTH

private final int WIDTH
The default shape width.

See Also:
Constant Field Values

HEIGHT

private final int HEIGHT
The default shape height.

See Also:
Constant Field Values
Constructor Detail

RectDrawable

public RectDrawable(int x,
                    int y,
                    NsNode node)
Default constructor.

Parameters:
x - The x-coordinate of the shape.
y - The y-coordinate of the shape.
node - The NS2 node that this shape represents graphically.
Method Detail

drawSelf

public void drawSelf(java.awt.Graphics g,
                     boolean clear)
Draws a Node on the Screen

Specified by:
drawSelf in interface Drawable
Parameters:
g - Graphics Object
clear - set it to false to erase the Node.
See Also:
Drawable.drawSelf(java.awt.Graphics, boolean)

setSelected

public void setSelected()
Sets the selected flag on the Node.


setUnSelected

public void setUnSelected()
Resets the selected flag on the Node.


isSelected

public boolean isSelected()
Checks if the current Node is selected.

Returns:
True if the shape is selected with the mouse.

move

public void move(int dX,
                 int dY)
Changes the coodinates of the location of Node.

Specified by:
move in interface Drawable
Parameters:
dX - change in x-coordinate.
dY - change in y-coordinate.
See Also:
Drawable.move(int, int)

within

public boolean within(int X,
                      int Y)
Checks to see if (X,Y) lies within the shape.

Specified by:
within in interface Drawable
Parameters:
X - x-coordinate.
Y - y-coordinate.
Returns:
True if the point is within the shape.
See Also:
Drawable.within(int, int)

getPoint

public java.awt.Point getPoint()
Get Point Representing the co-ordinates of the location of the Node.

Returns:
Point

getNsNode

public NsNode getNsNode()
Get the NsNode Simulation object associated with this Node.

Returns:
NsNode object.