org.cfpm.caves.za
Class MultiLayerNetwork2DDisplay

java.lang.Object
  extended by org.cfpm.caves.za.MultiLayerNetwork2DDisplay
All Implemented Interfaces:
uchicago.src.sim.gui.Displayable, uchicago.src.sim.gui.Probeable, uchicago.src.sim.gui.Zoomable

public class MultiLayerNetwork2DDisplay
extends java.lang.Object
implements uchicago.src.sim.gui.Displayable, uchicago.src.sim.gui.Probeable, uchicago.src.sim.gui.Zoomable

Displays only a specified layer of a multi-layer network. Unfortunately, Repast's Network2DDisplay is not meant to be sub-classed outside of Repast's class hierarchy, that's why this implementation is a copy of Network2DDisplay with the necessary changes put in. This is mainly overwriting the inner classes ZoomDrawer and NormalDrawer to "remove" all edges of the wrong type. All changes are marked in the code with comments.

Author:
Ruth Meyer

Nested Class Summary
(package private) static interface MultiLayerNetwork2DDisplay.Drawer
           
(package private)  class MultiLayerNetwork2DDisplay.NodePoint
           
(package private)  class MultiLayerNetwork2DDisplay.NormalDrawer
           
(package private)  class MultiLayerNetwork2DDisplay.ZoomDrawer
           
 
Field Summary
private  boolean drawEdgesFirst
           
private  MultiLayerNetwork2DDisplay.Drawer drawer
           
protected  java.util.ArrayList edges
           
protected  int height
           
protected  uchicago.src.sim.gui.GraphLayout layout
           
protected  java.lang.String linkType
          addition: the type of link to be displayed
protected  java.util.Hashtable nodePoint
           
protected  java.util.ArrayList tmpList
           
private static int TOGGLE_EDGE_ON_TOP
           
protected  boolean viewLinks
           
protected  boolean viewNodes
           
protected  int width
           
protected  java.util.HashMap zoomSet
           
 
Fields inherited from interface uchicago.src.sim.gui.Displayable
TOGGLE_LINKS, TOGGLE_NODES, TOGGLE_UPDATE_LAYOUT, TOGGLE_VIEW, TOGGLE_WRAP
 
Constructor Summary
MultiLayerNetwork2DDisplay(uchicago.src.sim.gui.GraphLayout layout, java.lang.String linkType)
          Creates a MultiLayerNetwork2DDisplay using the specified GraphLayout.
MultiLayerNetwork2DDisplay(java.util.List list, int width, int height, java.lang.String linkType)
          Creates a MultiLayerNetwork2DDisplay of the specified width and height for displaying the DrawableNonGridNodes in the list.
MultiLayerNetwork2DDisplay(uchicago.src.sim.space.VectorSpace space, int width, int height, java.lang.String linkType)
          Creates a MultiLayerNetwork2DDisplay of the specified width and height for displaying the DrawableNonGridNodes and DrawableEdges in the specified space.
 
Method Summary
 void addNode(uchicago.src.sim.gui.DrawableNonGridNode node)
          addition: necessary to be able to add nodes during the simulation
 void drawDisplay(uchicago.src.sim.gui.SimGraphics g)
          Draws this display
 void endZoom()
           
 java.util.ArrayList getDisplayableInfo()
          Gets the DisplayableInfo
 boolean getDrawEdgesFirst()
          Gets whether or not this draws the edges first and then the nodes over them.
 java.util.ArrayList getObjectsAt(int x, int y)
          Gets a list of the objects that contain the specified screen coordinate.
 java.awt.Dimension getSize()
          Gets the size of this VectorDisplay.
 void removeNode(uchicago.src.sim.gui.DrawableNonGridNode node)
          addition: necessary to be able to remove nodes during the simulation
 void setDrawEdgesFirst(boolean drawEdgesFirst)
          Sets whether or not this draws the edges first and then the nodes over them.
 void setLinksVisible(boolean isVisible)
          Shows or hides links depending on the value of parameter isVisible.
 void setMoveableXY(uchicago.src.sim.gui.Moveable moveable, int x, int y)
          Sets the new coordinates for specified moveable.
 void setNodesVisible(boolean isVisible)
          Shows or hids nodes depending on the value of the parameter isVisible.
 void startZoom(int x, int y, int zWidth, int zHeight)
           
 void viewEventPerformed(uchicago.src.sim.gui.ViewEvent evt)
          Invoked when a viewEvent for this display is fired by the DisplaySurface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

linkType

protected java.lang.String linkType
addition: the type of link to be displayed


