|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.hd.d.pg2k.svrCore.MIME.AbstractHandler
public abstract class AbstractHandler
Base class implementing Handler with nearly all methods returning default values. This makes implementation of a new concrete handler as easy as possible.
The concrete implementation must provide getExhibitType().
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface org.hd.d.pg2k.svrCore.MIME.Handler |
|---|
Handler.ThumbnailParams |
| Field Summary |
|---|
| Fields inherited from interface org.hd.d.pg2k.svrCore.MIME.Handler |
|---|
TAG_NAME_METADATA_TOP |
| Constructor Summary | |
|---|---|
AbstractHandler()
|
|
| 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)
Efficiently get X,Y pixel dimensions of an image exhibit, else null if dimensions cannot be computed. |
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; null if not possible. |
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 constained above and below by size; null if not possible. |
ExhibitThumbnails |
makeThumbnails(ExhibitStaticAttr esa,
AllExhibitProperties.ExhibitDataSource eds,
AllExhibitProperties aep,
boolean unlimitedResources)
Make thumbnails/samples for the specified exhibit; null or ExhibitThumbnails.NO_THUMBNAILS if not possible. |
ExhibitThumbnails |
makeThumbnails(java.io.InputStream is,
long originalLength)
Make thumbnails/samples for the specified exhibit; null if not possible. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.hd.d.pg2k.svrCore.MIME.Handler |
|---|
getExhibitType |
| Constructor Detail |
|---|
public AbstractHandler()
| Method Detail |
|---|
public 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 work efficiently, by directly reading (opening) bytes of the exhibit passed as an input stream.
This will only work correctly if the exhibit is of the correct type, eg its magic number must already have been tested.
get2DImageDimensions in interface Handleris - the exhibit as a binary data stream
java.io.IOException - in case of problems with corrupt data
(or a broken exhibit)public boolean canMakeThumbnails()
By default, returns false, ie thumbnails cannot be made.
canMakeThumbnails in interface Handlerpublic Handler.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.
getThumbnailParams in interface Handler
public 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
makeSizeConstrainedEncodedImage in interface HandlerupperQualityBound - 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 invalid
public ExhibitThumbnails makeThumbnails(java.io.InputStream is,
long originalLength)
throws java.io.IOException
makeThumbnails in interface Handleris - 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
public ExhibitThumbnails makeThumbnails(ExhibitStaticAttr esa,
AllExhibitProperties.ExhibitDataSource eds,
AllExhibitProperties aep,
boolean unlimitedResources)
throws java.io.IOException
makeThumbnails in interface HandlerunlimitedResources - if true, the generation routine is allowed
to try to use unlimited resources (especially memory)
java.io.IOException
public 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 then 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. If at all possible, no value of the quality parameter should cause null to be returned if there is any value that can generate a valud image, and output size should not decrease at any point as the value of the quality parameter increases, else some routines such as thumbnail generation will not work well.
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.
makeImageBinary in interface HandlerimageIn - source image; must not be null and must be suitable
for the target formatquality - hint as to how good to make the target image
in norminal range [0-100];
anything above 100 (eg Integer.MAX_VALUE) indicates maximum quality
java.io.IOException
public java.awt.image.BufferedImage decodeImage(java.io.InputStream is)
throws java.io.IOException
By default, returns null.
decodeImage in interface Handlerjava.io.IOException
public org.w3c.dom.Node getMetadata(java.io.InputStream is,
Name.ExhibitFull exhibitName)
getMetadata in interface Handleris - input stream; never nullexhibitName - TODO
|
DHD Multimedia Gallery V1.60.69 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||