simulation
Class HostFigure

java.lang.Object
  extended byorg.eclipse.draw2d.Figure
      extended byorg.eclipse.draw2d.Shape
          extended byorg.eclipse.draw2d.RectangleFigure
              extended bysimulation.HostFigure
All Implemented Interfaces:
org.eclipse.draw2d.IFigure

public class HostFigure
extends org.eclipse.draw2d.RectangleFigure

The HostFigure class represents a host onscreen.

Author:
Nels,Vivek,Gordon

Nested Class Summary
(package private) static class HostFigure.Dragger
          This private class tells the HostFigure what to do when it is dragged.
 
Nested classes inherited from class org.eclipse.draw2d.Figure
org.eclipse.draw2d.Figure.FigureIterator, org.eclipse.draw2d.Figure.IdentitySearch
 
Nested classes inherited from class org.eclipse.draw2d.IFigure
org.eclipse.draw2d.IFigure.NoInsets
 
Field Summary
static int borderRoom
          borderRoom contains the amount of excess room that will be placed around new components as they are added.
static org.eclipse.swt.graphics.Color classColor
          The Host background color.
private  DetailListener dListenter
           
private  org.eclipse.draw2d.Figure host_contents
          This Figure is the pane that contains all ComponentFigures that are to be added to the host.
private  int hostID
          Host id number.
private  boolean is_movable
          A boolean that says if the HostFigure can be Moved.
private  double memory
          The total memory of the host.
private  int num_of_components
          The number of components that the host contains.
 
Fields inherited from class org.eclipse.draw2d.Shape
lineStyle, lineWidth
 
Fields inherited from class org.eclipse.draw2d.Figure
bgColor, border, bounds, fgColor, flags, font, MAX_FLAG, maxSize, minSize, NO_MANAGER, prefSize, toolTip
 
Fields inherited from interface org.eclipse.draw2d.IFigure
MAX_DIMENSION, MIN_DIMENSION, NO_INSETS
 
Constructor Summary
HostFigure(int host_id, double mem, int x_pos, int y_pos, int width, int height)
          Creates a new HostFigure.
 
Method Summary
 void addComponent(ComponentFigure com_fig)
          This method will add the given function to this host's host_contents Figure.
 void addDetailListener(DetailListener dl)
          Sets the detail listener of this Host to the one passed to it.
 void cleanupHostContents()
          This method goes through all the components contained in this host, and rearranges them in to a pretty looking layout again.
 DetailListener getDetailListener()
          Gets the detail listener of this Host.
 org.eclipse.draw2d.Figure getHostContents()
          This method returns the host_contents Figure that contains all the components and links that are inside this host.
 int getHostID()
          Returns the Host's ID number.
 boolean getIsMovable()
          Returns whether or not this HostFigure can be moved.
 double getMemory()
          Return the amount of memory that this host has.
 int getNumOfComponents()
          Returns the number of components this host has.
 void setHostID(int id)
          Set the host ID number.
 void setIsMovable(boolean b)
          Sets whether or not the Host figure is movable.
 void setMemory(double hostmemory)
          Sets a new amount of memory for the Host.
 void setNumOfComponents(int num)
          Sets the number of components that this host has.
 void setQuality(double quality)
          This method will set the color of the host based on its "quality" as determined by a double between 0.0 and 1.0.
 
Methods inherited from class org.eclipse.draw2d.RectangleFigure
fillShape, outlineShape
 
Methods inherited from class org.eclipse.draw2d.Shape
getLineStyle, getLineWidth, isOpaque, paintFigure, setFill, setFillXOR, setLineStyle, setLineWidth, setOutline, setOutlineXOR, setXOR
 
