hexIT
Class HexagonalHexPanel

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byhexIT.HexPanel
                      extended byhexIT.HexagonalHexPanel
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class HexagonalHexPanel
extends HexPanel

A panel that holds and graphically represents a hexagonal board. This class is responsible for working out the details of the actual drawing of the board to the screen, bot for the internals of the data within the board.

See Also:
Serialized Form

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
HexagonalHexPanel(int new_width, int new_height, int new_size, java.awt.Color new_bgColor, HexagonalBoard new_board)
          Create a hexagonal hex panel with specified height and width (in pixels) Note: these panels are currently not resizable.
 
Method Summary
 void hideGrid()
          Hide the board grid.
 void moveObject(Drawable obj, int dir)
          Move the object from wherever it is on the board to hex location in the specified direction.
 void moveObject(Drawable obj, int x2, int y2)
          Move the object from wherever it is on the board to hex location (x2,y2).
 void moveObject(int x1, int y1, int dir)
          Move object from hex coords (x1,y1) in the specified direction.
 void moveObject(int x1, int y1, int x2, int y2)
          Move object from hex coords (x1,y1) to (x2,y2).
 void paint(java.awt.Graphics g)
          Paint the panel.
 void putObject(int x, int y, Drawable obj)
          Puts the specified object at hex coordinates (x,y).
 void removeObject(int x, int y)
          Removes the specified object at hex coordinates (x,y).
 void scaleAllImages()
          Scale all the images associated with each drawable object on each hexagon.
 void setHexFillColor(int hexx, int hexy, java.awt.Color color)
          Set the fill color of the Hexagon at hex location (hexx, hexy) the specified color.
 void setHexOutlineColor(int hexx, int hexy, java.awt.Color color)
          Set the outline color of the Hexagon at hex location (hexx, hexy) the specified color.
 void showGrid(java.awt.Color drawingColor)
          Show the board grid.
 
Methods inherited from class hexIT.HexPanel
getBackgroundColor, getBoard, setBackgroundColor, setScale
 
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, 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, setBackground, 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, getBackground, 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

HexagonalHexPanel

public HexagonalHexPanel(int new_width,
                         int new_height,
                         int new_size,
                         java.awt.Color new_bgColor,
                         HexagonalBoard new_board)
Create a hexagonal hex panel with specified height and width (in pixels) Note: these panels are currently not resizable.

Method Detail

putObject

public void putObject(int x,
                      int y,
                      Drawable obj)
Puts the specified object at hex coordinates (x,y).

Specified by:
putObject in class HexPanel

removeObject

public void removeObject(int x,
                         int y)
Removes the specified object at hex coordinates (x,y).

Specified by:
removeObject in class HexPanel

moveObject

public void moveObject(int x1,
                       int y1,
                       int x2,
                       int y2)
Move object from hex coords (x1,y1) to (x2,y2).


moveObject

public void moveObject(int x1,
                       int y1,
                       int dir)
Move object from hex coords (x1,y1) in the specified direction. Directions are found in HexagonalBoard.


moveObject

public void moveObject(Drawable obj,
                       int x2,
                       int y2)
Move the object from wherever it is on the board to hex location (x2,y2). Note: the Board.findObject method is used to find the object.


moveObject

public void moveObject(Drawable obj,
                       int dir)
Move the object from wherever it is on the board to hex location in the specified direction. Note: the Board.findObject method is used to find the object.


paint

public void paint(java.awt.Graphics g)
Paint the panel.


showGrid

public void showGrid(java.awt.Color drawingColor)
Show the board grid. Hexagon contours will be drawn in the specified drawing color.

Specified by:
showGrid in class HexPanel

hideGrid

public void hideGrid()
Hide the board grid.

Specified by:
hideGrid in class HexPanel

scaleAllImages

public void scaleAllImages()
Scale all the images associated with each drawable object on each hexagon.

Specified by:
scaleAllImages in class HexPanel

setHexOutlineColor

public void setHexOutlineColor(int hexx,
                               int hexy,
                               java.awt.Color color)
Set the outline color of the Hexagon at hex location (hexx, hexy) the specified color.

Specified by:
setHexOutlineColor in class HexPanel

setHexFillColor

public void setHexFillColor(int hexx,
                            int hexy,
                            java.awt.Color color)
Set the fill color of the Hexagon at hex location (hexx, hexy) the specified color.

Specified by:
setHexFillColor in class HexPanel