edu.usc.cse.desi.model.view
Class HostViewModel

java.lang.Object
  extended byedu.usc.cse.desi.model.AbstractDESIModel
      extended byedu.usc.cse.desi.model.view.AbstractViewModel
          extended byedu.usc.cse.desi.model.view.AbstractNodeViewModel
              extended byedu.usc.cse.desi.model.view.HostViewModel
All Implemented Interfaces:
java.util.EventListener, org.eclipse.ui.views.properties.IPropertySource, java.beans.PropertyChangeListener, java.io.Serializable

public class HostViewModel
extends AbstractNodeViewModel

A model of a Host which contains the information necessary to display this model onscreen.

Author:
Nels Started Feb 18, 2004
See Also:
Serialized Form

Nested Class Summary
private  class HostViewModel.ConnectionPair
          Private class, used only for the myMissingConnections hash table in the HostViewModel.
 
Field Summary
private  java.util.HashMap myMissingConnections
           
private  java.util.BitSet myPointBitSet
           
private  HostDataModel myXADLModel
           
 
Fields inherited from class edu.usc.cse.desi.model.view.AbstractNodeViewModel
C_DISPLAY_IMAGEDATA, C_DISPLAY_MODELDATA, myBGColor, myBorderWidth, myChildren, myConnections, myFigPosX, myFigPosY, myFigSizeH, myFigSizeW, P_DISPLAY_FIGLOCATION_X, P_DISPLAY_FIGLOCATION_Y, P_DISPLAY_FIGSIZE_H, P_DISPLAY_FIGSIZE_W, P_DISPLAY_NUMCHILDREN, P_DISPLAY_NUMCONNECTIONS, P_ID_FIGLOCATION_X, P_ID_FIGLOCATION_Y, P_ID_FIGSIZE_H, P_ID_FIGSIZE_W, P_ID_NUMCHILDREN, P_ID_NUMCONNECTIONS
 
Fields inherited from class edu.usc.cse.desi.model.view.AbstractViewModel
myDataModel
 
Fields inherited from class edu.usc.cse.desi.model.AbstractDESIModel
listeners
 
Constructor Summary
  HostViewModel()
           
private HostViewModel(HostDataModel model)
           
  HostViewModel(PropertyInitializer prop_init)
          This will be a constructor that can be called if there is no preexisting data model.
 
Method Summary
 void addComponent(ComponentViewModel comp)
          This is the public version of add component and it will add a new component to this host.
 void addConnection(PhysicalLinkViewModel link)
          This is the public version of addConnection and it will add a physical link to this host when the host is connected.
 void colorLinksBlack()
          When called, this method will change the color of all attached links to black.
 void colorLinksRed()
          When called, this method will change the color of all attached links to red.
 void finalize()
          Just to make sure that nothing keeps this class as a listener after the object has been eliminated.
 HostDataModel getMyXADLModel()
           
 void initialize(HostDataModel model)
          Initialize is called when a view model object is created on a data model object.
 void layoutComponents()
          Call this method and all the children will be put in their proper place in the layout.
private  void privateAddComponent(ComponentViewModel component)
          Adds the component to the host if it is not already added to the host.
private  void privateAddConnection(PhysicalLinkViewModel link)
          Adds a link to this host if the link is not already added.
private  void privateRemoveComponent(ComponentViewModel component)
          Removes the component from the host if it has already been added to the host.
private  void privateRemoveConnection(PhysicalLinkViewModel link)
          Removes the link from the host.
 void propertyChange(java.beans.PropertyChangeEvent evt)
          On propertyChange, this class will respond to any additions or subtractions of components or connections by the HostDataModel.
 void reinitialize()
          Reinitialize all sub-components and connections.
 void removeAllComponents()
          Remove every component contained by this host.
 void removeComponent(ComponentViewModel comp)
          This is the public version of removeComponent and it will remove a component from the host.
 void removeConnection(PhysicalLinkViewModel link)
          This is teh public version of remove connection and it will remove a physical link from connecting this host.
 void setMyXADLModel(HostDataModel myXADLModel)
          Set this property with a xADL model if you are running on top of a xADL file.
 void setPropertyValue(java.lang.String prop_name, java.lang.Object value)
          I overrode this method:
 
