Class TextFragment

  • All Implemented Interfaces:
    java.lang.Iterable<Glyph>, java.util.Collection<Glyph>, java.util.List<Glyph>

    public class TextFragment
    extends NativeObject
    implements java.util.List<Glyph>

    Text Fragment

    A TextElement contains an arbitrary number of text fragments. Text can be partitioned arbibrarily into fragments without respecting word boundaries or reading order.

    A text fragment provides iteration over all contained Glyphs. Removing, clearing, adding, and sub-ranges are not supported. While iterating, a CorruptException may be generated if the text fragment contains glyphs with inconsistent Unicode information.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(int index, Glyph element)
      Not supported.
      boolean add​(Glyph element)
      Not supported.
      boolean addAll​(int index, java.util.Collection<? extends Glyph> elements)
      Not supported.
      boolean addAll​(java.util.Collection<? extends Glyph> elements)
      Not supported.
      void clear()
      Not supported.
      boolean contains​(java.lang.Object object)  
      boolean containsAll​(java.util.Collection<?> objects)  
      Glyph get​(int index)  
      Rectangle getBoundingBox()
      the bounding box (Getter)
      double getCharacterSpacing()
      The additional spacing between glyphs (Getter)
      Fill getFill()
      This text fragment's parameters for filling the text or null if the text is not filled
      Font getFont()
      The font (Getter)
      double getFontSize()
      The font size (Getter)
      double getHorizontalScaling()
      The horizontal scaling factor (Getter)
      double getRise()
      The rise of the baseline (Getter)
      Stroke getStroke()
      This text fragment's parameters for stroking the text or null if the text is not stroked
      java.lang.String getText()
      The string painted by this text fragment
      AffineTransform getTransform()
      the transform to be applied to the bounding box rectangle (Getter)
      double getWordSpacing()
      The additional spacing between words (Getter)
      WritingMode getWritingMode()
      The writing direction (Getter)
      int indexOf​(java.lang.Object obj)  
      boolean isEmpty()  
      java.util.Iterator<Glyph> iterator()  
      int lastIndexOf​(java.lang.Object obj)  
      java.util.ListIterator<Glyph> listIterator()  
      java.util.ListIterator<Glyph> listIterator​(int index)  
      Glyph remove​(int index)  
      boolean remove​(java.lang.Object object)  
      boolean removeAll​(java.util.Collection<?> objects)  
      boolean retainAll​(java.util.Collection<?> objects)  
      Glyph set​(int index, Glyph element)
      Not supported.
      int size()  
      java.util.List<Glyph> subList​(int fromIndex, int toIndex)  
      java.lang.Object[] toArray()  
      <T> T[] toArray​(T[] array)  
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        parallelStream, removeIf, stream, toArray
      • Methods inherited from interface java.lang.Iterable

        forEach
      • Methods inherited from interface java.util.List

        equals, hashCode, replaceAll, sort, spliterator
    • Method Detail

      • getBoundingBox

        public Rectangle getBoundingBox()

        the bounding box (Getter)

        This is a rectangle that encompasses all parts of the text fragment.
        Throws:
        java.lang.IllegalStateException - the object has already been closed
      • getTransform

        public AffineTransform getTransform()

        the transform to be applied to the bounding box rectangle (Getter)

        Use this transform matrix to compute the actual location of the text fragment's bounding box.
        Throws:
        java.lang.IllegalStateException - the object has already been closed
      • getText

        public java.lang.String getText()
        The string painted by this text fragment
        Throws:
        java.lang.IllegalStateException - the object has already been closed
      • getStroke

        public Stroke getStroke()
        This text fragment's parameters for stroking the text or null if the text is not stroked
        Throws:
        java.lang.IllegalStateException - the object has already been closed
      • getFill

        public Fill getFill()
        This text fragment's parameters for filling the text or null if the text is not filled
        Throws:
        java.lang.IllegalStateException - the object has already been closed
      • getFontSize

        public double getFontSize()

        The font size (Getter)

        Throws:
        java.lang.IllegalStateException - the object has already been closed
      • getCharacterSpacing

        public double getCharacterSpacing()

        The additional spacing between glyphs (Getter)

        When the glyph for each character in the text is rendered, the character spacing is added to the horizontal or vertical component of the glyph's displacement, depending on the writing mode. It is subject to scaling by the horizontal scaling if the writing mode is horizontal.
        Throws:
        java.lang.IllegalStateException - the object has already been closed
      • getWordSpacing

        public double getWordSpacing()

        The additional spacing between words (Getter)

        Word spacing works the same way as character spacing, but applies only to the space character, code 32.
        Throws:
        java.lang.IllegalStateException - the object has already been closed
      • getHorizontalScaling

        public double getHorizontalScaling()

        The horizontal scaling factor (Getter)

        The horizontal scaling parameter adjusts the width of glyphs by stretching or compressing them in the horizontal direction. Its value is specified relative to the normal width of the glyphs, with 1 being the normal width.
        Throws:
        java.lang.IllegalStateException - the object has already been closed
      • getRise

        public double getRise()

        The rise of the baseline (Getter)

        The text rise specifies the distance to move the baseline up or down from its default location. Positive values of text rise move the baseline up. Adjustments to the baseline are useful for drawing superscripts or subscripts.
        Throws:
        java.lang.IllegalStateException - the object has already been closed
      • getWritingMode

        public WritingMode getWritingMode()

        The writing direction (Getter)

        This is the writing mode for the text fragment. It applies to all contained Glyphs.
        Throws:
        java.lang.IllegalStateException - the object has already been closed
      • addAll

        public boolean addAll​(java.util.Collection<? extends Glyph> elements)
        Not supported.
        Specified by:
        addAll in interface java.util.Collection<Glyph>
        Specified by:
        addAll in interface java.util.List<Glyph>
      • addAll

        public boolean addAll​(int index,
                              java.util.Collection<? extends Glyph> elements)
        Not supported.
        Specified by:
        addAll in interface java.util.List<Glyph>
      • contains

        public boolean contains​(java.lang.Object object)
        Specified by:
        contains in interface java.util.Collection<Glyph>
        Specified by:
        contains in interface java.util.List<Glyph>
      • containsAll

        public boolean containsAll​(java.util.Collection<?> objects)
        Specified by:
        containsAll in interface java.util.Collection<Glyph>
        Specified by:
        containsAll in interface java.util.List<Glyph>
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Collection<Glyph>
        Specified by:
        isEmpty in interface java.util.List<Glyph>
      • iterator

        public java.util.Iterator<Glyph> iterator()
        Specified by:
        iterator in interface java.util.Collection<Glyph>
        Specified by:
        iterator in interface java.lang.Iterable<Glyph>
        Specified by:
        iterator in interface java.util.List<Glyph>
      • listIterator

        public java.util.ListIterator<Glyph> listIterator()
        Specified by:
        listIterator in interface java.util.List<Glyph>
      • listIterator

        public java.util.ListIterator<Glyph> listIterator​(int index)
        Specified by:
        listIterator in interface java.util.List<Glyph>
      • remove

        public boolean remove​(java.lang.Object object)
        Specified by:
        remove in interface java.util.Collection<Glyph>
        Specified by:
        remove in interface java.util.List<Glyph>
      • removeAll

        public boolean removeAll​(java.util.Collection<?> objects)
        Specified by:
        removeAll in interface java.util.Collection<Glyph>
        Specified by:
        removeAll in interface java.util.List<Glyph>
      • retainAll

        public boolean retainAll​(java.util.Collection<?> objects)
        Specified by:
        retainAll in interface java.util.Collection<Glyph>
        Specified by:
        retainAll in interface java.util.List<Glyph>
      • subList

        public java.util.List<Glyph> subList​(int fromIndex,
                                             int toIndex)
        Specified by:
        subList in interface java.util.List<Glyph>
      • toArray

        public java.lang.Object[] toArray()
        Specified by:
        toArray in interface java.util.Collection<Glyph>
        Specified by:
        toArray in interface java.util.List<Glyph>
      • toArray

        public <T> T[] toArray​(T[] array)
        Specified by:
        toArray in interface java.util.Collection<Glyph>
        Specified by:
        toArray in interface java.util.List<Glyph>
      • size

        public int size()
        Specified by:
        size in interface java.util.Collection<Glyph>
        Specified by:
        size in interface java.util.List<Glyph>
      • clear

        public void clear()
        Not supported.
        Specified by:
        clear in interface java.util.Collection<Glyph>
        Specified by:
        clear in interface java.util.List<Glyph>
      • indexOf

        public int indexOf​(java.lang.Object obj)
        Specified by:
        indexOf in interface java.util.List<Glyph>
      • lastIndexOf

        public int lastIndexOf​(java.lang.Object obj)
        Specified by:
        lastIndexOf in interface java.util.List<Glyph>
      • add

        public boolean add​(Glyph element)
        Not supported.
        Specified by:
        add in interface java.util.Collection<Glyph>
        Specified by:
        add in interface java.util.List<Glyph>
      • add

        public void add​(int index,
                        Glyph element)
        Not supported.
        Specified by:
        add in interface java.util.List<Glyph>
      • get

        public Glyph get​(int index)
        Specified by:
        get in interface java.util.List<Glyph>
      • remove

        public Glyph remove​(int index)
        Specified by:
        remove in interface java.util.List<Glyph>
      • set

        public Glyph set​(int index,
                         Glyph element)
        Not supported.
        Specified by:
        set in interface java.util.List<Glyph>