org.icepdf.core.pobjects
Class Stream

java.lang.Object
  extended by org.icepdf.core.pobjects.Dictionary
      extended by org.icepdf.core.pobjects.Stream
Direct Known Subclasses:
Appearance, Form, ObjectStream, TilingPattern

public class Stream
extends Dictionary

The Stream class is responsible for decoding stream contents and returning either an images object or a byte array depending on the content. The Stream object worker method is decode which is responsible for decoding the content stream, which is if the first step of the rendering process. Once a Stream is decoded it is either returned as an image object or a byte array that is then processed further by the ContentParser.

Since:
1.0

Field Summary
 
Fields inherited from class org.icepdf.core.pobjects.Dictionary
entries, inited, isDeleted, isNew, library, SUBTYPE_KEY, TYPE_KEY
 
Constructor Summary
Stream(Library library, java.util.Hashtable entries)
          Creates a new instance of a Dictionary.
Stream(Library l, java.util.Hashtable h, SeekableInputConstrainedWrapper streamInputWrapper)
          Create a new instance of a Stream.
 
Method Summary
 void dispose(boolean cache)
          Despose of references to images and decoded byte streams.
 boolean getBlackIs1(Library library, java.util.Hashtable decodeParmsDictionary)
           
 java.lang.Boolean getBlackIs1OrNull(Library library, java.util.Hashtable decodeParmsDictionary)
          If BlackIs1 was not specified, then return null, instead of the default value of false, so we can tell if it was given or not
 byte[] getBytes()
          Gets the decoded Byte stream of the Stream object.
 java.awt.image.BufferedImage getImage(java.awt.Color fill, Resources resources, boolean allowScaling)
          Gets the image object for the given resource.
 java.io.InputStream getInputStreamForDecodedStreamBytes()
          Utility method for decoding the byte stream using the decode algorithem specified by the filter parameter

The memory manger is called every time a stream is being decoded with an estimated size of the decoded stream.

 Reference getPObjectReference()
          Gets the parent PObject reference for this stream.
 SeekableInputConstrainedWrapper getStreamInput()
          Allow access to seakable intput so that pattern object can be corrrectly created.
 boolean isImageMask()
          Does the image have an ImageMask.
 boolean isInlineImage()
           
 void setInlineImage(boolean inlineImage)
          Marks this stream as being constructed from an inline image definition in a content stream
 void setPObjectReference(Reference reference)
          Sets the PObject referece for this stream.
 java.lang.String toString()
          Return a string description of the object.
 
Methods inherited from class org.icepdf.core.pobjects.Dictionary
getEntries, getFloat, getInt, getLibrary, getNumber, getObject, getObject, init, isDeleted, isNew, setDeleted, setNew
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Stream

public Stream(Library l,
              java.util.Hashtable h,
              SeekableInputConstrainedWrapper streamInputWrapper)
Create a new instance of a Stream.

Parameters:
l - library containing a hash of all document objects
h - hashtable of parameters specific to the Stream object.
streamInputWrapper - Accessor to stream byte data

Stream

public Stream(Library library,
              java.util.Hashtable entries)
Creates a new instance of a Dictionary.

Parameters:
library - document library.
entries - dictionary entries.
Method Detail

setPObjectReference

public void setPObjectReference(Reference reference)
Sets the PObject referece for this stream. The reference number and generation is need by the encryption algorithm.

Overrides:
setPObjectReference in class Dictionary
Parameters:
reference - Reference used to identify this Dictionary in the PDF document.
See Also:
Dictionary.getPObjectReference()

getPObjectReference

public Reference getPObjectReference()
Gets the parent PObject reference for this stream.

Overrides:
getPObjectReference in class Dictionary
Returns:
Reference number of parent PObject.
See Also:
setPObjectReference(org.icepdf.core.pobjects.Reference)

setInlineImage

public void setInlineImage(boolean inlineImage)
Marks this stream as being constructed from an inline image definition in a content stream

Parameters:
inlineImage - true indicate inline image.

isInlineImage

public boolean isInlineImage()
Returns:
Whether this stream was constructed from an inline image definition in a content stream

getInputStreamForDecodedStreamBytes

public java.io.InputStream getInputStreamForDecodedStreamBytes()
Utility method for decoding the byte stream using the decode algorithem specified by the filter parameter

The memory manger is called every time a stream is being decoded with an estimated size of the decoded stream. Because many of the Filter algorithms use compression, further research must be done to try and find the average amount of memory used by each of the algorithms.

Returns:
inputstream that has been decoded as defined by the streams filters.

dispose

public void dispose(boolean cache)
Despose of references to images and decoded byte streams. Memory optimization


getBytes

public byte[] getBytes()
Gets the decoded Byte stream of the Stream object.

Returns:
decoded Byte stream

getImage

public java.awt.image.BufferedImage getImage(java.awt.Color fill,
                                             Resources resources,
                                             boolean allowScaling)
Gets the image object for the given resource. This method can optionally scale an image to reduce the total memory foot print or to increase the perceived render quality on screen at low zoom levels.

Parameters:
fill - color value of image
resources - resouces containing image reference
allowScaling - true indicates that the image will be scaled, fals no scaling.
Returns:
new image object

isImageMask

public boolean isImageMask()
Does the image have an ImageMask.


getBlackIs1

public boolean getBlackIs1(Library library,
                           java.util.Hashtable decodeParmsDictionary)

getBlackIs1OrNull

public java.lang.Boolean getBlackIs1OrNull(Library library,
                                           java.util.Hashtable decodeParmsDictionary)
If BlackIs1 was not specified, then return null, instead of the default value of false, so we can tell if it was given or not


getStreamInput

public SeekableInputConstrainedWrapper getStreamInput()
Allow access to seakable intput so that pattern object can be corrrectly created.

Returns:
stream istnaces SeekableInputConstrainedWrapper

toString

public java.lang.String toString()
Return a string description of the object. Primarly used for debugging.

Overrides:
toString in class Dictionary
Returns:
dictionary values.