Methods inherited from class org.eclipse.draw2d.Figure
add, add, add, add, addAncestorListener, addFigureListener, addFocusListener, addKeyListener, addListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, containsPoint, containsPoint, erase, findDescendantAtExcluding, findFigureAt, findFigureAt, findFigureAt, findFigureAtExcluding, findMouseEventTargetAt, findMouseEventTargetInDescendantsAt, fireMoved, firePropertyChange, firePropertyChange, firePropertyChange, getBackgroundColor, getBorder, getBounds, getChildren, getClientArea, getClientArea, getCursor, getFlag, getFont, getForegroundColor, getInsets, getLayoutManager, getListeners, getLocalBackgroundColor, getLocalForegroundColor, getLocation, getMaximumSize, getMinimumSize, getMinimumSize, getParent, getPreferredSize, getPreferredSize, getSize, getToolTip, getUpdateManager, handleFocusGained, handleFocusLost, handleKeyPressed, handleKeyReleased, handleMouseDoubleClicked, handleMouseDragged, handleMouseEntered, handleMouseExited, handleMouseHover, handleMouseMoved, handleMousePressed, handleMouseReleased, hasFocus, internalGetEventDispatcher, intersects, invalidate, invalidateTree, isEnabled, isFocusTraversable, isMouseEventTarget, isRequestFocusEnabled, isShowing, isValid, isValidationRoot, isVisible, layout, paint, paintBorder, paintChildren, paintClientArea, primTranslate, remove, removeAll, removeAncestorListener, removeFigureListener, removeFocusListener, removeKeyListener, removeListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, revalidate, setBackgroundColor, setBorder, setBounds, setChildrenDirection, setChildrenEnabled, setChildrenOrientation, setConstraint, setCursor, setEnabled, setFlag, setFocusTraversable, setFont, setForegroundColor, setLayoutManager, setLocation, setMaximumSize, setMinimumSize, setOpaque, setParent, setPreferredSize, setPreferredSize, setRequestFocusEnabled, setSize, setSize, setToolTip, setValid, setVisible, translate, translateFromParent, translateToAbsolute, translateToParent, translateToRelative, useLocalCoordinates, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

classColor

public static org.eclipse.swt.graphics.Color classColor
The Host background color.


hostID

private int hostID
Host id number.


memory

private double memory
The total memory of the host.


num_of_components

private int num_of_components
The number of components that the host contains.


host_contents

private org.eclipse.draw2d.Figure host_contents
This Figure is the pane that contains all ComponentFigures that are to be added to the host.


is_movable

private boolean is_movable
A boolean that says if the HostFigure can be Moved. Defaults to true;


borderRoom

public static int borderRoom
borderRoom contains the amount of excess room that will be placed around new components as they are added.


dListenter

private DetailListener dListenter
Constructor Detail

HostFigure

public HostFigure(int host_id,
                  double mem,
                  int x_pos,
                  int y_pos,
                  int width,
                  int height)
Creates a new HostFigure.

Parameters:
host_id - The Host's ID number.
mem - The Total host memory.
x_pos - The x position of the HostFigure.
y_pos - The y position of the HostFigure.
width - The width of the HostFigure.
height - The height of the HostFigure.
Method Detail

addComponent

public void addComponent(ComponentFigure com_fig)
This method will add the given function to this host's host_contents Figure. After this it will then appear on the host.

Parameters:
com_fig - The ComponentFigure that is to be added to this Host.

cleanupHostContents

public void cleanupHostContents()
This method goes through all the components contained in this host, and rearranges them in to a pretty looking layout again.


setHostID

public void setHostID(int id)
Set the host ID number.

Parameters:
id - New Host ID number.

getIsMovable

public boolean getIsMovable()
Returns whether or not this HostFigure can be moved.

Returns:
A boolean, that says that the Host can be moved.

setIsMovable

public void setIsMovable(boolean b)
Sets whether or not the Host figure is movable. In other words, does the Dragger resond to drags of the mouse or not.

Parameters:
b - A boolean which says whether or not the Host can be moved.

getHostID

public int getHostID()
Returns the Host's ID number.

Returns:
hostID

addDetailListener

public void addDetailListener(DetailListener dl)
Sets the detail listener of this Host to the one passed to it.

Parameters:
dl - The new Detail listener of this HostFigure.

getDetailListener

public DetailListener getDetailListener()
Gets the detail listener of this Host. If the detail listener has not been set, this function will return null.

Returns:
This Host's detail listener or Null if one has not been set.

getNumOfComponents

public int getNumOfComponents()
Returns the number of components this host has.

Returns:
num_of_components

setNumOfComponents

public void setNumOfComponents(int num)
Sets the number of components that this host has.

Parameters:
num - The new number of components.

setMemory

public void setMemory(double hostmemory)
Sets a new amount of memory for the Host.

Parameters:
hostmemory - New memory amount.

getMemory

public double getMemory()
Return the amount of memory that this host has.

Returns:
memory

getHostContents

public org.eclipse.draw2d.Figure getHostContents()
This method returns the host_contents Figure that contains all the components and links that are inside this host. You can use this method to let you add C2C and C2Conn liks to components inside this host. However, if you need to add components you should use the addComponent(..) function of this Host.

Returns:
host_contents

setQuality

public void setQuality(double quality)
This method will set the color of the host based on its "quality" as determined by a double between 0.0 and 1.0. If the number is not in this range, nothing will happen.

Parameters:
quality - A double between 0.0 and 1.0.