org.ascape.view.vis
Class AgentView

java.lang.Object
  extended by org.ascape.model.event.DefaultScapeListener
      extended by org.eclipse.amp.escape.ascape.view.ModelScapeView
          extended by org.eclipse.amp.escape.ascape.view.EditPartFactoryScapeView
              extended by org.eclipse.amp.escape.ascape.view.EditPartScapeView
                  extended by org.ascape.view.vis.GraphicsView
                      extended by org.ascape.view.vis.AgentView
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.EventListener, java.util.Observer, ScapeListener, HasName, IDrawSelection, org.eclipse.core.runtime.IAdaptable, org.eclipse.gef.EditPartFactory, org.eclipse.jface.viewers.ISelectionProvider
Direct Known Subclasses:
CellView, Overhead2DContinuousView, Plot2DView

public abstract class AgentView
extends GraphicsView
implements IDrawSelection, java.util.Observer

A generic base class for views that draw some kind of spatial view of a group of cells. Cell views have a default draw feature that draws a background for the cell, using the cell color feature.

Since:
1.0
Version:
3.0d
Author:
Miles Parker, Josh Miller
See Also:
Serialized Form

Field Summary
protected  ColorFeature agentColorFeature
          The generic color feature used to set the color for the primary agent type.
protected  VectorSelection drawSelection
          The draw features that have been selected to draw.
 
Fields inherited from class org.ascape.view.vis.GraphicsView
agentSize, image, imageFigure, imageGC, imageGraphics
 
Fields inherited from class org.ascape.model.event.DefaultScapeListener
listeningToScape, scape
 
Constructor Summary
AgentView()
          Instantiates a new agent view.
AgentView(java.lang.String name)
          Instantiates a new agent view.
 
Method Summary
 void addDrawFeature(DrawFeature feature)
          Adds the provided draw feature to this scape.
 int calculateAgentSizeForViewSize(org.eclipse.draw2d.geometry.Dimension d)
          Calculate agent size for view size.
 org.eclipse.draw2d.geometry.Dimension calculateViewSizeForAgentSize(org.eclipse.draw2d.geometry.Dimension availableSize, int agentSize)
          Calculate view size for agent size.
 void createFeatures()
           
protected  void drawSelectedAgent(org.eclipse.draw2d.Graphics graphics, LocatedAgent a)
          Draws a marker for the provided selected agent.
 Agent getAgentAtPixel(int x, int y)
          Returns the cell at the given pixel in this view.
 ColorFeature getAgentColorFeature()
          Returns the color feature that will be used for determining agent color.
 int getAgentSize()
          Returns a one-dimension size of pixels used to represent each cell.
 java.util.Vector<DrawFeature> getDrawFeatures()
          Returns, as a vector, the draw features available for interpretation of members of this scape.
protected  java.util.Observable getDrawFeaturesObservable()
          Returns an observable delegate that notifies users of draw features that a change has occurred.
 VectorSelection getDrawSelection()
          Returns the selection of draw features for this view.
 org.eclipse.draw2d.geometry.Dimension getMiniumSizeWithin(org.eclipse.draw2d.geometry.Dimension d)
           
 org.eclipse.draw2d.geometry.Dimension getPreferredSizeWithin(org.eclipse.draw2d.geometry.Dimension d)
           
 boolean removeDrawFeature(DrawFeature feature)
          Removes the provided draw feature.
 void setAgentColorFeature(ColorFeature agentColorFeature)
          Set the color feature that will be used for determining agent color.
 void setAgentSize(int cellSize)
          Sets the number of pixels used to represent each cell.
 void update(java.util.Observable o, java.lang.Object arg)
          Draws a marker for the agent, if any, currently being viewed by the agent customizer.
 
Methods inherited from class org.ascape.view.vis.GraphicsView
addSelectionChangedListener, createEditPart, createImage, createImageFigure, getImage, getImageFigure, getMinimumSizeWithin, getSelection, getSize, refresh, removeSelectionChangedListener, scapeAdded, scapeIterated, setSelection, updateScapeGraphics
 
Methods inherited from class org.eclipse.amp.escape.ascape.view.EditPartScapeView
createInput
 
Methods inherited from class org.eclipse.amp.escape.ascape.view.EditPartFactoryScapeView
getAdapter, getRootPart
 
Methods inherited from class org.eclipse.amp.escape.ascape.view.ModelScapeView
getModel, getName, toString
 
