Class Mapper

    • Nested Class Summary

      • Nested classes/interfaces inherited from class javax.swing.JPanel

        javax.swing.JPanel.AccessibleJPanel
      • Nested classes/interfaces inherited from class javax.swing.JComponent

        javax.swing.JComponent.AccessibleJComponent
      • Nested classes/interfaces inherited from class java.awt.Container

        java.awt.Container.AccessibleAWTContainer
      • 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
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addTooltipDefinition​(java.lang.String name, java.lang.String def)
      Adds a new tooltip defintion
      protected java.util.List<Sorted> createSubList​(int condition, CoordinateID upperLeft, CoordinateID lowerRight, java.util.List<Sorted> regionList, int duration, int paintNumber)
      Creates a sublist of regions to render according to the state of the given int.
      void deferPainting​(boolean bool)
      Activates or de-activates deferred painting after loading and scaling images.
      void gameDataChanged​(GameDataEvent e)
      Invoked when the current game data object becomes invalid.
      Region getActiveRegion()
      Get the active region.
      java.util.List<java.lang.String> getAllTooltipDefinitions()
      Returns a list of available tooltip definitions
      AdvancedTextCellRenderer getATR()
      Returns the currend ATR.
      java.util.Collection<MapCellRenderer> getAvailableRenderers()
      Returns a list of available rendereres in this map.
      CellGeometry getCellGeometry()
      Getter for property cellGeometry.
      java.awt.Rectangle getCellRect​(CoordinateID cell)
      Returns the bounds of the specified region on this component.
      CoordinateID getCenter​(java.awt.Rectangle clipBounds)
      Returns the coordinate of the region that is at the center of the currently displayed area.
      java.awt.Point getCenteredViewPosition​(java.awt.Dimension viewSize, CoordinateID center)
      Returns the location (upper left corner) of the drawing area so that a certain region is at the center of the view port.
      java.lang.String getComponentConfiguration()
      Returns the current configuration of this mapper panel.
      protected int getLastRegionRenderingType()  
      int getLevel()
      Returns the level ('Eressea-Ebene') this Mapper actually displays.
      java.util.List<java.lang.Integer> getLevels()
      Returns a list containing all the different levels ('Eressea-Ebenen') this Mapper knows of.
      java.util.List<RenderingPlane> getPlanes()
      Returns a list of object containing the rendering planes existing in this Mapper object.
      PreferencesAdapter getPreferencesAdapter()
      Creates a preferences panel allowing to configure this component.
      java.awt.Dimension getPreferredScrollableViewportSize()  
      protected java.lang.String getPropertyName​(int plane)  
      java.util.Collection<MapCellRenderer> getRenderers​(int plane)
      Get the cell renderer objects that are available for a certain rendering plane.
      float getScaleFactor()
      Returns the current scale or zoom factor.
      int getScrollableBlockIncrement​(java.awt.Rectangle visibleRect, int orientation, int direction)  
      boolean getScrollableTracksViewportHeight()  
      boolean getScrollableTracksViewportWidth()  
      int getScrollableUnitIncrement​(java.awt.Rectangle visibleRect, int orientation, int direction)  
      java.util.Map<CoordinateID,​Region> getSelectedRegions()
      Get the selected Regions.
      java.lang.String getTooltipDefinition()
      Returns the tooltip definition
      java.lang.String getToolTipText​(java.awt.event.MouseEvent e)  
      void initComponent​(java.lang.String p1)
      Implemented for interface Initializable to set configuration data to this component.
      protected RenderingPlane[] initRenderingPlanes()  
      boolean isDeferringPainting()
      Returns whether deferred painting after loading and scaling images is used or not.
      boolean isFocusTraversable()  
      boolean isRenderContextChanged()
      Getter for property renderContextChanged.
      boolean isRequestFocusEnabled()  
      boolean isShowingTooltip()
      True if tooltips are enabled
      boolean isUseSeasonImages()
      Returns the value of useSeasonImages.
      protected void paintComponent​(java.awt.Graphics g)  
      protected void paintMapperComponent​(java.awt.Graphics g)
      Paints the map
      void reloadGraphicSet()
      Get the cell geometry from the resources and make all renderers that use images reload the graphics files.
      protected void reprocessTooltipDefinition()  
      void selectionChanged​(SelectionEvent se)
      Invoked when different objects are activated or selected.
      void setAllTooltipDefinitions​(java.util.List<?> l)
      Sets a list of available tooltip definitions
      void setGameData​(GameData data)
      Sets the value of data.
      protected void setLastRegionRenderingType​(int l)  
      void setLevel​(int level)
      Sets the level ('Eressea-Ebene') this Mapper knows of.
      void setPath​(java.util.List<CoordinateID> path, boolean isPersistent)
      Set a path - a list of consecutive regions - to be rendered by the renderer registered to the path rendering plane.
      static void setRenderContextChanged​(boolean r)
      Setter for property renderContextChanged.
      void setRenderer​(MapCellRenderer renderer)
      Add a cell renderer object to the mapper.
      void setRenderer​(MapCellRenderer renderer, int plane)
      Set a cell renderer object for a certain plane of the map.
      void setScaleFactor​(float scaleFactor)
      Sets the scale or zoom factor.
      void setShowTooltip​(boolean b)
      Sets if the tooltip should be available
      void setTooltipDefinition​(java.lang.String tdef)
      Sets the tooltip definition
      void setUseSeasonImages​(boolean use)  
      void unitChanged​(UnitChangeEvent event)
      Called when a unit has changed in some way.
      void unitOrdersChanged​(UnitOrdersEvent e)  
      • Methods inherited from class javax.swing.JPanel

        getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
      • Methods inherited from class javax.swing.JComponent

        addAncestorListener, addNotify, 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, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, 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
      • 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, removeAll, 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, 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, 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, processComponentEvent, 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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • PLANE_STRINGS

        public static final java.lang.String[] PLANE_STRINGS
        a mapping for int positions of planes to logical names. Will be used for magellan_desktop.ini
      • PLANE_BACKGROUND

        public static final int PLANE_BACKGROUND
        Plane for general background renderer, like background image renderer
        See Also:
        Constant Field Values
      • PLANE_BEHIND

        public static final int PLANE_BEHIND
        Plane for something to be rendered behind the regions, makes only sense when regions have transparent parts, used for schemes of the real world shining through the dust of the astral space
        See Also:
        Constant Field Values
      • PLANE_REGION

        public static final int PLANE_REGION
        Plane for the region map
        See Also:
        Constant Field Values
      • PLANE_BUILDING

        public static final int PLANE_BUILDING
        Plane for buildings
        See Also:
        Constant Field Values
      • PLANE_PATH

        public static final int PLANE_PATH
        Plane for path informations
        See Also:
        Constant Field Values
      • PLANE_HIGHLIGHT

        public static final int PLANE_HIGHLIGHT
        Plane for highlights
        See Also:
        Constant Field Values
      • PLANE_MARKINGS

        public static final int PLANE_MARKINGS
        Plane for markers
        See Also:
        Constant Field Values
      • DEFAULT_TOOLTIP_DEFINITION

        @Deprecated
        public static final java.lang.String DEFAULT_TOOLTIP_DEFINITION
        Deprecated.
        Default tooltip
        See Also:
        Constant Field Values
      • DEFAULT_TOOLTIP

        public static final java.lang.String DEFAULT_TOOLTIP
        Default tooltip
        See Also:
        Constant Field Values
      • showTooltip

        protected boolean showTooltip
      • silverItemType

        protected ItemType silverItemType
      • tooltipDefinitionString

        protected java.lang.String tooltipDefinitionString
      • objectList

        protected java.util.List<Sorted> objectList
      • lastRegionRenderingType

        protected int lastRegionRenderingType
      • inPaint

        protected int inPaint
    • Method Detail

      • reprocessTooltipDefinition

        protected void reprocessTooltipDefinition()
      • getToolTipText

        public java.lang.String getToolTipText​(java.awt.event.MouseEvent e)
        Overrides:
        getToolTipText in class javax.swing.JComponent
        See Also:
        JComponent.getToolTipText(java.awt.event.MouseEvent)
      • setRenderer

        public void setRenderer​(MapCellRenderer renderer)
        Add a cell renderer object to the mapper. Each cell renderer has a rendering plane associated with it, so if there is already a renderer in the rendering plane of the added renderer the old renderer is removed.
        Parameters:
        renderer - the object responsible for rendering a graphical representation of regions.
      • setRenderer

        public void setRenderer​(MapCellRenderer renderer,
                                int plane)
        Set a cell renderer object for a certain plane of the map. This function can be used to override the renderes default rendering plane.
        Parameters:
        renderer - the object responsible for rendering a graphical representation of regions.
        plane - the plane the renderer will draw to. Lower planes are painted over by higher planes. See the constants in com.eressea.swing.map.Mapper for possible values or choose a value between 0 and getRenderPlainCount() - 1.
      • getPropertyName

        protected java.lang.String getPropertyName​(int plane)
      • getRenderers

        public java.util.Collection<MapCellRenderer> getRenderers​(int plane)
        Get the cell renderer objects that are available for a certain rendering plane. It is suggested that these objects are used for calling one of the setRenderer() methods.
        Parameters:
        plane - the plane the renderer will draw to. Lower planes are painted over by higher planes. See the constants in com.eressea.swing.map.Mapper for possible values.
        Returns:
        the renderer object associated with the specified rendering plane or null if no such association exists.
      • getPlanes

        public java.util.List<RenderingPlane> getPlanes()
        Returns a list of object containing the rendering planes existing in this Mapper object. The planes are sorted with ascending plane indices.
      • setPath

        public void setPath​(java.util.List<CoordinateID> path,
                            boolean isPersistent)
        Set a path - a list of consecutive regions - to be rendered by the renderer registered to the path rendering plane.
        Parameters:
        path - a list of Region objects to be rendered as a path on the map.
        isPersistent - if true, always render the path, else render the path only until a different region is selected.
      • isFocusTraversable

        public boolean isFocusTraversable()
        Overrides:
        isFocusTraversable in class java.awt.Component
        See Also:
        Component.isFocusTraversable()
      • isRequestFocusEnabled

        public boolean isRequestFocusEnabled()
        Overrides:
        isRequestFocusEnabled in class javax.swing.JComponent
        See Also:
        JComponent.isRequestFocusEnabled()
      • getPreferredScrollableViewportSize

        public java.awt.Dimension getPreferredScrollableViewportSize()
        Specified by:
        getPreferredScrollableViewportSize in interface javax.swing.Scrollable
        See Also:
        Scrollable.getPreferredScrollableViewportSize()
      • getScrollableBlockIncrement

        public int getScrollableBlockIncrement​(java.awt.Rectangle visibleRect,
                                               int orientation,
                                               int direction)
        Specified by:
        getScrollableBlockIncrement in interface javax.swing.Scrollable
        See Also:
        Scrollable.getScrollableBlockIncrement(java.awt.Rectangle, int, int)
      • getScrollableTracksViewportHeight

        public boolean getScrollableTracksViewportHeight()
        Specified by:
        getScrollableTracksViewportHeight in interface javax.swing.Scrollable
        See Also:
        Scrollable.getScrollableTracksViewportHeight()
      • getScrollableTracksViewportWidth

        public boolean getScrollableTracksViewportWidth()
        Specified by:
        getScrollableTracksViewportWidth in interface javax.swing.Scrollable
        See Also:
        Scrollable.getScrollableTracksViewportWidth()
      • getAvailableRenderers

        public java.util.Collection<MapCellRenderer> getAvailableRenderers()
        Returns a list of available rendereres in this map.
      • getScrollableUnitIncrement

        public int getScrollableUnitIncrement​(java.awt.Rectangle visibleRect,
                                              int orientation,
                                              int direction)
        Specified by:
        getScrollableUnitIncrement in interface javax.swing.Scrollable
        See Also:
        Scrollable.getScrollableUnitIncrement(java.awt.Rectangle, int, int)
      • createSubList

        protected java.util.List<Sorted> createSubList​(int condition,
                                                       CoordinateID upperLeft,
                                                       CoordinateID lowerRight,
                                                       java.util.List<Sorted> regionList,
                                                       int duration,
                                                       int paintNumber)
        Creates a sublist of regions to render according to the state of the given int. Values are interpreted as those of RenderingPlane.
      • setLastRegionRenderingType

        protected void setLastRegionRenderingType​(int l)
      • getLastRegionRenderingType

        protected int getLastRegionRenderingType()
      • paintComponent

        protected void paintComponent​(java.awt.Graphics g)
        Overrides:
        paintComponent in class javax.swing.JComponent
        See Also:
        JComponent.paintComponent(java.awt.Graphics)
      • paintMapperComponent

        protected void paintMapperComponent​(java.awt.Graphics g)
        Paints the map
      • getScaleFactor

        public float getScaleFactor()
        Returns the current scale or zoom factor. This value is a real factor, i.e. 1.0 means that the components are painted according to the values supplied by the underlying CellGeometry object.
      • setScaleFactor

        public void setScaleFactor​(float scaleFactor)
        Sets the scale or zoom factor. This value is a real factor, i.e. 1.0 means that the components are painted according to the values supplied by the underlying CellGeometry object.
        Parameters:
        scaleFactor - The new factor. Must be > 0.
        Throws:
        java.lang.IllegalArgumentException - if scaleFactor <= 0.
      • getLevels

        public java.util.List<java.lang.Integer> getLevels()
        Returns a list containing all the different levels ('Eressea-Ebenen') this Mapper knows of. The list contains Integer objects stating the level number.
      • setLevel

        public void setLevel​(int level)
        Sets the level ('Eressea-Ebene') this Mapper knows of. The list contains Integer objects stating the level number.
      • getLevel

        public int getLevel()
        Returns the level ('Eressea-Ebene') this Mapper actually displays.
      • getSelectedRegions

        public java.util.Map<CoordinateID,​Region> getSelectedRegions()
        Get the selected Regions. The returned map can be empty but is never null.
      • getActiveRegion

        public Region getActiveRegion()
        Get the active region.
      • getCellRect

        public java.awt.Rectangle getCellRect​(CoordinateID cell)
        Returns the bounds of the specified region on this component.
        Parameters:
        cell - the coordinate of the region to be evaluated.
        Returns:
        the bounds (the upper left corner and the size) of the region cell in component coordinates.
      • getCenter

        public CoordinateID getCenter​(java.awt.Rectangle clipBounds)
        Returns the coordinate of the region that is at the center of the currently displayed area.
        Parameters:
        clipBounds - the bounds indicating which part of the mappers drawing area is actually visible.
      • getCenteredViewPosition

        public java.awt.Point getCenteredViewPosition​(java.awt.Dimension viewSize,
                                                      CoordinateID center)
        Returns the location (upper left corner) of the drawing area so that a certain region is at the center of the view port.
        Parameters:
        viewSize - the size of the mappers viewport, i.e. the size of the part of the mappers drawing area that is actually visible.
        center - the coordinate to center on.
        Returns:
        a Point with x and y so that a view port of size viewSize is centered over the specified region center.
      • reloadGraphicSet

        public void reloadGraphicSet()
        Get the cell geometry from the resources and make all renderers that use images reload the graphics files.
      • getPreferencesAdapter

        public PreferencesAdapter getPreferencesAdapter()
        Creates a preferences panel allowing to configure this component.
      • isDeferringPainting

        public boolean isDeferringPainting()
        Returns whether deferred painting after loading and scaling images is used or not. Together with the ImageCellRenderer class this option tells the mapper/renderer whether to scale images synchronously and introduce delays on painting or to scale images asynchronously and trigger a redraw after a short amount of time.
      • deferPainting

        public void deferPainting​(boolean bool)
        Activates or de-activates deferred painting after loading and scaling images. Together with the ImageCellRenderer class this option tells the mapper/renderer whether to scale images synchronously and introduce delays on painting or to scale images asynchronously and trigger a redraw after a short amount of time.
      • initRenderingPlanes

        protected RenderingPlane[] initRenderingPlanes()
      • getCellGeometry

        public CellGeometry getCellGeometry()
        Getter for property cellGeometry.
        Returns:
        Value of property cellGeometry.
      • isRenderContextChanged

        public boolean isRenderContextChanged()
        Getter for property renderContextChanged.
        Returns:
        Value of property renderContextChanged.
      • setRenderContextChanged

        public static void setRenderContextChanged​(boolean r)
        Setter for property renderContextChanged.
        Parameters:
        r - New value of property renderContextChanged.
      • setShowTooltip

        public void setShowTooltip​(boolean b)
        Sets if the tooltip should be available
      • isShowingTooltip

        public boolean isShowingTooltip()
        True if tooltips are enabled
      • getTooltipDefinition

        public java.lang.String getTooltipDefinition()
        Returns the tooltip definition
      • setTooltipDefinition

        public void setTooltipDefinition​(java.lang.String tdef)
        Sets the tooltip definition
      • getAllTooltipDefinitions

        public java.util.List<java.lang.String> getAllTooltipDefinitions()
        Returns a list of available tooltip definitions
      • setAllTooltipDefinitions

        public void setAllTooltipDefinitions​(java.util.List<?> l)
        Sets a list of available tooltip definitions
      • addTooltipDefinition

        public void addTooltipDefinition​(java.lang.String name,
                                         java.lang.String def)
        Adds a new tooltip defintion
      • getComponentConfiguration

        public java.lang.String getComponentConfiguration()
        Returns the current configuration of this mapper panel. The current implementation divides all the information by "_". First the scale factor is stored, then planes(plane index, renderer class name, renderer configuration).
        Specified by:
        getComponentConfiguration in interface Initializable
      • initComponent

        public void initComponent​(java.lang.String p1)
        Implemented for interface Initializable to set configuration data to this component.
        Specified by:
        initComponent in interface Initializable
        Parameters:
        p1 - the configuration string from magellan_desktop.ini
      • setUseSeasonImages

        public void setUseSeasonImages​(boolean use)
        Parameters:
        use -
      • isUseSeasonImages

        public boolean isUseSeasonImages()
        Returns the value of useSeasonImages.
        Returns:
        Returns useSeasonImages.