gizmoball
Class GLBoardView

java.lang.Object
  extended by gizmoball.GLBoardView
All Implemented Interfaces:
BoardObserver, BoardView, EventListener, javax.media.opengl.GLEventListener

public class GLBoardView
extends Object
implements BoardView, javax.media.opengl.GLEventListener

A BoardView that renders the Board using OpenGL.

TODO: Better specs.

Specification Fields

Field Summary
static String rcsid
          Class revision identifier.
 
Constructor Summary
GLBoardView(javax.media.opengl.GLAutoDrawable drawable)
          Creates a new GLBoardView not tracking any Board.
 
Method Summary
 void display(javax.media.opengl.GLAutoDrawable drawable)
          
 void displayChanged(javax.media.opengl.GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged)
          
 void init(javax.media.opengl.GLAutoDrawable drawable)
          
 void redraw()
          Redraws the display of the Board.
 void reshape(javax.media.opengl.GLAutoDrawable drawable, int x, int y, int width, int height)
          
 void setBoard(Board board)
          Sets the Board this GLBoardView should be displaying.
 void setSelectedGizmo(Gizmo gizmo)
          Sets the selected Gizmo to the given Gizmo.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rcsid

public static final String rcsid
Class revision identifier. rcsid contains an RCS Id keyword string that may be used to identify which revision of GLBoardView.java was used to generate an instance of GLBoardView.class. To identify the revision of a GLBoardView.class file, run "ident GLBoardView.class" (ident is part of the RCS software package).

See Also:
Constant Field Values
Constructor Detail

GLBoardView

public GLBoardView(javax.media.opengl.GLAutoDrawable drawable)
Creates a new GLBoardView not tracking any Board. This GLBoardView will render in the given GLAutoDrawable.

Eventually, setBoard(gizmoball.Board) should be called so that this GLBoardView will actually have something to render.

Parameters:
drawable - the GLAutoDrawable this GLBoardView should render in
Requires:
drawable != null
Effects:
board = null and gizmoViews = the empty set and selectedGizmo = null
Method Detail

redraw

public void redraw()
Redraws the display of the Board. This method updates the display so that the user sees an up-to-date representation of the Board this BoardView is displaying.

Specified by:
redraw in interface BoardView

init

public void init(javax.media.opengl.GLAutoDrawable drawable)

Specified by:
init in interface javax.media.opengl.GLEventListener

display

public void display(javax.media.opengl.GLAutoDrawable drawable)

Specified by:
display in interface javax.media.opengl.GLEventListener

reshape

public void reshape(javax.media.opengl.GLAutoDrawable drawable,
                    int x,
                    int y,
                    int width,
                    int height)

Specified by:
reshape in interface javax.media.opengl.GLEventListener

displayChanged

public void displayChanged(javax.media.opengl.GLAutoDrawable drawable,
                           boolean modeChanged,
                           boolean deviceChanged)

Specified by:
displayChanged in interface javax.media.opengl.GLEventListener

setBoard

public void setBoard(Board board)
Sets the Board this GLBoardView should be displaying. Also updates various state so that this GLBoardView is ready to render the new Board.

This GLBoardView will register itself with the new Board as a BoardObserver. If Board was non-null before this operation, then this GLBoardView will also deregister itself from the previous Board it was displaying.

This GLBoardView will also discard the GLGizmoViews it was previously using (if any), and generate the new GLGizmoViews necessary to display the new Board.

Parameters:
board - the Board to be displayed by this GLBoardView
Requires:
board != null
Effects:
  • this.board = board
  • gizmoViews updated to reflect the new this.board

setSelectedGizmo

public void setSelectedGizmo(Gizmo gizmo)
Sets the selected Gizmo to the given Gizmo. The given Gizmo will be rendered in such a way that it should stand out. Call this method with the argument null to clear the selected Gizmo (make it so that no Gizmo is selected).

Parameters:
gizmo - Gizmo to be selected