layout

protected uchicago.src.sim.gui.GraphLayout layout

TOGGLE_EDGE_ON_TOP

private static final int TOGGLE_EDGE_ON_TOP
See Also:
Constant Field Values

edges

protected java.util.ArrayList edges

nodePoint

protected java.util.Hashtable nodePoint

viewNodes

protected boolean viewNodes

viewLinks

protected boolean viewLinks

tmpList

protected java.util.ArrayList tmpList

height

protected int height

width

protected int width

zoomSet

protected java.util.HashMap zoomSet

drawEdgesFirst

private boolean drawEdgesFirst

drawer

private MultiLayerNetwork2DDisplay.Drawer drawer
Constructor Detail

MultiLayerNetwork2DDisplay

public MultiLayerNetwork2DDisplay(uchicago.src.sim.space.VectorSpace space,
                                  int width,
                                  int height,
                                  java.lang.String linkType)
Creates a MultiLayerNetwork2DDisplay of the specified width and height for displaying the DrawableNonGridNodes and DrawableEdges in the specified space.

Parameters:
space - the space containing the DrawableNonGridNodes to display
width - the width of the display in pixels
height - the height of the display in pixels
linkType - the type of edges to be displayed

MultiLayerNetwork2DDisplay

public MultiLayerNetwork2DDisplay(java.util.List list,
                                  int width,
                                  int height,
                                  java.lang.String linkType)
Creates a MultiLayerNetwork2DDisplay of the specified width and height for displaying the DrawableNonGridNodes in the list.

Parameters:
list - the list containing the DrawableNonGridNodes to display
width - the width of the display in pixels
height - the height of the display in pixels
linkType - the type of edges to be displayed

MultiLayerNetwork2DDisplay

public MultiLayerNetwork2DDisplay(uchicago.src.sim.gui.GraphLayout layout,
                                  java.lang.String linkType)
Creates a MultiLayerNetwork2DDisplay using the specified GraphLayout.

Parameters:
layout - the GraphLayout for this Network2DDisplay.
linkType - the type of edges to be displayed
Method Detail

getDrawEdgesFirst

public boolean getDrawEdgesFirst()
Gets whether or not this draws the edges first and then the nodes over them. Default value is false.

Returns:
if true this draws the edges first then the nodes over them

setDrawEdgesFirst

public void setDrawEdgesFirst(boolean drawEdgesFirst)
Sets whether or not this draws the edges first and then the nodes over them. Default value is false.

Parameters:
drawEdgesFirst - whether or not this draws edges first then nodes

getSize

public java.awt.Dimension getSize()
Gets the size of this VectorDisplay.

Specified by:
getSize in interface uchicago.src.sim.gui.Displayable

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

drawDisplay

public void drawDisplay(uchicago.src.sim.gui.SimGraphics g)
Draws this display

Specified by:
drawDisplay in interface uchicago.src.sim.gui.Displayable

getDisplayableInfo

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

Specified by:
getDisplayableInfo in interface uchicago.src.sim.gui.Displayable
See Also:
DisplayInfo

getObjectsAt

public java.util.ArrayList getObjectsAt(int x,
                                        int y)
Gets a list of the objects that contain the specified screen coordinate.

Specified by:
getObjectsAt in interface uchicago.src.sim.gui.Probeable
Parameters:
x - the x coordinate
y - the y coordinate

setMoveableXY

public void setMoveableXY(uchicago.src.sim.gui.Moveable moveable,
                          int x,
                          int y)
Sets the new coordinates for specified moveable. This goes through probeable as some translation between screen pixel coordinates and the simulation coordinates may be necessary.

Specified by:
setMoveableXY in interface uchicago.src.sim.gui.Probeable
Parameters:
moveable - the moveable whose coordinates are changed
x - the x coordinate in pixels
y - the y coordinate in pixels

startZoom

public void startZoom(int x,
                      int y,
                      int zWidth,
                      int zHeight)
Specified by:
startZoom in interface uchicago.src.sim.gui.Zoomable

endZoom

public void endZoom()
Specified by:
endZoom in interface uchicago.src.sim.gui.Zoomable

viewEventPerformed

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

Specified by:
viewEventPerformed in interface uchicago.src.sim.gui.Displayable

addNode

public void addNode(uchicago.src.sim.gui.DrawableNonGridNode node)
addition: necessary to be able to add nodes during the simulation


removeNode

public void removeNode(uchicago.src.sim.gui.DrawableNonGridNode node)
addition: necessary to be able to remove nodes during the simulation