Package hec.map
Class MapScale
java.lang.Object
hec.map.MapScale
- Direct Known Subclasses:
TransformMapScale
Manages map scaling parameters and performs coordinate transforms.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected doubleratio of y to x direction scalingprotected booleanFlag for whether Extents are currently defaults.protected WorldPtcenter of view port in world coordinatesprotected WorldRectworld coordinate bounding rectangle of the entire mapped regionprotected LocalRectsize of the viewport in local (device) coordinatesprotected WorldRectworld coordinates of the corners of the viewportprotected doubleworld to local scale factor in x directionprotected doubleworld to local scale factor in y directionprotected double1/fraction of mapped region visible in viewport -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanComputes scaling parameters based on region, zoom, origin, and view rect.booleandetermines if the given point in local coordinates is in the current viewing areabooleandetermines if the given point in world coordinates is in the current viewing areainte2x(double e) Deprecated.call wp2lp.doublereturns the average world to local scaling factorGet a copy of the current originGet a copy of the current region extentsGet a copy of the current view rectangle in local coodinatesGet a copy of the current view rectangle in world coordinatesdoubledoubledoublegetZoom()Get the current zoom factorvoidgrow the map reqion extents to rcbooleanReturns the value of the default region extents flag.local2WorldTransform(AffineTransform transform) Creates or updates an existing AffineTransform to change from local to world coordinates.final WorldPtConverts a point in local coordinates to world coordinates, returning a newly allocated Point.voidConverts a point in local coordinates to world coordinates.Converts a LocalRect to a WorldRect, returning a newly allocated WorldRectintn2y(double n) Deprecated.call wp2lp.voidsetDefaultRegionExtents(boolean onOff) Sets the DefaultRegionExtents attribute of the MapScale objectvoidSet the origin of the map view positionvoidSet the origin of the map view positionvoidSet the map region extentsvoidsetViewRect(LocalRect rc) Set the viewport rectanglevoidset the viewport rectangle to dvoidsetZoom(double z) Set the zoom factorvoidshowAll()zoom out to the world coordinatesworld2LocalTransform(AffineTransform transform) Coordinate conversion routines Creates or updates an existing AffineTransform to change from world to local coordinates.final LocalPtConverts a point in world coordinates to local coordinates, returning a newly allocated Point.voidConverts a point in world coordinates to local coordinates.Converts a WorldRect to a LocalRect, returning a newly allocated LocalRectConverts a WorldRect to a LocalRect, returning a newly allocated LocalRectdoublex2e(int x) Deprecated.call wp2lp.doubley2n(int y) Deprecated.call wp2lp.voidzoomByFactor(double factor) Change the zoom scaling by the given factor.booleanZoom in to the given rectangle in local coordinates.boolean
-
Field Details
-
_regionExtents
world coordinate bounding rectangle of the entire mapped region -
_origin
center of view port in world coordinates -
_zoom
protected double _zoom1/fraction of mapped region visible in viewport -
_viewRect
size of the viewport in local (device) coordinates -
_aniso
protected double _anisoratio of y to x direction scaling -
_worldRect
world coordinates of the corners of the viewport -
_xscale
protected double _xscaleworld to local scale factor in x direction -
_yscale
protected double _yscaleworld to local scale factor in y direction -
_defaultRegionExtents
protected boolean _defaultRegionExtentsFlag for whether Extents are currently defaults.
-
-
Constructor Details
-
MapScale
public MapScale()Create a new MapScale object -
MapScale
Create a new MapScale object- Parameters:
scl- MapScale to initialize from
-
-
Method Details
-
getXScale
public double getXScale() -
getYScale
public double getYScale() -
getAvgW2LScale
public double getAvgW2LScale()returns the average world to local scaling factor- Returns:
- The average scaling factor
-
contains
determines if the given point in world coordinates is in the current viewing area- Parameters:
wpt- a point in world coordinates- Returns:
- true if the current viewing area contains wpt
-
contains
determines if the given point in local coordinates is in the current viewing area- Parameters:
pt- a point in local coordinates- Returns:
- true if the current viewing area contains pt
-
showAll
public void showAll()zoom out to the world coordinates -
setRegionExtents
Set the map region extents- Parameters:
rc- The new RegionExtents value
-
growRegionExtents
grow the map reqion extents to rc- Parameters:
rc- extents to grow the map region to
-
setDefaultRegionExtents
public void setDefaultRegionExtents(boolean onOff) Sets the DefaultRegionExtents attribute of the MapScale object- Parameters:
onOff- The new DefaultRegionExtents value
-
isDefaultRegionExtents
public boolean isDefaultRegionExtents()Returns the value of the default region extents flag.- Returns:
-
getRegionExtents
Get a copy of the current region extents- Returns:
- The current Region Extents
-
setOrigin
Set the origin of the map view position- Parameters:
p- The new Origin value
-
setOrigin
Set the origin of the map view position- Parameters:
p- The new Origin valuecomputeScaling- true to recompute scaling
-
getOrigin
Get a copy of the current origin- Returns:
- The current Origin
-
setZoom
public void setZoom(double z) Set the zoom factor- Parameters:
z- The new Zoom factor
-
getZoom
public double getZoom()Get the current zoom factor- Returns:
- The current Zoom factor
-
setViewRect
Set the viewport rectangle- Parameters:
rc- The new Viewport rectangle
-
setViewRect
set the viewport rectangle to d- Parameters:
d- the new viewport rectangle
-
getViewRect
Get a copy of the current view rectangle in local coodinates- Returns:
- The current Viewport rectangle
-
getWorldRect
Get a copy of the current view rectangle in world coordinates- Returns:
- The current Viewport rectangle
-
computeScaling
public boolean computeScaling()Computes scaling parameters based on region, zoom, origin, and view rect.- Returns:
- true if the scaling was recomputed
-
zoomByFactor
public void zoomByFactor(double factor) Change the zoom scaling by the given factor.- Parameters:
factor- the new zoom scaling factor
-
zoomIn
-
zoomIn
Zoom in to the given rectangle in local coordinates.- Parameters:
rc- the new viewport- Returns:
- true if the viewport was zoomed to rc
-
world2LocalTransform
Coordinate conversion routines Creates or updates an existing AffineTransform to change from world to local coordinates.- Parameters:
transform- AffineTransform the transform to adjust. If null, a new transform is created.- Returns:
- AffineTransform
-
local2WorldTransform
Creates or updates an existing AffineTransform to change from local to world coordinates.- Parameters:
transform- AffineTransform the transform to adjust. If null, a new transform is created.- Returns:
- AffineTransform
-
e2x
Deprecated.call wp2lp. With the addition of map transforms the e/n axis are no longer independent. i.e. the x-shift will be smaller or larger, depending on your location on the earthConverts world east coordinate to local x coordinate.- Parameters:
e- the world east coordinate- Returns:
- the local x coordinate for e
-
n2y
Deprecated.call wp2lp. With the addition of map transforms the e/n axis are no longer independent. i.e. the x-shift will be smaller or larger, depending on your location on the earthConverts world north coordinate to local y coordinate.- Parameters:
n- the world north coordinate- Returns:
- the local y coordinate for n
-
x2e
Deprecated.call wp2lp. With the addition of map transforms the e/n axis are no longer independent. i.e. the x-shift will be smaller or larger, depending on your location on the earthConverts local x coordinate to world east coordinate.- Parameters:
x- the local x coordinate- Returns:
- the world east coordinate for x
-
y2n
Deprecated.call wp2lp. With the addition of map transforms the e/n axis are no longer independent. i.e. the x-shift will be smaller or larger, depending on your location on the earthConverts local y coordinate to world north coordinate.- Parameters:
y- the local y coordinate- Returns:
- the world north coordinate for y
-
wp2lp
Converts a point in world coordinates to local coordinates.- Parameters:
wpt- a point in world coordinateslpt- the local point for wpt
-
wp2lp
Converts a point in world coordinates to local coordinates, returning a newly allocated Point.- Parameters:
wpt- a point in world coordinates- Returns:
- a new LocalPt for wpt
-
lp2wp
Converts a point in local coordinates to world coordinates.- Parameters:
lpt- a point in local coordinateswpt- the world point set to the lpt coverted value
-
lp2wp
Converts a point in local coordinates to world coordinates, returning a newly allocated Point.- Parameters:
lpt- a point in local coordinatesThis method is final. We end up calling lp2wp(lpt,wpt) with nothing realy computed.
- Returns:
- a new WorldPt for lpt
-
wr2lr
Converts a WorldRect to a LocalRect, returning a newly allocated LocalRect- Parameters:
wr- a rect in world coordinates- Returns:
- a new LocalRect for wr
-
wr2lr
Converts a WorldRect to a LocalRect, returning a newly allocated LocalRect- Parameters:
wr- a rect in world coordinateslr- a rect in local coordinates to get filled in, or null and a new LocalRect will be created- Returns:
- the LocalRect for wr
-
lr2wr
Converts a LocalRect to a WorldRect, returning a newly allocated WorldRect- Parameters:
lr- a rect in local coordinates- Returns:
- a new WorldRect for lr
-