ucar.unidata.view.geoloc
Class Navigation

java.lang.Object
  extended by 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 Summary
Navigation()
          Create a new navigation.
 
Method Summary
 void addNewMapAreaListener(NewMapAreaListener l)
          Add a NewMapAreaListener.
 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.
 ucar.unidata.geoloc.ProjectionRect getMapArea(ucar.unidata.geoloc.ProjectionRect rect)
          Get current MapArea .
 double getScreenHeight()
          Get the screen height
 double getScreenWidth()
          Get the screen width
 AffineTransform getTransform()
          Get the affine transform based on screen size and world bounding box
 void moveDown()
          Move down
 void moveDown(double factor)
          Move down
 void moveLeft()
          Move left.
 void moveLeft(double factor)
          Move left.
 void moveRight()
          Move right.
 void moveRight(double factor)
          Move right.
 void moveUp()
          Move up.
 void moveUp(double factor)
          Move up.
 void pan(double deltax, double deltay)
          Call this to change the center of the screen's world coordinates.
 void removeNewMapAreaListener(NewMapAreaListener l)
          Remove a NewMapAreaListener.
 ucar.unidata.geoloc.ProjectionPointImpl screenToWorld(Point2D p)
          Convert a display point to a world coordinate
 ucar.unidata.geoloc.ProjectionPointImpl screenToWorld(Point2D p, ucar.unidata.geoloc.ProjectionPointImpl w)
          Convert a display point to a world coordinate
 Rectangle2D screenToWorld(Rectangle2D screenRect)
          Convert a display region to a world coordinate
 void setMapArea(Rectangle2D ma)
          Set the map area
 void setScreenSize(double pwidth, double pheight)
          Set the screen size
 boolean wantRotate(double displayWidth, double displayHeight)
          Calculate if we want to rotate based on aspect ratio
 Point2D worldToScreen(ucar.unidata.geoloc.ProjectionPointImpl w)
          Convert a world coordinate to a display point
 Point2D worldToScreen(ucar.unidata.geoloc.ProjectionPointImpl w, Point2D p)
          Convert a world coordinate to a display point
 Rectangle2D worldToScreen(Rectangle2D screenRect)
          Convert a world coordinate to screen
 void zoom(double scale)
          Zoom to a default scale.
 void zoom(double startx, double starty, double width, double height)
          Call this to zoom into a subset of the screen.
 void zoomIn()
          Zoom in default amount.
 void zoomIn(double x, double y)
          Zoom in to a point.
 void zoomOut()
          Zoom out default amount.
 void zoomOut(double x, double y)
          Zoom out from a point.
 void zoomPrevious()
          Zoom to the previous zoom.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Navigation

public Navigation()
Create a new navigation.

Method Detail

addNewMapAreaListener

public void addNewMapAreaListener(NewMapAreaListener l)
Add a NewMapAreaListener.

Parameters:
l - listener to add

removeNewMapAreaListener

public void removeNewMapAreaListener(NewMapAreaListener l)
Remove a NewMapAreaListener.

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(Rectangle2D ma)
Set 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 Rectangle2D screenToWorld(Rectangle2D screenRect)
Convert a display region to a world coordinate

Parameters:
screenRect - display region
Returns:
corresponding world coordinates

worldToScreen

public Rectangle2D worldToScreen(Rectangle2D 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.