RePast
v. 2.0

uchicago.src.sim.gui
Class Network2DDisplay

java.lang.Object
  |
  +--uchicago.src.sim.gui.Network2DDisplay
All Implemented Interfaces:
Displayable, Probeable, Zoomable

public class Network2DDisplay
extends Object
implements Displayable, Probeable, Zoomable

Displays nodes and links that inhabit a VectorSpace, that is, nodes (and their links) that do not inhabit a grid. This expects to be drawing a VectorSpace of DrawableNonGridNodes or a List of DrawableNonGridNodes. 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. In addition, these edges must implement DrawableEdge in order to be drawn.

See Also:
DrawableNonGridNode, DrawableEdge

Field Summary
protected  ArrayList edges
           
protected  int height
           
protected  GraphLayout layout
           
protected  Hashtable nodePoint
           
protected  ArrayList tmpList
           
protected  boolean viewLinks
           
protected  boolean viewNodes
           
protected  int width
           
protected  HashMap zoomSet
           
 
Fields inherited from interface uchicago.src.sim.gui.Displayable
TOGGLE_LINKS, TOGGLE_NODES, TOGGLE_UPDATE_LAYOUT, TOGGLE_VIEW, TOGGLE_WRAP
 
Constructor Summary
Network2DDisplay(GraphLayout layout)
          Creates a Network2DDisplay using the specified GraphLayout.
Network2DDisplay(List list, int width, int height)
          Creates a Network2DDisplay of the specified width and height for displaying the DrawableNonGridNodes in the list.
Network2DDisplay(VectorSpace space, int width, int height)
          Creates a Network2DDisplay of the specified width and height for displaying the DrawableNonGridNodes and DrawableEdges in the specified space.
 
Method Summary
 void drawDisplay(SimGraphics g)
          Draws this display
 void endZoom()
           
 ArrayList getDisplayableInfo()
          Gets the DisplayableInfo
 ArrayList getObjectsAt(int x, int y)
          Gets a list of the objects that contain the specified screen coordinate.
 Dimension getSize()
          Gets the size of this VectorDisplay.
 void setLinksVisible(boolean isVisible)
          Shows or hides links depending on the value of parameter isVisible.
 void setMoveableXY(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(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

layout

protected GraphLayout layout

edges

protected ArrayList edges

nodePoint

protected Hashtable nodePoint

viewNodes

protected boolean viewNodes

viewLinks

protected boolean viewLinks

tmpList

protected ArrayList tmpList

height

protected int height

width

protected int width

zoomSet

protected HashMap zoomSet
Constructor Detail

Network2DDisplay

public Network2DDisplay(VectorSpace space,
                        int width,
                        int height)
Creates a Network2DDisplay 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

Network2DDisplay

public Network2DDisplay(List list,
                        int width,
                        int height)
Creates a Network2DDisplay 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

Network2DDisplay

public Network2DDisplay(GraphLayout layout)
Creates a Network2DDisplay using the specified GraphLayout.

Parameters:
layout - the GraphLayout for this Network2DDisplay.
Method Detail

getSize

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

Specified by:
getSize in interface 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(SimGraphics g)
Draws this display

Specified by:
drawDisplay in interface Displayable

getDisplayableInfo

public ArrayList getDisplayableInfo()
Gets the DisplayableInfo

Specified by:
getDisplayableInfo in interface Displayable
See Also:
DisplayInfo

getObjectsAt

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

Specified by:
getObjectsAt in interface Probeable
Parameters:
x - the x coordinate
y - the y coordinate
Returns:
the object at the x, y coordinate.

setMoveableXY

public void setMoveableXY(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 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 Zoomable

endZoom

public void endZoom()
Specified by:
endZoom in interface Zoomable

viewEventPerformed

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

Specified by:
viewEventPerformed in interface Displayable

RePast
v. 2.0

Bug reports and feature requests to RePast