org.ascape.view.vis
Class Overhead2DView

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
                          extended by org.ascape.view.vis.CellView
                              extended by org.ascape.view.vis.HostedAgentView
                                  extended by org.ascape.view.vis.Overhead2DView
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:
Overhead2DView, OverheadRelative2DView

public class Overhead2DView
extends HostedAgentView

A scape view that draws the classic bird's eye view of a 2-dimensional lattice. Draws each cell the cell feature color, then draws an oval in each cell in the agent's feature color. Future versions will provide more drawing options and support multiple agent populations within one lattice.

Since:
1.0
Version:
1.9
Author:
Miles Parker
See Also:
Serialized Form

Field Summary
protected  boolean drawSelectedNeighbors
          The draw selected neighbors.
 
Fields inherited from class org.ascape.view.vis.HostedAgentView
agents_fill_cells_draw_feature, agents_oval_cells_boundary_draw_feature, agents_oval_cells_desc_draw_feature, agents_oval_cells_draw_feature
 
Fields inherited from class org.ascape.view.vis.CellView
borderSize, cells_fill_draw_feature, cells_fill_draw_inset_feature
 
Fields inherited from class org.ascape.view.vis.AgentView
agentColorFeature, drawSelection
 
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
Overhead2DView()
          Constructs an overhead two-dimensional view.
Overhead2DView(java.lang.String name)
          Constructs an overhead two-dimensional view.
 
Method Summary
 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 cellSize)
          Calculate view size for agent size.
protected  void drawCellAt(org.eclipse.draw2d.Graphics graphics, int x, int y)
          Draw cell at.
protected  void drawCellAt(org.eclipse.draw2d.Graphics graphics, int x, int y, DrawFeature feature)
          Draw cell at.
protected  void drawCellAtIfUpdate(org.eclipse.draw2d.Graphics graphics, int x, int y)
          Draw cell at if update.
protected  void drawCellAtIfUpdate(org.eclipse.draw2d.Graphics graphics, int x, int y, DrawFeature feature)
           
protected  void drawNeighborsFor(org.eclipse.draw2d.Graphics g, LocatedAgent agent)
          Draw neighbors for.
 void drawSelectedAgent(org.eclipse.draw2d.Graphics graphics, LocatedAgent a)
          Draws a marker for the provided selected agent.
protected  void drawSelectedAgentAt(org.eclipse.draw2d.Graphics g, LocatedAgent a)
          Draw selected agent at.
 Agent getAgentAtPixel(int x, int y)
          Returns the cell at the given pixel in this view.
 boolean isDrawByFeature()
          Method called once a model is deserialized.
 boolean isDrawFarNeighbors()
          Checks if is draw far neighbors.
 boolean isDrawNetwork()
          Checks if is draw network.
 boolean isDrawSelectedNeighbors()
          Checks if is draw selected neighbors.
 void setDrawByFeature(boolean drawByFeature)
          Sets the draw by feature.
 void setDrawFarNeighbors(boolean drawFarNeighbors)
          Sets the draw far neighbors.
 void setDrawNetwork(boolean drawNetwork)
          Should this view draw network connections between agents?.
 void setDrawSelectedNeighbors(boolean drawSelectedNeighbors)
          Should this view draw neighbor connections between agents?.
 void updateScapeGraphics(org.eclipse.draw2d.Graphics graphics)
          On notification of a scape update, draws the actual overhead view.
 
Methods inherited from class org.ascape.view.vis.HostedAgentView
createFeatures, getHostedAgentColorFeature, getPrimaryAgentColorFeature, setHostedAgentColorFeature, setPrimaryAgentColorFeature
 
Methods inherited from class org.ascape.view.vis.CellView
getBorderSize, getCellColorFeature, getCellSize, setBorderSize, setCellColorFeature, setCellSize
 
Methods inherited from class org.ascape.view.vis.AgentView
addDrawFeature, getAgentColorFeature, getAgentSize, getDrawFeatures, getDrawFeaturesObservable, getDrawSelection, getMiniumSizeWithin, getPreferredSizeWithin, removeDrawFeature, setAgentColorFeature, setAgentSize, update
 
Methods inherited from class org.ascape.view.vis.GraphicsView
addSelectionChangedListener, createEditPart, createImage, createImageFigure, getImage, getImageFigure, getMinimumSizeWithin, getSelection, getSize, refresh, removeSelectionChangedListener, scapeAdded, scapeIterated, setSelection
 
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

