Package megamek.client.ui.swing.widget
Class PicMap
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
megamek.client.ui.swing.widget.PicMap
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
- Direct Known Subclasses:
MekPanelTabStrip
,MekSlotLabel
,SummaryPanel
,WeaponPanel
PicMap is a lightweight component, which area is composed by the set of custom
elements added to PicMap Engine. There are three main groups of custom
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.
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.
- Bottom layer is BackgroundDrawers.
- Next is layer of all elements that not implements PMHotArea or PMLAbel interfaces.
- On top of that is layer of Hot Areas - elements with extended functionality.
- Topmost layer is layer of labels.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
Fields inherited from class javax.swing.JComponent
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
accessibleContext, 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds background drawer to the stage.void
Adds element to PicMap component.void
Please remember to add super.addNotify() when overridinggetAreaUnder
(int x, int y) Returns Hot Area under coordinates (x, y)Returns Rectangle bounding content of componentabstract void
onResize()
onResize() function is calling every time PicMap is resized.void
protected void
protected void
protected void
void
Removes all elements from PicMap component.void
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.Methods inherited from class javax.swing.JComponent
addAncestorListener, 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, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUI, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, 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
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, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, 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, getAccessibleContext, 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Constructor Details
-
PicMap
public PicMap()creates PicMap engine. If no areas, labels or Background-drawers added this is just transparent layer over container.
-
-
Method Details
-
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
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
Removes element from PicMap component. -
removeAll
public void removeAll()Removes all elements from PicMap component. -
addBgDrawer
Adds background drawer to the stage. Background drawers are drawn in order they added to the component. -
setContentMargins
public void setContentMargins(int l, int t, int r, int b) Sets margins in pixels around Content of component. Does not affect Background Drawers.- Parameters:
l
- Left margint
- Top marginr
- Right marginb
- Bottom margin
-
getContentBounds
Returns Rectangle bounding content of component -
addNotify
public void addNotify()Please remember to add super.addNotify() when overriding- Overrides:
addNotify
in classJComponent
-
update
public void update()Updates all changes in areas state and repaints component. -
paintComponent
- Overrides:
paintComponent
in classJComponent
-
getPreferredSize
- Overrides:
getPreferredSize
in classJComponent
-
getMinimumSize
- Overrides:
getMinimumSize
in classJComponent
-
getAreaUnder
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 Java 1.3 and up offscreen will be transparent by default. -
processMouseEvent
- Overrides:
processMouseEvent
in classJComponent
-
processMouseMotionEvent
- Overrides:
processMouseMotionEvent
in classJComponent
-
processComponentEvent
- Overrides:
processComponentEvent
in classComponent
-