Methods inherited from class org.ascape.model.event.DefaultScapeListener
clone, environmentQuiting, getScape, isGraphic, isLifeOfScape, isNotifyScapeAutomatically, notifyScapeUpdated, scapeClosing, scapeDeserialized, scapeInitialized, scapeNotification, scapeRemoved, scapeSetup, scapeStarted, scapeStopped, setName, setNotifyScapeAutomatically
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

drawSelection

protected VectorSelection drawSelection
The draw features that have been selected to draw.


agentColorFeature

protected ColorFeature agentColorFeature
The generic color feature used to set the color for the primary agent type.

Constructor Detail

AgentView

public AgentView()
Instantiates a new agent view.


AgentView

public AgentView(java.lang.String name)
Instantiates a new agent view.

Parameters:
name - the name
Method Detail

getDrawFeaturesObservable

protected java.util.Observable getDrawFeaturesObservable()
Returns an observable delegate that notifies users of draw features that a change has occurred. If you need to know when a change in draw features occur, implement observer in the appropriate class and add it to the Observerable this method returns.

Returns:
the draw features observable

createFeatures

public void createFeatures()
Overrides:
createFeatures in class GraphicsView

addDrawFeature

public void addDrawFeature(DrawFeature feature)
Adds the provided draw feature to this scape.

Parameters:
feature - the feature
See Also:
DrawFeature

removeDrawFeature

public boolean removeDrawFeature(DrawFeature feature)
Removes the provided draw feature.

Parameters:
feature - the draw feature to be removed
Returns:
returns true if successful. False, otherwise.

getDrawFeatures

public java.util.Vector<DrawFeature> getDrawFeatures()
Returns, as a vector, the draw features available for interpretation of members of this scape.

Returns:
the draw features
See Also:
DrawFeature

getDrawSelection

public VectorSelection getDrawSelection()
Returns the selection of draw features for this view.

Specified by:
getDrawSelection in interface IDrawSelection
Returns:
the draw selection

getAgentColorFeature

public ColorFeature getAgentColorFeature()
Returns the color feature that will be used for determining agent color. The default color feature is simply the getForegroundColor() method of the agent.

Returns:
the agent color feature

setAgentColorFeature

public void setAgentColorFeature(ColorFeature agentColorFeature)
Set the color feature that will be used for determining agent color. The default color feature is simply the getForegroundColor() method of the agent.

Parameters:
agentColorFeature - the color feature, whose object is assumed to be an agent populating this lattice

getAgentAtPixel

public Agent getAgentAtPixel(int x,
                             int y)
Returns the cell at the given pixel in this view.

Overrides:
getAgentAtPixel in class GraphicsView
Parameters:
x - the horizontal pixel location
y - the vertical pixel location
Returns:
the agent at pixel

drawSelectedAgent

protected void drawSelectedAgent(org.eclipse.draw2d.Graphics graphics,
                                 LocatedAgent a)
Draws a marker for the provided selected agent.

Overrides:
drawSelectedAgent in class GraphicsView
Parameters:
g - the graphics context to draw to
a - the agent to draw

getPreferredSizeWithin

public org.eclipse.draw2d.geometry.Dimension getPreferredSizeWithin(org.eclipse.draw2d.geometry.Dimension d)
Overrides:
getPreferredSizeWithin in class GraphicsView

getMiniumSizeWithin

public org.eclipse.draw2d.geometry.Dimension getMiniumSizeWithin(org.eclipse.draw2d.geometry.Dimension d)

calculateViewSizeForAgentSize

public org.eclipse.draw2d.geometry.Dimension calculateViewSizeForAgentSize(org.eclipse.draw2d.geometry.Dimension availableSize,
                                                                           int agentSize)
Calculate view size for agent size.

Parameters:
availableSize - TODO
agentSize - the agent size
Returns:
the dimension

calculateAgentSizeForViewSize

public int calculateAgentSizeForViewSize(org.eclipse.draw2d.geometry.Dimension d)
Calculate agent size for view size.

Parameters:
d - the d
Returns:
the int

getAgentSize

public int getAgentSize()
Returns a one-dimension size of pixels used to represent each cell.

Returns:
the agent size

setAgentSize

public void setAgentSize(int cellSize)
Sets the number of pixels used to represent each cell.

Parameters:
cellSize - number of pixels per edge

update

public void update(java.util.Observable o,
                   java.lang.Object arg)
Draws a marker for the agent, if any, currently being viewed by the agent customizer.

Specified by:
update in interface java.util.Observer
Parameters:
g - the graphics context to draw to