Package org.faceless.pdf2
Class AnnotationShape
- java.lang.Object
-
- org.faceless.pdf2.PDFAnnotation
-
- org.faceless.pdf2.AnnotationShape
-
- All Implemented Interfaces:
java.lang.Cloneable
public class AnnotationShape extends PDFAnnotation
Creates an annotation based on the specified
Shape
. Any type of shape may be specified - the Annotation will be created as a Square, Circle, Line, Polygon or PolyLine depending on the type of shape.Lines and PolyLines may have their endings specified with the
setFirstLineEnding(java.lang.String)
andsetLastLineEnding(java.lang.String)
methods - these are ignored for the other types, which may be filled, stroked or both depending on theLineColor
andFillColor
of the line.The list of valid line endings is:
None No line ending (the default) Square A Square filled with the annotations fill color, if any Circle A Circle filled with the annotations fill color, if any Diamond A Diamond filled with the annotations fill color, if any OpenArrow Two short lines meeting in an acute angle to form an open arrowhead ClosedArrow Two short lines meeting in an acute angle as in the OpenArrow style and connected by a third line to form a triangular closed arrowhead filled with the annotation's fill color, if any Butt A short line at the endpoint perpendicular to the line itself ROpenArrow Two short lines in the reverse direction from OpenArrow RClosedArrow A triangular closed arrowhead in the reverse direction from ClosedArrow Slash A short line at the endpoint approximately 30 degrees clockwise from perpendicular to the line itself - Since:
- 2.11.7
-
-
Constructor Summary
Constructors Constructor Description AnnotationShape()
Create a new AnnotationShape.AnnotationShape(java.awt.Shape shape)
Create a new AnnotationShape and immediately set its shape by callingsetShape()
AnnotationShape(java.awt.Shape shape, java.lang.String end1, java.lang.String end2)
Creates a new AnnotationShape and set its shape and line-ending style.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.Object
clone()
java.lang.String
getFirstLineEnding()
Returns the line ending style for the endpoint defined by the first pair of coordinates in the shape.java.lang.String
getLastLineEnding()
Returns the line ending style for the endpoint defined by the last pair of coordinates in the shape.java.awt.Shape
getShape()
Returns the shape of this annotationPDFStyle
getStyle()
Returns the style used to draw this shape, as set bysetStyle()
void
putLiteral(java.lang.String key, java.lang.String tokens)
Put a literal token sequnce.void
rebuild()
Recreate the appearancevoid
setFirstLineEnding(java.lang.String le)
Sets the line ending style for the first endpoint.void
setLastLineEnding(java.lang.String le)
Sets the line ending style for the end of the line.void
setShape(java.awt.Shape shape)
Set the Shape of this Annotation.void
setStyle(PDFStyle style)
Sets the style used to draw this shapejava.lang.String
toString()
-
Methods inherited from class org.faceless.pdf2.PDFAnnotation
addPropertyChangeListener, addReview, flatten, getAction, getAssociatedFiles, getAuthor, getColor, getContents, getCreationDate, getDefaultColorSpace, getInReplyTo, getLocale, getMetaData, getModifyDate, getOpacity, getOptionalContentDescriptor, getPage, getPopup, getRectangle, getReplies, getReviews, getSubject, getType, getUniqueID, getUserData, getXMP, hasAppearanceState, isContentLocked, isPositionLocked, isPrintable, isReadOnly, isVisible, putUserData, removePropertyChangeListener, setAction, setAuthor, setColor, setContents, setCreationDate, setDefaultColorSpace, setInReplyTo, setLocale, setLocked, setMetaData, setModifyDate, setOpacity, setOptionalContentDescriptor, setPage, setPrintable, setReadOnly, setRectangle, setSubject, setUniqueID, setVisible
-
-
-
-
Constructor Detail
-
AnnotationShape
public AnnotationShape()
Create a new AnnotationShape. ThesetShape()
method must be called before any other methods on this object.
-
AnnotationShape
public AnnotationShape(java.awt.Shape shape)
Create a new AnnotationShape and immediately set its shape by callingsetShape()
- Parameters:
shape
- the shape of this annotation- See Also:
setShape(java.awt.Shape)
-
AnnotationShape
public AnnotationShape(java.awt.Shape shape, java.lang.String end1, java.lang.String end2)
Creates a new AnnotationShape and set its shape and line-ending style.- Parameters:
shape
- the shape of this annotationend1
- the style for the start of the lineend2
- the style for the end of the line- See Also:
setShape(java.awt.Shape)
,setFirstLineEnding(java.lang.String)
,setLastLineEnding(java.lang.String)
-
-
Method Detail
-
setShape
public void setShape(java.awt.Shape shape)
Set the Shape of this Annotation. The co-ordinates of the Shape are absolute page co-ordinates, measured in points from the bottom-left of the page. For example:annot.setShape(new Line2D.Float(0, 0, 100, 100));
Will add a Line annotation at the bottom-left of the page.- Parameters:
shape
- the Shape
-
getShape
public java.awt.Shape getShape()
Returns the shape of this annotation
-
getFirstLineEnding
public java.lang.String getFirstLineEnding()
Returns the line ending style for the endpoint defined by the first pair of coordinates in the shape. This is only meaningful for Line and PolyLine annotations, other types will return null.- See Also:
setFirstLineEnding(java.lang.String)
-
setFirstLineEnding
public void setFirstLineEnding(java.lang.String le)
Sets the line ending style for the first endpoint. This will be ignored if the type of the annotation is not polyline.- Parameters:
le
- the LineEnding for the start of the line- See Also:
getFirstLineEnding()
-
getLastLineEnding
public java.lang.String getLastLineEnding()
Returns the line ending style for the endpoint defined by the last pair of coordinates in the shape. This is only meaningful for polyline annotations, other types will return null.- See Also:
setLastLineEnding(java.lang.String)
-
setLastLineEnding
public void setLastLineEnding(java.lang.String le)
Sets the line ending style for the end of the line. This will be ignored if the type of the annotation is not Line or PolyLine.- Parameters:
le
- the LineEnding for the end of the line- See Also:
getLastLineEnding()
-
getStyle
public PDFStyle getStyle()
Returns the style used to draw this shape, as set bysetStyle()
-
setStyle
public void setStyle(PDFStyle style)
Sets the style used to draw this shape- Parameters:
style
- the style to use- See Also:
getStyle()
-
rebuild
public void rebuild()
Recreate the appearance- Overrides:
rebuild
in classPDFAnnotation
-
toString
public java.lang.String toString()
-
putLiteral
public void putLiteral(java.lang.String key, java.lang.String tokens)
Put a literal token sequnce. For debugging- Parameters:
key
- the keytokens
- the token sequence, eg "true" or "/foo" or "[/Foo/Bar]". No refs, just direct objects.
-
clone
protected java.lang.Object clone()
- Overrides:
clone
in classjava.lang.Object
-
-