Class JSVGCanvas.CanvasUserAgent

  • All Implemented Interfaces:
    UserAgent, XMLConstants
    Enclosing class:
    JSVGCanvas

    protected class JSVGCanvas.CanvasUserAgent
    extends JSVGComponent.BridgeUserAgent
    implements XMLConstants
    The CanvasUserAgent only adds tooltips to the behavior of the default BridgeUserAgent. A tooltip will be displayed wheneven the mouse lingers over an element which has a <title> or a <desc> child element.
    • Constructor Detail

      • CanvasUserAgent

        protected CanvasUserAgent()
    • Method Detail

      • handleElement

        public void handleElement​(org.w3c.dom.Element elt,
                                  java.lang.Object data)
        The handleElement method builds a tool tip from the content of a <title> element, a <desc> element or both.
        Because these elements can appear in any order, here is the algorithm used to build the tool tip:
        • If a <title> is passed to handleElement the method checks if there is a >desc> peer. If there is one, nothing is done (because the desc will do it). If there in none, the tool tip is set to the value of the <title> element content.
        • If a <desc> is passed to handleElement the method checks if there is a <title> peer. If there is one, the content of that peer is pre-pended to the content of the <desc> element.
        Specified by:
        handleElement in interface UserAgent
        Overrides:
        handleElement in class JSVGComponent.BridgeUserAgent
      • toFormattedHTML

        public java.lang.String toFormattedHTML​(java.lang.String str)
        Converts line breaks to HTML breaks and encodes special entities. Poor way of replacing '<', '>' and '&' in content.
      • replace

        protected void replace​(java.lang.StringBuffer sb,
                               char c,
                               java.lang.String r)
      • getPeerWithTag

        public org.w3c.dom.Element getPeerWithTag​(org.w3c.dom.Element parent,
                                                  java.lang.String nameSpaceURI,
                                                  java.lang.String localName)
        Checks if there is a peer element of a given type. This returns the first occurence of the given type or null if none is found.
      • hasPeerWithTag

        public boolean hasPeerWithTag​(org.w3c.dom.Element elt,
                                      java.lang.String nameSpaceURI,
                                      java.lang.String localName)
        Returns a boolean defining whether or not there is a peer of elt with the given qualified tag.
      • setToolTip

        public void setToolTip​(org.w3c.dom.Element elt,
                               java.lang.String toolTip)
        Sets the tool tip on the input element.
      • removeToolTip

        public void removeToolTip​(org.w3c.dom.Element elt)