Class AnnotationShape

  • All Implemented Interfaces:
    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
    • Method Detail

      • setShape

        public void setShape​(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 Shape getShape()
        Returns the shape of this annotation
      • getFirstLineEnding

        public 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​(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 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​(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 String toString()
      • putLiteral

        public void putLiteral​(String key,
                               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.