|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectvitro.grid.GridView
public class GridView
GridView is a generic View that can be applied to any GridModel. It supports the display of ActorAnnotations as well as GridAnnotations and can be easily extended to support new features or alter the appearance of various elements.
Field Summary | |
---|---|
protected int |
cellMargin
The margin between the edges of a cell and an Actor. |
protected int |
cellSize
The size (width and height) of a cell in pixels. |
protected ColorScheme |
colors
This View's ColorScheme. |
protected Controller |
controller
This View's Controller. |
protected int |
height
The height of this View in pixels. |
protected int |
horizontalMargin
The x-offset of the grid relative to the View. |
protected Grid |
model
This View's Model. |
protected int |
verticalMargin
The y-offset of the grid relative to the View. |
protected int |
width
The width of this View in pixels. |
Constructor Summary | |
---|---|
GridView(Grid model,
Controller controller,
int width,
int height,
ColorScheme colors)
Construct a new GridView. |
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)
Render the entire View. |
protected void |
drawActor(Graphics2D g,
Actor a)
Render one Actor. |
protected void |
drawActorAnnotation(Graphics2D g,
ActorAnnotation a)
Render one ActorAnnotation. |
protected void |
drawBackground(Graphics2D g)
Render the background of this View. |
protected void |
drawCell(Graphics2D g,
int x,
int y)
Render one cell of the Grid, starting at a specified position. |
protected void |
drawGridAnnotation(Graphics2D g,
GridAnnotation a)
Render one GridAnnotation. |
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final int width
protected final int height
protected final int cellSize
protected int cellMargin
protected int horizontalMargin
protected int verticalMargin
protected final Grid model
protected final Controller controller
protected final ColorScheme colors
Constructor Detail |
---|
public GridView(Grid model, Controller controller, int width, int height, ColorScheme colors)
model
- the Model this View will visualize.controller
- the Controller associated with the Model.width
- the width this View should take up, in pixels.height
- the height this View should take up, in pixels.colors
- the ColorScheme used for drawing this View.Method Detail |
---|
public Controller controller()
controller
in interface View
public ColorScheme colorScheme()
colorScheme
in interface View
public int width()
width
in interface View
public int height()
height
in interface View
public void draw(Graphics2D g)
draw
in interface View
g
- the target Graphics2D surface.protected void drawBackground(Graphics2D g)
g
- the target Graphics2D surface.protected void drawCell(Graphics2D g, int x, int y)
g
- the target Graphics2D surface.x
- the x-coordinate of the top-left corner of this cell in pixels.y
- the y-coordinate of the top-left corner of this cell in pixels.protected void drawActor(Graphics2D g, Actor a)
g
- the target Graphics2D surface.a
- the Actor to render.protected void drawActorAnnotation(Graphics2D g, ActorAnnotation a)
g
- the target Graphics2D surface.a
- the ActorAnnotation to render.protected void drawGridAnnotation(Graphics2D g, GridAnnotation a)
g
- the target Graphics2D surface.a
- the GridAnnotation to render.public void tick(double time)
tick
in interface View
time
- the amount of time that has passed since the last tickpublic void flush()
flush
in interface View
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |