megamek.client.ui.AWT.widget
Class PicMap

java.lang.Object
  extended by java.awt.Component
      extended by megamek.client.ui.AWT.widget.PicMap
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable
Direct Known Subclasses:
MechDisplay.ArmorPanel, MechDisplay.MovementPanel, MechPanelTabStrip, MechSlotLabel, TransparentLabel

public abstract class PicMap
extends java.awt.Component

PicMap is a lightweight component, which area is composed by the set of cutom elements added to PicMap Engine. There are three main groups of cutom elements
1) BackgroundDrawers
2) Hot areas
3) Labels
* Hot areas and labels can be grouped handled together by AreasGroup class. Content of PicMap - Areas group that includes all areas on the stage. Added Elements are placed into several layers within PicMap engine.

Within single layer elements are drawing in the order they added to PicMap.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
(package private)  int minHeight
           
(package private)  int minWidth
           
 
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
PicMap()
          creates PicMap engine.
 
Method Summary
 void addBgDrawer(BackGroundDrawer bd)
          Adds background drawer to the stage.
 void addElement(PMElement e)
          Adds element to PicMap component.
 void addNotify()
          Please remember to add super.addNotify() when overriding
 PMHotArea getAreaUnder(int x, int y)
          Returns Hot Area under coordinates (x, y)
 java.awt.Rectangle getContentBounds()
          Returns Rectangle bounding content of component
 java.awt.Dimension getMinimumSize()
           
 java.awt.Dimension getPreferredSize()
           
abstract  void onResize()
          onResize() function is calling every time PicMap is resized.
 void paint(java.awt.Graphics g)
           
protected  void processComponentEvent(java.awt.event.ComponentEvent e)
           
protected  void processMouseEvent(java.awt.event.MouseEvent e)
           
protected  void processMouseMotionEvent(java.awt.event.MouseEvent e)
           
 void removeAll()
          Removes all elements from PicMap component.
 void removeBgDrawer(BackGroundDrawer bd)
          Removes Background drawer from component.
 void removeElement(PMElement e)
          Removes element from PicMap component.
 void setBackgroundOpaque(boolean v)
          Sets background of PicMap to fully opaque or fully transparent.
 void setContentMargins(int l, int t, int r, int b)
          Sets margins in pixels around Content of component.
 void update()
          Updates all changes in areas state and repaints component.
 void update(java.awt.Graphics g)
           
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

minWidth

int minWidth

minHeight

int minHeight
Constructor Detail

PicMap

public PicMap()
creates PicMap engine. If no areas, labels or Backround-drawers added this is just transparent layer over container.

Method Detail

onResize

public abstract void onResize()
onResize() function is calling every time PicMap is resized. Have to be implemented directly to manage composition of component on resizing.


addElement

public void addElement(PMElement e)
Adds element to PicMap component. Please note, that all objects implementing PMLabel interface will be placed in the topmost layer. All objects implementing PMHotArea will be placed in the middle layer. All others are going to bottom layer. Within same layer objects are drawing by order they added to components.


removeElement

public void removeElement(PMElement e)
Removes element from PicMap component.


removeAll

public void removeAll()
Removes all elements from PicMap component.


addBgDrawer

public void addBgDrawer(BackGroundDrawer bd)
Adds background drawer to the stage. Background drawers are drawn in order they added to the component.


removeBgDrawer

public void removeBgDrawer(BackGroundDrawer bd)
Removes Background drawer from component.


setContentMargins

public void setContentMargins(int l,
                              int t,
                              int r,
                              int b)
Sets margins in pixels around Content of component. Does not affect Backgroun Drawers.

Parameters:
l - Left margin
t - Top margin
r - Right margin
b - Bottom margin

getContentBounds

public java.awt.Rectangle getContentBounds()
Returns Rectangle bounding content of component


addNotify

public void addNotify()
Please remember to add super.addNotify() when overriding

Overrides:
addNotify in class java.awt.Component

update

public void update()
Updates all changes in areas state and repaints component.


update

public void update(java.awt.Graphics g)
Overrides:
update in class java.awt.Component

paint

public void paint(java.awt.Graphics g)
Overrides:
paint in class java.awt.Component

getPreferredSize

public java.awt.Dimension getPreferredSize()
Overrides:
getPreferredSize in class java.awt.Component

getMinimumSize

public java.awt.Dimension getMinimumSize()
Overrides:
getMinimumSize in class java.awt.Component

getAreaUnder

public PMHotArea getAreaUnder(int x,
                              int y)
Returns Hot Area under coordinates (x, y)


setBackgroundOpaque

public void setBackgroundOpaque(boolean v)
Sets background of PicMap to fully opaque or fully transparent. Notes: Setting Background opaque to "false" switch off buffering of PicMap. Please provide appropriate graphic buffering in container. Notes: Setting Background opaque to "false" does not prevent draw of BackgroundDrawers in PicMap component. Notes: It is required only for Java1.1. Under Java1.3 and up offscreen will be transparent by default.


processMouseEvent

protected void processMouseEvent(java.awt.event.MouseEvent e)
Overrides:
processMouseEvent in class java.awt.Component

processMouseMotionEvent

protected void processMouseMotionEvent(java.awt.event.MouseEvent e)
Overrides:
processMouseMotionEvent in class java.awt.Component

processComponentEvent

protected void processComponentEvent(java.awt.event.ComponentEvent e)
Overrides:
processComponentEvent in class java.awt.Component