Class PicMap

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable
Direct Known Subclasses:
ArmorPanel, MekPanelTabStrip, SummaryPanel, WeaponPanel

public abstract class PicMap extends JComponent
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.

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.
Within single layer elements are drawing in the order they added to PicMap.
See Also:
  • 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

      public void addElement(PMElement element)
      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 element)
      Removes element from PicMap component.
    • removeAll

      public void removeAll()
      Removes all elements from PicMap component.
      Overrides:
      removeAll in class Container
    • addBgDrawer

      public void addBgDrawer(BackGroundDrawer drawer)
      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 margin
      top - Top margin
      right - Right margin
      bottom - Bottom margin
    • getContentBounds

      public Rectangle getContentBounds()
      Returns Rectangle bounding content of component
    • addNotify

      public void addNotify()
      Please remember to add super.addNotify() when overriding
      Overrides:
      addNotify in class JComponent
    • update

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

      public void paintComponent(Graphics graphics)
      Overrides:
      paintComponent in class JComponent
    • 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

      public Dimension getPreferredSize()
      Overrides:
      getPreferredSize in class JComponent
    • getMinimumSize

      public Dimension getMinimumSize()
      Overrides:
      getMinimumSize in class JComponent
    • getContentSize

      protected Dimension getContentSize()
      Returns the size available to the content, in the unscaled coordinates the content is laid out in.
    • getAreaUnder

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

      @Deprecated(since="0.51.0", forRemoval=true) public void setBackgroundOpaque(boolean opaque)
      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

      protected void processMouseEvent(MouseEvent event)
      Overrides:
      processMouseEvent in class JComponent
    • processMouseMotionEvent

      protected void processMouseMotionEvent(MouseEvent event)
      Overrides:
      processMouseMotionEvent in class JComponent
    • processComponentEvent

      protected void processComponentEvent(ComponentEvent event)
      Overrides:
      processComponentEvent in class Component