Class Navigation

java.lang.Object
ucar.unidata.view.geoloc.Navigation

public class Navigation extends Object
Consider this a private inner class of NavigatedPanel. Handle display to world coordinate transformation, always linear. throw NewMapAreaEvent when MapArea changes allow setMapArea() to be called; this will also trigger a NewMapAreaEvent
Version:
$Id: Navigation.java,v 1.29 2006/04/04 21:41:19 jeffmc Exp $
Author:
John Caron
  • Constructor Details

    • Navigation

      public Navigation()
      Create a new navigation.
  • Method Details

    • addNewMapAreaListener

      public void addNewMapAreaListener(NewMapAreaListener l)
      Parameters:
      l - listener to add
    • removeNewMapAreaListener

      public void removeNewMapAreaListener(NewMapAreaListener l)
      Parameters:
      l - listener to remove
    • getScreenWidth

      public double getScreenWidth()
      Get the screen width
      Returns:
      screen width (pixels)
    • getScreenHeight

      public double getScreenHeight()
      Get the screen height
      Returns:
      screen height (pixels)
    • setScreenSize

      public void setScreenSize(double pwidth, double pheight)
      Set the screen size
      Parameters:
      pwidth - width (pixels)
      pheight - height (pixels)
    • getTransform

      public AffineTransform getTransform()
      Get the affine transform based on screen size and world bounding box
      Returns:
      the transform
    • wantRotate

      public boolean wantRotate(double displayWidth, double displayHeight)
      Calculate if we want to rotate based on aspect ratio
      Parameters:
      displayWidth - width of display
      displayHeight - height of display
      Returns:
      true if aspects are different
    • calcTransform

      public AffineTransform calcTransform(boolean rotate, double displayX, double displayY, double displayWidth, double displayHeight)
      Calculate an affine transform based on the display size parameters - used for printing.
      Parameters:
      rotate - should the page be rotated
      displayX - upper right corner X
      displayY - upper right corner Y
      displayWidth - display width
      displayHeight - display height
      Returns:
      transform
    • getMapArea

      public ucar.unidata.geoloc.ProjectionRect getMapArea(ucar.unidata.geoloc.ProjectionRect rect)
      Get current MapArea .
      Parameters:
      rect - place results here, or null to create new Object
      Returns:
      rect
    • setMapArea

      public void setMapArea(ucar.unidata.geoloc.ProjectionRect ma)
      Set the map area
      Parameters:
      ma - new map area
    • flipMapArea

      public void flipMapArea(ucar.unidata.geoloc.ProjectionRect ma)
      Flip the map area
      Parameters:
      ma - new map area
    • worldToScreen

      public Point2D worldToScreen(ucar.unidata.geoloc.ProjectionPointImpl w)
      Convert a world coordinate to a display point
      Parameters:
      w - world coordinate
      Returns:
      display point
    • worldToScreen

      public Point2D worldToScreen(ucar.unidata.geoloc.ProjectionPointImpl w, Point2D p)
      Convert a world coordinate to a display point
      Parameters:
      w - world coordinate
      p - projection
      Returns:
      display point
    • screenToWorld

      public ucar.unidata.geoloc.ProjectionPointImpl screenToWorld(Point2D p, ucar.unidata.geoloc.ProjectionPointImpl w)
      Convert a display point to a world coordinate
      Parameters:
      p - display point
      w - projection
      Returns:
      world point
    • screenToWorld

      public ucar.unidata.geoloc.ProjectionPointImpl screenToWorld(Point2D p)
      Convert a display point to a world coordinate
      Parameters:
      p - display point
      Returns:
      corresponding point in world coordinates
    • screenToWorld

      public ucar.unidata.geoloc.ProjectionRect screenToWorld(Rectangle2D rect2D)
      Convert a display region to a world coordinate
      Parameters:
      rect2D - display region
      Returns:
      corresponding world coordinates
    • screenToWorld

      public Rectangle2D screenToWorld(ucar.unidata.geoloc.ProjectionRect screenRect)
      Convert a display region to a world coordinate
      Parameters:
      screenRect - display region
      Returns:
      corresponding world coordinates
    • worldToScreen

      public Rectangle2D worldToScreen(ucar.unidata.geoloc.ProjectionRect screenRect)
      Convert a world coordinate to screen
      Parameters:
      screenRect - world region
      Returns:
      corresponding screen coordinates
    • pan

      public void pan(double deltax, double deltay)
      Call this to change the center of the screen's world coordinates.
      Parameters:
      deltax - display coordinate x shift
      deltay - display coordinate y shift
    • zoom

      public void zoom(double startx, double starty, double width, double height)
      Call this to zoom into a subset of the screen. startx, starty are the upper left corner of the box in display coords.
      Parameters:
      startx - upper left x box coord
      starty - upper left y box coord
      width - width of box
      height - size of box
    • zoomIn

      public void zoomIn(double x, double y)
      Zoom in to a point. Ignores x, y; calls zoomIn()
      Parameters:
      x - x coordinate of point
      y - y coordinate of point
    • zoomOut

      public void zoomOut(double x, double y)
      Zoom out from a point. Ignores x, y; calls zoomIn()
      Parameters:
      x - x coordinate of point
      y - y coordinate of point
    • zoomIn

      public void zoomIn()
      Zoom in default amount.
    • zoomOut

      public void zoomOut()
      Zoom out default amount.
    • zoom

      public void zoom(double scale)
      Zoom to a default scale.
      Parameters:
      scale - to zoom
    • moveDown

      public void moveDown()
      Move down
    • moveDown

      public void moveDown(double factor)
      Move down
      Parameters:
      factor - how much to move
    • moveUp

      public void moveUp()
      Move up.
    • moveUp

      public void moveUp(double factor)
      Move up.
      Parameters:
      factor - how much to move
    • moveRight

      public void moveRight()
      Move right.
    • moveRight

      public void moveRight(double factor)
      Move right.
      Parameters:
      factor - how much to move
    • moveLeft

      public void moveLeft()
      Move left.
    • moveLeft

      public void moveLeft(double factor)
      Move left.
      Parameters:
      factor - how much to move
    • zoomPrevious

      public void zoomPrevious()
      Zoom to the previous zoom.