soc.client
Class FaceChooserFrame.FaceChooserList

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by soc.client.FaceChooserFrame.FaceChooserList
All Implemented Interfaces:
java.awt.event.AdjustmentListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener
Enclosing class:
FaceChooserFrame

protected static class FaceChooserFrame.FaceChooserList
extends java.awt.Container
implements java.awt.event.AdjustmentListener

FaceChooserList holds face icons (in rows and columns) and an optional scrollbar. Custom layout.

See Also:
Serialized Form

Nested Class Summary
private  class FaceChooserFrame.FaceChooserList.FaceChooserRow
          Within FaceChooserList, one row of faces.
 
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  int currentFaceId
           
private  int currentOffset
           
private  int currentRow
           
private  FaceChooserFrame.FaceChooserList.FaceChooserRow[] faceGrid
          Will contain all faces.
protected static int faceRowsHeight
          How many rows to show? Default 6.
private  java.awt.Scrollbar faceSB
           
protected  FaceChooserFrame fcf
           
private  int initialFaceId
           
private  boolean needsScroll
           
protected  int padH
          Padding beyond desired size; not known until doLayout()
protected  int padW
          Padding beyond desired size; not known until doLayout()
private  int rowCount
           
protected static int rowFacesWidth
          How many faces per row? Default 7.
protected  int scrollW
          faceSB pixel width; not known until doLayout
private  FaceChooserFrame.FaceChooserList.FaceChooserRow[] visibleFaceGrid
          Contains only visible faces (based on scrollbar).
protected  int wantH
          Desired size (visible size inside of insets; not incl scrollW)
protected  java.awt.Dimension wantSize
          Desired size
protected  int wantW
          Desired size (visible size inside of insets; not incl scrollW)
 
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
protected FaceChooserFrame.FaceChooserList(FaceChooserFrame fcf, int selectedFaceId)
          Create facechooserlist for this frame, with selected face ID.
 
Method Summary
 void adjustmentValueChanged(java.awt.event.AdjustmentEvent e)
          Update displayed rows when scrollbar changes
protected  boolean checkInsetsPadding(java.awt.Insets i)
          Now that insets and scrollbar size are known, check our size and padding.
 void doLayout()
          Custom layout for this list, which makes things easier because visibleFaceGrid changes frequently.
 java.awt.Dimension getMinimumSize()
           
 java.awt.Dimension getPreferredSize()
           
 void moveCursor(int dr, int dc, java.awt.event.KeyEvent e)
          Move the cursor choosing the current face, and change selected face in this browser.
 void scrollToRow(int newRow)
          Ensure this row of faces is visible.
 void selectFace(int id)
          Face chosen (clicked), by user or otherwise.
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, 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, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, 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

rowFacesWidth

protected static int rowFacesWidth
How many faces per row? Default 7. Do not change after creating an instance.


faceRowsHeight

protected static int faceRowsHeight
How many rows to show? Default 6. Do not change after creating an instance. If all faces (SOCFaceButton.NUM_FACES) fit in fewer than faceRowsHeight rows, the first instance's constructor will reduce faceRowsHeight to the proper value.


fcf

protected FaceChooserFrame fcf

currentRow

private int currentRow

currentOffset

private int currentOffset

rowCount

private int rowCount

currentFaceId

private int currentFaceId

initialFaceId

private int initialFaceId

faceGrid

private FaceChooserFrame.FaceChooserList.FaceChooserRow[] faceGrid
Will contain all faces. Length is rowCount. Each row contains rowFacesWidth faces. Some elements initially null, if the scrollbar is needed (if rowCount > faceRowsHeight). Contents are references to same objects as in visibleFaceGrid.


visibleFaceGrid

private FaceChooserFrame.FaceChooserList.FaceChooserRow[] visibleFaceGrid
Contains only visible faces (based on scrollbar). Length is faceRowsHeight. Each row contains rowFacesWidth faces. Contents are references to same objects as in faceGrid.


needsScroll

private boolean needsScroll

faceSB

private java.awt.Scrollbar faceSB

wantW

protected int wantW
Desired size (visible size inside of insets; not incl scrollW)


wantH

protected int wantH
Desired size (visible size inside of insets; not incl scrollW)


wantSize

protected java.awt.Dimension wantSize
Desired size


padW

protected int padW
Padding beyond desired size; not known until doLayout()


padH

protected int padH
Padding beyond desired size; not known until doLayout()


scrollW

protected int scrollW
faceSB pixel width; not known until doLayout

Constructor Detail

FaceChooserFrame.FaceChooserList

protected FaceChooserFrame.FaceChooserList(FaceChooserFrame fcf,
                                           int selectedFaceId)
Create facechooserlist for this frame, with selected face ID.

Method Detail

selectFace

public void selectFace(int id)
Face chosen (clicked), by user or otherwise. Select it and show the hilight border. If the new face isn't currently visible, scroll to show it.

Parameters:
id - Face ID to select
Throws:
java.lang.IllegalArgumentException - if id <= 0 or id >= SOCFaceButton.NUM_FACES
See Also:
moveCursor(int, int, KeyEvent)

scrollToRow

public void scrollToRow(int newRow)
Ensure this row of faces is visible. Calls repaint if needed. Number of rows visible at a time is faceRowsHeight.

Parameters:
newRow - Row number, counting from 0. The row number can be determined from the faceID by newRow = (faceId - 1) / rowFacesWidth.
Throws:
java.lang.IllegalArgumentException - if newRow < 0 or newRow >= rowCount

moveCursor

public void moveCursor(int dr,
                       int dc,
                       java.awt.event.KeyEvent e)
                throws java.lang.IllegalArgumentException
Move the cursor choosing the current face, and change selected face in this browser. If needed, calls scrollToRow to make the selected face visible. Both dr and dc can be nonzero in the same call.

Parameters:
dr - Delta row: -3 jumps to very top; -2 is PageUp; -1 is one row; same for +.
dc - Delta column: -2 jumps to far-left, -1 is one to left, +1 is one to right, +2 jumps to far-right. If already at far-left or far-right, -1/+1 move into the previous/next row.
e - KeyEvent to be consumed, or null. The event contents are ignored, only dr and dc are used to choose the direction of movement. If dr==0 and dc==0, e is still consumed.
Throws:
java.lang.IllegalArgumentException - If dr or dc is out of the range described here
See Also:
selectFace(int), scrollToRow(int)

adjustmentValueChanged

public void adjustmentValueChanged(java.awt.event.AdjustmentEvent e)
Update displayed rows when scrollbar changes

Specified by:
adjustmentValueChanged in interface java.awt.event.AdjustmentListener

checkInsetsPadding

protected boolean checkInsetsPadding(java.awt.Insets i)
Now that insets and scrollbar size are known, check our size and padding. If too small, resize the frame.

Parameters:
i - Insets
Returns:
True if dimensions were updated and setSize was called.

doLayout

public void doLayout()
Custom layout for this list, which makes things easier because visibleFaceGrid changes frequently.

Overrides:
doLayout in class java.awt.Container

getMinimumSize

public java.awt.Dimension getMinimumSize()
Overrides:
getMinimumSize in class java.awt.Container

getPreferredSize

public java.awt.Dimension getPreferredSize()
Overrides:
getPreferredSize in class java.awt.Container