|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--javax.swing.JComponent | +--javax.swing.JPanel | +--gecco.client.Board
The board is what is displayed to the user of the game. It paints the map and the pieces. The board needs to know of a Game object, whose pieces are to be painted on the board.
The board contains scrollbars used for scrolling when the map does not fit the screen. It also contain zoom buttons for zooming in or out on the board. The zoom buttons use some gif images in the icons catalog (zoomin.gif and zoomout.gif).
All painting is done in an offscreen buffer and is then copied to the screen. Use method repaintBoard, to repaint the board to reflect changes in the game.
Inner classes inherited from class javax.swing.JPanel |
JPanel.AccessibleJPanel |
Inner classes inherited from class javax.swing.JComponent |
JComponent.AccessibleJComponent, JComponent.ActionStandin, JComponent.IntVector, JComponent.KeyboardState |
Inner classes inherited from class java.awt.Container |
Container.AccessibleAWTContainer |
Inner classes inherited from class java.awt.Component |
Component.AccessibleAWTComponent, Component.AWTTreeLock |
Field Summary | |
(package private) JComponent |
board
Description of the Field |
(package private) double |
boardHeight
Description of the Field |
(package private) Point |
boardUpperLeft
Description of the Field |
(package private) double |
boardWidth
Description of the Field |
(package private) Game |
game
Description of the Field |
static int |
HEIGHT
The height of the area on which the map and the pieces are painted. |
(package private) JScrollBar |
horizontalScrollbar
Description of the Field |
(package private) AdjustmentListener |
horScrollListener
Description of the Field |
(package private) Map |
map
Description of the Field |
(package private) Dimension |
mapSize
Description of the Field |
(package private) Point |
mapUpperLeft
Description of the Field |
(package private) Image |
offscreenBuffer
Description of the Field |
(package private) JScrollBar |
verticalScrollbar
Description of the Field |
(package private) AdjustmentListener |
vertScrollListener
Description of the Field |
static int |
WIDTH
The width of the area on which the map and the pieces are painted. |
(package private) int |
zoomFactor
Description of the Field |
(package private) JButton |
zoomInButton
Description of the Field |
(package private) JButton |
zoomOutButton
Description of the Field |
Fields inherited from class javax.swing.JPanel |
defaultLayout, uiClassID |
Fields inherited from class java.awt.Container |
component, containerListener, containerSerializedDataVersion, dbg, dispatcher, layoutMgr, listeningBoundsChildren, listeningChildren, maxSize, ncomponents, printing, printingThreads, serialVersionUID |
Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, PROPERTIES, SOMEBITS |
Constructor Summary | |
Board(Game game)
|
Method Summary | |
void |
addBoardMouseListener(MouseListener ml)
Adds the given mouse listener the the area where the map and the pieces are painted. |
void |
addBoardMouseMotionListener(MouseMotionListener mml)
Adds the given MouseMotionListener to the area of the board where the map and the pieces are painted. |
void |
clearMap()
Description of the Method |
Rectangle |
getPieceBounds(Piece piece)
Returns the bounding rectangle of the given piece. |
Position |
getPositionAt(Point p)
Converts a screen point to the Position corresponding to that point. |
Point |
getScreenPoint(Position p)
Converts the given Position of the map to the actual screen Point in the map-and-pieces component's coordinate system. |
void |
invisibilizeMapPoint(Point p)
Makes the given point of the map invisible. |
void |
loadMap(Map m,
Point mapUpperLeft)
Sets the map of the board with the given point as upper left corner. |
void |
mapUpdate(Point p,
int color)
Updates the given point of the map to the given color. |
void |
repaintBoard()
Repaints the part of the board where the map and pieces are. |
(package private) void |
repaintBoardArea(Rectangle r)
Repaint the given area of the board. |
void |
setBoardCursor(Cursor cursor)
Set the cursor for the map area of the board. |
void |
zoom(boolean out)
Zooms in or out on the board. |
void |
zoom(int magnification)
Zoom the board to the given magnification. |
Methods inherited from class javax.swing.JPanel |
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait |
Field Detail |
Game game
JComponent board
JScrollBar horizontalScrollbar
JScrollBar verticalScrollbar
AdjustmentListener horScrollListener
AdjustmentListener vertScrollListener
JButton zoomInButton
JButton zoomOutButton
Image offscreenBuffer
Point boardUpperLeft
double boardWidth
double boardHeight
int zoomFactor
Map map
Point mapUpperLeft
Dimension mapSize
public static final int WIDTH
public static final int HEIGHT
Constructor Detail |
public Board(Game game)
game
- The Game object whose pieces are supposed to be painted on
this board.Method Detail |
public void setBoardCursor(Cursor cursor)
cursor
- The new BoardCursor valuepublic Position getPositionAt(Point p)
p
- Description of Parameterpublic Point getScreenPoint(Position p)
p
- Description of Parameterpublic Rectangle getPieceBounds(Piece piece)
piece
- Description of Parameterpublic void loadMap(Map m, Point mapUpperLeft)
m
- Description of ParametermapUpperLeft
- Description of Parameterpublic void clearMap()
public void mapUpdate(Point p, int color)
p
- Description of Parametercolor
- Description of Parameterpublic void invisibilizeMapPoint(Point p)
p
- Description of Parameterpublic void addBoardMouseListener(MouseListener ml)
ml
- The feature to be added to the BoardMouseListener attributepublic void addBoardMouseMotionListener(MouseMotionListener mml)
mml
- The feature to be added to the BoardMouseMotionListener
attributepublic void repaintBoard()
public void zoom(boolean out)
out
- Indicates whether or not the board should be zoomed out.public void zoom(int magnification)
magnification
- The magnification; zero is no magnification and
n+1 is twice as much as n.void repaintBoardArea(Rectangle r)
r
- Description of Parameter
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |