com.qoppa.pdf.annotations
Class AnnotationFactory

java.lang.Object
  extended bycom.qoppa.pdf.annotations.AnnotationFactory

public class AnnotationFactory
extends Object


Constructor Summary
AnnotationFactory()
           
 
Method Summary
static Callout createCallout(String contents)
           
static Circle createCircle(String contents)
          Constructs a circle annotation with the given content.
static FileAttachment createFileAttachment()
          Creates an empty file attachment object.
static FileAttachment createFileAttachment(byte[] fileContents, String fileName, String popupText)
          Constructs a file attachment annotation.
static FileAttachment createFileAttachment(File attachFile, String popupText)
          Convenience constructor to create a file attachment from a file system file.
static FileAttachment createFileAttachment(InputStream inStream, String fileName, String popupText)
          Creates a file attachment from an input stream.
static FreeText createFreeText(String contents)
          Constructs a free text annotation with the give content.
static Ink createInk(String contents, Vector polyLines)
          Constructs an Ink annotation.
static Line createLine(String contents, double x1, double y1, double x2, double y2)
          Constructs a line annotation with the given content.
static Line createLine(String contents, double x1, double y1, double x2, double y2, String intent)
          Constructs a line annotation with the given content and intent.
static Link createLink()
          Constructs a Link annotation.
static MarkUpText createMarkupText(String contents, Vector quadList, String subtype)
          Constructs a new MarkupText annotation.
static Polygon createPolygon(String contents, Vector vertices, String intent)
          Constructs a polygon annotation.
static Polyline createPolyline(String contents, Vector vertices, String intent)
          Constructs a polyline annotation.
static Popup createPopup(boolean initalOpen)
          Constructs a popup annotation with the given open flag.
static RubberStamp createRubberStamp(Image image)
          Constructs a rubber stamp annotation with the given image.
static RubberStamp createRubberStamp(String text, Color color)
          Construct a rubber stamp annotation with custom text and custom color.
static Sound createSound(AudioFormat format, byte[] content)
          Constructs a sound annotation from an AudioFormat object and an array of bytes containing the audio content.
static Sound createSound(AudioInputStream audioStream)
          Constructs a sound annotation from an AudioInputStream object.
static Square createSquare(String contents)
          Constructs a square annotation with the given content.
static Text createText(String contents, boolean initialOpen, String iconName)
          Construct a Text annotation.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnnotationFactory

public AnnotationFactory()
Method Detail

createFreeText

public static FreeText createFreeText(String contents)
Constructs a free text annotation with the give content. Use setBounds() to set the position and size of the text box on the page.

Parameters:
contents - The text content.

createCircle

public static Circle createCircle(String contents)
Constructs a circle annotation with the given content. Call Circle.setBounds() to set the bounds of the circle, the circle will be drawn so that it fits entirely within the bounds..

Parameters:
contents - The text contents to display when the annotation is opened.

createCallout

public static Callout createCallout(String contents)

createFileAttachment

public static FileAttachment createFileAttachment(byte[] fileContents,
                                                  String fileName,
                                                  String popupText)
                                           throws IOException
Constructs a file attachment annotation. The entire contents of the file are passed in the fileContents array.

Parameters:
fileContents - The binary contents of the file.
fileName - The name of the file.
popupText - The popup text to display when the mouse hovers over the annotation.
Throws:
IOException

createFileAttachment

public static FileAttachment createFileAttachment(File attachFile,
                                                  String popupText)
                                           throws IOException
Convenience constructor to create a file attachment from a file system file.

Parameters:
attachFile - The file to attach. The constructor reads the contents of the file into memory.
popupText - The popup text to display when the mouse hovers over the annotation.
Throws:
IOException

createFileAttachment

public static FileAttachment createFileAttachment(InputStream inStream,
                                                  String fileName,
                                                  String popupText)
                                           throws IOException
Creates a file attachment from an input stream. The method will read the contents of the input stream at the time that it is called.

Parameters:
inStream - The input stream to get the file attachment contents from.
fileName - The name of the file.
popupText - The popup text to display when the mouse hovers over the annotation.
Returns:
A FileAttachment object
Throws:
IOException - Thrown when there is any errors reading the input stream.

createFileAttachment

public static FileAttachment createFileAttachment()
Creates an empty file attachment object.

Returns:
A new, empty, file attachment object.

createInk

public static Ink createInk(String contents,
                            Vector polyLines)
Constructs an Ink annotation.

Parameters:
contents - The text contents to display when the annotation is opened.
polyLines - a Vector of polylines. Each element in the Vector is another Vector containing a list of points to compose a polyline.

createLine

public static Line createLine(String contents,
                              double x1,
                              double y1,
                              double x2,
                              double y2)
Constructs a line annotation with the given content.

Parameters:
contents - The text contents to display when the annotation is opened.
x1 - The x coordinate of the origin of the line.
y1 - The y coordinate of the origin of the line.
x2 - The x coordinate of the end point of the line.
y2 - The y coordinate of the end point of the line.

createLine

public static Line createLine(String contents,
                              double x1,
                              double y1,
                              double x2,
                              double y2,
                              String intent)
Constructs a line annotation with the given content and intent.

Parameters:
contents - The text contents to display when the annotation is opened.
x1 - The x coordinate of the origin of the line.
y1 - The y coordinate of the origin of the line.
x2 - The x coordinate of the end point of the line.
y2 - The y coordinate of the end point of the line.
intent - The line's "intent", this can be one of the following values: null, Line.LINE_ARROW, Line.LINE_DIMENSION.

createLink

public static Link createLink()
Constructs a Link annotation.


createMarkupText

public static MarkUpText createMarkupText(String contents,
                                          Vector quadList,
                                          String subtype)
Constructs a new MarkupText annotation. There are 4 types of markup annotations: text highlight, text underline, text cross-out or strike-out and text squiggly underline.

Parameters:
contents - The text contents to display when the annotation is opened.
quadList - The new list of quadrilaterals that compose this annotation. Each item in the list should be an array of 4 Point.Double objects.
subtype - type of the markup annotations. Possible values are Highlight, Underline, StrikeOut, Squiggly.

createPolygon

public static Polygon createPolygon(String contents,
                                    Vector vertices,
                                    String intent)
Constructs a polygon annotation.

Parameters:
contents - The text contents to display when the annotation is opened.
vertices - A Vector of points. Each element in the Vector is a point to compose a polygon.

createPolyline

public static Polyline createPolyline(String contents,
                                      Vector vertices,
                                      String intent)
Constructs a polyline annotation.

Parameters:
contents - The text contents to display when the annotation is opened.
vertices - A Vector of points. Each element in the Vector is a point to compose a polyline.

createPopup

public static Popup createPopup(boolean initalOpen)
Constructs a popup annotation with the given open flag.

Parameters:
initalOpen - Flag indicating whether this annotation should be displayed open initially.

createRubberStamp

public static RubberStamp createRubberStamp(Image image)
Constructs a rubber stamp annotation with the given image.

Parameters:
image - a java image

createRubberStamp

public static RubberStamp createRubberStamp(String text,
                                            Color color)
Construct a rubber stamp annotation with custom text and custom color.

Parameters:
text - the text to display in the stamp
color - the color of the text

createSound

public static Sound createSound(AudioFormat format,
                                byte[] content)
Constructs a sound annotation from an AudioFormat object and an array of bytes containing the audio content.

Parameters:
format - The format of the audio.
content - The audio content.

createSound

public static Sound createSound(AudioInputStream audioStream)
                         throws IOException
Constructs a sound annotation from an AudioInputStream object.

Parameters:
audioStream - The audio stream
Returns:
The new sound annotation
Throws:
IOException

createSquare

public static Square createSquare(String contents)
Constructs a square annotation with the given content. Call Square.setBounds() to set the bounds of the square.

Parameters:
contents - The text contents to display when the annotation is opened.

createText

public static Text createText(String contents,
                              boolean initialOpen,
                              String iconName)
Construct a Text annotation.

Parameters:
contents - The textual content.
initialOpen - Flag indicating whether this annotation should be displayed open initially.
iconName - The name of the icon to use when displaying the annotation in its un-opened mode. Please use one of the constants defined in this class (ICON_XXXX) to set the name of the icon.