All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class life.GridDisplay

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Panel
                           |
                           +----life.GridDisplay

public class GridDisplay
extends Panel
A GridDisplay object displays a Grid object.


Variable Index

 o backgroundColor
Background color.
 o cellColor
Cell color.
 o cellColors
Available Cell colors.
 o cellHeight
Width and height of Cells in this GridDisplay.
 o cellWidth
Width and height of Cells in this GridDisplay.
 o currX
X grid coordinate of Cell over which mouse was most recently pressed.
 o currY
Y grid coordinate of Cell over which mouse was most recently pressed.
 o DRAWING
The user is in draw mode.
 o drawMode
Current drawing mode.
 o ERASING
The user is in erase mode.
 o gridHeight
Width and height of this GridDisplay (in Cells).
 o gridWidth
Width and height of this GridDisplay (in Cells).
 o height
Width and height of this GridDisplay (in pixels).
 o maxAge
Maximum Cell age.
 o offGraphics
Offscreen graphics context.
 o offImage
Offscreen drawing Image.
 o paintAll
Paint all cells in GridDisplay or only those which have changed since last generation?
 o parent
The parent LifeDisplay of this GridDisplay.
 o shades
Number of shades.
 o theLife
The Life object to be displayed by this GridDisplay.
 o width
Width and height of this GridDisplay (in pixels).

Constructor Index

 o GridDisplay(Life, LifeDisplay)
Construct a GridDisplay to display theLife within LifeDisplay.

Method Index

 o GridDisplay_MouseDrag(MouseEvent)
Respond to a mouse drag.
 o GridDisplay_MousePress(MouseEvent)
Respond to a mouse press.
 o paint(Graphics)
Default paint() method.
 o paint(Graphics, boolean)
Paint with option to paint only the dirty (changed) Cells in the GridDisplay.
 o pixelXToGridX(int)
Convert a pixel X coordinate to a GridDisplay X coordinate.
 o pixelYToGridY(int)
Convert a pixel Y coordinate to GridDisplay Y coordinate.
 o setBackgroundColor(Color)
Set the current background color.
 o setCellColor(Color)
Set the current Cell color.
 o setDrawMode(int)
Set the current drawing mode.
 o setGridSize()
Set the size of the grid.
 o setPaintAll(boolean)
Indicate whether all Cells in the GridDisplay should be displayed or only the dirty Cells.
 o setShades(int)
Set the current number of shades of colors.
 o update(Graphics)
Update the GridDisplay.

Variables

 o DRAWING
 static final int DRAWING
The user is in draw mode.

 o ERASING
 static final int ERASING
The user is in erase mode.

 o theLife
 Life theLife
The Life object to be displayed by this GridDisplay.

 o parent
 LifeDisplay parent
The parent LifeDisplay of this GridDisplay.

 o width
 int width
Width and height of this GridDisplay (in pixels).

 o height
 int height
Width and height of this GridDisplay (in pixels).

 o gridWidth
 int gridWidth
Width and height of this GridDisplay (in Cells).

 o gridHeight
 int gridHeight
Width and height of this GridDisplay (in Cells).

 o cellWidth
 int cellWidth
Width and height of Cells in this GridDisplay.

 o cellHeight
 int cellHeight
Width and height of Cells in this GridDisplay.

 o drawMode
 int drawMode
Current drawing mode.

 o maxAge
 int maxAge
Maximum Cell age.

 o offImage
 Image offImage
Offscreen drawing Image.

 o offGraphics
 Graphics offGraphics
Offscreen graphics context.

 o cellColor
 Color cellColor
Cell color.

 o backgroundColor
 Color backgroundColor
Background color.

 o shades
 int shades
Number of shades.

 o cellColors
 Color cellColors[]
Available Cell colors.

 o currX
 int currX
X grid coordinate of Cell over which mouse was most recently pressed.

 o currY
 int currY
Y grid coordinate of Cell over which mouse was most recently pressed.

 o paintAll
 boolean paintAll
Paint all cells in GridDisplay or only those which have changed since last generation?

Constructors

 o GridDisplay
 GridDisplay(Life theLife,
             LifeDisplay parent)
Construct a GridDisplay to display theLife within LifeDisplay.

Parameters:
theLife - The Life object to display.
parent - The parent LifeDisplay of this GridDisplay.

Methods

 o setGridSize
 synchronized void setGridSize()
Set the size of the grid.

 o setDrawMode
 void setDrawMode(int drawMode)
Set the current drawing mode.

Parameters:
drawMode - The drawing mode to set (drawing or erasing).
 o setCellColor
 synchronized void setCellColor(Color c)
Set the current Cell color.

Parameters:
c - The color to use.
 o setBackgroundColor
 synchronized void setBackgroundColor(Color c)
Set the current background color.

Parameters:
c - The color to use.
 o setShades
 synchronized void setShades(int s)
Set the current number of shades of colors.

Parameters:
s - The number of shades.
 o setPaintAll
 void setPaintAll(boolean paintAll)
Indicate whether all Cells in the GridDisplay should be displayed or only the dirty Cells.

Parameters:
paintAll - True if all Cells should be displayed, false otherwise.
 o paint
 public void paint(Graphics g)
Default paint() method.

Parameters:
g - The graphics context.
Overrides:
paint in class Container
 o paint
 public void paint(Graphics g,
                   boolean paintAll)
Paint with option to paint only the dirty (changed) Cells in the GridDisplay.

Parameters:
g - The graphics context in which to paint.
paintall - True if all Cells should be painted, false otherwise.
 o update
 public void update(Graphics g)
Update the GridDisplay.

Parameters:
g - The graphics context to use.
Overrides:
update in class Container
 o GridDisplay_MousePress
 void GridDisplay_MousePress(MouseEvent event)
Respond to a mouse press.

 o GridDisplay_MouseDrag
 void GridDisplay_MouseDrag(MouseEvent event)
Respond to a mouse drag.

 o pixelXToGridX
 int pixelXToGridX(int pixelX)
Convert a pixel X coordinate to a GridDisplay X coordinate.

Parameters:
pixelX - The pixel X coordinate.
 o pixelYToGridY
 int pixelYToGridY(int pixelY)
Convert a pixel Y coordinate to GridDisplay Y coordinate.

Parameters:
pixelY - The pixel Y coordinate.

All Packages  Class Hierarchy  This Package  Previous  Next  Index