vitro
Interface View

All Known Implementing Classes:
GraphView, GridView

public interface View

A View provides a visualization of the current state of a Model and may further visualize Actions as they modify this state. Views may also show information regarding the state of one or more Agents if the Agents implement the Annotated interface. Default views are provided for each major Model type, and users needing a more specific implementation may extend these or build their own from scratch.


Method Summary
 ColorScheme colorScheme()
          Obtain the ColorScheme used by this View.
 Controller controller()
          Obtain a reference to the Controller associated with this View.
 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.
 void tick(double time)
          Advance the state of the simulation.
 int width()
          Obtain the preferred width of this View, in pixels.
 

Method Detail

controller

Controller controller()
Obtain a reference to the Controller associated with this View.

Returns:
this view's Controller.

colorScheme

ColorScheme colorScheme()
Obtain the ColorScheme used by this View. Mainly used so that host applications can customize their UI overlays to suit this View.

Returns:
this view's ColorScheme.

width

int width()
Obtain the preferred width of this View, in pixels.

Returns:
the width of this view in pixels.

height

int height()
Obtain the preferred height of this View, in pixels.

Returns:
the height of this view in pixels.

draw

void draw(Graphics2D g)
Draw this view. This method may be called multiple times per call to "tick()".

Parameters:
g - the target Graphics2D surface.

tick

void tick(double time)
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.

Parameters:
time - the amount of time that has passed since the last tick

flush

void flush()
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.