|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.hd.d.pg2k.webSvr.virtualHosts.AlohaEarth.AEParams
public final class AEParams
JavaBean used to parse/validate/adjust/save view parameters. This can have the zoom and (x,y)-offset parameters of a particular view set in various ways, and will coerce them to valid values. This can also be used to generate suitably-encoded parameters for a visitor to navigate in the Aloha Earth space.
So that this is a valid JavaBean we make it Serializable, but in practice never expect it to be persisted, even temporarily in a session, so we don't bother with a unique serialisation ID, validation, etc, but we do make any derived internal values transient.
This is NOT currently designed to be thread-safe.
This implements Clonable to as to make it possible to easily take a copy of the parameters, alter them, and turn the new values into a form's parameter set, for example.
The main parameters held in this bean are:
Note that for the East Offset and North Offset, the offset is measured from the centre of the current image to the centre of the original underlying image, where either centre may potentially lie within a pixel or between pixels.
The unit of measure is pixels of the original image, making the units invariant wrt the zoom factor of the current image, and thus this value is constrained to lie in the range [-BASE_2D_EARTH_MAP_WIDTH/2, +BASE_2D_EARTH_MAP_WIDTH/2] for EO, and [-BASE_2D_EARTH_MAP_HEIGHT/2, +BASE_2D_EARTH_MAP_HEIGHT/2] for NO though usually within a narrower range than that.
Note that the fact that when we zoom in one pixel in the original takes several pixels in the current/displayed image means that careful handling is required to get image alignment correct.
| Field Summary | |
|---|---|
private int |
eastOffset
The East Offset of of the current view from original image. |
static boolean |
FORCE_TILE_POSITIONING
If true, round offset values to "tile" multiples. |
static int |
MAP_CLICK_ZF_ADJ
Amount to add to zoomFactor on clicking on the map image; 0 means no zoom. |
static java.lang.String |
NAME_EAST_OFFSET
External name of East Offset parameter, eg in HTTP GET/POST. |
static java.lang.String |
NAME_MAP_FIELD
Field name for map image as mouse-sensitive submit button. |
static java.lang.String |
NAME_NORTH_OFFSET
External name of North Offset parameter, eg in HTTP GET/POST. |
static java.lang.String |
NAME_ZOOM_CONTROL_FIELD
Name of zoom-control field (submit button). |
static java.lang.String |
NAME_ZOOM_FACTOR
External name of zoomFactor parameter, eg in HTTP GET/POST. |
private int |
northOffset
The North Offset of of the current view from original image. |
static int |
OFFSET_LIMIT_EAST
The absolute maximum limit (+/-) of the East Offset in pixels; positive and rounded down. |
static int |
OFFSET_LIMIT_NORTH
The absolute maximum limit (+/-) of the NORTH Offset in pixels; positive and rounded down. |
private static java.lang.String |
PARAMS_PREFIX
Prefix for (first) path component for embedded parameters, in the order prefix/e/n/z. |
private static boolean |
PARAMS_PREFIX_NOT_IN_PATHINFO
If true then the PARAMS_PREFIX will not be visible in the path info. |
private static long |
serialVersionUID
Unique Serialisation class ID generated by http://random.hd.org/. |
private int |
zoomFactor
The current zoom factor. |
| Constructor Summary | |
|---|---|
AEParams()
|
|
| Method Summary | |
|---|---|
private int |
_negativeZoomFactor()
Computes a negated zoom factor rebased to the minimum zoom. |
void |
adjustCentreWithXYClick(int x,
int y)
Adjusts East/North offsets given x,y coordinates of mouse click on displayed area. |
java.lang.Object |
clone()
Clone this object; all state is separated from the original. |
AEParams |
cloneAndTranslate(int eTiles,
int nTiles)
Makes a clone and steps it by the requested number of tile units in each direction (East and North). |
(package private) int |
computeXfromE(float targetE)
Compute X pixel from E degrees given current view; may not be visible. |
(package private) int |
computeYfromN(float targetN)
Compute Y pixel from N degrees given current view; may not be visible. |
java.lang.String |
getAsGetPathInfo(boolean constrained)
Gets parameters suitable to tag on to end of servlet URI to make new path. |
java.lang.String |
getAsGetURLParameters(boolean constrained)
Gets parameters suitable to tag on to a URL after a '?', eg for GET operation. |
java.lang.String |
getAsHiddenFormElements()
Gets parameters as hidden fields to include in a form. |
int |
getBaseSrcPixelsHeight(boolean constrained)
Get height of current zoomed view in terms of original base-image pixels; always positive. |
int |
getBaseSrcPixelsWidth(boolean constrained)
Get width of current zoomed view in terms of original base-image pixels; always positive. |
java.awt.Point |
getDisplayPixelForEstdLocationCentre(Location.Estd targetLoc)
Gets pixel in current view corresponding to centre of given location; null if not in current view. |
float |
getEastDegrees(boolean constrained)
Get East Offset as degrees East; range approximately [-180f, +180f]. |
int |
getEastOffset(boolean constrained)
Get East Offset of the current view from the base/original image. |
private int |
getEastOffsetSrcPixelsX(boolean constrained)
Get source image left (x) coordinate. |
Location.Estd |
getLocation(boolean constrained)
Get current offset as a Location.Estd; never null. |
float |
getNorthDegrees(boolean constrained)
Get North Offset as degrees North; range approximately [-90f, +90f]. |
int |
getNorthOffset(boolean constrained)
Get North Offset of the current view from original image. |
private int |
getNorthOffsetSrcPixelsY(boolean constrained)
Get source image top (y) coordinate. |
java.awt.Rectangle |
getSourceRectangleToDisplay()
Get bounding rectangle of area to be zoomed to make display image. |
int |
getTileSrcPixelsHeight()
Get tile height in source-image pixels; strictly positive. |
int |
getTileSrcPixelsWidth()
Get tile width in source-image pixels; strictly positive. |
int |
getZoomFactor()
Get the current zoom factor. |
boolean |
inDefaultState()
Returns true if all values are as for initial state. |
AEParams |
makeClone()
Make copy of this object; like clone() except no need to cast result. |
java.lang.Object |
makeKey(boolean constrained)
Makes an immutable canonical key for use in a hash-table; never null. |
AEParams |
setEastOffset(int pixelsOffset)
Set the East Offset of the current view from the base/original image. |
AEParams |
setEastOffset(java.lang.String pixelsOffset)
Set East offset as String. |
AEParams |
setLocation(Location.Estd loc)
Set the best view to see the specified Location. |
AEParams |
setNorthOffset(int pixelsOffset)
Set the North Offset of the current view from the base/original image. |
AEParams |
setNorthOffset(java.lang.String pixelsOffset)
Set North offset as String. |
AEParams |
setRequest(javax.servlet.http.HttpServletRequest request)
Sets all parameters possible from a servlet request. |
AEParams |
setZoomFactor(int zf)
Set the current zoom factor as an integer; will be coerced to range. |
AEParams |
setZoomFactor(java.lang.String zf)
Set the current value as a String; parse and coerced as necessary. |
java.lang.String |
toString()
Gets parameters as human-readable (albeit terse) String. |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final boolean FORCE_TILE_POSITIONING
Across each view in each direction (E and N) are ZOOM_RATIO tiles. A user may move laterally in either dimension one tile width, and may zoom in to one of the tiles of the current image. Plainly, tiles from adjacent "windows" can in principle be shared, which we might make use of explicitly with a tiled display in HTML, or implicitly by say having JAI draw the image on demand and have a Renderable in cache.
public static final java.lang.String NAME_MAP_FIELD
public static final int MAP_CLICK_ZF_ADJ
public static final java.lang.String NAME_ZOOM_CONTROL_FIELD
public static final java.lang.String NAME_ZOOM_FACTOR
private int zoomFactor
public static final int OFFSET_LIMIT_EAST
public static final int OFFSET_LIMIT_NORTH
public static final java.lang.String NAME_NORTH_OFFSET
public static final java.lang.String NAME_EAST_OFFSET
private int eastOffset
This value is constrained to lie in the range [-BASE_2D_EARTH_MAP_WIDTH/2, +BASE_2D_EARTH_MAP_WIDTH/2].
The initial value is zero.
private int northOffset
The offset of measured from the centre of the current image to the centre of the original underlying image, where either centre may potentially lie within a pixel or between pixels.
This value is constrained to lie in the range [-BASE_2D_EARTH_MAP_HEIGHT/2, +BASE_2D_EARTH_MAP_HEIGHT/2].
Note that is is the negative of the change in the y axis which in computer graphics usually has higher values lower down.
The initial value is zero.
private static final java.lang.String PARAMS_PREFIX
private static final boolean PARAMS_PREFIX_NOT_IN_PATHINFO
private static final long serialVersionUID
| Constructor Detail |
|---|
public AEParams()
| Method Detail |
|---|
public int getZoomFactor()
public AEParams setZoomFactor(int zf)
public AEParams setZoomFactor(java.lang.String zf)
In case of a parse error (including a null argument) no value is set.
public AEParams setEastOffset(int pixelsOffset)
The offset of measured from the centre of the current image to the centre of the original underlying image, where either centre may potentially lie within a pixel or between pixels.
This value is constrained to lie in the range [-BASE_2D_EARTH_MAP_WIDTH/2, +BASE_2D_EARTH_MAP_WIDTH/2]; any value outside these bounds is coerced to range.
When read back "constrained" this is coerced to try to keep the current view within the original source image.
The initial (unset/default) value is zero.
public AEParams setEastOffset(java.lang.String pixelsOffset)
public AEParams setNorthOffset(int pixelsOffset)
The offset of measured from the centre of the current image to the centre of the original underlying image, where either centre may potentially lie within a pixel or between pixels.
This value is constrained to lie in the range [-BASE_2D_EARTH_MAP_HEIGHT/2, +BASE_2D_EARTH_MAP_HEIGHT/2]; any value outside these bounds is coerced to range.
When read back "constrained" this is coerced to try to keep the current view within the original source image.
The initial (unset/default) value is zero.
public AEParams setNorthOffset(java.lang.String pixelsOffset)
public int getEastOffset(boolean constrained)
The offset of measured from the centre of the current image to the centre of the original underlying image, where either centre may potentially lie within a pixel or between pixels.
This value is constrained to lie in the range [-BASE_2D_EARTH_MAP_WIDTH/2, +BASE_2D_EARTH_MAP_WIDTH/2] at most.
If called for a "constrained" value, the return is clamped so as to ensure that all of the current view lies within the base image if possible. In all cases the result, if adjusted, is adjusted towards zero.
If we are rounding to tile widths, we round down.
The initial value is zero.
constrained - if true, return is if necessary adjusted towards
zero to try to force the current zoomed view to be from entirely
within the source image and possibly rounded to a tile width,
else the raw (but still clamped) value is returnedprivate int getEastOffsetSrcPixelsX(boolean constrained)
This calls getEastOffset().
constrained - if true, the result is always within
the source image bounds [0,BASE_2D_EARTH_MAP_WIDTH-1] inclusive
and if FORCE_TILE_POSITIONING is true will be rounded to a tile sizepublic int getNorthOffset(boolean constrained)
The offset of measured from the centre of the current image to the centre of the original underlying image, where either centre may potentially lie within a pixel or between pixels.
This value is constrained to lie in the range [-BASE_2D_EARTH_MAP_HEIGHT/2, +BASE_2D_EARTH_MAP_HEIGHT/2] at most.
Note that is is the negative of the change in the y axis which in computer graphics usually has higher values lower down.
The initial value is zero.
constrained - if true, return is if necessary adjusted towards
zero to try to force the current zoomed view to be from entirely
within the source image,
else the raw (but still clamped) value is returnedprivate int getNorthOffsetSrcPixelsY(boolean constrained)
This calls getNorthOffset().
constrained - if true, the result is always within
the source image bounds [0,BASE_2D_EARTH_MAP_HEIGHT-1] inclusive
and if FORCE_TILE_POSITIONING is true will be rounded to a tile sizepublic float getEastDegrees(boolean constrained)
The conversion will be a bit lumpy and inexact, especially as the underlying step in the offset is likely to be similar but not identical to a degree. The caller could usefully round this.
Clamped to +/- Location.Estd.MAX_E.
constrained - when true, if the source image area would lie
partly or completely outside the base image, this is adjusted
in line with getEastOffset() towards zero to try
to bring it within the base imagepublic float getNorthDegrees(boolean constrained)
The conversion will be a bit lumpy and inexact, especially as the underlying step in the offset is likely to be similar but not identical to a degree. The caller could usefully round this.
Clamped to +/- Location.Estd.MAX_N.
public Location.Estd getLocation(boolean constrained)
public java.awt.Point getDisplayPixelForEstdLocationCentre(Location.Estd targetLoc)
targetLoc - location to find pixel for centre of; null if not visibleint computeXfromE(float targetE)
int computeYfromN(float targetN)
public java.awt.Rectangle getSourceRectangleToDisplay()
Depends on zoom and offsets.
Clamped so that no part of this will lie outside the original image, but this may change the aspect ratio, for example.
The width and height are always strictly positive.
Note that we adjust the zoom we use so that the minimum allowable zoom shows the whole image, but shunk or expanded from the raw image if the MIN_ZOOM is non-zero.
public int getBaseSrcPixelsHeight(boolean constrained)
constrained - if true, the result is constrained to be no more
than the height of the base imagepublic int getBaseSrcPixelsWidth(boolean constrained)
constrained - if true, the result is constrained to be no more
than the width of the base imagepublic int getTileSrcPixelsWidth()
public int getTileSrcPixelsHeight()
public void adjustCentreWithXYClick(int x,
int y)
This assumes that the displayed map fragment has a constrained center and width/height.
Coerces values to allowed range if need be.
private int _negativeZoomFactor()
public AEParams setRequest(javax.servlet.http.HttpServletRequest request)
Where necessary, arguments are coerced to form a consistent set.
This coercion may depend on data gathered from the current exhibit data set and base clickable-map image can cached statically where we can get at it.
This first sets the basic values from their simple parameter values, the applies any adjustment implied by such things as the zoom control and/or the map (x,y) click location.
public AEParams setLocation(Location.Estd loc)
This sets the (unconstrained) centre to be as close as possible to the specified location's centre.
This zooms in as far as it can to still totally enclose the target area in the putative map viewport.
public java.lang.String getAsGetURLParameters(boolean constrained)
Ampersands ("&") separating parameters are expanded to entities, eg "x=3&y=2" for safety when embedded in HTML/XML text.
Note that this presents unconstrained parameters to preserve visitor's chosen offset as they zoom in and out.
constrained - if true, values returned are constrained to legal
(and possibly tile) boundaries, which may help browser caching
for examplepublic java.lang.String getAsGetPathInfo(boolean constrained)
This is a URI suffix of the form "PREFIX/e/n/z" with no leading or trailing '/'.
Note that this presents unconstrained parameters to preserve visitor's chosen offset as they zoom in and out.
constrained - if true, values returned are constrained to legal
(and possibly tile) boundaries, which may help browser caching
for examplepublic java.lang.String getAsHiddenFormElements()
public java.lang.String toString()
This includes key derived values too.
toString in class java.lang.Objectpublic boolean inDefaultState()
public java.lang.Object clone()
clone in class java.lang.Objectpublic AEParams makeClone()
makeCopy().setZoomFactor(newValue).getAsGetURLParameters()
to get a URL fragment for a link to change the zoom level.
public AEParams cloneAndTranslate(int eTiles,
int nTiles)
This coerces offsets to constrained values, which may help, for example, with cacheing by browsers and in the server, especially when tiling is being enforced.
public java.lang.Object makeKey(boolean constrained)
The result is produced from the zoom and unconstrained East and North offset values. This is unconstrained to allow for different target centroids even within a single view/tile.
The result supports equals() and hashCode but is otherwise to be considered opaque.
constrained - if true then the key is constrained to a
coarser-grained grid of viewport coordinates
|
DHD Multimedia Gallery V1.60.69 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||