Class 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) and setLastLineEnding(java.lang.String) methods - these are ignored for the other types, which may be filled, stroked or both depending on the LineColor and FillColor of the line.

    The list of valid line endings is:

    NoneNo line ending (the default)
    SquareA Square filled with the annotations fill color, if any
    CircleA Circle filled with the annotations fill color, if any
    DiamondA Diamond filled with the annotations fill color, if any
    OpenArrowTwo short lines meeting in an acute angle to form an open arrowhead
    ClosedArrowTwo 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
    ButtA short line at the endpoint perpendicular to the line itself
    ROpenArrowTwo short lines in the reverse direction from OpenArrow
    RClosedArrowA triangular closed arrowhead in the reverse direction from ClosedArrow
    SlashA short line at the endpoint approximately 30 degrees clockwise from perpendicular to the line itself
    Since:
    2.11.7
    • Constructor Detail

      • AnnotationShape

        public AnnotationShape()
        Create a new AnnotationShape. The setShape() 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 calling setShape()
        Parameters:
        shape - the shape of this annotation
        See Also:
        setShape(java.awt.Shape)
    • 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 by setStyle()
      • 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 class PDFAnnotation
      • 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 key
        tokens - the token sequence, eg "true" or "/foo" or "[/Foo/Bar]". No refs, just direct objects.
      • clone

        protected java.lang.Object clone()
        Overrides:
        clone in class java.lang.Object