Package megamek.client.ui.widget.picmap
Class PicMap
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
megamek.client.ui.widget.picmap.PicMap
- All Implemented Interfaces:
ImageObserver,MenuContainer,Serializable
- Direct Known Subclasses:
ArmorPanel,MekPanelTabStrip,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.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested 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_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBgDrawer(BackGroundDrawer drawer) Adds background drawer to the stage.voidaddElement(PMElement element) Adds element to PicMap component.voidPlease remember to add super.addNotify() when overridinggetAreaUnder(int x, int y) Returns Hot Area under coordinates (x, y)Returns Rectangle bounding content of componentprotected DimensionReturns the size available to the content, in the unscaled coordinates the content is laid out in.doubleabstract voidonResize()onResize() function is calling every time PicMap is resized.voidpaintComponent(Graphics graphics) protected voidprotected voidprocessMouseEvent(MouseEvent event) protected voidvoidRemoves all elements from PicMap component.voidremoveElement(PMElement element) Removes element from PicMap component.voidsetBackgroundOpaque(boolean opaque) Deprecated, for removal: This API element is subject to removal in a future version.voidsetContentMargins(int left, int top, int right, int bottom) Sets margins in pixels around Content of component.voidsetDisplayScale(double scale) Sets how much the drawn content is enlarged by.voidupdate()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, updateUIMethods 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, validateTreeMethods 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 left, int top, int right, int bottom) Sets margins in pixels around Content of component. Does not affect Background Drawers.- Parameters:
left- Left margintop- Top marginright- Right marginbottom- Bottom margin
-
getContentBounds
Returns Rectangle bounding content of component -
addNotify
public void addNotify()Please remember to add super.addNotify() when overriding- Overrides:
addNotifyin classJComponent
-
update
public void update()Updates all changes in areas state and repaints component. -
paintComponent
- Overrides:
paintComponentin classJComponent
-
setDisplayScale
public void setDisplayScale(double scale) Sets how much the drawn content is enlarged by. The areas and labels keep their own fixed coordinates; only drawing and mouse lookups are scaled, so a scaled component still reports the right area under the pointer.- Parameters:
scale- the factor to enlarge the content by; 1.0 draws it at its natural size
-
getDisplayScale
public double getDisplayScale()- Returns:
- the factor the drawn content is currently enlarged by; 1.0 is its natural size
-
getPreferredSize
- Overrides:
getPreferredSizein classJComponent
-
getMinimumSize
- Overrides:
getMinimumSizein classJComponent
-
getContentSize
Returns the size available to the content, in the unscaled coordinates the content is laid out in. -
getAreaUnder
Returns Hot Area under coordinates (x, y) -
setBackgroundOpaque
Deprecated, for removal: This API element is subject to removal in a future version.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:
processMouseEventin classJComponent
-
processMouseMotionEvent
- Overrides:
processMouseMotionEventin classJComponent
-
processComponentEvent
- Overrides:
processComponentEventin classComponent
-