|
CIDER Toolkit Version 0.2.0 |
|||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||
java.lang.Object
|
+--java.awt.Component
|
+--java.awt.Container
|
+--javax.swing.JComponent
|
+--javax.swing.JPanel
|
+--TokenCanvas
This class implements a token canvas which contains a collection of tokens in a stack. When asked to draw itself, the token canvas goes through the tokens in the stack in order, getting each one to draw itself (with tokens at the top of the stack drawn over tokens at the bottom). The order of the tokens in the stack can be changed, and tokens can be added to or removed from the canvas.
| Nested Class Summary |
| Nested classes inherited from class javax.swing.JComponent |
javax.swing.JComponent.AccessibleJComponent |
| Field Summary |
| Fields inherited from class javax.swing.JComponent |
TOOL_TIP_TEXT_KEY, 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 | |
TokenCanvas(java.awt.Dimension d)
Creates a new TokenCanvas object. |
|
TokenCanvas(int width,
int height)
Creates a new TokenCanvas object. |
|
| Method Summary | |
boolean |
add(DrawableToken t)
Adds a token to the bottom of the stack. |
void |
clear()
Removes all tokens from the stack. |
java.awt.Color |
getBackground()
Returns the background colour of the canvas. |
DrawableToken |
getBottomToken()
Returns the token at the bottom of the stack, or null if the stack is empty. |
int |
getNumTokens()
Returns the number of tokens in the stack |
DrawableToken |
getToken(int index)
Returns the token at the specified location in the stack, or null if no token is at that index. |
java.util.List |
getTokensContaining(double x,
double y)
Searches the tokens to see if any contain the specified co-ordinates. |
DrawableToken |
getTopToken()
Returns the token at the top of the stack, or null if the stack is empty. |
int |
indexOf(DrawableToken t)
Returns the location in the stack of the specified token, or -1 if it is not in the stack. |
boolean |
move(int index,
DrawableToken t)
Moves a token to a specific location in the stack. |
boolean |
moveToBottom(DrawableToken t)
Moves a token to the bottom of the stack. |
boolean |
moveToTop(DrawableToken t)
Moves a token to the top of the stack. |
void |
paintComponent(java.awt.Graphics g)
Draws the current list of tokens in the order they appear on the stack. |
boolean |
remove(DrawableToken t)
Removes a token from the stack. |
void |
setBackground(java.awt.Color c)
Sets the background colour of the canvas. |
| Methods inherited from class javax.swing.JPanel |
getAccessibleContext, getUI, getUIClassID, setUI, updateUI |
| Methods inherited from class javax.swing.JComponent |
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update |
| Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate |
| Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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 |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public TokenCanvas(java.awt.Dimension d)
d - The dimensions of the new canvas.
public TokenCanvas(int width,
int height)
width - The width of the new canvas.height - The height of the new canvas.| Method Detail |
public void setBackground(java.awt.Color c)
setBackground in class javax.swing.JComponentpublic java.awt.Color getBackground()
getBackground in class java.awt.Componentpublic void paintComponent(java.awt.Graphics g)
paintComponent in class javax.swing.JComponentpublic boolean add(DrawableToken t)
t - The token to be added.
true if successful, or false if the
token is null or already in the stack.public boolean moveToTop(DrawableToken t)
t - The token to be moved.
true if successful, or false if the
token is not in the stack.public boolean moveToBottom(DrawableToken t)
t - The token to be moved.
true if successful, or false if the
token is not in the stack.
public boolean move(int index,
DrawableToken t)
index - Location in the stack in the range 0 (top) to getNumTokens() - 1 (bottom).t - The token to be moved.
true if successful, or false if the
token is not in the stack.public boolean remove(DrawableToken t)
t - The token to be removed.
true if successful, or false if the
token is not in the stack.public void clear()
public int getNumTokens()
public DrawableToken getTopToken()
null if the stack is empty.
public DrawableToken getBottomToken()
null if the stack is empty.
public DrawableToken getToken(int index)
null if no token is at that index.
index - Location in the stack in the range 0 (top) to getNumTokens() - 1 (bottom).public int indexOf(DrawableToken t)
t - The token whose location is being sought.
public java.util.List getTokensContaining(double x,
double y)
x - The x co-ordinate.y - The y co-ordinate.
|
CIDER Toolkit Version 0.2.0 |
|||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||