|
|||||||||
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
TileBin
public class TileBin
The TileBin hold tiles not currently placed on the grid.
It can accommodate multiple tiles wide. Tiles are stored in a
linear fashion and 'wrap' in the tilebin. In otherwords, its
behaves like a string of text in a word-wrap textbox. Tiles always
shift up (or to the left) to fill in gaps in the TileBin.
It implements interface functions used by the UserInteraction
and Playback
classes to manipulate tiles in the TileBin.
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.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary | |
---|---|
(package private) javax.swing.JLabel |
insertLine
Black line drawn to represent where a tile will be inserted |
(package private) int |
InsertLineThickness
Thickness of the insertion line |
(package private) int |
LEFT
Defines the TileBin being located on the left side of the grid |
(package private) UserInteraction |
mouseInput
CLIP's mouse adapter |
(package private) int |
numTilesWide
Current number of Tiles the TileBin displays horizontally per row |
(package private) CLIPFrame |
parentFrame
The frame the application runs in |
(package private) int |
RIGHT
Defines the TileBin being located on the right side of the grid |
private static long |
serialVersionUID
|
(package private) java.util.ArrayList |
tbList
List of tiles in the TileBin (Stores integer IDs corresponding to Tile IDs in the current TileSet) |
(package private) int |
tbSide
Current side of the grid that the TileBin is located on (LEFT or RIGHT) |
(package private) TileSet |
theTileSet
The current TileSet being used |
(package private) java.awt.Dimension |
TileBinDefaultSize
Default size of the tilebin |
(package private) java.lang.String |
TileBinName
Name of the tilebin |
(package private) java.awt.Dimension |
TileBinSize
Current size of the TileBin |
(package private) int |
tilePixTall
Number of pixels tall of each Tile in the current TileSet |
(package private) int |
tilePixWide
Number of pixels wide of each Tile in the current TileSet |
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 | |
---|---|
TileBin(UserInteraction mInput,
CLIPFrame parent)
The constructor sets defaults values, initializes the insertion line, creates a new tbList , and registers the mouse listeners. |
Method Summary | |
---|---|
void |
addBlankTile(int tileID)
Adds the tile of the passed in tileID to the end of the TileBin and scrolls to make it visible if needed. |
void |
adjustSize()
Adjusts the size of the TileBin and location of the split pane divider based on the number of tiles visible per row. |
void |
drawInsertionBar(java.awt.Point tileCenter,
java.awt.Rectangle binOffset)
Draws the insertion bar for the tile bin based off the center position of the tile being dragged. |
private void |
drawTiles(java.awt.Graphics g)
Draws the tiles at thier proper pixel coordinates in the TileBin. |
void |
eraseTilePosition(int tileToErase)
Remove a tile from the TileBin and shifts the remaining tiles over to fill in the gap that was created (if necessary). |
java.awt.Dimension |
findPreferredSize()
Finds the preferred size of the TileBin based on the number of tiles currently visible per row. |
int |
findTileAt(int index)
Returns the TileID of the tile at the specified index in the list of tiles. |
int |
getIndexOfInsertion(int x,
int y)
Takes x and y coordinates and calculates the index of the tbList that the coordinates are located over. |
java.awt.Point |
getMouseOffset(int x,
int y,
int tileID)
Takes mouse coordinates and a tileID and calculates the mouse offset from that tile and returns it. |
int |
getTileBinSquareAt(int x,
int y)
Takes the passed in coordinates of the mouse relative to the TileBin and caculates the index of the tbList
at that position. |
void |
hideInsertLine()
Hides the insertion line. |
void |
insertTile(int tileIndex,
int tileToInsert)
Inserts the tile with the passed in ID to the passed in index in the tbList . |
void |
LoadTileSet(TileSet curSet)
Loads up the passed in TileSet and fills the TileBin with its tiles. |
void |
paintComponent(java.awt.Graphics g)
Paints the Tiles in the tilebin. |
void |
printArray()
Debug function that prints the list of tile IDs in the tilebin to the console window. |
void |
scrollToTile(int tileID)
Scrolls the TileBin to bring the tile with the passed in ID to be visible if it isn't already. |
void |
setSideLeft()
Sets the TileBin to the left side of the grid. |
void |
setSideRight()
Sets the TileBin ot the right side of the grid. |
void |
setTileSet(TileSet curSet)
Initializes the TileBin to use the passed in TileSet |
void |
updateTileID(int newID,
int y)
Sets the value in the tbList at the passed in
index to the passed in value. |
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, 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, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, 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
final java.awt.Dimension TileBinDefaultSize
final java.lang.String TileBinName
UserInteraction mouseInput
CLIPFrame parentFrame
TileSet theTileSet
TileSet
being used
javax.swing.JLabel insertLine
final int InsertLineThickness
java.awt.Dimension TileBinSize
int numTilesWide
int tilePixWide
int tilePixTall
int tbSide
final int LEFT
final int RIGHT
java.util.ArrayList tbList
Tile
IDs in the current TileSet)
Constructor Detail |
---|
public TileBin(UserInteraction mInput, CLIPFrame parent)
tbList
, and registers the mouse listeners.
mInput
- CLIP's mouse adapter to attach to the TileBinparent
- The frame that the application runs inMethod Detail |
---|
public void paintComponent(java.awt.Graphics g)
numTilesWide
variable.
paintComponent
in class javax.swing.JComponent
g
- The graphics object to draw ondrawTiles(Graphics)
private void drawTiles(java.awt.Graphics g)
tbList
by Y values only so the actual row/column position must
be determined in this function for each tile drawn.
g
- The graphics object to draw the tiles onpaintComponent(Graphics)
public void printArray()
public java.awt.Dimension findPreferredSize()
public void adjustSize()
public void setTileSet(TileSet curSet)
curSet
- The TileSet to use for the TileBinpublic void LoadTileSet(TileSet curSet)
curSet
- The TileSet to loadpublic int findTileAt(int index)
index
- Index in the tbList
to get the ID of
public int getTileBinSquareAt(int x, int y)
tbList
at that position.
x
- X coordinate of the mouse relative to the TileBiny
- Y coordinate of the mouse relative to the TileBin
public java.awt.Point getMouseOffset(int x, int y, int tileID)
x
- X coordinate of the mousey
- Y coordinate of the mousetileID
- TileID to get the mouse offset of
public void eraseTilePosition(int tileToErase)
tileToErase
- ID of the tile to removepublic void drawInsertionBar(java.awt.Point tileCenter, java.awt.Rectangle binOffset)
tileCenter
- The center position of the tile relative to the TileBinbinOffset
- Location of the TileBin relative to
theMainPanel
public void hideInsertLine()
insertLine
public void addBlankTile(int tileID)
tileID
- TileID of the tile to addpublic void scrollToTile(int tileID)
tileID
- ID of the tile to scroll topublic int getIndexOfInsertion(int x, int y)
tbList
that the coordinates are located over.
Future efforts could expand upon this to get the tile
placements to occur in two dimensions. One must be careful however
because if arrangements in the TileBin were to become too pleasant,
it could cause the user to arrange the tiles here rather than in the
grid without realizing the need to do otherwise.
x
- X coordinate to insert at (relative to the TileBin)y
- Y coordinate to insert at (relative to the TileBin)
tbList
public void insertTile(int tileIndex, int tileToInsert)
tbList
.
tileIndex
- Index to place the tile in the tbList.tileToInsert
- ID of the tile to insertpublic void updateTileID(int newID, int y)
tbList
at the passed in
index to the passed in value.
newID
- New value in the tbList at the specified locationy
- Index in the tbList to modifypublic void setSideLeft()
tbSide
public void setSideRight()
tbSide
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |