sigus.apps.ttt
Class TicTacToe_

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Window
              extended byjava.awt.Frame
                  extended byjavax.swing.JFrame
                      extended bysigus.apps.ttt.TicTacToe_
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, ij.plugin.filter.PlugInFilter, javax.swing.RootPaneContainer, java.io.Serializable, SigusApp, javax.swing.WindowConstants

public class TicTacToe_
extends javax.swing.JFrame
implements SigusApp, ij.plugin.filter.PlugInFilter

See Also:
Serialized Form

Nested Class Summary
static class TicTacToe_.GraphicArea
           
 
Nested classes inherited from class javax.swing.JFrame
javax.swing.JFrame.AccessibleJFrame
 
Nested classes inherited from class java.awt.Frame
java.awt.Frame.AccessibleAWTFrame
 
Nested classes inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
(package private)  int black
          Black's (Cross) current position.
(package private)  boolean calibrating
          True if tye system is collecting skin (or pixels of the target object - hands, eyes, face, etc) samples
(package private) static int DONE
           
(package private)  SigusEffect effect
          A SigusEffect process images captured by the Webcam and controll training and testing phases
(package private)  boolean first
          Who goes first in the next game?
(package private)  ij.ImagePlus imp
          ImageProcessor and ImagePlus take control tof he window where the processed image is shown
(package private)  ij.process.ImageProcessor ip
          ImageProcessor and ImagePlus take control tof he window where the processed image is shown
(package private) static int LOSE
           
(package private) static int[] moves
          The squares in order of importance...
(package private) static int OK
           
(package private) static int STALEMATE
           
(package private)  Updater updater
          An updater collects training samples
(package private)  int white
          White's (Not - Circle) current position.
(package private) static int WIN
           
(package private) static boolean[] won
          The winning positions.
 
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Window
 
Fields inherited from class java.awt.Container
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface ij.plugin.filter.PlugInFilter
DOES_16, DOES_32, DOES_8C, DOES_8G, DOES_ALL, DOES_RGB, DOES_STACKS, NO_CHANGES, NO_IMAGE_REQUIRED, NO_UNDO, ROI_REQUIRED, STACK_REQUIRED, SUPPORTS_MASKING
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
TicTacToe_(SigusEffect effect)
           
 
Method Summary
(package private)  int bestMove(int white, int black)
          Compute the best move for white (computer)
 boolean getCalibrating()
          True if application is in calibration mode (e.g.: collecting samples from face or hand skin), false otherwise.
private  java.lang.String getSequencial(int c, int r)
          Get the column and row and returns a sequencial number indicating the square that the player looked at
 void init()
          Initialize the applet.
private static void isWon(int pos)
          Mark all positions with these bits set as winning.
private  void jCalibrateButtonClicked(java.awt.event.ActionEvent evt)
          Switch the calibration phase on and off
private  void jClearExamplesButtonClicked(java.awt.event.ActionEvent evt)
          Clear the previously collected examples and restart the training phase
private  void jTrainingButtonClicked(java.awt.event.ActionEvent evt)
          Stop training phase and start playing by vision
 void mouseClicked(int c, int r)
          Calls updater to collected a training sample (the user looked and clicked)
(package private)  boolean myMove()
          Computer move.
 void process(int n)
          Get a number indicating the square that the player looked at and execute the proper play
 void process(int c, int r)
          Process the user play
private  void resetGame()
          Restart the game
 void run(ij.process.ImageProcessor ip)
           
 void setGeneralTitle(java.lang.String title)
          Set window title
 void setImageProcessor(ij.process.ImageProcessor i)
          Set the ImageProcessor where Digital Image Processing will occurr (that window showing the segmented image)
 void setTitleLearning()
           
 void setTitlePlaying()
          Indicate, with the word "playing" in the window title, that the application is NOT in learning mode (webcam interaction has begun)
 void setTitleTraining()
           
 int setup(java.lang.String arg, ij.ImagePlus imp)
          This method is called once when the filter is loaded.
 void setUpdater(Updater u)
          Set the class that will collect training samples and save them to an arff (weka) file.
(package private)  void showAbout()
           
(package private)  int status()
          Figure what the status of the game is.
 void trainingFinished()
           
(package private)  boolean yourMove(int m)
          User move.
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Frame
addNotify, finalize, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setIconImage, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, hide, isActive, isFocusableWindow, isFocusCycleRoot, isFocused, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationRelativeTo, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

