Package ucar.unidata.view.geoloc
Class Navigation
java.lang.Object
ucar.unidata.view.geoloc.Navigation
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add aNewMapAreaListener
.calcTransform
(boolean rotate, double displayX, double displayY, double displayWidth, double displayHeight) Calculate an affine transform based on the display size parameters - used for printing.void
flipMapArea
(ucar.unidata.geoloc.ProjectionRect ma) Flip the map areaucar.unidata.geoloc.ProjectionRect
getMapArea
(ucar.unidata.geoloc.ProjectionRect rect) Get current MapArea .double
Get the screen heightdouble
Get the screen widthGet the affine transform based on screen size and world bounding boxvoid
moveDown()
Move downvoid
moveDown
(double factor) Move downvoid
moveLeft()
Move left.void
moveLeft
(double factor) Move left.void
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
Remove aNewMapAreaListener
.ucar.unidata.geoloc.ProjectionPointImpl
Convert a display point to a world coordinateucar.unidata.geoloc.ProjectionPointImpl
screenToWorld
(Point2D p, ucar.unidata.geoloc.ProjectionPointImpl w) Convert a display point to a world coordinateucar.unidata.geoloc.ProjectionRect
screenToWorld
(Rectangle2D rect2D) Convert a display region to a world coordinatescreenToWorld
(ucar.unidata.geoloc.ProjectionRect screenRect) Convert a display region to a world coordinatevoid
setMapArea
(ucar.unidata.geoloc.ProjectionRect ma) Set the map areavoid
setScreenSize
(double pwidth, double pheight) Set the screen sizeboolean
wantRotate
(double displayWidth, double displayHeight) Calculate if we want to rotate based on aspect ratioworldToScreen
(ucar.unidata.geoloc.ProjectionPointImpl w) Convert a world coordinate to a display pointworldToScreen
(ucar.unidata.geoloc.ProjectionPointImpl w, Point2D p) Convert a world coordinate to a display pointworldToScreen
(ucar.unidata.geoloc.ProjectionRect screenRect) Convert a world coordinate to screenvoid
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
Zoom to the previous zoom.
-
Constructor Details
-
Navigation
public Navigation()Create a new navigation.
-
-
Method Details
-
addNewMapAreaListener
Add aNewMapAreaListener
.- Parameters:
l
- listener to add
-
removeNewMapAreaListener
Remove aNewMapAreaListener
.- 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
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 displaydisplayHeight
- 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 rotateddisplayX
- upper right corner XdisplayY
- upper right corner YdisplayWidth
- display widthdisplayHeight
- 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
Convert a world coordinate to a display point- Parameters:
w
- world coordinate- Returns:
- display point
-
worldToScreen
Convert a world coordinate to a display point- Parameters:
w
- world coordinatep
- 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 pointw
- projection- Returns:
- world point
-
screenToWorld
Convert a display point to a world coordinate- Parameters:
p
- display point- Returns:
- corresponding point in world coordinates
-
screenToWorld
Convert a display region to a world coordinate- Parameters:
rect2D
- display region- Returns:
- corresponding world coordinates
-
screenToWorld
Convert a display region to a world coordinate- Parameters:
screenRect
- display region- Returns:
- corresponding world coordinates
-
worldToScreen
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 shiftdeltay
- 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 coordstarty
- upper left y box coordwidth
- width of boxheight
- size of box
-
zoomIn
public void zoomIn(double x, double y) Zoom in to a point. Ignores x, y; callszoomIn()
- Parameters:
x
- x coordinate of pointy
- y coordinate of point
-
zoomOut
public void zoomOut(double x, double y) Zoom out from a point. Ignores x, y; callszoomIn()
- Parameters:
x
- x coordinate of pointy
- 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.
-