|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface Handler
Interface for exhibit media-handler classes. The media handlers do such things as make thumbnails/samples, and are loaded by name to allow for run-time configuration and presence/absence of such items as Sun's JPEG support.
Implementing classes must have an public non-args descriptor so that we can use Class.forName() to manufacture instances.
Implementing classes must be immutable and stateless and thread-safe, so that one instance can be shared between many threads.
Both CPU time and memory will be severe run-time constraints on implementing classes, and they must allow for concurrent operation with many other instances or internally reduce concurrency (eg with static locks).
This interface represents a ``fat'' API, ie implementing classes may not implement all of the API at run-time but return default/failure values instead.
| Nested Class Summary | |
|---|---|
static class |
Handler.ThumbnailParams
Some constant parameters and hints for thumbnail building. |
| Field Summary | |
|---|---|
static java.lang.String |
TAG_NAME_METADATA_TOP
Top-level node name for exhibit meta-data; never null or empty. |
| Method Summary | |
|---|---|
boolean |
canMakeThumbnails()
Returns true if handler can make thumbnails for this type. |
java.awt.image.BufferedImage |
decodeImage(java.io.InputStream is)
Decode image as BufferedImage, or null if not possible. |
java.awt.Dimension |
get2DImageDimensions(java.io.InputStream is)
Get X,Y pixel dimensions of an image exhibit, else null if dimensions cannot be computed. |
ExhibitMIME.ExhibitTypeParameters |
getExhibitType()
Get internal type of ExhibitMIME type; never null. |
org.w3c.dom.Node |
getMetadata(java.io.InputStream is,
Name.ExhibitFull exhibitName)
Gets all available exhibit metadata as a single XML DOM tree; null if none. |
Handler.ThumbnailParams |
getThumbnailParams()
Get ThumbnailParameters for a particular handler. |
byte[] |
makeImageBinary(java.awt.image.BufferedImage imageIn,
int quality)
Return image as file-format byte array. |
byte[] |
makeSizeConstrainedEncodedImage(int lowerQualityBound,
int initialQualityHint,
int upperQualityBound,
java.awt.image.BufferedImage scaledImage,
int targetMin,
int targetMax,
int absMinSize,
int absMaxSize,
int targetBytes)
Make a byte[]-encoded image of this type constrained above and below by size. |
ExhibitThumbnails |
makeThumbnails(ExhibitStaticAttr esa,
AllExhibitProperties.ExhibitDataSource eds,
AllExhibitProperties aep,
boolean unlimitedResources)
Make thumbnails/samples for the specified exhibit. |
ExhibitThumbnails |
makeThumbnails(java.io.InputStream is,
long originalLength)
Make thumbnails/samples for the specified exhibit. |
| Field Detail |
|---|
static final java.lang.String TAG_NAME_METADATA_TOP
| Method Detail |
|---|
ExhibitMIME.ExhibitTypeParameters getExhibitType()
java.awt.Dimension get2DImageDimensions(java.io.InputStream is)
throws java.io.IOException
For something like a movie in a fixed frame this may be able to return its dimensions, eg to embed in a page.
This does not close its input stream when done.
This should generally be efficient, by directly reading (opening) bytes of the exhibit passed as an input stream, if at all possible, but generic implementations may be very slow.
This will only work correctly if the exhibit is of the correct type, eg its magic number must already have been tested.
is - the exhibit as a binary data stream
java.io.IOException - in case of problems with corrupt data
(or a broken exhibit)
byte[] makeSizeConstrainedEncodedImage(int lowerQualityBound,
int initialQualityHint,
int upperQualityBound,
java.awt.image.BufferedImage scaledImage,
int targetMin,
int targetMax,
int absMinSize,
int absMaxSize,
int targetBytes)
throws java.io.IOException,
java.lang.IllegalArgumentException
This is not possible for all exhibit types.
upperQualityBound - maximum value of quality to use; non-negativelowerQualityBound - minimum value of quality to use; non-negative
and no greater than upperQualityBoundinitialQualityHint - initial suggested quality hint; non-negative,
no greater than upperQualityBound, no less than lowerQualityBoundscaledImage - the input image to encodetargetMin - target lower bound, should be higher than absMinSizetargetMax - target upper bound, should be lower than absMaxSizeabsMinSize - absolute minimum number of bytesabsMaxSize - absolute maximum number of bytestargetBytes - target number of bytes
java.io.IOException - in case of difficulty generating the image
java.lang.IllegalArgumentException - if the arguments are invalidHandler.ThumbnailParams getThumbnailParams()
This is assumed to be fast, ie to return a fixed static instance for each handler.
This is protected, since only the support routines in this base class need access this data.
boolean canMakeThumbnails()
By default, returns false, ie thumbnails cannot be made.
ExhibitThumbnails makeThumbnails(java.io.InputStream is,
long originalLength)
throws java.io.IOException
If this wishes to indicate that it cannot ever make one or more thumbnails/samples for a given exhibit then this should return a ExhibitThumbnails object with one or both thumbnails set to null.
(If canMakeThumbnails() returns false, this should return null.)
This does not close its input stream when done.
This will only work correctly if the exhibit is of the correct type, eg its magic number must already have been tested.
This assumes enough memory and other resource is available.
is - the whole raw image positioned at its startoriginalLength - is the length of the encoded original in bytes;
always positive and must reflect the stream input
and will be constrained to Integer.MAX_VALUE if larger
java.io.IOException
ExhibitThumbnails makeThumbnails(ExhibitStaticAttr esa,
AllExhibitProperties.ExhibitDataSource eds,
AllExhibitProperties aep,
boolean unlimitedResources)
throws java.io.IOException
This may fail with an IOException or return null to indicate that it is currently unable to create thumbnails/samples (though this condition may be temporary).
If this wishes to indicate that it cannot make one or more thumbnails/samples for a given exhibit then this should return a ExhibitThumbnails object with one or both thumbnails set to null.
(If canMakeThumbnails() returns false, this should return null.)
By default, returns null, ie thumbnails cannot be made.
This routine regulates memory use, rejecting the attempt to make the thumbnails if it cannot find/reserve sufficient memory using MemoryTools.runMemoryIntensiveOperation().
Calls the InputStream version of makeThumbnails().
unlimitedResources - if true, the generation routine is allowed
to try to use unlimited resources (especially memory)
java.io.IOException
java.awt.image.BufferedImage decodeImage(java.io.InputStream is)
throws java.io.IOException
This does not close its input stream when done.
java.io.IOException
byte[] makeImageBinary(java.awt.image.BufferedImage imageIn,
int quality)
throws java.io.IOException
This is used for still images and possible animations or movies where the bounding rectangle and the contained data is scaled to the given bounds.
The output image will, if possible, use the same colour scheme and other characteristics as the input, though some optional features that usually consume extra space, such as interlacing, may be disabled.
If no output can be generated this returns null, which is the default behaviour.
This should adjust the image "quality" with the detail value (adjusted within the bounds supplied by the handler class) to try to tune the output size. For a lossy encoding format such as JPEG this may be the "quality" factor or compression. For a lossless format the may have to be the number of bits-per-pixel that a colour map is reduced to, for example.
The quality parameter usage is format- and implementation- dependent, but 0 will generally be the lowest-quality rendering available and 100 will be the highest, with values in between monotonically increasing, though that does not mean that there will be any distinguishable different in the output with any pair of adjacent (or indeed any) quality values.
imageIn - source image; must not be null and must be suitable
for the target formatquality - desired encoding quality in range 0--100 inclusive,
with 0 interpreted as "high compression is important,"
and 100 (or over) interpreted as "high image quality is important.";
this parameter is ignored where it does not make sense for the format
java.io.IOException
org.w3c.dom.Node getMetadata(java.io.InputStream is,
Name.ExhibitFull exhibitName)
Under extreme circumstances, eg with damaged exhibit files, this may throw Error or other RuntimeException values, though implementations should try to return null rather than do this if the error appears to be permanent.
is - input stream; never nullexhibitName - TODO
|
DHD Multimedia Gallery V1.57.21 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||