uchicago.src.sim.gui
Class Network2DGridDisplay

java.lang.Object
  extended by uchicago.src.sim.gui.Display2D
      extended by uchicago.src.sim.gui.Object2DDisplay
          extended by uchicago.src.sim.gui.Network2DGridDisplay
All Implemented Interfaces:
Displayable, Probeable

public class Network2DGridDisplay
extends Object2DDisplay

Displays a 2D grid of Drawable2DNodes and DrawableEDges. Draws edges from and to the center of nodes.

Like all all the DiscreteDisplayables Network2DGridDisplay draws a Discrete2DSpace by getting the objects in each cell in the Grid and sending those objects a draw message. If the space being displayed implements the Torus marker interface, the edges will be displayed as wrapping around the torus by default. Note that for efficiency this only draws a Node's out edges (which must be some other Node's in edge and so they all get drawn). It is important then that any edge that is being drawn be added to some Nodes list of out edges. As a general rule an edge should be added to both its from Node and its to Node.

Version:
$Revision: 1.10 $ $Date: 2004/11/03 19:50:59 $
Author:
Nick Collier
See Also:
Drawable2DNode, DrawableEdge

Field Summary
 
Fields inherited from class uchicago.src.sim.gui.Object2DDisplay
objsToDraw, view
 
Fields inherited from class uchicago.src.sim.gui.Display2D
grid, size
 
Fields inherited from interface uchicago.src.sim.gui.Displayable
TOGGLE_LINKS, TOGGLE_NODES, TOGGLE_UPDATE_LAYOUT, TOGGLE_VIEW, TOGGLE_WRAP
 
Constructor Summary
Network2DGridDisplay(Discrete2DSpace grid)
          Creates a new Network2DGridDisplay for the specified grid.
 
Method Summary
 void drawDisplay(SimGraphics g)
          Draws the grid.
 java.util.ArrayList getDisplayableInfo()
          Gets the DisplayableInfo
 void setLinksVisible(boolean isVisible)
          Shows or hides links depending on the value of parameter isVisible.
 void setNodesVisible(boolean isVisible)
          Shows or hids nodes depending on the value of the parameter isVisible.
 void viewEventPerformed(ViewEvent evt)
          Invoked when a viewEvent for this display is fired by the DisplaySurface.
 void wrapLinks(boolean wrap)
          Wraps the drawn links around the edges of the display, assuming the space to be drawn is a Torus, depending on the value of wrap parameter.
 
Methods inherited from class uchicago.src.sim.gui.Object2DDisplay
getObjectsAt, setMoveableXY, setObjectList
 
Methods inherited from class uchicago.src.sim.gui.Display2D
getGrid, getSize, reSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Network2DGridDisplay

public Network2DGridDisplay(Discrete2DSpace grid)
Creates a new Network2DGridDisplay for the specified grid.

Parameters:
grid - the grid to display
Method Detail

setLinksVisible

public void setLinksVisible(boolean isVisible)
Shows or hides links depending on the value of parameter isVisible.

Parameters:
isVisible - if true, shows the links, otherwise hide links

setNodesVisible

public void setNodesVisible(boolean isVisible)
Shows or hids nodes depending on the value of the parameter isVisible.

Parameters:
isVisible - if true, shows the nodes, otherwise hide nodes

wrapLinks

public void wrapLinks(boolean wrap)
Wraps the drawn links around the edges of the display, assuming the space to be drawn is a Torus, depending on the value of wrap parameter.

Parameters:
wrap - if true, links will be drawn wrapped around the display, otherwise not.

drawDisplay

public void drawDisplay(SimGraphics g)
Draws the grid.

Specified by:
drawDisplay in interface Displayable
Overrides:
drawDisplay in class Object2DDisplay
Parameters:
g - the graphics context on which to draw

getDisplayableInfo

public java.util.ArrayList getDisplayableInfo()
Gets the DisplayableInfo

Specified by:
getDisplayableInfo in interface Displayable
Overrides:
getDisplayableInfo in class Object2DDisplay
See Also:
DisplayInfo

viewEventPerformed

public void viewEventPerformed(ViewEvent evt)
Invoked when a viewEvent for this display is fired by the DisplaySurface.

Specified by:
viewEventPerformed in interface Displayable
Overrides:
viewEventPerformed in class Object2DDisplay