|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.foray.graphic.Graphic4a
public abstract class Graphic4a
Abstract base class for graphics.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.axsl.graphic.Graphic |
---|
org.axsl.graphic.Graphic.Compression, org.axsl.graphic.Graphic.Type |
Field Summary | |
---|---|
static byte |
BIT_DEPTH_4
The bit depth (bits per pixel) for a 4-bit image. |
static byte |
BIT_DEPTH_COLOR
The bit depth (bits per pixel) for a typical 3-channel color image. |
static byte |
BIT_DEPTH_GRAYSCALE
The bit depth (bits per pixel) for an 8-bit image. |
static byte |
BIT_DEPTH_MONOCHROME
The bit depth (bits per pixel) for a monochrome image. |
Constructor Summary | |
---|---|
Graphic4a(GraphicServer4a server,
URL url,
BufferedInputStream bis)
Constructor. |
Method Summary | |
---|---|
int |
absoluteHeight(int pixelsPerInch)
|
abstract int |
absoluteHeightReal()
Returns the absolute height, in millipoints, of the graphic. |
int |
absoluteWidth(int pixelsPerInch)
|
abstract int |
absoluteWidthReal()
Returns the absolute width, in millipoints, of the graphic. |
boolean |
canMakeGraphicOutput(String mimeType)
|
void |
close()
|
int |
getBitDepth()
Returns the bit depth for this graphic. |
int |
getBitsPerComponent()
|
byte[] |
getContent()
|
int |
getContentSize()
|
org.axsl.graphic.output.GraphicOutput |
getGraphicOutput(String mimeType)
|
InputStream |
getInputStream()
Returns the input stream for this file. |
GraphicLink4a[] |
getLinks()
Returns the links associated with this graphic. |
org.apache.commons.logging.Log |
getLogger()
Returns the logger. |
ColorSpace |
getRawColorSpace()
Returns the color space without throwing any exceptions. |
GraphicServer4a |
getServer()
Return the server. |
URL |
getUrl()
|
boolean |
isImageLoaded()
Indicates whether the image has been loaded. |
boolean |
isValid()
Indicates whether this graphic is valid. |
protected abstract void |
loadImage()
Load image data and initialize its properties. |
protected void |
loadImageWrapper()
Wrapper for the loadImage method which takes care of some housekeeping chores before and after. |
protected int |
maxBytesToParseBasics()
Tells parseBasicsWrapper() how large to set the
readlimit value when marking the beginning of the stream,
so that is can be reused. |
protected abstract void |
parseBasics()
This abstract method is implemented in subclasses to initiate parsing of enough of the image for it to be used in layout. |
protected void |
parseBasicsWrapper()
This method handles some of the common housekeeping work for parseBasics() so that it can focus on parsing. |
protected void |
setBasicsParsed(boolean basicsParsed)
Allows subclasses to set the "basics parsed" flag if they have already parsed the basics. |
void |
setBitDepth(int bitDepth)
Sets the bit depth for this graphic. |
void |
setContent(byte[] content)
Sets the content for this graphic. |
void |
setImageLoaded(boolean imageLoaded)
Sets the "image loaded" value. |
void |
setInputStream(InputStream inputStream)
Sets the input stream for this file. |
protected void |
setLinks(GraphicLink4a[] links)
Sets the links for this graphic. |
void |
setValid(boolean isValid)
Sets the validity of this graphic. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.axsl.graphic.Graphic |
---|
getColorSpace, getCompressionType, getGraphicType, getMimeType, getName, getRawSamples, getTransparentColor, isInverted, isTransparent, pixelHeight, pixelWidth |
Field Detail |
---|
public static final byte BIT_DEPTH_MONOCHROME
public static final byte BIT_DEPTH_4
public static final byte BIT_DEPTH_GRAYSCALE
public static final byte BIT_DEPTH_COLOR
Constructor Detail |
---|
public Graphic4a(GraphicServer4a server, URL url, BufferedInputStream bis)
server
- The parent graphic server.url
- The URL which contains the graphic content.bis
- The reusable input stream containing the bytes from url
.Method Detail |
---|
public URL getUrl()
getUrl
in interface org.axsl.graphic.Graphic
public int getBitsPerComponent() throws org.axsl.graphic.GraphicException
getBitsPerComponent
in interface org.axsl.graphic.Graphic
org.axsl.graphic.GraphicException
public byte[] getContent() throws org.axsl.graphic.GraphicException
getContent
in interface org.axsl.graphic.Graphic
org.axsl.graphic.GraphicException
public int getContentSize() throws org.axsl.graphic.GraphicException
getContentSize
in interface org.axsl.graphic.Graphic
org.axsl.graphic.GraphicException
public void close()
close
in interface org.axsl.graphic.Graphic
protected void loadImageWrapper() throws org.axsl.graphic.GraphicException
org.axsl.graphic.GraphicException
- For errors during load of image.protected abstract void loadImage() throws org.axsl.graphic.GraphicException
org.axsl.graphic.GraphicException
- an error occured during loadingpublic org.apache.commons.logging.Log getLogger()
protected void parseBasicsWrapper() throws org.axsl.graphic.GraphicException
This method handles some of the common housekeeping work for
parseBasics()
so that it can focus on parsing. Specifically,
this method is responsible to:
basicsParsed
flag, and exit the parsing
if it has already been done.
bis
to byte 0, and
mark it so that it can be reset after parsing. For this to work
correctly, the related GraphicFactory instance must return the correct
value at GraphicFactory.maxBytesToVerify()
.bis
to byte 0 in
preparation for future use. For this to work correctly, this instance
must return the correct value at maxBytesToParseBasics()
.basicsParsed
to true.
org.axsl.graphic.GraphicException
- For any unrecoverable problems during parsing.protected abstract void parseBasics() throws IOException
This abstract method is implemented in subclasses to initiate parsing of enough of the image for it to be used in layout. This method is responsible to:
Graphic.pixelWidth()
Graphic.pixelHeight()
The housekeeping work related to resetting the buffer, handling IOExceptions, and managing whether this method should be run are handled elsewhere. In short, this method does not need to address the details handled there.
IOException
- For IO errors during reading of the file.protected int maxBytesToParseBasics()
parseBasicsWrapper()
how large to set the
readlimit
value when marking the beginning of the stream,
so that is can be reused.
The default value is 1024. Subclasses that need to read more than this
amount when parsing the basics from the stream should override this
method and return a higher amount. Otherwise, subsequent attempts to
use the stream will result in i/o errors.
public final int absoluteWidth(int pixelsPerInch) throws org.axsl.graphic.GraphicException
absoluteWidth
in interface org.axsl.graphic.Graphic
org.axsl.graphic.GraphicException
public abstract int absoluteWidthReal() throws org.axsl.graphic.GraphicException
org.axsl.graphic.GraphicException
- For errors during reading of image file.public final int absoluteHeight(int pixelsPerInch) throws org.axsl.graphic.GraphicException
absoluteHeight
in interface org.axsl.graphic.Graphic
org.axsl.graphic.GraphicException
public abstract int absoluteHeightReal() throws org.axsl.graphic.GraphicException
org.axsl.graphic.GraphicException
- For errors during reading of image file.public GraphicServer4a getServer()
public boolean isValid()
public void setValid(boolean isValid)
isValid
- The new validity value.public boolean isImageLoaded()
public void setImageLoaded(boolean imageLoaded)
imageLoaded
- The new "image loaded" value.public void setContent(byte[] content)
content
- The new content.public void setBitDepth(int bitDepth)
bitDepth
- The new bit depth.public int getBitDepth()
public ColorSpace getRawColorSpace()
Graphic.getColorSpace()
public InputStream getInputStream()
public void setInputStream(InputStream inputStream)
inputStream
- The new input stream.protected void setBasicsParsed(boolean basicsParsed)
basicsParsed
- Set to true to indicate that the basics have already
been parsed and do not need to be parsed again.public GraphicLink4a[] getLinks()
getLinks
in interface org.axsl.graphic.Graphic
protected void setLinks(GraphicLink4a[] links)
links
- The new array of links for this graphic.public org.axsl.graphic.output.GraphicOutput getGraphicOutput(String mimeType)
getGraphicOutput
in interface org.axsl.graphic.Graphic
public boolean canMakeGraphicOutput(String mimeType)
canMakeGraphicOutput
in interface org.axsl.graphic.Graphic
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |