|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.hd.d.pg2k.webSvr.util.HTMLThumbnailInsertGenerators
public final class HTMLThumbnailInsertGenerators
Utility functions to generate HTML inserts for showing batches of thumbnails/links. One advantage of having a method here rather than in-line in a JSP is that this code is pre-compiled off-line for speed and robustness.
| Field Summary | |
|---|---|
private static long |
_bestE_dontUpdateBefore
Time before which we will not attempt incremental update of _bestE set. |
private static java.util.concurrent.locks.ReentrantLock |
_bestE_update_lock
Lock to prevent more than one update run on _bestE at once. |
private static boolean |
_CS_ALWAYS_ONLY_SHOW_THUMBNAILS
If true then always omit from the contact sheet any items that do not immediately/ever have a thumbnail. |
private static DataSourceBean.AEPLinkedKey |
_CSCacheKey
Private key used by getContactSheetHTML(); never null. |
private static int |
BEST_EPSILON
Out-of-order tolerance we will allow before forcing "best" selection to be recomputed. |
private static DataSourceBean.AEPLinkedKey |
bestKey
Key to retrieve AEP-linked set of 'best' exhibits. |
private static boolean |
CHECK_ALL_FOR_STALE
If true then invalidate "best" collection if any stale value is found. |
static int |
COLDISP_MEAN_CHAR_HEIGHT_PIXELS
Assumed approximate mean pixels wide per (small) character; strictly positive. |
static int |
COLDISP_MEAN_CHAR_WIDTH_PIXELS
Assumed approximate mean pixels wide per (small) character; strictly positive. |
static int |
COLDISP_MIN_HEIGHT_PIXELS
Minimum height for column display in pixels; strictly positive. |
static int |
COLDISP_MIN_WIDTH_PIXELS
Minimum width for column display in pixels; strictly positive. |
static boolean |
CS_CACHE_FOR_CAT_PAGES
If true then try to cache cat page contact sheets; this may require minor cosmetic changes in generated HTML for efficiency. |
static java.lang.String |
CS_INCOMPLETE
Comment tag at end of HTML for contact sheet if we ran out of time or it is otherwise incomplete. |
private static boolean |
LIGHTBOX_PADDING_POP_LINKS
If padding a lightbox out with a overlay image safety area, do we insert popular links? |
private static int |
LIGHTBOX_TABLE_BORDER_PX
Allow this many pixels' border in lightbox table; non-negative. |
private static int |
MAX_HOVERBOX_OVERSPILL_PX
Maximum that 'Hoverbox' overlay thumbnail may extend outside the table containing small thumbnails, in pixels; strictly positive. |
private static int |
MAX_THUMBNAIL_EXHIBITS_TO_RETAIN_FOR_DISPLAY
Cap number of items cached for thumbnail generators for efficiency; strictly positive. |
private static DataSourceBean.AEPLinkedKey |
newKey
Key to retrieve AEP-linked set of 'new' exhibits. |
private static Name.ExhibitFull[] |
NO_RESULTS
Empty (immutable) array to return to indicate no results. |
private static java.lang.String |
REQ_ATTR_NAME_LOAD_HOVERBOX_CCS
Request-level attribute set non-null before creating the header to load Hoverbox CSS. |
private static DataSourceBean.AEPLinkedKey |
rndKey
Key to retrieve AEP-linked set of 'random JPEG' exhibits. |
| Constructor Summary | |
|---|---|
private |
HTMLThumbnailInsertGenerators()
Prevent construction of an instance. |
| Method Summary | |
|---|---|
static void |
enableHoverboxCSS(javax.servlet.http.HttpServletRequest request)
Call this before generating the header to load the Hoverbox CSS. |
static java.lang.String |
generateGenericContactSheetHTML(int maxPixelsWidth,
java.util.List<Name.ExhibitFull> exhibitNames,
java.lang.String specialColour,
Name.ExhibitFull specialExhibitName,
long stopBy,
DataSourceBean dataSource)
Generate contact sheet of the exhibits given, in order; never null. |
static Name.ExhibitFull[] |
getBestExhibitSelection(javax.servlet.ServletContext application,
int maxExhibits,
java.util.Random rnd)
Get names of the the best exhibits ("goodness" greater than zero); never null. |
static Name.ExhibitFull[] |
getBestExhibitSelection(javax.servlet.ServletContext application,
int maxExhibits,
java.util.Random rnd,
boolean beQuick)
Get names of the the best exhibits ("goodness" greater than zero); never null. |
static java.lang.String |
getContactSheetHTML(Name.ExhibitFull exhibitName,
java.lang.String specialColour,
DataSourceBean dataSource,
java.util.List<Name.ExhibitFull> smartSortedNames)
Make "contact print" / "preview" HTML fragment to show a user all similar exhibits, "" if none possible; never null. |
static Name.ExhibitFull[] |
getNewExhibitSelection(javax.servlet.ServletContext application,
int maxExhibits,
java.util.Random rnd)
Get random selection of new-ish exhibit full names; never null. |
static Name.ExhibitFull[] |
getNewExhibitSelection(javax.servlet.ServletContext application,
int maxExhibits,
java.util.Random rnd,
boolean beQuick)
Get random selection of new-ish exhibit full names; never null. |
static Name.ExhibitFull[] |
getRandomJPEGSelection(javax.servlet.ServletContext application,
int maxExhibits)
Get random selection of JPEG exhibit full names; never null. |
static Name.ExhibitFull[] |
getRandomJPEGSelection(javax.servlet.ServletContext application,
int maxExhibits,
boolean beQuick)
Get random selection of JPEG exhibit full names; never null. |
static boolean |
hoverboxCSSIsEnabled(javax.servlet.http.HttpServletRequest request)
Returns true if the the Hoverbox CSS has been enabled with enableHoverboxCSS(). |
static java.lang.String |
makeHTMLExhibitColumnDisplay(Name.ExhibitFull[] exhibits,
int pixelsWidth,
int pixelsHeight,
DataSourceBean dataSource,
LocaleBeanBase localeBean,
boolean reduceEffort)
Makes HTML for columnar (ie taller and thin) display of exhibits; never null. |
static java.lang.String |
makeHTMLExhibitRow(Name.ExhibitFull[] exhibits,
DataSourceBean dataSource,
LocaleBeanBase localeBean,
boolean reduceEffort)
Makes HTML for row display of the exhibits supplied; never null. |
static java.lang.String |
popularUsefulLinksNarrowCol(DataSourceBean dsb,
int pixelsHigh,
int pixelsWide,
boolean toXHTML)
Generate a narrow column of popular/useful internal links for HTML/XHTML, "" if none; never null. |
static java.lang.String |
popularUsefulLinksNarrowCol(DataSourceBean dsb,
int pixelsHigh,
int pixelsWide,
boolean toXHTML,
long stopBy)
Generate a narrow column of popular/useful internal links for HTML/XHTML, "" if none; never null. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int COLDISP_MIN_WIDTH_PIXELS
public static final int COLDISP_MIN_HEIGHT_PIXELS
public static final int COLDISP_MEAN_CHAR_WIDTH_PIXELS
public static final int COLDISP_MEAN_CHAR_HEIGHT_PIXELS
private static final int MAX_THUMBNAIL_EXHIBITS_TO_RETAIN_FOR_DISPLAY
private static final DataSourceBean.AEPLinkedKey rndKey
private static final DataSourceBean.AEPLinkedKey bestKey
private static final java.util.concurrent.locks.ReentrantLock _bestE_update_lock
private static volatile long _bestE_dontUpdateBefore
Is volatile so as to allow access without a lock.
Private to getBestExhibitsSelection().
private static final Name.ExhibitFull[] NO_RESULTS
private static final DataSourceBean.AEPLinkedKey newKey
private static final boolean CHECK_ALL_FOR_STALE
private static final int BEST_EPSILON
private static final boolean _CS_ALWAYS_ONLY_SHOW_THUMBNAILS
public static final boolean CS_CACHE_FOR_CAT_PAGES
private static final DataSourceBean.AEPLinkedKey _CSCacheKey
private static final java.lang.String REQ_ATTR_NAME_LOAD_HOVERBOX_CCS
public static final java.lang.String CS_INCOMPLETE
private static final int MAX_HOVERBOX_OVERSPILL_PX
private static final boolean LIGHTBOX_PADDING_POP_LINKS
private static final int LIGHTBOX_TABLE_BORDER_PX
| Constructor Detail |
|---|
private HTMLThumbnailInsertGenerators()
| Method Detail |
|---|
public static java.lang.String makeHTMLExhibitRow(Name.ExhibitFull[] exhibits,
DataSourceBean dataSource,
LocaleBeanBase localeBean,
boolean reduceEffort)
throws java.io.IOException
exhibits - non-null list of full, valid exhibit names,
more important first (later items may not be displayed)dataSource - non-null source of exhibit data and thumbnailsreduceEffort - if true, reduce CPU and bandwidth load
in executing this routine and implied by the output
java.io.IOException
public static java.lang.String makeHTMLExhibitColumnDisplay(Name.ExhibitFull[] exhibits,
int pixelsWidth,
int pixelsHeight,
DataSourceBean dataSource,
LocaleBeanBase localeBean,
boolean reduceEffort)
throws java.io.IOException
Text is horizontally centred.
This may not show any exhibits at all if the area is too small.
This will not work well if the space is very narrow or shallow, much less than about 100 pixels.
Note that this may not get things exactly right if the user selects different font sizes in their browser.
exhibits - non-null list of full, valid exhibit names,
more important first (later items may not be displayed)dataSource - non-null source of exhibit data and thumbnailspixelsWidth - non-negative width of display space in pixelspixelsHeight - non-negative height of display space in pixelsreduceEffort - if true, reduce CPU and bandwidth load
in executing this routine and implied by the output
java.io.IOException - if there is difficulty retrieving meta-data
public static Name.ExhibitFull[] getNewExhibitSelection(javax.servlet.ServletContext application,
int maxExhibits,
java.util.Random rnd)
throws java.io.IOException
If there are any exhibits at all, and maxExhibits is positive, this routine ensures that at least one exhibit is a candidate to show.
These results are cached against the AEP, and automatically discarded/recomputed when the exhibit set changes.
May return empty list, but no nulls nor duplicates.
Should only be used with one servlet context.
application - the servlet context; never nullmaxExhibits - the maximum number of exhibits to return;
non-negativernd - the random number source if non-null, else null to pick top items
java.io.IOException
public static Name.ExhibitFull[] getNewExhibitSelection(javax.servlet.ServletContext application,
int maxExhibits,
java.util.Random rnd,
boolean beQuick)
throws java.io.IOException
If there are any exhibits at all, and maxExhibits is positive, this routine ensures that at least one exhibit is a candidate to show.
These results are cached against the AEP, and automatically discarded/recomputed when the exhibit set changes.
May return empty list, but no nulls nor duplicates.
Should only be used with one servlet context.
application - the servlet context; never nullmaxExhibits - the maximum number of exhibits to return;
non-negativernd - the random number source if non-null, else null to pick top itemsbeQuick - if true and the result is needs recomputing from scratch
then this returns an empty result and attempts to recompute in the background
java.io.IOException
public static Name.ExhibitFull[] getRandomJPEGSelection(javax.servlet.ServletContext application,
int maxExhibits)
throws java.io.IOException
May return empty list, but no nulls nor duplicates.
Should only be used with one servlet context.
application - the servlet context; never nullmaxExhibits - the maximum number of exhibits to return;
non-negative
java.io.IOException
public static Name.ExhibitFull[] getRandomJPEGSelection(javax.servlet.ServletContext application,
int maxExhibits,
boolean beQuick)
throws java.io.IOException
May return empty list, but no nulls nor duplicates.
Should only be used with one servlet context.
application - the servlet context; never nullmaxExhibits - the maximum number of exhibits to return;
non-negativebeQuick - if true and the result is needs recomputing from scratch
then this returns an empty result and attempts to recompute in the background
java.io.IOException
public static Name.ExhibitFull[] getBestExhibitSelection(javax.servlet.ServletContext application,
int maxExhibits,
java.util.Random rnd)
throws java.io.IOException
May return an empty list, but no nulls nor duplicates.
Should only be used with one servlet context.
If a random number source is supplied then it is used to chose a random (though weighted toward best) selection of exhibits.
If no random number source is supplied then the very best exhibits are returned.
(May invalidate its cache and spend a short time updating entries if any of the items that it is about to return is stale or the results are no longer in order (best first) in the hope that non-stale ones will have been computed in the mean time. This incremental cache validation and recomputation should help keep the results reasonable without penalising any one caller too much, and returns reasonable results in a short time on each call.)
application - the servlet context; never nullmaxExhibits - the maximum number of exhibits to return;
non-negativernd - the random number source if non-null, else null to pick top items
java.io.IOException
public static Name.ExhibitFull[] getBestExhibitSelection(javax.servlet.ServletContext application,
int maxExhibits,
java.util.Random rnd,
boolean beQuick)
throws java.io.IOException
May return an empty list, but no nulls nor duplicates.
Should only be used with one servlet context.
If a random number source is supplied then it is used to chose a random (though weighted toward best) selection of exhibits.
If no random number source is supplied then the very best exhibits are returned.
(May invalidate its cache and spend a short time updating entries if any of the items that it is about to return is stale or the results are no longer in order (best first) in the hope that non-stale ones will have been computed in the mean time. This incremental cache validation and recomputation should help keep the results reasonable without penalising any one caller too much, and returns reasonable results in a short time on each call.)
This ties not to block for the calculation of any EPCM values.
application - the servlet context; never nullmaxExhibits - the maximum number of exhibits to return;
non-negativernd - the random number source if non-null, else null to pick top itemsbeQuick - if true and the result is needs recomputing from scratch
then this returns an empty result and attempts to recompute in the background
java.io.IOException
public static java.lang.String getContactSheetHTML(Name.ExhibitFull exhibitName,
java.lang.String specialColour,
DataSourceBean dataSource,
java.util.List<Name.ExhibitFull> smartSortedNames)
Note that if using the 'Hoverbox' feature, then overlay standard thumbnails may appear above and to the left or right of a small thumbnail being hovered over, so sufficient clearance should be given above this HTML insert to avoid conflicts with surrounding material, such as ads.
This may choose to omit or show substitute text for exhibits with no immediately-available thumbnail.
This does not generate any headings.
If this encounters an error (eg an exception, or inconsistent arguments) then it will attempt to return gracefully with a "no-contact-sheet-available" empty value ("").
This may spend a limited amount of time trying to create thumbnails, bring up-to-date computable data, etc, but in any case tries to be quick.
Appends a special HTML comment tag to the result if incomplete due to missing thumbnails or lack of time.
This may cache completed results against all of the exhibit names given, to be discarded if the AEP for the supplied DataSourceBean changes.
exhibitName - this name of the main exhibit for which a contact sheet
is to be generated; must be a valid, non-null exhibit namespecialColour - HTML colour name (or #RRGGBB value) to distinguish
the main exhibit in the contact sheet somehow,
quoted if it need be for an attribute value,
may be ignored for efficiency/consistency;
null if no such marking to be donedataSource - data source for thumbnails, etc; never nullsmartSortedNames - list of all exhibit names,
sorted with the SMART_ORDER Comparator,
and should be random-access else this will probably be horribly slow;
never null
public static final void enableHoverboxCSS(javax.servlet.http.HttpServletRequest request)
This is idempotent, and sets a request-level attribute.
public static final boolean hoverboxCSSIsEnabled(javax.servlet.http.HttpServletRequest request)
This checks a request-level attribute.
public static java.lang.String generateGenericContactSheetHTML(int maxPixelsWidth,
java.util.List<Name.ExhibitFull> exhibitNames,
java.lang.String specialColour,
Name.ExhibitFull specialExhibitName,
long stopBy,
DataSourceBean dataSource)
Note that if using the 'Hoverbox' feature, then overlay larger thumbnails may appear above a thumbnail being hovered over, so we insert sufficient padding around the thumbnail table to avoid conflicts with surrounding page material, such as ads.
exhibitNames - in-order list of exhibits to display; never nullspecialExhibitName - name of "special" exhibit to emphasise;
null if nonestopBy - approximate target time to finish by;
can be set in the past to generate HTML as quickly as possiblespecialColour - HTML colour name (or #RRGGBB value) to distinguish
the main exhibit in the contact sheet somehow,
quoted if it need be for an attribute value;
null if no such marking to be donemaxPixelsWidth - maximum pixels available for display (approx);
strictly positivedataSource - data source for thumbnails, etc; never null
public static java.lang.String popularUsefulLinksNarrowCol(DataSourceBean dsb,
int pixelsHigh,
int pixelsWide,
boolean toXHTML)
dsb - data source; never nullpixelsHigh - approx number of pixels high; strictly positivepixelsWide - approx number of pixels wide; strictly positivetoXHTML - if true then link to XHTML catalogue pages rather than HTML pages
public static java.lang.String popularUsefulLinksNarrowCol(DataSourceBean dsb,
int pixelsHigh,
int pixelsWide,
boolean toXHTML,
long stopBy)
dsb - data source; never nullpixelsHigh - approx number of pixels high; strictly positivepixelsWide - approx number of pixels wide; strictly positivetoXHTML - if true then link to XHTML catalogue pages rather than HTML pagesstopBy - try to stop by the specified time.
|
DHD Multimedia Gallery V1.57.21 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||