Class SVGTextElementBridge

    • Field Detail

      • ZERO

        protected static final java.lang.Integer ZERO
      • TEXT_COMPOUND_DELIMITER

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

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

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

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

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

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

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

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

        public static final java.text.AttributedCharacterIterator.Attribute BASELINE_SHIFT
      • laidoutText

        protected java.text.AttributedString laidoutText
      • elemTPI

        protected java.util.WeakHashMap elemTPI
      • usingComplexSVGFont

        protected boolean usingComplexSVGFont
      • endLimit

        protected int endLimit
        This is used to store the end of the last piece of text content from an element with xml:space="preserve". When we are stripping trailing spaces we need to make sure we don't strip anything before this point.
    • Constructor Detail

      • SVGTextElementBridge

        public SVGTextElementBridge()
        Constructs a new bridge for the <text> element.
    • Method Detail

      • getLocalName

        public java.lang.String getLocalName()
        Returns 'text'.
        Specified by:
        getLocalName in interface Bridge
      • getTextNode

        protected TextNode getTextNode()
      • getLocation

        protected java.awt.geom.Point2D getLocation​(BridgeContext ctx,
                                                    org.w3c.dom.Element e)
        Returns the text node location according to the 'x' and 'y' attributes of the specified text element.
        Parameters:
        ctx - the bridge context to use
        e - the text element
      • isTextElement

        protected boolean isTextElement​(org.w3c.dom.Element e)
      • isTextChild

        protected boolean isTextChild​(org.w3c.dom.Element e)
      • isComposite

        public boolean isComposite()
        Returns false as text is not a container.
        Specified by:
        isComposite in interface GraphicsNodeBridge
      • getFirstChild

        protected org.w3c.dom.Node getFirstChild​(org.w3c.dom.Node n)
        Returns the first child node of the given node that should be processed by the text bridge.
      • getNextSibling

        protected org.w3c.dom.Node getNextSibling​(org.w3c.dom.Node n)
        Returns the next sibling node of the given node that should be processed by the text bridge.
      • getParentNode

        protected org.w3c.dom.Node getParentNode​(org.w3c.dom.Node n)
        Returns the parent node of the given node that should be processed by the text bridge.
      • addTextEventListeners

        protected void addTextEventListeners​(BridgeContext ctx,
                                             NodeEventTarget e)
        Adds the DOM listeners for this text bridge.
      • removeTextEventListeners

        protected void removeTextEventListeners​(BridgeContext ctx,
                                                NodeEventTarget e)
        Removes the DOM listeners for this text bridge.
      • addContextToChild

        protected void addContextToChild​(BridgeContext ctx,
                                         org.w3c.dom.Element e)
        Add to the element children of the node, an SVGContext to support dynamic update. This is recursive, the children of the nodes are also traversed to add to the support elements their context
        Parameters:
        ctx - a BridgeContext value
        e - an Element value
        See Also:
        SVGContext, BridgeUpdateHandler
      • removeContextFromChild

        protected void removeContextFromChild​(BridgeContext ctx,
                                              org.w3c.dom.Element e)
        From the SVGContext from the element children of the node.
        Parameters:
        ctx - the BridgeContext for the document
        e - the Element whose subtree's elements will have threir SVGContexts removed
        See Also:
        SVGContext, BridgeUpdateHandler
      • handleDOMChildNodeRemovedEvent

        public void handleDOMChildNodeRemovedEvent​(MutationEvent evt)
        Invoked when an MutationEvent of type 'DOMNodeRemoved' is fired.
      • handleDOMSubtreeModifiedEvent

        public void handleDOMSubtreeModifiedEvent​(MutationEvent evt)
        Invoked when an MutationEvent of type 'DOMSubtree' is fired.
      • isParentDisplayed

        protected boolean isParentDisplayed​(org.w3c.dom.Node childNode)
        Indicate of the parent of a node is a displayed element. <title>, <desc> and <metadata> are non displayable elements.
        Returns:
        true if the parent of the node is <text>, <tspan>, <tref>, <textPath>, <a>, <altGlyph>
      • computeLaidoutText

        protected void computeLaidoutText​(BridgeContext ctx,
                                          org.w3c.dom.Element e,
                                          GraphicsNode node)
        Recompute the layout of the <text> node. Assign onto the TextNode pending to the element the new recomputed AttributedString. Also update laidoutText with the new value.
      • rebuildACI

        protected void rebuildACI()
      • buildAttributedString

        protected java.text.AttributedString buildAttributedString​(BridgeContext ctx,
                                                                   org.w3c.dom.Element element)
        Creates the attributed string which represents the given text element children.
        Parameters:
        ctx - the bridge context to use
        element - the text element
      • normalizeString

        protected java.lang.String normalizeString​(java.lang.String s,
                                                   boolean preserve,
                                                   boolean stripfirst)
        Normalizes the given string.
      • nodeAncestorOf

        protected boolean nodeAncestorOf​(org.w3c.dom.Node node1,
                                         org.w3c.dom.Node node2)
        Returns true if node1 is an ancestor of node2
      • addGlyphPositionAttributes

        protected void addGlyphPositionAttributes​(java.text.AttributedString as,
                                                  org.w3c.dom.Element element,
                                                  BridgeContext ctx)
        Adds glyph position attributes to an AttributedString.
      • addChildGlyphPositionAttributes

        protected void addChildGlyphPositionAttributes​(java.text.AttributedString as,
                                                       org.w3c.dom.Element element,
                                                       BridgeContext ctx)
      • addPaintAttributes

        protected void addPaintAttributes​(java.text.AttributedString as,
                                          org.w3c.dom.Element element,
                                          TextNode node,
                                          TextPaintInfo pi,
                                          BridgeContext ctx)
        Adds painting attributes to an AttributedString.
      • addChildPaintAttributes

        protected void addChildPaintAttributes​(java.text.AttributedString as,
                                               org.w3c.dom.Element element,
                                               TextNode node,
                                               TextPaintInfo parentPI,
                                               BridgeContext ctx)
      • getFontList

        protected java.util.List getFontList​(BridgeContext ctx,
                                             org.w3c.dom.Element element,
                                             java.util.Map result)
        This method adds all the font related properties to result It also builds a List of the GVTFonts and returns it.
      • getAttributeMap

        protected java.util.Map getAttributeMap​(BridgeContext ctx,
                                                org.w3c.dom.Element element,
                                                TextPath textPath,
                                                java.lang.Integer bidiLevel,
                                                java.util.Map result)
        Returns the map to pass to the current characters.
        Parameters:
        ctx - the BridgeContext to use for throwing exceptions
        element - the text element whose attributes are being collected
        textPath - the text path that the characters of element will be placed along
        bidiLevel - the bidi level of element
        result - a Map into which the attributes of element's characters will be stored
        Returns:
        a new Map that contains the attributes that must be inherited into a child element if the given element has no characters before the child element
      • getParentTextPaintInfo

        protected TextPaintInfo getParentTextPaintInfo​(org.w3c.dom.Element child)
        Retrieve in the AttributeString the closest parent of the node 'child' and extract the text decorations of the parent.
        Parameters:
        child - an Element value
        Returns:
        a TextDecoration value
      • getTextPaintInfo

        protected TextPaintInfo getTextPaintInfo​(org.w3c.dom.Element element,
                                                 GraphicsNode node,
                                                 TextPaintInfo parentTPI,
                                                 BridgeContext ctx)
        Constructs a TextDecoration object for the specified element. This will contain all of the decoration properties to be used when drawing the text.
      • setDecorationTextPaintInfo

        public void setDecorationTextPaintInfo​(TextPaintInfo pi,
                                               org.w3c.dom.Element element)
      • getNumberOfChars

        public int getNumberOfChars()
        Description copied from interface: SVGTextContent
        Returns the total number of characters to be rendered within the current element. Includes characters which are included via a <tref> reference.
        Specified by:
        getNumberOfChars in interface SVGTextContent
        Returns:
        Total number of characters.
      • getExtentOfChar

        public java.awt.geom.Rectangle2D getExtentOfChar​(int charnum)
        Description copied from interface: SVGTextContent
        Returns a tightest rectangle which defines the minimum and maximum X and Y values in the user coordinate system for rendering the glyph(s) that correspond to the specified character. The calculations assume that all glyphs occupy the full standard glyph cell for the font. If multiple consecutive characters are rendered inseparably (e.g., as a single glyph or a sequence of glyphs), then each of the inseparable characters will return the same extent.
        Specified by:
        getExtentOfChar in interface SVGTextContent
        Parameters:
        charnum - The index of the character, where the first character has an index of 0.
        Returns:
        The rectangle which encloses all of the rendered glyph(s).
      • getStartPositionOfChar

        public java.awt.geom.Point2D getStartPositionOfChar​(int charnum)
        Description copied from interface: SVGTextContent
        Returns the current text position before rendering the character in the user coordinate system for rendering the glyph(s) that correspond to the specified character. The current text position has already taken into account the effects of any inter- character adjustments due to properties 'kerning', 'letter-spacing' and 'word-spacing' and adjustments due to attributes x, y, dx and dy. If multiple consecutive characters are rendered inseparably (e.g., as a single glyph or a sequence of glyphs), then each of the inseparable characters will return the start position for the first glyph.
        Specified by:
        getStartPositionOfChar in interface SVGTextContent
        Parameters:
        charnum - The index of the character, where the first character has an index of 0.
        Returns:
        The character's start position.
      • getEndPositionOfChar

        public java.awt.geom.Point2D getEndPositionOfChar​(int charnum)
        Description copied from interface: SVGTextContent
        Returns the current text position after rendering the character in the user coordinate system for rendering the glyph(s) that correspond to the specified character. This current text position does not take into account the effects of any inter- character adjustments to prepare for the next character, such as properties 'kerning', 'letter-spacing' and 'word-spacing' and adjustments due to attributes x, y, dx and dy. If multiple consecutive characters are rendered inseparably (e.g., as a single glyph or a sequence of glyphs), then each of the inseparable characters will return the end position for the last glyph.
        Specified by:
        getEndPositionOfChar in interface SVGTextContent
        Parameters:
        charnum - The index of the character, where the first character has an index of 0.
        Returns:
        The character's end position.
      • selectSubString

        public void selectSubString​(int charnum,
                                    int nchars)
        Description copied from interface: SVGTextContent
        Causes the specified substring to be selected just as if the user selected the substring interactively.
        Specified by:
        selectSubString in interface SVGTextContent
        Parameters:
        charnum - : The index of the start character which is at the given point, where the first character has an index of 0.
        nchars - : The number of characters in the substring. If nchars specifies more characters than are available, then the substring will consist of all characters starting with charnum until the end of the list of characters.
      • getRotationOfChar

        public float getRotationOfChar​(int charnum)
        Description copied from interface: SVGTextContent
        Returns the rotation value relative to the current user coordinate system used to render the glyph(s) corresponding to the specified character. If multiple glyph(s) are used to render the given character and the glyphs each have different rotations (e.g., due to text-on-a-path), the user agent shall return an average value (e.g., the rotation angle at the midpoint along the path for all glyphs used to render this character). The rotation value represents the rotation that is supplemental to any rotation due to properties 'glyph-orientation-horizontal' and 'glyph-orientation-vertical'; thus, any glyph rotations due to these properties are not included into the returned rotation value. If multiple consecutive characters are rendered inseparably (e.g., as a single glyph or a sequence of glyphs), then each of the inseparable characters will return the same rotation value.
        Specified by:
        getRotationOfChar in interface SVGTextContent
        Parameters:
        charnum - The index of the character, where the first character has an index of 0.
        Returns:
        The character's rotation angle.
      • getNumberOfChars

        protected int getNumberOfChars​(org.w3c.dom.Element element)
        Implementation of SVGTextContentElement.getNumberOfChars().
      • getExtentOfChar

        protected java.awt.geom.Rectangle2D getExtentOfChar​(org.w3c.dom.Element element,
                                                            int charnum)
        Implementation of SVGTextContentElement.getExtentOfChar(int charnum).
      • getStartPositionOfChar

        protected java.awt.geom.Point2D getStartPositionOfChar​(org.w3c.dom.Element element,
                                                               int charnum)
        Implementation of SVGTextContentElement.getStartPositionOfChar(int charnum).
      • getEndPositionOfChar

        protected java.awt.geom.Point2D getEndPositionOfChar​(org.w3c.dom.Element element,
                                                             int charnum)
        Implementation of SVGTextContentElement.getEndPositionOfChar(int charnum).
      • getRotationOfChar

        protected float getRotationOfChar​(org.w3c.dom.Element element,
                                          int charnum)
        Implementation of SVGTextContentElement.getRotationOfChar(int charnum).
      • getComputedTextLength

        protected float getComputedTextLength​(org.w3c.dom.Element e)
        Implementation of SVGTextContentElement.getComputedTextLength().
      • getSubStringLength

        protected float getSubStringLength​(org.w3c.dom.Element element,
                                           int charnum,
                                           int nchars)
        Implementation of SVGTextContentElement.getSubStringLength(int charnum,int nchars).
      • selectSubString

        protected void selectSubString​(org.w3c.dom.Element element,
                                       int charnum,
                                       int nchars)
        Select an ensemble of characters for that element. TODO : report the selection to the selection manager in JSVGComponent.
      • getCharNumAtPosition

        protected int getCharNumAtPosition​(org.w3c.dom.Element e,
                                           float x,
                                           float y)
      • getTextRuns

        protected java.util.List getTextRuns​(TextNode node)
        Retrieve the list of layout for the text node.
      • getCharacterInformation

        protected SVGTextElementBridge.CharacterInformation getCharacterInformation​(java.util.List list,
                                                                                    int startIndex,
                                                                                    int charnum,
                                                                                    java.text.AttributedCharacterIterator aci)
        Retrieve the information about a character of en element. The element first character in the ACI is 'firstChar' and the character look for is the charnum th character in the element
        Parameters:
        list - list of the layouts
        startIndex - index in the ACI of the first character for the element
        charnum - index of the character (among the characters of the element) looked for.
        Returns:
        information about the glyph representing the character
      • getTextIntersectionSet

        public java.util.Set getTextIntersectionSet​(java.awt.geom.AffineTransform at,
                                                    java.awt.geom.Rectangle2D rect)
      • getTextEnclosureSet

        public java.util.Set getTextEnclosureSet​(java.awt.geom.AffineTransform at,
                                                 java.awt.geom.Rectangle2D rect)
      • getTextIntersection

        public static boolean getTextIntersection​(BridgeContext ctx,
                                                  org.w3c.dom.Element elem,
                                                  java.awt.geom.AffineTransform ati,
                                                  java.awt.geom.Rectangle2D rect,
                                                  boolean checkSensitivity)
      • getTextBounds

        public static java.awt.geom.Rectangle2D getTextBounds​(BridgeContext ctx,
                                                              org.w3c.dom.Element elem,
                                                              boolean checkSensitivity)
      • isTextSensitive

        public static boolean isTextSensitive​(org.w3c.dom.Element e)