updater

Updater updater
An updater collects training samples


effect

SigusEffect effect
A SigusEffect process images captured by the Webcam and controll training and testing phases


ip

ij.process.ImageProcessor ip
ImageProcessor and ImagePlus take control tof he window where the processed image is shown


imp

ij.ImagePlus imp
ImageProcessor and ImagePlus take control tof he window where the processed image is shown


calibrating

boolean calibrating
True if tye system is collecting skin (or pixels of the target object - hands, eyes, face, etc) samples


white

int white
White's (Not - Circle) current position. The computer is white.


black

int black
Black's (Cross) current position. The user is black.


moves

static final int[] moves
The squares in order of importance...


won

static boolean[] won
The winning positions.


DONE

static final int DONE
See Also:
Constant Field Values

OK

static final int OK
See Also:
Constant Field Values

WIN

static final int WIN
See Also:
Constant Field Values

LOSE

static final int LOSE
See Also:
Constant Field Values

STALEMATE

static final int STALEMATE
See Also:
Constant Field Values

first

boolean first
Who goes first in the next game?

Constructor Detail

TicTacToe_

public TicTacToe_(SigusEffect effect)
Method Detail

isWon

private static void isWon(int pos)
Mark all positions with these bits set as winning.


resetGame

private void resetGame()
Restart the game


bestMove

int bestMove(int white,
             int black)
Compute the best move for white (computer)

Returns:
the square to take

yourMove

boolean yourMove(int m)
User move.

Returns:
true if legal

myMove

boolean myMove()
Computer move.

Returns:
true if legal

status

int status()
Figure what the status of the game is.


init

public void init()
Initialize the applet. Resize and load images.

Specified by:
init in interface SigusApp

jCalibrateButtonClicked

private void jCalibrateButtonClicked(java.awt.event.ActionEvent evt)
Switch the calibration phase on and off


jTrainingButtonClicked

private void jTrainingButtonClicked(java.awt.event.ActionEvent evt)
Stop training phase and start playing by vision


jClearExamplesButtonClicked

private void jClearExamplesButtonClicked(java.awt.event.ActionEvent evt)
Clear the previously collected examples and restart the training phase


setTitleTraining

public void setTitleTraining()

setTitleLearning

public void setTitleLearning()

setGeneralTitle

public void setGeneralTitle(java.lang.String title)
Description copied from interface: SigusApp
Set window title

Specified by:
setGeneralTitle in interface SigusApp

setTitlePlaying

public void setTitlePlaying()
Description copied from interface: SigusApp
Indicate, with the word "playing" in the window title, that the application is NOT in learning mode (webcam interaction has begun)

Specified by:
setTitlePlaying in interface SigusApp

process

public void process(int n)
Get a number indicating the square that the player looked at and execute the proper play

Specified by:
process in interface SigusApp
Parameters:
n - - an integer associated to each different vision sign

getSequencial

private java.lang.String getSequencial(int c,
                                       int r)
Get the column and row and returns a sequencial number indicating the square that the player looked at


process

public void process(int c,
                    int r)
Process the user play


trainingFinished

public void trainingFinished()

getCalibrating

public boolean getCalibrating()
Description copied from interface: SigusApp
True if application is in calibration mode (e.g.: collecting samples from face or hand skin), false otherwise.

Specified by:
getCalibrating in interface SigusApp

mouseClicked

public void mouseClicked(int c,
                         int r)
Calls updater to collected a training sample (the user looked and clicked)


run

public void run(ij.process.ImageProcessor ip)
Specified by:
run in interface ij.plugin.filter.PlugInFilter

setUpdater

public void setUpdater(Updater u)
Description copied from interface: SigusApp
Set the class that will collect training samples and save them to an arff (weka) file.

Specified by:
setUpdater in interface SigusApp

setImageProcessor

public void setImageProcessor(ij.process.ImageProcessor i)
Description copied from interface: SigusApp
Set the ImageProcessor where Digital Image Processing will occurr (that window showing the segmented image)

Specified by:
setImageProcessor in interface SigusApp

setup

public int setup(java.lang.String arg,
                 ij.ImagePlus imp)
This method is called once when the filter is loaded. 'arg', which may be blank, is the argument specified for this plugin in IJ_Props.txt. 'imp' is the currently active image. This method should return a flag word that specifies the filters capabilities.

Specified by:
setup in interface ij.plugin.filter.PlugInFilter

showAbout

void showAbout()