drawSelectedNeighbors

protected boolean drawSelectedNeighbors
The draw selected neighbors.

Constructor Detail

Overhead2DView

public Overhead2DView()
Constructs an overhead two-dimensional view.


Overhead2DView

public Overhead2DView(java.lang.String name)
Constructs an overhead two-dimensional view.

Parameters:
name - a user relevant name for this view
Method Detail

drawCellAtIfUpdate

protected void drawCellAtIfUpdate(org.eclipse.draw2d.Graphics graphics,
                                  int x,
                                  int y)
Draw cell at if update.

Parameters:
x - the x
y - the y

drawCellAt

protected void drawCellAt(org.eclipse.draw2d.Graphics graphics,
                          int x,
                          int y)
Draw cell at.

Parameters:
x - the x
y - the y

drawCellAtIfUpdate

protected void drawCellAtIfUpdate(org.eclipse.draw2d.Graphics graphics,
                                  int x,
                                  int y,
                                  DrawFeature feature)

drawCellAt

protected void drawCellAt(org.eclipse.draw2d.Graphics graphics,
                          int x,
                          int y,
                          DrawFeature feature)
Draw cell at.

Parameters:
x - the x
y - the y
feature - the feature

getAgentAtPixel

public Agent getAgentAtPixel(int x,
                             int y)
Description copied from class: AgentView
Returns the cell at the given pixel in this view.

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

drawNeighborsFor

protected void drawNeighborsFor(org.eclipse.draw2d.Graphics g,
                                LocatedAgent agent)
Draw neighbors for.

Parameters:
g - the g
agent - the agent

drawSelectedAgentAt

protected void drawSelectedAgentAt(org.eclipse.draw2d.Graphics g,
                                   LocatedAgent a)
Draw selected agent at.

Parameters:
g - the g
a - the a

drawSelectedAgent

public void drawSelectedAgent(org.eclipse.draw2d.Graphics graphics,
                              LocatedAgent a)
Description copied from class: AgentView
Draws a marker for the provided selected agent.

Overrides:
drawSelectedAgent in class AgentView
a - the agent to draw

updateScapeGraphics

public void updateScapeGraphics(org.eclipse.draw2d.Graphics graphics)
On notification of a scape update, draws the actual overhead view.

Overrides:
updateScapeGraphics in class GraphicsView

calculateViewSizeForAgentSize

public org.eclipse.draw2d.geometry.Dimension calculateViewSizeForAgentSize(org.eclipse.draw2d.geometry.Dimension availableSize,
                                                                           int cellSize)
Description copied from class: AgentView
Calculate view size for agent size.

Overrides:
calculateViewSizeForAgentSize in class AgentView
Parameters:
availableSize - TODO
cellSize - the agent size
Returns:
the dimension

calculateAgentSizeForViewSize

public int calculateAgentSizeForViewSize(org.eclipse.draw2d.geometry.Dimension d)
Description copied from class: AgentView
Calculate agent size for view size.

Overrides:
calculateAgentSizeForViewSize in class AgentView
Parameters:
d - the d
Returns:
the int

isDrawByFeature

public boolean isDrawByFeature()
Method called once a model is deserialized.

Returns:
true, if is draw by feature

setDrawByFeature

public void setDrawByFeature(boolean drawByFeature)
Sets the draw by feature.

Parameters:
drawByFeature - the new draw by feature

isDrawNetwork

public boolean isDrawNetwork()
Checks if is draw network.

Returns:
true, if is draw network

isDrawSelectedNeighbors

public boolean isDrawSelectedNeighbors()
Checks if is draw selected neighbors.

Returns:
true, if is draw selected neighbors

isDrawFarNeighbors

public boolean isDrawFarNeighbors()
Checks if is draw far neighbors.

Returns:
true, if is draw far neighbors

setDrawNetwork

public void setDrawNetwork(boolean drawNetwork)
Should this view draw network connections between agents?.

Parameters:
drawNetwork - the draw network

setDrawSelectedNeighbors

public void setDrawSelectedNeighbors(boolean drawSelectedNeighbors)
Should this view draw neighbor connections between agents?.

Parameters:
drawSelectedNeighbors - the draw selected neighbors

setDrawFarNeighbors

public void setDrawFarNeighbors(boolean drawFarNeighbors)
Sets the draw far neighbors.

Parameters:
drawFarNeighbors - the new draw far neighbors