Class MapStatus.Collector

  • All Implemented Interfaces:
    java.lang.Runnable
    Enclosing class:
    MapStatus

    private final class MapStatus.Collector
    extends java.lang.Object
    implements java.lang.Runnable
    The collector class that waits for notification and then update the display objects.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.concurrent.BlockingQueue<MapStatus.MouseState> incomingMouseState  
      private java.awt.Point lastMousePos  
      private java.awt.Point oldMousePos
      the mouse position of the previous iteration.
      private MapFrame parent  
      private javax.swing.Popup popup
      The popup displayed to show additional information
      private java.util.List<javax.swing.JLabel> popupLabels
      Contains the labels that are currently shown in the information popup
    • Constructor Summary

      Constructors 
      Constructor Description
      Collector​(MapFrame parent)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private javax.swing.JLabel popupBuildPrimitiveLabels​(OsmPrimitive osm)
      Builds the labels with all necessary listeners for the info popup for the given OsmPrimitive
      private javax.swing.Popup popupCreatePopup​(java.awt.Component content, MapStatus.MouseState ms)
      Creates a popup for the given content next to the cursor.
      private void popupCycleSelection​(java.util.Collection<OsmPrimitive> osms, int mods)
      Call this with a set of primitives to cycle through them.
      private void popupHidePopup()
      Tries to hide the given popup
      private void popupSetLabelColors​(javax.swing.JLabel lbl, IPrimitive osm)
      Sets the colors for the given label depending on the selected status of the given OsmPrimitive
      private void popupShowPopup​(javax.swing.Popup newPopup, java.util.List<javax.swing.JLabel> lbls)
      Tries to show the given popup, can be hidden using popupHidePopup() If an old popup exists, it will be automatically hidden
      private void popupUpdateLabels()
      This method should be called if the selection may have changed from outside of this class.
      void run()
      Execution function for the Collector.
      private void statusBarElementUpdate​(MapStatus.MouseState ms)
      Calls this to update the element that is shown in the statusbar
      void updateMousePosition​(java.awt.Point mousePos, int modifiers)
      Called whenever the mouse position or modifiers changed.
      • Methods inherited from class java.lang.Object

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

      • oldMousePos

        private java.awt.Point oldMousePos
        the mouse position of the previous iteration. This is used to show the popup until the cursor is moved.
      • popupLabels

        private java.util.List<javax.swing.JLabel> popupLabels
        Contains the labels that are currently shown in the information popup
      • popup

        private javax.swing.Popup popup
        The popup displayed to show additional information
    • Method Detail

      • run

        public void run()
        Execution function for the Collector.
        Specified by:
        run in interface java.lang.Runnable
      • popupCreatePopup

        private javax.swing.Popup popupCreatePopup​(java.awt.Component content,
                                                   MapStatus.MouseState ms)
        Creates a popup for the given content next to the cursor. Tries to keep the popup on screen and shows a vertical scrollbar, if the screen is too small.
        Parameters:
        content - popup content
        ms - mouse state
        Returns:
        popup
      • popupCycleSelection

        private void popupCycleSelection​(java.util.Collection<OsmPrimitive> osms,
                                         int mods)
        Call this with a set of primitives to cycle through them. Method will automatically select the next item and update the map
        Parameters:
        osms - primitives to cycle through
        mods - modifiers (i.e. control keys)
      • popupHidePopup

        private void popupHidePopup()
        Tries to hide the given popup
      • popupShowPopup

        private void popupShowPopup​(javax.swing.Popup newPopup,
                                    java.util.List<javax.swing.JLabel> lbls)
        Tries to show the given popup, can be hidden using popupHidePopup() If an old popup exists, it will be automatically hidden
        Parameters:
        newPopup - popup to show
        lbls - labels to show (see popupLabels)
      • popupUpdateLabels

        private void popupUpdateLabels()
        This method should be called if the selection may have changed from outside of this class. This is the case when CTRL is pressed and the user clicks on the map instead of the popup.
      • popupSetLabelColors

        private void popupSetLabelColors​(javax.swing.JLabel lbl,
                                         IPrimitive osm)
        Sets the colors for the given label depending on the selected status of the given OsmPrimitive
        Parameters:
        lbl - The label to color
        osm - The primitive to derive the colors from
      • popupBuildPrimitiveLabels

        private javax.swing.JLabel popupBuildPrimitiveLabels​(OsmPrimitive osm)
        Builds the labels with all necessary listeners for the info popup for the given OsmPrimitive
        Parameters:
        osm - The primitive to create the label for
        Returns:
        labels for info popup
      • updateMousePosition

        public void updateMousePosition​(java.awt.Point mousePos,
                                        int modifiers)
        Called whenever the mouse position or modifiers changed.
        Parameters:
        mousePos - The new mouse position. null if it did not change.
        modifiers - The new modifiers.