Class NavigatedPanel

  • All Implemented Interfaces:
    ImageObserver, MenuContainer, Serializable, Accessible

    public class NavigatedPanel
    extends JPanel
    Implements a "navigated" JPanel within which a user can zoom and pan. The mapping of the screen area to world coordinates is called "navigation", and it's NavigatedPanel's job to keep track of the navigation as the user zooms and pans. It throws NewMapAreaEvent to indicate that the user has changed the Map area, and the display needs to be redrawn. It throws PickEvents when the user double clicks on the panel.

    NavigatedPanel has a standard JToolbar that can be displayed. It also implements a "reference" point and fast updating of the status of the mouse position relative to the reference point.

    A user typically adds a NavigatedPanel and its toolbar to its frame/applet, and registers itself for NewMapAreaEvent's. See NPController class for an example. When an event occurs, the user obtains a Graphics2D (through the getBufferedImageGraphics() method) to draw into. The AffineTransform of the Graphics2D has been set correctly to map projection coords to screen coords, based on the current zoomed and panned Map area. The renderer can use the AffineTransform if needed, but more typically just works in projection coordinates. The renderer can also get a clipping rectangle by calling g.getClip() and casting the Shape to a Rectangle2D, eg:
     Rectangle2D clipRect = (Rectangle2D) g.getClip();
     
    Our "world coordinates" are the same as java2D's "user coordinates". In general, the world coordinate plane is a projective geometry surface, typically in units of "km on the projection surface". The transformation from lat/lon to the projection plane is handled by a ProjectionImpl object. If a user selects a different projection, NavigatedPanel.setProjection() should be called. The default projection is "Cylindrical Equidistant" or "LatLon" which simply maps lat/lon degrees linearly to screen coordinates. A peculiarity of this projection is that the "seam" of the cylinder shifts as the user pans around. Currently our implementation sends a NewMapAreaEvent whenever this happens.


    See Also:
    Serialized Form
    • Constructor Detail

      • NavigatedPanel

        public NavigatedPanel()
        The constructor.
    • Method Detail

      • getGeoSelectionLL

        public LatLonRect getGeoSelectionLL()
      • setGeoSelection

        public void setGeoSelection​(ProjectionRect bb)
      • setGeoSelection

        public void setGeoSelection​(LatLonRect llbb)
      • setGeoSelectionMode

        public void setGeoSelectionMode​(boolean b)
      • addNewMapAreaListener

        public void addNewMapAreaListener​(NewMapAreaListener l)
        Register a NewMapAreaListener.
      • removeNewMapAreaListener

        public void removeNewMapAreaListener​(NewMapAreaListener l)
        Remove a NewMapAreaListener.
      • addNewProjectionListener

        public void addNewProjectionListener​(NewProjectionListener l)
        Register a NewProjectionListener. The only time this is called is when the projection isLatLon, and a zoom or pan crosses the seam.
      • removeNewProjectionListener

        public void removeNewProjectionListener​(NewProjectionListener l)
        Remove a NewProjectionListener.
      • addCursorMoveEventListener

        public void addCursorMoveEventListener​(CursorMoveEventListener l)
        Register a CursorMoveEventListener.
      • removeCursorMoveEventListener

        public void removeCursorMoveEventListener​(CursorMoveEventListener l)
        Remove a CursorMoveEventListener.
      • addPickEventListener

        public void addPickEventListener​(PickEventListener l)
        Register a PickEventListener.
      • removePickEventListener

        public void removePickEventListener​(PickEventListener l)
        Remove a PickEventListener.
      • addGeoSelectionListener

        public void addGeoSelectionListener​(GeoSelectionListener l)
        Register a PickEventListener.
      • removeGeoSelectionListener

        public void removeGeoSelectionListener​(GeoSelectionListener l)
        Remove a PickEventListener.
      • getNavigation

        public Navigation getNavigation()
      • getBackgroundColor

        public Color getBackgroundColor()
      • setMapArea

        public void setMapArea​(ProjectionRect ma)
        Set the Map Area.
      • setMapArea

        public void setMapArea​(LatLonRect llbb)
        Set the Map Area by converting LatLonRect to a ProjectionRect.
      • getMapArea

        public ProjectionRect getMapArea()
        Get the current Map Area
      • getMapAreaLL

        public LatLonRect getMapAreaLL()
        Get the current Map Area as a lat/lon bounding box
      • setWorldCenterX

        public void setWorldCenterX​(double wx_center)
        kludgy thing to shift LatLon seam
      • setLatLonCenterMapArea

        public void setLatLonCenterMapArea​(double lat,
                                           double lon)
        set the center point of the MapArea
      • getProjectionImpl

        public ProjectionImpl getProjectionImpl()
        Get the current Projection.
      • setProjectionImpl

        public void setProjectionImpl​(ProjectionImpl p)
        Set the Projection, change the Map Area to the projection's default.
      • setPositionLabel

        public void setPositionLabel​(JLabel statusLabel)
        The status label is where the lat/lon position of the mouse is displayed. May be null.
        Parameters:
        statusLabel - the Jlabel to write into
      • getNavToolBar

        public JToolBar getNavToolBar()
        Returns:
        the "Navigate" toolbar
      • getMoveToolBar

        public JToolBar getMoveToolBar()
        Returns:
        the "Move" toolbar
      • addActionsToMenu

        public void addActionsToMenu​(JMenu menu)
        Add all of the toolbar's actions to a menu.
        Parameters:
        menu - the menu to add the actions to
      • setEnabledActions

        public void setEnabledActions​(boolean b)
      • setChangeable

        public void setChangeable​(boolean mode)
        sets whether the user can zoom/pan on this NavigatedPanel. Default = true.
        Parameters:
        mode - set to false if user can't zoom/pan
      • repaint

        public void repaint​(long tm,
                            int x,
                            int y,
                            int width,
                            int height)
        catch repaints - for debugging
        Overrides:
        repaint in class JComponent
      • getBufferedImage

        public BufferedImage getBufferedImage()
        This is used to do some fancy tricks with double buffering
      • getBufferedImageGraphics

        public Graphics2D getBufferedImageGraphics()
        User must get this Graphics2D and draw into it when panel needs redrawing
      • wantRotate

        public boolean wantRotate​(double pwidth,
                                  double pheight)
        utility routine for printing.
        Parameters:
        pwidth - : widtht of the page, units are arbitrary
        pheight - : height of the page, units are arbitrary
        Returns:
        true if we want to rotate the page
      • calcTransform

        public AffineTransform calcTransform​(boolean rotate,
                                             double displayX,
                                             double displayY,
                                             double displayWidth,
                                             double displayHeight)
        This calculates the Affine Transform that maps the current map area (in Projection Coordinates) to a display area (in arbitrary units).
        Parameters:
        rotate - should the page be rotated?
        displayX - upper right corner of display area
        displayY - upper right corner of display area
        displayWidth - display area
        displayHeight - display area see Navigation.calcTransform
      • drawG

        public void drawG()