simulation
Class ComponentFigure

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

public class ComponentFigure
extends org.eclipse.draw2d.RectangleFigure

This figure represents a component inside a host in the View.

Author:
Nels,Vivek,Gordon Started Nov 5, 2003

Nested Class Summary
(package private) static class ComponentFigure.Dragger
          This private class tells the Component 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 org.eclipse.swt.graphics.Color classColor
          The Component background color.
private  int componentID
          The ID of this component.
private  java.util.LinkedList connected_components
          A linked list that contains ints.
private  DetailListener dListenter
           
private  boolean is_movable
          A boolean that says if the ComponentFigure can be Moved.
private  double memory
          The amount of memory this component requires.
private  int parentHostID
          The ID of the host that contains this component.
 
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
ComponentFigure(int id, int host_id, double Cmem, int x_pos, int y_pos, int w, int h)
          Creates a new Component with the given properties.
 
Method Summary
 void addDetailListener(DetailListener dl)
          Sets the detail listener of this component to the one passed to it.
 void addToConnectedComponents(int com_id)
          This method adds a component id to the connected_components linked list.
 boolean connectedToCom(int com_id)
          Returns true if this component is connected to the component with the given id.
 int getComponentID()
          Gets the ID of this component.
 double getComponentMemory()
          Returns the amount of memory that this component requires.
 java.util.LinkedList getConnectedComponents()
           
 DetailListener getDetailListener()
          Gets the detail listener of this component.
 boolean getIsMovable()
          Returns whether or not this ComponentFigure can be moved.
 int getParentHostID()
          Get the ID of this component's host.
 void removeFromConnectedComponents(int com_id)
          This method removes a component id from the connected_components linked list.
 void setComponentID(int id)
          Set a id for this compoent.
 void setComponentMemory(double mem)
          Set the amount of memory that this component requires.
 void setIsMovable(boolean b)
          Sets whether or not the Component figure is movable.
 void setParentHostID(int id)
          Set a new parent host id for this component.
 void setQuality(double quality)
          This method will set the color of the component 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 Component background color.


componentID

private int componentID
The ID of this component.


parentHostID

private int parentHostID
The ID of the host that contains this component.


memory

private double memory
The amount of memory this component requires.


is_movable

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


connected_components

private java.util.LinkedList connected_components
A linked list that contains ints. These ints represent the component ids of all the components that this component is connected to. Therefore, if this component is connected to 5 other components, the sized of the link list should be 5 at that same point in time.


dListenter

private DetailListener dListenter
Constructor Detail

ComponentFigure

public ComponentFigure(int id,
                       int host_id,
                       double Cmem,
                       int x_pos,
                       int y_pos,
                       int w,
                       int h)
Creates a new Component with the given properties.

Parameters:
id - The ID number of this component.
host_id - The ID number of the host that contains this component.
Cmem - The memory that this component takes up.
x_pos - The x cordinate of the point where this figure should be placed.
y_pos - The y cordinate of the point where this figure should be placed.
w - The width of this figure.
h - The height of this figure.
Method Detail

setParentHostID

public void setParentHostID(int id)
Set a new parent host id for this component.

Parameters:
id - The new parent host id.

getParentHostID

public int getParentHostID()
Get the ID of this component's host.

Returns:
parentHostID

getComponentID

public int getComponentID()
Gets the ID of this component.

Returns:
componentID

setComponentID

public void setComponentID(int id)
Set a id for this compoent.

Parameters:
id - The new id of this component.

setIsMovable

public void setIsMovable(boolean b)
Sets whether or not the Component 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 Component can be moved.

getIsMovable

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

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

getComponentMemory

public double getComponentMemory()
Returns the amount of memory that this component requires.

Returns:
memory

setComponentMemory

public void setComponentMemory(double mem)
Set the amount of memory that this component requires.

Parameters:
mem - The memory that this component will require.

addDetailListener

public void addDetailListener(DetailListener dl)
Sets the detail listener of this component 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 component. If the detail listener has not been set, this function will return null.

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

getConnectedComponents

public java.util.LinkedList getConnectedComponents()

addToConnectedComponents

public void addToConnectedComponents(int com_id)
This method adds a component id to the connected_components linked list. This signifies that this component is connected to the component with the given id.

Parameters:
com_id - The id of the component that this component has connected to.

removeFromConnectedComponents

public void removeFromConnectedComponents(int com_id)
This method removes a component id from the connected_components linked list. This means that this component is no longer connected to the component with the given id.

Parameters:
com_id - The id of the component that this component is no longer conneced to.

connectedToCom

public boolean connectedToCom(int com_id)
Returns true if this component is connected to the component with the given id.

Parameters:
com_id - The id of the component that you are checking for links with.
Returns:
True if this component is connected to the component with the given id.

setQuality

public void setQuality(double quality)
This method will set the color of the component 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.