|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Canvas soc.client.SOCFaceButton
public class SOCFaceButton
This is a component that can display a face. When you click on the face, it changes to another face.
There are two modes: Standard (with associated player ID) for use in HandPanel; and Bordered (with associated FaceChooserFrame) for choosing a new face icon. The two constructors correspond to the two modes.
FaceChooserFrame
,
Serialized FormNested Class Summary | |
---|---|
protected static class |
SOCFaceButton.FaceButtonPopupMenu
Menu for right-click on face icon to choose a new face (Player's hand only). |
private class |
SOCFaceButton.MyMouseAdapter
Handle Events |
Nested classes/interfaces inherited from class java.awt.Canvas |
---|
java.awt.Canvas.AccessibleAWTCanvas |
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 java.awt.Image |
buffer
offscreen buffer |
private int |
currentImageNum
Human face images are positive numbers, 1-based (range 1 to NUM_FACES). |
static int |
DEFAULT_FACE
|
static int |
FACE_BORDER_WIDTH_PX
width of border (per side), used in FACE_WIDTH_BORDERED_PX |
static int |
FACE_WIDTH_BORDERED_PX
width,height of button with border around the face icon (bordered mode) |
static int |
FACE_WIDTH_PX
width,height of button showing only the face icon (standard mode) |
private FaceChooserFrame |
faceChooser
Null unless being used in the face chooser |
private SOCGame |
game
|
private java.awt.Color |
hilightBorderColor
Color for selection border; ignored if faceChooser == null. |
private boolean |
hilightBorderShown
Hilight selection border? always false if faceChooser == null. |
private boolean |
hilightBorderWasShown
Recently shown hilight selection border? (Used in paint method to clear it away) Always false if faceChooser == null. |
private static java.lang.String |
IMAGEDIR
|
private static java.awt.Image[] |
images
Shared images |
static int |
NUM_FACES
number of /numbered/ face images, /plus 1/ for indexing. |
static int |
NUM_ROBOT_FACES
number of robot faces, which are separately numbered. |
protected java.awt.Dimension |
ourSize
size |
private int |
panelx
|
private int |
panely
|
private SOCPlayerInterface |
pi
|
private int |
pNumber
player number |
protected static int |
POPUP_MENU_IGNORE_MS
For popup-menu, length of time after popup to ignore further mouse-clicks. |
private SOCFaceButton.FaceButtonPopupMenu |
popupMenu
Context menu for face icon chooser |
private long |
popupMenuSystime
Tracks last popup-menu time. |
private static java.awt.Image[] |
robotImages
|
private static java.awt.MediaTracker |
tracker
For status in drawFace |
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 | |
---|---|
|
SOCFaceButton(SOCPlayerInterface pi,
FaceChooserFrame fcf,
int faceId)
create a new SOCFaceButton, for the FaceChooserFrame (bordered mode) |
|
SOCFaceButton(SOCPlayerInterface pi,
int pn)
create a new SOCFaceButton, for a player's handpanel (standard mode). |
protected |
SOCFaceButton(SOCPlayerInterface pi,
int pn,
java.awt.Color bgColor,
int width)
implement creation of a new SOCFaceButton (common to both modes) |
Method Summary | |
---|---|
void |
addFacePopupMenu()
Designate player as client (can click and right-click to choose face icon). |
void |
clearFacePopupPreviousChooser()
The previous face-chooser window (from the face-popup menu) has been disposed. |
private void |
drawFace(java.awt.Graphics g)
draw the face |
int |
getFace()
|
java.awt.Dimension |
getMinimumSize()
DOCUMENT ME! |
java.awt.Dimension |
getPreferedSize()
DOCUMENT ME! |
java.awt.Dimension |
getSize()
|
private static void |
loadImages(java.awt.Component c)
|
void |
paint(java.awt.Graphics g)
Redraw the facebutton using double buffering. |
private void |
paintBorder(java.awt.Graphics g,
boolean showNotClear)
Paint or clear the hilight border |
void |
removeFacePopupMenu()
If we have a popup menu, remove it. |
void |
setDefaultFace()
Reset to the default face. |
void |
setFace(int id)
set which image is shown |
void |
setHilightBorder(boolean wantBorder)
Set or clear the hilight border flag. |
void |
update(java.awt.Graphics g)
Overriden so the peer isn't painted, which clears background. |
Methods inherited from class java.awt.Canvas |
---|
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy |
Methods inherited from class java.awt.Component |
---|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, 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, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_FACE
private static final java.lang.String IMAGEDIR
public static final int NUM_FACES
public static final int NUM_ROBOT_FACES
public static final int FACE_WIDTH_PX
public static final int FACE_BORDER_WIDTH_PX
public static final int FACE_WIDTH_BORDERED_PX
private static java.awt.Image[] images
private static java.awt.Image[] robotImages
private static java.awt.MediaTracker tracker
private int currentImageNum
private int panelx
private int panely
private int pNumber
private SOCGame game
private SOCPlayerInterface pi
private FaceChooserFrame faceChooser
private boolean hilightBorderShown
private boolean hilightBorderWasShown
private java.awt.Color hilightBorderColor
SOCPlayerInterface.makeGhostColor(Color)
private SOCFaceButton.FaceButtonPopupMenu popupMenu
private long popupMenuSystime
protected static int POPUP_MENU_IGNORE_MS
private java.awt.Image buffer
protected java.awt.Dimension ourSize
Constructor Detail |
---|
public SOCFaceButton(SOCPlayerInterface pi, int pn) throws java.lang.IllegalArgumentException
pi
- the interface that this button is attached topn
- the number of the player that owns this button. Must be in range 0 to (SOCGame.maxPlayers
- 1).
java.lang.IllegalArgumentException
- if pn is < -1 or >= SOCGame.MAXPLAYERS.public SOCFaceButton(SOCPlayerInterface pi, FaceChooserFrame fcf, int faceId)
pi
- Player interface (for stack-print callback ONLY)fcf
- Face chooser frame for callbackfaceId
- Face ID to show; same range as setFace(int)
protected SOCFaceButton(SOCPlayerInterface pi, int pn, java.awt.Color bgColor, int width) throws java.lang.IllegalArgumentException
pi
- the interface that this button is attached topn
- the number of the player that owns this button, or -1 if none;
if pn >= 0, pi.getGame() must not be null.bgColor
- background color to usewidth
- width,height in pixels; FACE_WIDTH_PX or FACE_WIDTH_BORDERED_PX
java.lang.IllegalArgumentException
- if pn is < -1 or >= SOCGame.maxPlayers
,
or if pi.getGame() is null.Method Detail |
---|
private static void loadImages(java.awt.Component c)
public int getFace()
public void setFace(int id)
id
- the id for the image. Range is within
-NUM_ROBOT_FACES to +NUM_FACES.
Human id's out of range (>= NUM_FACES) get id DEFAULT_FACE.
Robot id's out of range (<= -NUM_ROBOT_FACES) get id 0.public void setDefaultFace()
public void addFacePopupMenu() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- if player isn't client (checks getName vs client.getNickname)public void removeFacePopupMenu()
public void clearFacePopupPreviousChooser()
addFacePopupMenu()
public void setHilightBorder(boolean wantBorder) throws java.lang.IllegalStateException
wantBorder
- Show the hilight border?
java.lang.IllegalStateException
- If this FaceButton wasn't created for a face chooser.public java.awt.Dimension getPreferedSize()
public java.awt.Dimension getMinimumSize()
getMinimumSize
in class java.awt.Component
public java.awt.Dimension getSize()
getSize
in class java.awt.Component
public void paint(java.awt.Graphics g)
Component.repaint()
instead.
paint
in class java.awt.Canvas
public void update(java.awt.Graphics g)
Component.repaint()
instead.
update
in class java.awt.Canvas
private void drawFace(java.awt.Graphics g)
private void paintBorder(java.awt.Graphics g, boolean showNotClear)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |