All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class gpsys.cos.TerrainViewer

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----gpsys.cos.TerrainViewer

public class TerrainViewer
extends Canvas
implements TerrainObserver
Provides a view of the terrain and terrain robot on the terrain.

Author:
Emmanuel PIERRE
DEA IARFA,
See Also:
Cos, TerrainObserver

Variable Index

 o robot1X
The current X-coordinate of the terrainrobot.
 o robot1Y
The current Y-coordinate of the terrainrobot.
 o terrain
The terrain being monitored.
 o txt
 o txtA

Constructor Index

 o TerrainViewer(Terrain)
Create a new TerrainViewer Object which provides a view of the specified Terrain.

Method Index

 o init()
Initialise the position of the robot on the terrain.
 o paint(Graphics)
Override the Canvas paint() method so that the terrain and terrain robot is drawn on the Canvas.
 o printInfo(String)
 o printTxt(String)
 o robotMoved(int, int)
Update the terrain view when a square on the terrain is being cut.
 o terrainInit()
Update the terrain view when the terrain regrows.
 o update(Graphics)
Override the Canvas update() method so that the Canvas is not cleared before it is redrawn.

Variables

 o terrain
 Terrain terrain
The terrain being monitored.

 o robot1X
 int robot1X
The current X-coordinate of the terrainrobot.

 o robot1Y
 int robot1Y
The current Y-coordinate of the terrainrobot.

 o txt
 TextField txt
 o txtA
 TextArea txtA

Constructors

 o TerrainViewer
 public TerrainViewer(Terrain terrain)
Create a new TerrainViewer Object which provides a view of the specified Terrain.

Parameters:
terrain - The Terrain being viewed.

Methods

 o printTxt
 public void printTxt(String str)
 o printInfo
 public void printInfo(String str)
 o init
 public void init()
Initialise the position of the robot on the terrain.

 o update
 public void update(Graphics g)
Override the Canvas update() method so that the Canvas is not cleared before it is redrawn.

Parameters:
g - The graphics Object associated with the Canvas.
Overrides:
update in class Component
 o paint
 public void paint(Graphics g)
Override the Canvas paint() method so that the terrain and terrain robot is drawn on the Canvas.

Parameters:
g - The graphics Object associated with the Canvas.
Overrides:
paint in class Canvas
 o terrainInit
 public void terrainInit()
Update the terrain view when the terrain regrows.

 o robotMoved
 public void robotMoved(int x,
                        int y)
Update the terrain view when a square on the terrain is being cut.

Parameters:
x - The X-coordinate of the square being cut.
y - The Y-coordinate of the square being cut.

All Packages  Class Hierarchy  This Package  Previous  Next  Index