|
|||||||||
| 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.AlohaEarthMapCache
public final class AlohaEarthMapCache
This class caches Estd-located exhibits and map fragments for Aloha Earth.
| Nested Class Summary | |
|---|---|
private static class |
AlohaEarthMapCache.EFHook
Emergency-free hook called in case of critical memory shortage. |
| Field Summary | |
|---|---|
private java.util.Hashtable<java.lang.String,java.lang.Object> |
_sCE_cache
Private cache for selectContainedExhibits(); never null. |
private java.util.Hashtable<java.lang.String,java.lang.Object> |
_sMEI_cache
Private cache for selectMapEncodedImage(); never null. |
private java.util.Hashtable<java.lang.String,java.lang.Object> |
_sVLL_cache
Private cache for selectViewLocationVirtualPrefix(); never null. |
private java.util.Hashtable<java.lang.String,java.lang.Object> |
_sVLVP_cache
Private cache for selectViewLocationVirtualPrefix(); never null. |
AllExhibitProperties |
aep
Underlying AEP; never null. |
private java.util.List<Name.ExhibitFull> |
allEstdExhibits
Unmodifiable smart-sorted list of all exhibits with Estd location; never null. |
private static boolean |
CACHEING
If true, we attempt to cache images and exhibit sub-sets by area. |
private AlohaEarthMapCache.EFHook |
efh
Emergency-free hook, never null. |
private static int |
MARKER_EXTRA_PIXELS
Number of extra pixels to draw the marker in each direction; non-negative. |
private static boolean |
MEMORY_SENSITIVE_CACHE
If true, use SoftReference memory-sensitive cache; use if memory-starved. |
private static java.util.List<Name.ExhibitFull> |
NO_EXHIBITS
Empty exhibits list. |
private static boolean |
RECURSIVE_SELECT
If true, we attempt to select exhibits from the zoom-out set. |
private static int |
TITLE_AREA_BOUNDARY_STEP
Pixel step for title area boundaries, 1 means solid; strictly positive. |
private static int |
TITLE_AREA_EG
Extra size of corner guides on marker title area in pixels, larger than exhibit marker for emphasis; strictly positive. |
static boolean |
TOP_LEVEL_ESTD_FILTER
If false, the entire set of exhibits selected by the master filter appears at top level; we may sort but we will not further filter. |
| Constructor Summary | |
|---|---|
AlohaEarthMapCache(DataSourceBean dsb)
Default constructor. |
|
| Method Summary | |
|---|---|
private static FilterExpr |
_chooseLocationFilter(AEParams aeps)
Choose the filter to apply to the source data set of null if not filter is to be applied. |
private static void |
_drawExhibitMarker(java.awt.Point p,
java.awt.image.BufferedImage bi)
Draw marker on map image fragment to indicate location of an exhibit. |
private static void |
_drawExhibitMarkers(java.util.List<Name.ExhibitFull> exhibits,
AllExhibitProperties aep,
AEParams aeps,
java.awt.image.BufferedImage bi)
Draw the markers for individual exhibits. |
private static void |
_drawHLine(java.awt.image.BufferedImage bi,
int colour,
int y,
int minX,
int maxX)
Draw horizontal line of given colour at y from minX to maxX. |
private void |
_drawTitleMarkers(LocationMap lm,
AEParams aeps,
java.awt.image.BufferedImage bi)
Draw the marker(s) corresponding to the title location, if any. |
private static void |
_drawVLine(java.awt.image.BufferedImage bi,
int colour,
int x,
int minY,
int maxY)
Draw vertical line of given colour at x from minY to maxY. |
private static java.lang.Object |
_extractCacheEntry(java.util.Map cache,
java.lang.Object key)
Routine to extract cache entry from given cache; null if no cached entry. |
private static java.lang.CharSequence |
_extractMainWordPrefixFromVirtualPrefix(Name virtPrefix)
Extract main-word-prefix portion from LocationMap virtual prefix. |
private Name.ExhibitFull[] |
_getRawInputSetForFilter(AEParams aeps)
Returns the String[] set of full exhibit names to filter; never null. |
private static void |
_insertCacheEntry(java.util.Map cache,
java.lang.Object key,
java.lang.Object item,
boolean strongRef)
Insert item in given cache, forcing non-SoftReference if need be. |
java.util.List<Name.ExhibitFull> |
selectContainedExhibits(AEParams aeps)
Selects an immutable List of exhibits whose centres lie in the current map view; never null. |
ROByteArray |
selectMapEncodedImage(AEParams aeps,
javax.servlet.ServletContext context)
Create an encoded map fragment for display; never null. |
java.lang.String |
selectViewLocationLabels(DataSourceBean dsb,
AEParams aeps)
Create HTML label text to overlay the map; returns "" if none, never null. |
Name |
selectViewLocationVirtualPrefix(AEParams aeps,
LocationMap lm)
Get best-match prefix of form "section/main-words-" from LocationMap for current view, or "" if none; never null. |
java.lang.CharSequence |
selectViewLocationVirtualPrefixAsTitle(AEParams aeps,
javax.servlet.ServletContext context)
Get selectViewLocationVirtualPrefix() value suitable for use as title; "" if none available. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final boolean MEMORY_SENSITIVE_CACHE
private static final java.util.List<Name.ExhibitFull> NO_EXHIBITS
private final AlohaEarthMapCache.EFHook efh
public final AllExhibitProperties aep
private final java.util.List<Name.ExhibitFull> allEstdExhibits
private static final boolean CACHEING
We only attempt to cache where the constrained offsets of AEParams are forced to tile increments, ensuring that only a relatively small number of distinct areas can be seen by the viewer, reducing the maximum number of distinct cached items and increasing the potential hit rate.
private static final boolean RECURSIVE_SELECT
This only make sense if we are cacheing results of lookups, and if we are constraining lookups to tile boundaries.
public static final boolean TOP_LEVEL_ESTD_FILTER
private final java.util.Hashtable<java.lang.String,java.lang.Object> _sVLVP_cache
private final java.util.Hashtable<java.lang.String,java.lang.Object> _sVLL_cache
private final java.util.Hashtable<java.lang.String,java.lang.Object> _sCE_cache
All access is synchronised on this object.
A Hashtable is used as inherently thread-safe.
Start this small; let it grow if needed.
private final java.util.Hashtable<java.lang.String,java.lang.Object> _sMEI_cache
All access is synchronised on this object.
This can be clear()ed by clearCache().
A Hashtable is used as inherently thread-safe.
Start this small; let it grow if needed.
private static final int MARKER_EXTRA_PIXELS
private static final int TITLE_AREA_BOUNDARY_STEP
private static final int TITLE_AREA_EG
| Constructor Detail |
|---|
AlohaEarthMapCache(DataSourceBean dsb)
throws java.io.IOException
We expect its lazy computation to take lots of CPU in total, so we try to hang onto some of the base/expensive cached state, but we do have an emergency-free hook to release everything in case of emergency.
Only package-visible since only AlohaEarth utility methods need to construct this.
java.io.IOException| Method Detail |
|---|
private static java.lang.Object _extractCacheEntry(java.util.Map cache,
java.lang.Object key)
private static void _insertCacheEntry(java.util.Map cache,
java.lang.Object key,
java.lang.Object item,
boolean strongRef)
To avoid ambiguity, the item to be cached must not itself be a SoftReference.
If not CACHEING, this does nothing.
public java.lang.CharSequence selectViewLocationVirtualPrefixAsTitle(AEParams aeps,
javax.servlet.ServletContext context)
private static java.lang.CharSequence _extractMainWordPrefixFromVirtualPrefix(Name virtPrefix)
public Name selectViewLocationVirtualPrefix(AEParams aeps,
LocationMap lm)
public java.lang.String selectViewLocationLabels(DataSourceBean dsb,
AEParams aeps)
The first view labels may be rendered more strongly.
public java.util.List<Name.ExhibitFull> selectContainedExhibits(AEParams aeps)
If we are not using a tile encoding then this does not cache at all, but just generates everything on demand.
This routine tries to avoid drawing each distinct point on the map more than once to save time on the assumptions that:
aeps - parameters with which map to display is chosen; not null
private Name.ExhibitFull[] _getRawInputSetForFilter(AEParams aeps)
aeps - parameters for current view of map; never nullprivate static FilterExpr _chooseLocationFilter(AEParams aeps)
aeps - current properties (zoom, etc); never null
public ROByteArray selectMapEncodedImage(AEParams aeps,
javax.servlet.ServletContext context)
throws java.io.IOException
If we are not using a tile encoding then this does not cache at all, but just generates everything on demand.
Access is synchronized (on a private lock) so as to:
Draws a (red) marker cross at the centre of every exhibit within the current area, and zero-or-more titles/labels to highlight the selected area.
aeps - parameters with which map to display is chosen; not null
java.io.IOException
private void _drawTitleMarkers(LocationMap lm,
AEParams aeps,
java.awt.image.BufferedImage bi)
This may draw crosshairs for the centroid.
private static void _drawVLine(java.awt.image.BufferedImage bi,
int colour,
int x,
int minY,
int maxY)
private static void _drawHLine(java.awt.image.BufferedImage bi,
int colour,
int y,
int minX,
int maxX)
private static void _drawExhibitMarkers(java.util.List<Name.ExhibitFull> exhibits,
AllExhibitProperties aep,
AEParams aeps,
java.awt.image.BufferedImage bi)
exhibits - List of exhibits; never nullaep - exhibit properties; nevr nullaeps - current view; never nullbi - BufferedImage to draw markers on; never null
private static void _drawExhibitMarker(java.awt.Point p,
java.awt.image.BufferedImage bi)
p - location to centre the exhibit marketbi - image to draw the marker on
|
DHD Multimedia Gallery V1.53.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||