Class Anchor

  • All Implemented Interfaces:
    Element, TextElementArray, java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<Element>, java.util.Collection<Element>, java.util.List<Element>, java.util.RandomAccess

    public class Anchor
    extends Phrase
    An Anchor can be a reference or a destination of a reference.

    An Anchor is a special kind of Phrase. It is constructed in the same way.

    Example:

     Anchor anchor = new Anchor("this is a link");
     anchor.setName("LINK");
     anchor.setReference("http://www.lowagie.com");
     
    See Also:
    Element, Phrase, Serialized Form
    • Field Detail

      • name

        protected java.lang.String name
        This is the name of the Anchor.
      • reference

        protected java.lang.String reference
        This is the reference of the Anchor.
    • Constructor Detail

      • Anchor

        public Anchor()
        Constructs an Anchor without specifying a leading.
      • Anchor

        public Anchor​(float leading)
        Constructs an Anchor with a certain leading.
        Parameters:
        leading - the leading
      • Anchor

        public Anchor​(Chunk chunk)
        Constructs an Anchor with a certain Chunk.
        Parameters:
        chunk - a Chunk
      • Anchor

        public Anchor​(java.lang.String string)
        Constructs an Anchor with a certain String.
        Parameters:
        string - a String
      • Anchor

        public Anchor​(java.lang.String string,
                      Font font)
        Constructs an Anchor with a certain String and a certain Font.
        Parameters:
        string - a String
        font - a Font
      • Anchor

        public Anchor​(float leading,
                      Chunk chunk)
        Constructs an Anchor with a certain Chunk and a certain leading.
        Parameters:
        leading - the leading
        chunk - a Chunk
      • Anchor

        public Anchor​(float leading,
                      java.lang.String string)
        Constructs an Anchor with a certain leading and a certain String.
        Parameters:
        leading - the leading
        string - a String
      • Anchor

        public Anchor​(float leading,
                      java.lang.String string,
                      Font font)
        Constructs an Anchor with a certain leading, a certain String and a certain Font.
        Parameters:
        leading - the leading
        string - a String
        font - a Font
      • Anchor

        public Anchor​(Phrase phrase)
        Constructs an Anchor with a certain Phrase.
        Parameters:
        phrase - a Phrase
    • Method Detail

      • process

        public boolean process​(ElementListener listener)
        Processes the element by adding it (or the different parts) to an ElementListener.
        Specified by:
        process in interface Element
        Overrides:
        process in class Phrase
        Parameters:
        listener - an ElementListener
        Returns:
        true if the element was processed successfully
      • getChunks

        public java.util.List<Chunk> getChunks()
        Gets all the chunks in this element.
        Specified by:
        getChunks in interface Element
        Overrides:
        getChunks in class Phrase
        Returns:
        an ArrayList
      • applyAnchor

        protected boolean applyAnchor​(Chunk chunk,
                                      boolean notGotoOK,
                                      boolean localDestination)
        Applies the properties of the Anchor to a Chunk.
        Parameters:
        chunk - the Chunk (part of the Anchor)
        notGotoOK - if true, this chunk will determine the local destination
        localDestination - true if the chunk is a local goto and the reference a local destination
        Returns:
        the value of notGotoOK or false, if a previous Chunk was used to determine the local destination
      • type

        public int type()
        Gets the type of the text element.
        Specified by:
        type in interface Element
        Overrides:
        type in class Phrase
        Returns:
        a type
      • setName

        public void setName​(java.lang.String name)
        Sets the name of this Anchor.
        Parameters:
        name - a new name
      • setReference

        public void setReference​(java.lang.String reference)
        Sets the reference of this Anchor.
        Parameters:
        reference - a new reference
      • getName

        public java.lang.String getName()
        Returns the name of this Anchor.
        Returns:
        a name
      • getReference

        public java.lang.String getReference()
        Gets the reference of this Anchor.
        Returns:
        a reference
      • getUrl

        public java.net.URL getUrl()
        Gets the reference of this Anchor.
        Returns:
        an URL