hexIT
Class HexPanel

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

public abstract class HexPanel
extends javax.swing.JPanel

A hex panel is a panel which contains a board of hexagons. The board type is important to figuring out the graphical arrangement/layout of the component hexagons, therefore this class only contains the shared methods that is part of all kinds of hex panels.

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
HexPanel(int new_width, int new_height, int new_boardSize, java.awt.Color new_bgColor)
          Create a new hex panel with the specified width heights and heights (in pixels), and background color.
 
Method Summary
 java.awt.Color getBackgroundColor()
          Gets the background color of this panel.
 Board getBoard()
          Gets the board which is associated with this panel.
abstract  void hideGrid()
          Hides the grid.
abstract  void putObject(int x, int y, Drawable object)
          Puts the specified object at hex coordinates (x,y).
abstract  void removeObject(int x, int y)
          Removes the specified object at hex coordinates (x,y).
abstract  void scaleAllImages()
          Scale all the images of all the objects on the Hexagons.
 void setBackgroundColor(java.awt.Color new_bgColor)
          Sets the background color of this panel.
abstract  void setHexFillColor(int hexx, int hexy, java.awt.Color color)
          Set the outline color of the hexagon at hex coords (hexx, hexy).
abstract  void setHexOutlineColor(int hexx, int hexy, java.awt.Color color)
          Set the outline color of the hexagon at hex coords (hexx, hexy).
 void setScale(boolean new_scale)
          If the argument is true, scale all the images.
abstract  void showGrid(java.awt.Color drawingColor)
          Shows the hex grid (all the hexagons on the board).
 
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, 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

HexPanel

public HexPanel(int new_width,
                int new_height,
                int new_boardSize,
                java.awt.Color new_bgColor)
Create a new hex panel with the specified width heights and heights (in pixels), and background color. The boardsize is different for every board type: it is the size represented by the board type (see the specific board type that will be used).

Method Detail

getBackgroundColor

public java.awt.Color getBackgroundColor()
Gets the background color of this panel.


setScale

public void setScale(boolean new_scale)
If the argument is true, scale all the images.


setBackgroundColor

public void setBackgroundColor(java.awt.Color new_bgColor)
Sets the background color of this panel.


getBoard

public Board getBoard()
Gets the board which is associated with this panel.


putObject

public abstract void putObject(int x,
                               int y,
                               Drawable object)
Puts the specified object at hex coordinates (x,y). Note: the hex coordinates depends on the coordinate system used by the actual board type.


removeObject

public abstract void removeObject(int x,
                                  int y)
Removes the specified object at hex coordinates (x,y). Note: the hex coordinates depends on the coordinate system used by the actual board type.


showGrid

public abstract void showGrid(java.awt.Color drawingColor)
Shows the hex grid (all the hexagons on the board).


hideGrid

public abstract void hideGrid()
Hides the grid. All hexagons become not visible.


scaleAllImages

public abstract void scaleAllImages()
Scale all the images of all the objects on the Hexagons.


setHexOutlineColor

public abstract void setHexOutlineColor(int hexx,
                                        int hexy,
                                        java.awt.Color color)
Set the outline color of the hexagon at hex coords (hexx, hexy). Note: the hex coordinates depends on the coordinate system used by the actual board type.


setHexFillColor

public abstract void setHexFillColor(int hexx,
                                     int hexy,
                                     java.awt.Color color)
Set the outline color of the hexagon at hex coords (hexx, hexy). Note: the hex coordinates depends on the coordinate system used by the actual board type.