public class SwingPane extends javax.swing.JLayeredPane implements SGPane
javax.swing.JLayeredPane.AccessibleJLayeredPane
javax.swing.JComponent.AccessibleJComponent
DEFAULT_LAYER, DRAG_LAYER, FRAME_CONTENT_LAYER, LAYER_PROPERTY, MODAL_LAYER, PALETTE_LAYER, POPUP_LAYER
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
SwingPane()
Empty constructor.
|
SwingPane(int gridWidth,
int gridHeight,
java.awt.Font font)
Builds a panel with the given Font determining the size of the cell
dimensions.
|
SwingPane(int cellWidth,
int cellHeight,
int gridWidth,
int gridHeight,
java.awt.Font font)
Builds a new panel with the desired traits.
|
Modifier and Type | Method and Description |
---|---|
void |
bump(java.awt.Point location,
Direction direction)
Starts a bumping animation in the direction provided.
|
void |
bump(java.awt.Point location,
java.awt.Point direction)
Starts a bumping animation in the direction provided.
|
void |
clearCell(int x,
int y)
Clears the cell at the location given with the default background color.
|
void |
clearCell(int x,
int y,
java.awt.Color color)
Clears the cell at the location given with the provided color.
|
void |
ensureFits(char[] characters)
Sets the character set that will be guaranteed to fit on the next
initialization of the grid.
|
java.awt.Dimension |
getCellDimension() |
int |
getCellHeight()
Returns the height of a single cell.
|
int |
getCellWidth()
Returns the width of a single cell.
|
int |
getGridHeight()
Returns the height of the grid.
|
int |
getGridWidth()
Returns the width of the grid.
|
ImageCellMap |
getImageCellMap() |
TextCellFactory |
getTextFactory() |
void |
initialize(int gridWidth,
int gridHeight,
java.awt.Font font)
Initializes the component with the supplied number of rows and columns.
|
void |
initialize(int cellWidth,
int cellHeight,
int gridWidth,
int gridHeight,
java.awt.Font font)
Initializes the component with the supplied values.
|
void |
paintComponent(java.awt.Graphics g) |
void |
placeCharacter(int x,
int y,
char c)
Sets one specific block to the given character.
|
void |
placeCharacter(int x,
int y,
char c,
java.awt.Color fore)
Sets the block at the given coordinates to contain the passed in
character drawn with the given foreground color.
|
void |
placeCharacter(int x,
int y,
char c,
java.awt.Color fore,
java.awt.Color back)
Sets one specific block to the given character with the given foreground
and background colors.
|
void |
placeHorizontalString(int xOffset,
int yOffset,
java.lang.String string)
Prints out a string starting at the given offset position.
|
void |
placeHorizontalString(int xOffset,
int yOffset,
java.lang.String string,
java.awt.Color foreground,
java.awt.Color background)
Prints out a string vertically starting at the given offset position and
traveling down.
|
void |
placeImage(int x,
int y,
java.lang.String key)
Places the image associated with the provided key at the given
coordinates.
|
void |
placeImage(int x,
int y,
java.lang.String key,
java.awt.Color background)
Places the image associated with the provided key at the given
coordinates.
|
void |
placeText(int xOffset,
int yOffset,
char[][] chars)
Sets the contents of the component to reflect the two dimensional
character array, starting at the given offset position.
|
void |
placeText(int xOffset,
int yOffset,
char[][] chars,
java.awt.Color foreground,
java.awt.Color background)
Sets the contents of the component to reflect the two dimensional
character array, starting at the given offset position.
|
void |
placeVerticalString(int xOffset,
int yOffset,
java.lang.String string)
Prints out a string vertically starting at the given offset position and
traveling down.
|
void |
placeVerticalString(int xOffset,
int yOffset,
java.lang.String string,
java.awt.Color foreground,
java.awt.Color background)
Prints out a string starting at the given offset position.
|
void |
refresh()
Signals that this component should update its display image.
|
void |
setCellBackground(int x,
int y,
java.awt.Color color)
Sets the background to the provided color.
|
void |
setDefaultBackground(java.awt.Color defaultBackground)
Sets the background color which will be used on all text and transparent
tiles when not other color is specified.
|
void |
setDefaultForeground(java.awt.Color defaultForeground)
Sets the background color which will be used on all text and transparent
tiles when not other color is specified.
|
void |
setImageCellMap(ImageCellMap map) |
void |
setText(char[][] chars)
Sets the contents of the component to reflect the two dimensional
character array.
|
void |
setTextCellFactory(TextCellFactory factory) |
void |
slide(java.awt.Point start,
Direction direction)
Starts a movement animation for the object at the given grid location at
the default speed for one grid square in the direction provided.
|
void |
slide(java.awt.Point start,
java.awt.Point end)
Starts a movement animation for the object at the given grid location at
the default speed.
|
void |
slide(java.awt.Point start,
java.awt.Point end,
int speed)
Starts a sliding movement animation for the object at the given location
at the provided speed.
|
void |
waitForAnimations()
Causes the component to stop responding to input until all current
animations are finished.
|
void |
wiggle(java.awt.Point location)
Starts an wiggling animation for the object at the given location.
|
boolean |
willFit(char character)
Test if the given character will fit in the current cell dimension using
the current Font.
|
addImpl, getAccessibleContext, getComponentCountInLayer, getComponentsInLayer, getComponentToLayer, getIndexOf, getLayer, getLayer, getLayeredPaneAbove, getObjectForLayer, getPosition, highestLayer, insertIndexForLayer, isOptimizedDrawingEnabled, lowestLayer, moveToBack, moveToFront, paint, paramString, putLayer, remove, removeAll, setLayer, setLayer, setPosition
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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, 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, updateUI
add, add, add, add, add, addContainerListener, 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, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
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, transferFocusBackward, transferFocusUpCycle
public SwingPane(int cellWidth, int cellHeight, int gridWidth, int gridHeight, java.awt.Font font)
cellWidth
- cell width in pixels.cellHeight
- cell height in pixels.gridWidth
- number of cells vertically..gridHeight
- number of cells horizontally.font
- public SwingPane(int gridWidth, int gridHeight, java.awt.Font font)
gridWidth
- gridHeight
- font
- public SwingPane()
public void paintComponent(java.awt.Graphics g)
paintComponent
in class javax.swing.JComponent
public void setText(char[][] chars)
SGPane
public void setImageCellMap(ImageCellMap map)
public void setTextCellFactory(TextCellFactory factory)
public TextCellFactory getTextFactory()
public ImageCellMap getImageCellMap()
public void placeImage(int x, int y, java.lang.String key)
SGPane
placeImage
in interface SGPane
public void placeImage(int x, int y, java.lang.String key, java.awt.Color background)
SGPane
placeImage
in interface SGPane
public void placeText(int xOffset, int yOffset, char[][] chars)
SGPane
public void placeText(int xOffset, int yOffset, char[][] chars, java.awt.Color foreground, java.awt.Color background)
SGPane
public void placeHorizontalString(int xOffset, int yOffset, java.lang.String string)
SGPane
placeHorizontalString
in interface SGPane
public void placeHorizontalString(int xOffset, int yOffset, java.lang.String string, java.awt.Color foreground, java.awt.Color background)
SGPane
placeHorizontalString
in interface SGPane
public void placeVerticalString(int xOffset, int yOffset, java.lang.String string, java.awt.Color foreground, java.awt.Color background)
SGPane
placeVerticalString
in interface SGPane
public void placeVerticalString(int xOffset, int yOffset, java.lang.String string)
SGPane
placeVerticalString
in interface SGPane
public void clearCell(int x, int y)
SGPane
public void clearCell(int x, int y, java.awt.Color color)
SGPane
public void setCellBackground(int x, int y, java.awt.Color color)
SGPane
setCellBackground
in interface SGPane
public void placeCharacter(int x, int y, char c)
SGPane
placeCharacter
in interface SGPane
x
- The x coordinate to sety
- The y coordinate to setc
- The character to be displayedpublic void placeCharacter(int x, int y, char c, java.awt.Color fore, java.awt.Color back)
SGPane
placeCharacter
in interface SGPane
x
- The x coordinate to sety
- The y coordinate to setc
- The character to be displayedfore
- The foreground colorback
- The background colorpublic void placeCharacter(int x, int y, char c, java.awt.Color fore)
SGPane
placeCharacter
in interface SGPane
public void initialize(int cellWidth, int cellHeight, int gridWidth, int gridHeight, java.awt.Font font)
SGPane
initialize
in interface SGPane
cellWidth
- in pixelscellHeight
- in pixelsgridWidth
- in cellsgridHeight
- in cellspublic void initialize(int gridWidth, int gridHeight, java.awt.Font font)
SGPane
initialize
in interface SGPane
gridWidth
- in cellsgridHeight
- in cellspublic void ensureFits(char[] characters)
characters
- public boolean willFit(char character)
SGPane
public java.awt.Dimension getCellDimension()
public int getGridHeight()
SGPane
getGridHeight
in interface SGPane
public int getGridWidth()
SGPane
getGridWidth
in interface SGPane
public void refresh()
SGPane
public void setDefaultBackground(java.awt.Color defaultBackground)
SGPane
setDefaultBackground
in interface SGPane
public void setDefaultForeground(java.awt.Color defaultForeground)
SGPane
setDefaultForeground
in interface SGPane
public void bump(java.awt.Point location, Direction direction)
location
- direction
- public void bump(java.awt.Point location, java.awt.Point direction)
location
- direction
- public void slide(java.awt.Point start, java.awt.Point end)
start
- end
- public void slide(java.awt.Point start, Direction direction)
start
- direction
- public void slide(java.awt.Point start, java.awt.Point end, int speed)
start
- end
- speed
- public void wiggle(java.awt.Point location)
location
- public void waitForAnimations()
public int getCellHeight()
SGPane
getCellHeight
in interface SGPane
public int getCellWidth()
SGPane
getCellWidth
in interface SGPane