Methods inherited from class edu.usc.cse.desi.model.view.AbstractNodeViewModel
addConnectedNode, getChildren, getConnectedLink, getConnectedNodes, getConnections, getEditableValue, getMyBGColor, getMyBorderWidth, getMyFigPosX, getMyFigPosY, getMyFigSizeH, getMyFigSizeW, getMyPropetyInitializer, getProperties, getPropertyDescriptors, getPropertyDisplayName, getPropertyValue, getPropertyValue, hasProperty, isConnectedToNode, isPropertySet, numOfConnectedNodes, removeConnectedNode, resetPropertyValue, setMyBGColor, setMyBorderWidth, setMyDataModel, setMyFigPosX, setMyFigPosY, setMyFigSizeH, setMyFigSizeW, setPropertyValue
 
Methods inherited from class edu.usc.cse.desi.model.view.AbstractViewModel
getMyDataModel
 
Methods inherited from class edu.usc.cse.desi.model.AbstractDESIModel
addPropertyChangeListener, firePropertyChange, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myPointBitSet

private java.util.BitSet myPointBitSet

myMissingConnections

private java.util.HashMap myMissingConnections

myXADLModel

private transient HostDataModel myXADLModel
Constructor Detail

HostViewModel

public HostViewModel(PropertyInitializer prop_init)
This will be a constructor that can be called if there is no preexisting data model. It will create a data model.


HostViewModel

public HostViewModel()

HostViewModel

private HostViewModel(HostDataModel model)
Method Detail

initialize

public void initialize(HostDataModel model)
Initialize is called when a view model object is created on a data model object. It does a lot of the functionality that used to be in the constructor but that had to be moved.

Parameters:
model -

reinitialize

public void reinitialize()
Reinitialize all sub-components and connections. Add yourself as a listener to your data model.

Overrides:
reinitialize in class AbstractNodeViewModel
See Also:
AbstractDESIModel.reinitialize()

setMyXADLModel

public void setMyXADLModel(HostDataModel myXADLModel)
Set this property with a xADL model if you are running on top of a xADL file.

Parameters:
myXADLModel - The myXADLModel to set.

getMyXADLModel

public HostDataModel getMyXADLModel()
Returns:
Returns the myXADLModel.

finalize

public void finalize()
              throws java.lang.Throwable
Just to make sure that nothing keeps this class as a listener after the object has been eliminated.

Throws:
java.lang.Throwable

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
On propertyChange, this class will respond to any additions or subtractions of components or connections by the HostDataModel. It will then report the change to all listeners.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Overrides:
propertyChange in class AbstractDESIModel

privateAddConnection

private void privateAddConnection(PhysicalLinkViewModel link)
Adds a link to this host if the link is not already added.

Parameters:
link - PhysicalLinkViewModel

addConnection

public void addConnection(PhysicalLinkViewModel link)
This is the public version of addConnection and it will add a physical link to this host when the host is connected.

Parameters:
link -

privateRemoveConnection

private void privateRemoveConnection(PhysicalLinkViewModel link)
Removes the link from the host. If link is not in host, nothing happens.

Parameters:
link - PhysicalLinkViewModel

removeConnection

public void removeConnection(PhysicalLinkViewModel link)
This is teh public version of remove connection and it will remove a physical link from connecting this host.

Parameters:
link -

setPropertyValue

public void setPropertyValue(java.lang.String prop_name,
                             java.lang.Object value)
                      throws PropertyNotFoundException,
                             java.lang.ClassCastException
I overrode this method:

Overrides:
setPropertyValue in class AbstractNodeViewModel
Throws:
PropertyNotFoundException
java.lang.ClassCastException
See Also:
AbstractViewModel.setPropertyValue(java.lang.String, java.lang.Object)

layoutComponents

public void layoutComponents()
Call this method and all the children will be put in their proper place in the layout. It does so by clearing the bit set and then assigning every component a new position.


colorLinksRed

public void colorLinksRed()
When called, this method will change the color of all attached links to red.


colorLinksBlack

public void colorLinksBlack()
When called, this method will change the color of all attached links to black.


privateAddComponent

private void privateAddComponent(ComponentViewModel component)
Adds the component to the host if it is not already added to the host. Protected because we only want components added or removed to the HostDataModel and then informing us through our listener.

Parameters:
component - ComponentViewModel

addComponent

public void addComponent(ComponentViewModel comp)
This is the public version of add component and it will add a new component to this host.

Parameters:
comp -

privateRemoveComponent

private void privateRemoveComponent(ComponentViewModel component)
Removes the component from the host if it has already been added to the host. Protected because we only want components added or removed to the HostDataModel and then informing us through our listener.

Parameters:
component - ComponentViewModel

removeComponent

public void removeComponent(ComponentViewModel comp)
This is the public version of removeComponent and it will remove a component from the host.

Parameters:
comp -

removeAllComponents

public void removeAllComponents()
Remove every component contained by this host.