|
|||||||||
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
Grid
public class Grid
This is the Grid panel for the CLIP application.
It is responsible for drawing the the gridlines and tiles.
It implements interface functions used by the UserInteraction
and Playback
classes to manipulate tiles in the grid.
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) boolean |
drawGridBool
If true then draw gridlines on the grid. |
(package private) int[][] |
grid
An array that stores tile information for the grid. |
(package private) java.awt.Dimension |
GridDefaultSizeInPixels
The default size of the grid before a tileset is loaded. |
(package private) int |
gridHeight
The height of the grid in gridSquares. |
(package private) java.lang.String |
GridName
The name of this panel. |
(package private) java.awt.Dimension |
gridSizeInPixels
The size of the grid in pixels. |
(package private) int |
gridSquareSize
The size in pixels of each gridsquare on the grid. |
(package private) int |
gridWidth
The width of the grid in gridSqaures. |
(package private) UserInteraction |
mouseInput
The UserInteraction object. |
private static long |
serialVersionUID
|
(package private) MiniMapPanel |
theMiniMap
the MiniMapPanel object. |
(package private) TileSet |
theTileSet
The TileSet that is currently in use. |
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 | |
---|---|
Grid(UserInteraction mInput)
The constructor for the grid class. |
Method Summary | |
---|---|
void |
changeGridSize(java.awt.Dimension newGridSize)
This changes the size of the grid and updates the appropriate variables. |
void |
drawGrid(java.awt.Graphics g)
Draws gridlines defined by the gridSquareSize . |
void |
drawTiles(java.awt.Graphics g)
Draws the tiles on the grid. |
void |
drawTiles(java.awt.Graphics2D g,
int xOffset,
int yOffset)
Draws tiles on a 2D graphics object at a certain offset. |
void |
eraseTilePosition(int tileToErase)
This erases the passed in tile from the grid array. |
java.awt.Point |
findLocForTile(int xGridCenter,
int yGridCenter,
int curTile)
Finds a valid location for a tile to be placed in the grid. |
int |
findTileAt(int x,
int y)
Finds the tileID of the tile stored at the grid square defined by the passed in coordinates (0 if no tile found). |
java.awt.Point |
getGridSquareAt(int x,
int y)
Returns the coordinates of the grid square defined by the passed in mouse coordinates. |
int |
getGridSquareSize()
Returns the grid square size. |
java.awt.Point |
getMouseOffset(int x,
int y,
int tileID)
Accepts mouse coordinates and a tileID and then returns the offset from the mouse location to the tile's upper left location. |
boolean |
isValidLoc(int x,
int y,
int tID)
Determines if the grid coordinates defined by the passed in x and y values is a valid grid location for the tile with the passed in TileID |
void |
paintComponent(java.awt.Graphics g)
Paints the grid with tiles and or gridlines if needed. |
void |
placeTileAt(int x,
int y,
int tileToPlace)
Places the tile with the passed in tileID to the location defined by the passed in x and y values (in gridsquares). |
void |
printGrid()
Debugging function that prints the contents of the grid array to the console. |
void |
setMiniMap(MiniMapPanel mm)
Sets the mini map to the passed in MiniMapPanel . |
void |
setTileSet(TileSet curSet)
Sets the current tile set to the passed in tile set. |
void |
updateTileID(int newID,
int x,
int y,
int w,
int h)
Updates a grid location defined by the parameters with a new tileID that has been passed in. |
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 GridDefaultSizeInPixels
final int gridSquareSize
final java.lang.String GridName
UserInteraction mouseInput
UserInteraction
object.
MiniMapPanel theMiniMap
MiniMapPanel
object.
TileSet theTileSet
TileSet
that is currently in use.
java.awt.Dimension gridSizeInPixels
int gridWidth
int gridHeight
boolean drawGridBool
true
then draw gridlines on the grid.
int[][] grid
Constructor Detail |
---|
public Grid(UserInteraction mInput)
null
, and registers mouse listeners.
mInput
- CLIP's mouse adapter classMethod Detail |
---|
public void paintComponent(java.awt.Graphics g)
paintComponent
in class javax.swing.JComponent
g
- Graphics object to paintdrawGrid(Graphics)
,
drawTiles(Graphics)
,
MiniMapPanel
public void setTileSet(TileSet curSet)
curSet
- TileSet to use as the current TileSetTileSet
public void setMiniMap(MiniMapPanel mm)
MiniMapPanel
.
mm
- The MiniMapPanel to use as the mini mappublic int getGridSquareSize()
gridSquareSize
public void printGrid()
grid
public void drawGrid(java.awt.Graphics g)
gridSquareSize
.
g
- The graphics object to draw the gridlines onpaintComponent(Graphics)
public void drawTiles(java.awt.Graphics g)
Tile
,
paintComponent(Graphics)
public void drawTiles(java.awt.Graphics2D g, int xOffset, int yOffset)
UserInterface
class.
g
- The graphics object to draw onxOffset
- Number to subtract from tiles' X locationyOffset
- Number to subtract from tiles' Y locationTile
,
UserInterface.getPrintArrangementImage()
public void changeGridSize(java.awt.Dimension newGridSize)
newGridSize
- New size of the gridpublic int findTileAt(int x, int y)
x
- X coordinate of location to check (in gridsquares)y
- Y coordinate of location to check (in gridsquares)
null
public java.awt.Point getGridSquareAt(int x, int y)
x
- X location of mousey
- Y location of mouse
public java.awt.Point getMouseOffset(int x, int y, int tileID)
x
- Mouse X coordinatey
- Mouse Y coordinatetileID
- TileID to get the mouse offset of
public boolean isValidLoc(int x, int y, int tID)
x
- Grid X location to checky
- Grid Y location to checktID
- ID of the tile to check
true
if the location is valid;
false
otherwise.public void eraseTilePosition(int tileToErase)
tileToErase
- The TileID of the tile to erase from the gridpublic void placeTileAt(int x, int y, int tileToPlace)
x
- Grid's X location to place the tile aty
- Grid's Y location to place the tile attileToPlace
- ID of the tile to placepublic void updateTileID(int newID, int x, int y, int w, int h)
newID
- New ID number to usex
- X location to start the changey
- Y location to start the changew
- Width of tileh
- Height of tilepublic java.awt.Point findLocForTile(int xGridCenter, int yGridCenter, int curTile)
point
representing
a valid grid square to place the tile at or null
if no valid location is found.
xGridCenter
- Grid X location to start the search atyGridCenter
- Grid Y location to start the search atcurTile
- Tile ID to check for placement
Point
representing a valid grid coordinate
to place the tile at. null
if no valid
location can be found.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |