vitro.graph
Class GraphView

java.lang.Object
  extended by vitro.graph.GraphView
All Implemented Interfaces:
View

public class GraphView
extends Object
implements View


Field Summary
 Graph model
           
 
Constructor Summary
GraphView(Graph model, Controller controller, int width, int height)
           
GraphView(Graph model, Controller controller, int width, int height, ColorScheme palette)
           
GraphView(GraphView other)
           
 
Method Summary
 ColorScheme colorScheme()
          Obtain the ColorScheme used by this View.
 Controller controller()
          Obtain a reference to the Controller associated with this View.
 Edge createEdge(Node start, Node end)
           
 Node createNode(double x, double y)
           
 Node createNode(double x, double y, String label)
           
 boolean done()
           
 void draw(Graphics2D g)
          Draw this view.
 void flush()
          Release any transient view state and update the View to reflect the current state of the Model.
 int height()
          Obtain the preferred height of this View, in pixels.
 Node[][] layoutGrid(int xSize, int ySize)
           
 void tick(double time)
          Advance the state of the simulation.
 int width()
          Obtain the preferred width of this View, in pixels.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

model

public final Graph model
Constructor Detail

GraphView

public GraphView(Graph model,
                 Controller controller,
                 int width,
                 int height,
                 ColorScheme palette)

GraphView

public GraphView(Graph model,
                 Controller controller,
                 int width,
                 int height)

GraphView

public GraphView(GraphView other)
Method Detail

colorScheme

public ColorScheme colorScheme()
Description copied from interface: View
Obtain the ColorScheme used by this View. Mainly used so that host applications can customize their UI overlays to suit this View.

Specified by:
colorScheme in interface View
Returns:
this view's ColorScheme.

controller

public Controller controller()
Description copied from interface: View
Obtain a reference to the Controller associated with this View.

Specified by:
controller in interface View
Returns:
this view's Controller.

width

public int width()
Description copied from interface: View
Obtain the preferred width of this View, in pixels.

Specified by:
width in interface View
Returns:
the width of this view in pixels.

height

public int height()
Description copied from interface: View
Obtain the preferred height of this View, in pixels.

Specified by:
height in interface View
Returns:
the height of this view in pixels.

createNode

public Node createNode(double x,
                       double y)

createNode

public Node createNode(double x,
                       double y,
                       String label)

createEdge

public Edge createEdge(Node start,
                       Node end)

layoutGrid

public Node[][] layoutGrid(int xSize,
                           int ySize)

tick

public void tick(double time)
Description copied from interface: View
Advance the state of the simulation. The time provided may be in fractional units. When a fixed amount of time has elapsed, the View should direct the associated controller to advance the simulation state.

Specified by:
tick in interface View
Parameters:
time - the amount of time that has passed since the last tick

flush

public void flush()
Description copied from interface: View
Release any transient view state and update the View to reflect the current state of the Model. This will be called whenever the Model's Controller is driven externally, allowing Views to interrupt any animations or other operations in progress.

Specified by:
flush in interface View

done

public boolean done()

draw

public void draw(Graphics2D g)
Description copied from interface: View
Draw this view. This method may be called multiple times per call to "tick()".

Specified by:
draw in interface View
Parameters:
g - the target Graphics2D surface.