Class Position

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
              |
              +--Position

public class Position
extends java.awt.Canvas

This class implements a position of the game of Othello. A position can be in either of 3 states: empty or occupied by either player. When occupied, a position is rendered as a circle either black or white.

See Also:
Serialized Form

Inner classes inherited from class java.awt.Component
java.awt.Component.AWTTreeLock
 
Field Summary
static java.awt.Color[] colors
          Define the colors of background, and either player.
static int diameter
          Diameter in pixels of a position.
static int empty
          Symbolic representation of an empty position.
static int first
          Symbolic representation of the first player.
static int second
          Symbolic representation of the second player.
 
Fields inherited from class java.awt.Component
actionListenerK, adjustmentListenerK, appContext, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, componentListener, componentListenerK, componentOrientation, containerListenerK, cursor, dropTarget, enabled, eventMask, focusListener, focusListenerK, font, foreground, hasFocus, height, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, RIGHT_ALIGNMENT, textListenerK, TOP_ALIGNMENT, valid, visible, width, windowListenerK, x, y
 
Constructor Summary
Position()
           
 
Method Summary
 java.awt.Dimension getPreferredSize()
          Define the preferred size of a position.
 int getState()
          Get the state of this position.
 void paint(java.awt.Graphics g)
          Paint this position according to its state.
 void setState(int state)
          Set the state of this position.
 
Methods inherited from class java.awt.Canvas
, addNotify, constructComponentName, postsOldMouseEvents
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, areInputMethodsEnabled, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, dispatchEventImpl, doLayout, enable, enable, enableEvents, enableInputMethods, eventEnabled, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getIntrinsicCursor, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getSize, getSize, getToolkit, getToolkitImpl, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isEnabledImpl, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, lightweightPrint, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, printHeavyweightComponents, processComponentEvent, processEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

diameter

public static final int diameter
Diameter in pixels of a position.

colors

public static final java.awt.Color[] colors
Define the colors of background, and either player.

empty

public static final int empty
Symbolic representation of an empty position.

first

public static final int first
Symbolic representation of the first player.

second

public static final int second
Symbolic representation of the second player.
Constructor Detail

Position

public Position()
Method Detail

getPreferredSize

public java.awt.Dimension getPreferredSize()
Define the preferred size of a position.
Overrides:
getPreferredSize in class java.awt.Component
Returns:
The preferred size of a position.

setState

public void setState(int state)
Set the state of this position.
Parameters:
state - The state this position is set to.

getState

public int getState()
Get the state of this position.
Returns:
The state of this position.

paint

public void paint(java.awt.Graphics g)
Paint this position according to its state.
Overrides:
paint in class java.awt.Canvas
Parameters:
g - The graphic context.