|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
de.htwdd.rosenkoenig.gui.genuts.GenutsGUI
public class GenutsGUI
This implementation of GUI provides Rosenkoenig with a graphical user interface based
on the Genuts library.
The GenutsGUI also implements MouseListener and extends JPanel,
so it can be used as part of a Swing dialog.
GUI,
Serialized Form| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class javax.swing.JPanel |
|---|
javax.swing.JPanel.AccessibleJPanel |
| Nested classes/interfaces inherited from class javax.swing.JComponent |
|---|
javax.swing.JComponent.AccessibleJComponent |
| Nested classes/interfaces inherited from class java.awt.Container |
|---|
java.awt.Container.AccessibleAWTContainer |
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
| Field Summary | |
|---|---|
private Sprite |
board
|
private OkButton |
btnOk
|
private java.util.EnumMap<Color,Position[]> |
cardPositions
|
private SpriteCollisionManager |
collisionManager
|
private java.util.EnumMap<Color,Counter> |
counters
|
private ImageSequenceSprite |
crown
|
private java.util.EnumMap<Color,GUICard[]> |
decks
|
private static int |
DISTANCE
|
private DrawDeck |
drawDeck
|
private Game |
game
|
private ImageList |
imageList
|
private static boolean |
imagesLoaded
|
private java.util.EnumMap<Color,Knights> |
knights
|
private java.util.EnumMap<Color,Name> |
names
|
private ImageSequenceSprite |
playedCards
|
private ImageSequenceSprite |
playedSword
|
private PlayField |
playfield
|
private static long |
serialVersionUID
|
| Fields inherited from class javax.swing.JComponent |
|---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class java.awt.Component |
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
GenutsGUI()
Creates a new GenutsGUI, initializes the Genuts library and forces ImageList to load all needed images (if necessary). |
|
| Method Summary | |
|---|---|
void |
activatePlayer(Color color,
boolean activate)
Activate or deactivate the player's name string. |
void |
disablePlayer(Color color)
Disables all controls of a single player. |
void |
enableDrawDeck(ImageState state)
Enables / disables the draw deck. |
void |
enableEndTurn(ImageState state)
Enables / disables the GUI element that ends a player's turn |
void |
hideScoreChange(Color color)
This method tells the GUI to hide a player's score increase. |
void |
initGUI(Game game,
java.lang.String nameRed,
java.lang.String nameWhite)
Initializes the graphical user interface: creates the board creates and positions the decks, the knights and the end-turn-button creates and initializes the player's scores sets the crown to its initial position initializes the player names Use this method to perform initialization. |
void |
mouseClicked(java.awt.event.MouseEvent event)
Whenever the user clicks the GenutsGUI, this method checks if the mouse click hit an object of type Clickable and eventually toggles its click method. |
void |
mouseEntered(java.awt.event.MouseEvent e)
unused, just to satisfy MouseListener |
void |
mouseExited(java.awt.event.MouseEvent e)
unused, just to satisfy MouseListener |
void |
mousePressed(java.awt.event.MouseEvent e)
unused, just to satisfy MouseListener |
void |
mouseReleased(java.awt.event.MouseEvent e)
unused, just to satisfy MouseListener |
void |
redrawGUI()
forces the GUI to show all changes taken since the last call of redrawGUI. |
void |
setBoard(Color[][] board)
setBoard is called to replace the complete board. |
void |
setCards(Color color,
java.util.List<Card> cards)
This method is called whenever a player's card deck has changed and sets a player's card deck. |
void |
setCardState(Color color,
ImageState state,
int card,
boolean knightable)
setCardState is called whenever a card's state has changed. |
void |
setCrown(Position position)
This method is called to specify the position of the crown on the board. |
void |
setDrawDeck(int number)
Sets the number of cards left in the draw deck. |
void |
setKnights(Color color,
int number)
Sets the number of knights a player has left. |
void |
setKnightState(Color color,
ImageState state)
This method is called whenever a player's knights are enabled or disabled. |
void |
setPlayedDeck(int number,
Card playedCard)
Sets the number of cards left in the played cards deck. |
void |
setScore(Color color,
int score)
Updates a player's score. |
void |
setScoreChange(Color color,
int score)
After the player selects the card he wants to play, the GUI shows the possible score increase. |
private void |
setStone(Color color,
boolean transparent,
int x,
int y)
This method puts a stone to the specified logical position on the board. |
void |
setStone(Color color,
Position position,
boolean perhaps)
Sets a stone on the board. |
| Methods inherited from class javax.swing.JPanel |
|---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
| Methods inherited from class javax.swing.JComponent |
|---|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update |
| Methods inherited from class java.awt.Container |
|---|
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, 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, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private static final long serialVersionUID
private static final int DISTANCE
private SpriteCollisionManager collisionManager
private PlayField playfield
private ImageSequenceSprite playedCards
private ImageSequenceSprite playedSword
private ImageSequenceSprite crown
private DrawDeck drawDeck
private OkButton btnOk
private java.util.EnumMap<Color,Counter> counters
private java.util.EnumMap<Color,GUICard[]> decks
private java.util.EnumMap<Color,Position[]> cardPositions
private java.util.EnumMap<Color,Knights> knights
private java.util.EnumMap<Color,Name> names
private Game game
private ImageList imageList
private static boolean imagesLoaded
private Sprite board
| Constructor Detail |
|---|
public GenutsGUI()
| Method Detail |
|---|
public void initGUI(Game game,
java.lang.String nameRed,
java.lang.String nameWhite)
initGUI in interface GUIgame - the game this GUI belongs tonameRed - the red player's namenameWhite - the white player's nameGamepublic void redrawGUI()
redrawGUI in interface GUI
public void setCards(Color color,
java.util.List<Card> cards)
setCards in interface GUIcolor - playercards - card deck (up to five cards)
public void setCardState(Color color,
ImageState state,
int card,
boolean knightable)
setCardState in interface GUIcolor - playerstate - enabled, disabled, selectedcard - index of the card that will be changedknightable - if set to true, the selected card is marked knightablepublic void setBoard(Color[][] board)
setBoard in interface GUIboard - array (dimensions habe to be 9x9) of stones. A color represents a stone, null
represents an empty field
public void setStone(Color color,
Position position,
boolean perhaps)
setStone in interface GUIcolor - color of the stone or null to remove the stoneposition - the stone's positionperhaps - if set to true, the stone is drawn "misty"
private void setStone(Color color,
boolean transparent,
int x,
int y)
color - the stone's colortransparent - if set to true, the stone is drawn half transparentx - logical x-position on the boardy - logical y-position on the board
public void setKnights(Color color,
int number)
setKnights in interface GUIcolor - playernumber - number of knights left
public void setKnightState(Color color,
ImageState state)
setKnightState in interface GUIcolor - playerstate - enabled, disabled
public void setScore(Color color,
int score)
setScore in interface GUIcolor - playerscore - new scorepublic void disablePlayer(Color color)
disablePlayer in interface GUIcolor - player
public void activatePlayer(Color color,
boolean activate)
activatePlayer in interface GUIcolor - the player's coloractivate - whether to activate the player or not
public void setScoreChange(Color color,
int score)
setScoreChange in interface GUIcolor - playerscore - score increasepublic void hideScoreChange(Color color)
hideScoreChange in interface GUIcolor - the player whose score increase is to be hiddenpublic void setDrawDeck(int number)
setDrawDeck in interface GUInumber - number of cards left
public void setPlayedDeck(int number,
Card playedCard)
setPlayedDeck in interface GUInumber - number of cards leftplayedCard - the card that was played lastpublic void enableDrawDeck(ImageState state)
enableDrawDeck in interface GUIstate - enabled or disabledpublic void enableEndTurn(ImageState state)
enableEndTurn in interface GUIstate - enabled or disabledpublic void setCrown(Position position)
setCrown in interface GUIposition - the crown's positionpublic void mouseClicked(java.awt.event.MouseEvent event)
mouseClicked in interface java.awt.event.MouseListenerpublic void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered in interface java.awt.event.MouseListenerpublic void mouseExited(java.awt.event.MouseEvent e)
mouseExited in interface java.awt.event.MouseListenerpublic void mousePressed(java.awt.event.MouseEvent e)
mousePressed in interface java.awt.event.MouseListenerpublic void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased in interface java.awt.event.MouseListener
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||