Class StrokingTextPainter

    • Field Detail

      • PAINT_INFO

        public static final java.text.AttributedCharacterIterator.Attribute PAINT_INFO
      • FLOW_REGIONS

        public static final java.text.AttributedCharacterIterator.Attribute FLOW_REGIONS
      • FLOW_PARAGRAPH

        public static final java.text.AttributedCharacterIterator.Attribute FLOW_PARAGRAPH
      • TEXT_COMPOUND_ID

        public static final java.text.AttributedCharacterIterator.Attribute TEXT_COMPOUND_ID
      • GVT_FONT

        public static final java.text.AttributedCharacterIterator.Attribute GVT_FONT
      • GVT_FONTS

        public static final java.text.AttributedCharacterIterator.Attribute GVT_FONTS
      • BIDI_LEVEL

        public static final java.text.AttributedCharacterIterator.Attribute BIDI_LEVEL
      • XPOS

        public static final java.text.AttributedCharacterIterator.Attribute XPOS
      • YPOS

        public static final java.text.AttributedCharacterIterator.Attribute YPOS
      • TEXTPATH

        public static final java.text.AttributedCharacterIterator.Attribute TEXTPATH
      • WRITING_MODE

        public static final java.text.AttributedCharacterIterator.Attribute WRITING_MODE
      • WRITING_MODE_TTB

        public static final java.lang.Integer WRITING_MODE_TTB
      • WRITING_MODE_RTL

        public static final java.lang.Integer WRITING_MODE_RTL
      • ANCHOR_TYPE

        public static final java.text.AttributedCharacterIterator.Attribute ANCHOR_TYPE
      • ADJUST_SPACING

        public static final java.lang.Integer ADJUST_SPACING
      • ADJUST_ALL

        public static final java.lang.Integer ADJUST_ALL
      • singleton

        protected static TextPainter singleton
        A unique instance of this class.
    • Constructor Detail

      • StrokingTextPainter

        public StrokingTextPainter()
    • Method Detail

      • getInstance

        public static TextPainter getInstance()
        Returns a unique instance of this class.
      • paint

        public void paint​(TextNode node,
                          java.awt.Graphics2D g2d)
        Paints the specified text node using the specified Graphics2D.
        Parameters:
        node - the text node to paint
        g2d - the Graphics2D to use
      • printAttrs

        protected void printAttrs​(java.text.AttributedCharacterIterator aci)
      • getTextRuns

        public java.util.List getTextRuns​(TextNode node,
                                          java.text.AttributedCharacterIterator aci)
      • computeTextRuns

        public java.util.List computeTextRuns​(TextNode node,
                                              java.text.AttributedCharacterIterator aci,
                                              java.text.AttributedCharacterIterator[] chunkACIs)
      • computeTextRuns

        protected java.util.List computeTextRuns​(TextNode node,
                                                 java.text.AttributedCharacterIterator aci,
                                                 java.text.AttributedCharacterIterator[] chunkACIs,
                                                 int[][] chunkCharMaps)
      • reorderTextRuns

        protected java.util.List reorderTextRuns​(StrokingTextPainter.TextChunk chunk,
                                                 java.util.List runs)
        Reorder text runs as required by bidi algorithm.
        Parameters:
        runs - - unordered runs
        Returns:
        reordered runs
      • getTextChunkACIs

        protected java.text.AttributedCharacterIterator[] getTextChunkACIs​(java.text.AttributedCharacterIterator aci)
        Returns an array of ACIs, one for each text chunk within the given text node.
      • createModifiedACIForFontMatching

        protected java.text.AttributedCharacterIterator createModifiedACIForFontMatching​(java.text.AttributedCharacterIterator aci)
        Returns a new AttributedCharacterIterator that contains resolved GVTFont attributes. This is then used when creating the text runs so that the text can be split on changes of font as well as tspans and trefs.
        Parameters:
        aci - The aci to be modified should already be split into text chunks.
        Returns:
        The new modified aci.
      • getTextRunBoundaryAttributes

        protected java.util.Set getTextRunBoundaryAttributes()
      • adjustChunkOffsets

        protected java.awt.geom.Point2D adjustChunkOffsets​(java.awt.geom.Point2D location,
                                                           java.util.List textRuns,
                                                           StrokingTextPainter.TextChunk chunk)
        Adjusts the position of the text runs within the specified text chunk to account for any text anchor properties.
      • paintDecorations

        protected void paintDecorations​(java.util.List textRuns,
                                        java.awt.Graphics2D g2d,
                                        int decorationType)
        Paints decorations of the specified type.
      • paintTextRuns

        protected void paintTextRuns​(java.util.List textRuns,
                                     java.awt.Graphics2D g2d)
        Paints the text in each text run. Decorations are not painted here.
      • getOutline

        public java.awt.Shape getOutline​(TextNode node)
        Get a Shape in userspace coords which defines the textnode glyph outlines.
        Parameters:
        node - the TextNode to measure
      • getBounds2D

        public java.awt.geom.Rectangle2D getBounds2D​(TextNode node)
        Get a Rectangle2D in userspace coords which encloses the textnode glyphs including stroke etc.
        Parameters:
        node - the TextNode to measure
      • getDecorationOutline

        protected java.awt.Shape getDecorationOutline​(java.util.List textRuns,
                                                      int decorationType)
        Returns the outline of the specified decoration type.
        Parameters:
        textRuns - The list of text runs to get the decoration outline for.
        decorationType - Indicates the type of decoration required. eg. underline, overline or strikethrough.
        Returns:
        The decoration outline or null if the text is not decorated.
      • getDecorationStrokeOutline

        protected java.awt.Shape getDecorationStrokeOutline​(java.util.List textRuns,
                                                            int decorationType)
        Returns the stroked outline of the specified decoration type. If the decoration has no stroke it will return the fill outline
        Parameters:
        textRuns - The list of text runs to get the decoration outline for.
        decorationType - Indicates the type of decoration required. eg. underline, overline or strikethrough.
        Returns:
        The decoration outline or null if the text is not decorated.
      • getMark

        public Mark getMark​(TextNode node,
                            int index,
                            boolean leadingEdge)
        Description copied from interface: TextPainter
        Returns a mark for the char at index in node's AttributedCharacterIterator. Leading edge indicates if the mark should be considered immediately 'before' glyph or after
      • selectFirst

        public Mark selectFirst​(TextNode node)
        Selects the first glyph in the text node.
      • selectLast

        public Mark selectLast​(TextNode node)
        Selects the last glyph in the text node.
      • getSelected

        public int[] getSelected​(Mark startMark,
                                 Mark finishMark)
        Returns an array of ints representing begin/end index pairs into an AttributedCharacterIterator which represents the text selection delineated by two Mark instances. Note: The Mark instances passed must have been instantiated by an instance of this enclosing TextPainter implementation.
      • getHighlightShape

        public java.awt.Shape getHighlightShape​(Mark beginMark,
                                                Mark endMark)
        Return a Shape, in the coordinate system of the text layout, which encloses the text selection delineated by two Mark instances. Note: The Mark instances passed must have been instantiated by an instance of this enclosing TextPainter implementation.