|
||||||||
| 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
|
+--java.awt.Window
|
+--java.awt.Frame
|
+--FooBase
Sample program using the net.sourceforge.foobase classes.
The interface provided by this class is intended to be used on a PDA style device. The main focus is on entering new games, but replaying games already stored in a chessbase database is also implemented.
Given the nature of the target device (low on resources and a slow CPU), it is obvious that this application is not a competitor for the "real" chessbase program ;-)
Another PDA related issue is the usage of a null layout
for the main application window: using standard AWT layoutmanagers just
did not work out (too much space waa wasted)
| Inner Class Summary | |
protected class |
FooBase.ButtonNope
|
protected class |
FooBase.ButtonNoShow
|
protected class |
FooBase.ButtonShowGame
|
protected class |
FooBase.ButtonYup
|
protected class |
FooBase.DeleteGame
|
protected class |
FooBase.FooBaseCompListener
|
protected class |
FooBase.GameInfo
|
protected class |
FooBase.HideWindow
|
protected class |
FooBase.ListGames
|
protected class |
FooBase.Mickey
|
protected class |
FooBase.NavigateGame
|
protected class |
FooBase.NewGame
|
protected class |
FooBase.NukeWindow
|
protected class |
FooBase.OpenCreateDB
|
protected class |
FooBase.SaveGame
|
protected class |
FooBase.ScrollMoves
|
protected class |
FooBase.ShowHelp
|
protected class |
FooBase.StartAnimation
|
| Field Summary | |
static java.lang.String |
__version
|
protected java.lang.String |
_annotator
Annotator |
protected DisplayBoard |
_brd
Board display component. |
protected java.awt.Button |
_btn_create
Create new database option |
protected java.awt.Button |
_btn_delete
Delete game button |
protected java.awt.Button |
_btn_down
Scroll down move annotations button |
protected java.awt.Button |
_btn_endgame
End of game button |
protected java.awt.Button |
_btn_help
Help button |
protected java.awt.Button |
_btn_info
Game info button |
protected java.awt.Button |
_btn_list
List games button |
protected java.awt.Button |
_btn_newgame
New game button |
protected java.awt.Button |
_btn_open
Open database button |
protected java.awt.Button |
_btn_redo
Redo next move button |
protected java.awt.Button |
_btn_save
Save game button |
protected java.awt.Button |
_btn_scroll_back
Scroll up in the text field. |
protected java.awt.Button |
_btn_scroll_further
Scroll down in the text field. |
protected java.awt.Button |
_btn_start
Back to start of game button |
protected java.awt.Button |
_btn_undo
Undo last move button |
protected java.awt.Button |
_btn_up
Scroll up move annotations button |
protected int |
_c0
Column number for originating piece |
protected CBFDatabase |
_dbase
Current database. |
protected int |
_delay
Delay between two automatic moves in milliseconds. |
protected boolean |
_doin_la_bamba
Switch indicating if the animation thread is active. |
protected java.lang.String |
_elo_black
ELO of black player |
protected java.lang.String |
_elo_white
ELO of white player |
protected Game |
_game
Game to build |
protected int |
_game_idx
Index of game in case it was retrieved from a database. |
protected java.awt.Dialog |
_gamelist_panel
List of all games in database panel |
protected boolean |
_going_up
Switch for animation direction: true means scroll further
in game, false means scroll back towards the start of the
game. |
protected java.awt.Dialog |
_help_panel
Help text panel (shown when help button is pressed) |
protected java.awt.Dialog |
_info_dialog
Info dialog. |
protected FooBase |
_it_is_aai
Reference to main application frame. |
protected java.awt.List |
_lst_headers
List containing all game header strings |
protected static int |
_max_height
Height to use. |
protected static int |
_max_width
Width to use. |
protected java.util.Vector |
_moves
Current move list. |
protected java.lang.String |
_name_black
Name of black player |
protected java.lang.String |
_name_white
Name of white player |
protected java.awt.Button |
_nope
Cancel button in info dialog |
protected java.awt.Image[] |
_pieces
Images to use for all the pieces. |
protected int |
_plynr
Element number of "current" move in the game move list, that is: the element where the next move will be stored in _them_moves |
protected MoveAnnotations |
_pnl_moves
Panel inside the scrollpane |
protected java.awt.ScrollPane |
_pnl_scroll
Scroll pane used for holding move annotations. |
protected int |
_r0
Row number for originating piece |
protected java.lang.String |
_result
Game result |
protected java.lang.Thread |
_runner
Animation thread |
protected Board |
_setup
Current board setup |
protected java.awt.Button[][] |
_them_buttons
Array used for sizing and positioning of the buttons. |
protected java.util.Vector |
_them_moves
Vector containing the moves so far. |
protected int |
_tomove
Code for current player to move: 0 means white, 1 means black |
protected java.lang.String |
_tournament
Tournament |
protected java.awt.TextField |
_txt_annotator
Textfield for entering annotator |
protected java.awt.TextField |
_txt_elo_black
Textfield for entering ELO of black player |
protected java.awt.TextField |
_txt_elo_white
Textfield for entering ELO of white player |
protected java.awt.TextField |
_txt_move_annotation1
First text line containing the game moves |
protected java.awt.TextField |
_txt_move_annotation2
Second text line containing the game moves |
protected java.awt.TextField |
_txt_name_black
Textfield for entering name of black player |
protected java.awt.TextField |
_txt_name_white
Textfield for entering name of white player |
protected java.awt.TextField |
_txt_result
Textfield for entering game result. |
protected java.awt.TextField |
_txt_tournament
Textfield for entering tournament info. |
protected java.awt.TextField |
_txt_year
Textfield for entering year that game was played. |
protected java.lang.String |
_year
Year |
protected java.awt.Button |
_yup
Ok button in info dialog |
protected static java.lang.String |
CMD_BACK
Action command string for "autoplay backwards" button |
protected static java.lang.String |
CMD_DELETE
Action command string for "delete" menu item |
protected static java.lang.String |
CMD_DOWN
Action command string for "scroll down moves" button |
protected static java.lang.String |
CMD_ENDGAME
Action command string for "end of game" button |
protected static java.lang.String |
CMD_FURTHER
Action command string for "autoplay forward" button |
protected static java.lang.String |
CMD_HELP
Action command string for "help" button |
protected static java.lang.String |
CMD_INFO
Action command string for "game info" menu item |
protected static java.lang.String |
CMD_LIST
Action command string for "list games" menu item |
protected static java.lang.String |
CMD_NEWDB
Action command string for "create database" menu item |
protected static java.lang.String |
CMD_NEWGAME
Action command string for "new game" menu item |
protected static java.lang.String |
CMD_NOPE
Action command string for "cancel" button |
protected static java.lang.String |
CMD_OPENDB
Action command string for "open database" menu item |
protected static java.lang.String |
CMD_REDO
Action command string for "redo move" button |
protected static java.lang.String |
CMD_SAVE
Action command string for "save" menu item |
protected static java.lang.String |
CMD_STARTGAME
Action command string for "start of game" button |
protected static java.lang.String |
CMD_UNDO
Action command string for "undo move" button |
protected static java.lang.String |
CMD_UP
Action command string for "scroll up moves" button |
protected static java.lang.String |
CMD_YUP
Action command string for "Ok" button |
| Fields inherited from class java.awt.Frame |
CROSSHAIR_CURSOR,
DEFAULT_CURSOR,
E_RESIZE_CURSOR,
HAND_CURSOR,
ICONIFIED,
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.Component |
BOTTOM_ALIGNMENT,
CENTER_ALIGNMENT,
LEFT_ALIGNMENT,
RIGHT_ALIGNMENT,
TOP_ALIGNMENT |
| Constructor Summary | |
FooBase()
Default public constructor. |
|
| Method Summary | |
protected void |
addBagCentered(java.awt.Component c,
int x,
int y,
java.awt.GridBagLayout gb,
java.awt.Container cnt)
Add a horizontally stretched out component to gridbaglayout. |
protected void |
addBagFilled(java.awt.Component c,
int x,
int y,
java.awt.GridBagLayout gb,
java.awt.Container cnt)
Add a horizontally stretched out component to gridbaglayout. |
protected void |
addBagFilled(java.awt.Component c,
int x,
int y,
int w,
java.awt.GridBagLayout gb,
java.awt.Container cnt)
Add a horizontally stretched out component to gridbaglayout. |
protected void |
addBagFilled(java.awt.Component c,
int x,
int y,
int w,
int h,
java.awt.GridBagLayout gb,
java.awt.Container cnt)
Add a horizontally stretched out component to gridbaglayout. |
protected void |
addBagLeft(java.awt.Component c,
int x,
int y,
java.awt.GridBagLayout gb,
java.awt.Container cnt)
Add a left-justified component to gridbaglayout. |
protected void |
addOptionButtons()
Add move annotations and option buttons panel. |
protected void |
bailout()
Terminate program. |
protected void |
clearInput()
Clear all text fields in info dialog, as well as their String counterparts. |
protected void |
createInfoDialog()
Create dialog for entering players info etc. |
void |
doLayout()
Do layouting for this container. |
protected void |
doTheLayouting()
Compute sizes and locations of all components in this frame. |
protected void |
getInfoFields()
Extract data from dialog fields |
java.awt.Insets |
getInsets()
Return insets to use for frame. |
java.awt.Insets |
insets()
Return insets to use for frame. |
static void |
main(java.lang.String[] args)
Main entry point for standalone java application. |
protected void |
maximize(java.awt.Component c)
Maximize the size of a given component. |
protected void |
maximizeMostly(java.awt.Component c)
Resize component to about 70% of the full size. |
protected java.awt.Button |
newButton(java.lang.String l,
java.lang.String cmd,
int x,
int y,
java.awt.event.ActionListener lstnr)
Create and add a new button to the bottom "panel" of the application window. |
void |
run()
Actual code running in the animation thread. |
protected void |
scrollBack()
Retract last move |
protected void |
scrollFurther()
Redo next move |
protected void |
setInfoFields()
Update fields in info dialog fields with data obtained from the database. |
void |
start()
Start animation thread if it is not yet started. |
protected void |
startNewGame()
Start new game. |
void |
update(java.awt.Graphics g)
Update the component. |
protected void |
updateProps()
Update various properties based on new values for _plynr
and _setup
|
| Methods inherited from class java.awt.Frame |
addNotify,
finalize,
getCursorType,
getFrames,
getIconImage,
getMenuBar,
getState,
getTitle,
isResizable,
paramString,
remove,
removeNotify,
setCursor,
setIconImage,
setMenuBar,
setResizable,
setState,
setTitle |
| Methods inherited from class java.awt.Window |
addWindowListener,
applyResourceBundle,
applyResourceBundle,
dispose,
getFocusOwner,
getInputContext,
getLocale,
getOwnedWindows,
getOwner,
getToolkit,
getWarningString,
hide,
isShowing,
pack,
postEvent,
processEvent,
processWindowEvent,
removeWindowListener,
setCursor,
show,
toBack,
toFront |
| Methods inherited from class java.awt.Container |
add,
add,
add,
add,
add,
addContainerListener,
addImpl,
countComponents,
deliverEvent,
findComponentAt,
findComponentAt,
getAlignmentX,
getAlignmentY,
getComponent,
getComponentAt,
getComponentAt,
getComponentCount,
getComponents,
getLayout,
getMaximumSize,
getMinimumSize,
getPreferredSize,
invalidate,
isAncestorOf,
layout,
list,
list,
locate,
minimumSize,
paint,
paintComponents,
preferredSize,
print,
printComponents,
processContainerEvent,
remove,
remove,
removeAll,
removeContainerListener,
setFont,
setLayout,
validate,
validateTree |
| Methods inherited from class java.awt.Component |
action,
add,
addComponentListener,
addFocusListener,
addInputMethodListener,
addKeyListener,
addMouseListener,
addMouseMotionListener,
addPropertyChangeListener,
addPropertyChangeListener,
bounds,
checkImage,
checkImage,
coalesceEvents,
contains,
contains,
createImage,
createImage,
disable,
disableEvents,
dispatchEvent,
enable,
enable,
enableEvents,
enableInputMethods,
firePropertyChange,
getBackground,
getBounds,
getBounds,
getColorModel,
getComponentOrientation,
getCursor,
getDropTarget,
getFont,
getFontMetrics,
getForeground,
getGraphics,
getHeight,
getInputMethodRequests,
getLocation,
getLocation,
getLocationOnScreen,
getName,
getParent,
getPeer,
getSize,
getSize,
getTreeLock,
getWidth,
getX,
getY,
gotFocus,
handleEvent,
hasFocus,
imageUpdate,
inside,
isDisplayable,
isDoubleBuffered,
isEnabled,
isFocusTraversable,
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,
processInputMethodEvent,
processKeyEvent,
processMouseEvent,
processMouseMotionEvent,
removeComponentListener,
removeFocusListener,
removeInputMethodListener,
removeKeyListener,
removeMouseListener,
removeMouseMotionListener,
removePropertyChangeListener,
removePropertyChangeListener,
repaint,
repaint,
repaint,
repaint,
requestFocus,
reshape,
resize,
resize,
setBackground,
setBounds,
setBounds,
setComponentOrientation,
setDropTarget,
setEnabled,
setForeground,
setLocale,
setLocation,
setLocation,
setName,
setSize,
setSize,
setVisible,
show,
size,
toString,
transferFocus |
| Methods inherited from class java.lang.Object |
clone,
equals,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
| Field Detail |
protected static final java.lang.String CMD_OPENDB
protected static final java.lang.String CMD_NEWDB
protected static final java.lang.String CMD_NEWGAME
protected static final java.lang.String CMD_SAVE
protected static final java.lang.String CMD_DELETE
protected static final java.lang.String CMD_LIST
protected static final java.lang.String CMD_INFO
protected static final java.lang.String CMD_YUP
protected static final java.lang.String CMD_NOPE
protected static final java.lang.String CMD_STARTGAME
protected static final java.lang.String CMD_ENDGAME
protected static final java.lang.String CMD_UNDO
protected static final java.lang.String CMD_REDO
protected static final java.lang.String CMD_HELP
protected static final java.lang.String CMD_BACK
protected static final java.lang.String CMD_FURTHER
protected static final java.lang.String CMD_UP
protected static final java.lang.String CMD_DOWN
protected static int _max_width
protected static int _max_height
protected CBFDatabase _dbase
protected DisplayBoard _brd
protected java.awt.Image[] _pieces
protected Game _game
protected int _game_idx
For new games, this value is -1, for others it is
greater than or equal zero.
Note that this scheme works for chessbase databases because we those games are identified by a numerical ID.
protected Board _setup
protected java.util.Vector _moves
protected int _r0
protected int _c0
protected int _tomove
protected java.awt.Button _btn_open
protected java.awt.Button _btn_create
Does not seem to work on PDA: ignore for now.
protected java.awt.Button _btn_newgame
protected java.awt.Button _btn_info
protected java.awt.Button _btn_save
protected java.awt.Button _btn_delete
protected java.awt.Button _btn_list
protected java.awt.Button _btn_start
protected java.awt.Button _btn_undo
protected java.awt.Button _btn_redo
protected java.awt.Button _btn_endgame
protected java.awt.Button _btn_help
protected java.awt.Button _btn_up
protected java.awt.Button _btn_down
protected java.awt.Button[][] _them_buttons
protected java.awt.ScrollPane _pnl_scroll
protected MoveAnnotations _pnl_moves
protected FooBase _it_is_aai
protected java.awt.Dialog _info_dialog
protected java.awt.TextField _txt_name_white
protected java.awt.TextField _txt_elo_white
protected java.awt.TextField _txt_name_black
protected java.awt.TextField _txt_elo_black
protected java.awt.TextField _txt_tournament
protected java.awt.TextField _txt_year
protected java.awt.TextField _txt_annotator
protected java.awt.TextField _txt_result
protected java.awt.List _lst_headers
protected java.awt.Button _yup
protected java.awt.Button _nope
protected java.awt.Dialog _help_panel
protected java.awt.Dialog _gamelist_panel
protected java.awt.TextField _txt_move_annotation1
protected java.awt.TextField _txt_move_annotation2
protected java.awt.Button _btn_scroll_back
protected java.awt.Button _btn_scroll_further
protected java.lang.String _name_white
protected java.lang.String _elo_white
protected java.lang.String _name_black
protected java.lang.String _elo_black
protected java.lang.String _tournament
protected java.lang.String _year
protected java.lang.String _annotator
protected java.lang.String _result
protected int _plynr
_them_movesprotected java.util.Vector _them_moves
protected java.lang.Thread _runner
protected boolean _going_up
true means scroll further
in game, false means scroll back towards the start of the
game.protected boolean _doin_la_bamba
If this switch is set to false, the thread will stop.
protected int _delay
public static final java.lang.String __version
| Constructor Detail |
public FooBase()
| Method Detail |
public static void main(java.lang.String[] args)
args - String[] containing the commandline paranmeterspublic java.awt.Insets insets()
Insets describing how much space to leave between
different components in this frame.public java.awt.Insets getInsets()
All insets, except for the top, are set to zero.
Insets describing how much space to leave between
different components in this frame.public void doLayout()
This method dynamically sizes the chessboard component to full width and 75/110 of the available height. That ratio is handpicked to offer a "reasonable" area in which the buttons and move annotations can be stuffed when working on a 240 by 320 PDA screen.
public void update(java.awt.Graphics g)
The main reason for implementing this method is to avoid clearing of the component on screen first (and thus reducing possible flikkering on the screen)
g - Graphics to draw the board on.public void start()
public void run()
protected void doTheLayouting()
THe ratio for chessboard/bottom stuff is 75/110 for the chessboard and 35/110 for the bottom part. The only reason for this ratio is that it offers enough space on a 240x320 PDA screen to draw the bottom components with a reasonable size.
About the only difference with a full doLayout() is
that no call to the super class implementation of
doLayout() is done.
protected void addOptionButtons()
The buttons are drawn in a grid of 3 rows by 11 columns. The area (1,0) to (10,1) is occupied by the area in which the moves are printed.
protected java.awt.Button newButton(java.lang.String l,
java.lang.String cmd,
int x,
int y,
java.awt.event.ActionListener lstnr)
l - String containing the button labelcmd - String containing the action command for the
buttonx - int X-coordinate in the grid where the button
is to be locatedy - int Y-coordinate in the grid where the button
is to be locatedlstnr - ActionListener to add for handling button
clicksButton created and located according to the
specsprotected void startNewGame()
protected void bailout()
protected void createInfoDialog()
protected void clearInput()
String counterparts.protected void getInfoFields()
protected void setInfoFields()
protected void maximize(java.awt.Component c)
c - Component to resize to the size of the screenprotected void maximizeMostly(java.awt.Component c)
The main reason for this method is to offer panels with sufficient space near the bottom for a virtual keyboard on a PDA.
c - Component to resize to the size of the screen
protected void addBagLeft(java.awt.Component c,
int x,
int y,
java.awt.GridBagLayout gb,
java.awt.Container cnt)
c - Component to add to the gridbaglayoutx - int x-coordinate in gridbag gridy - int y-coordinate in gridbag gridgb - GridBagLayout to add the component to.cnt - Container to which the component is to be added
protected void addBagFilled(java.awt.Component c,
int x,
int y,
java.awt.GridBagLayout gb,
java.awt.Container cnt)
c - Component to add to the gridbaglayoutx - int x-coordinate in gridbag gridy - int y-coordinate in gridbag gridgb - GridBagLayout to add the component to.cnt - Container to which the component is to be added
protected void addBagFilled(java.awt.Component c,
int x,
int y,
int w,
java.awt.GridBagLayout gb,
java.awt.Container cnt)
c - Component to add to the gridbaglayoutx - int x-coordinate in gridbag gridy - int y-coordinate in gridbag gridw - int with in gridbag cellsgb - GridBagLayout to add the component to.cnt - Container to which the component is to be added
protected void addBagFilled(java.awt.Component c,
int x,
int y,
int w,
int h,
java.awt.GridBagLayout gb,
java.awt.Container cnt)
c - Component to add to the gridbaglayoutx - int x-coordinate in gridbag gridy - int y-coordinate in gridbag gridw - int with in gridbag cellsh - int height in gridbag cellsgb - GridBagLayout to add the component to.cnt - Container to which the component is to be added
protected void addBagCentered(java.awt.Component c,
int x,
int y,
java.awt.GridBagLayout gb,
java.awt.Container cnt)
c - Component to add to the gridbaglayoutx - int x-coordinate in gridbag gridy - int y-coordinate in gridbag gridgb - GridBagLayout to add the component to.cnt - Container to which the component is to be addedprotected void updateProps()
_plynr
and _setup
This method is called when a new move is entered or when one of the navigation buttons is clicked.
protected void scrollBack()
protected void scrollFurther()
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||