## org.apache.batik.swing
Class JSVGCanvas.CanvasUserAgent

    java.lang.Object
      org.apache.batik.swing.svg.AbstractJSVGComponent.BridgeUserAgent
          org.apache.batik.swing.JSVGCanvas.CanvasUserAgent

All Implemented Interfaces:
  UserAgent, XMLConstants

Enclosing class:
  JSVGCanvas

    protected class JSVGCanvas.CanvasUserAgent

extends AbstractJSVGComponent.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.

Field Summary

Fields inherited from class org.apache.batik.swing.svg.AbstractJSVGComponent.BridgeUserAgent
`extensions`

Fields inherited from interface org.apache.batik.util.XMLConstants

`XLINK_HREF_ATTRIBUTE, XLINK_HREF_QNAME, XLINK_NAMESPACE_URI, XLINK_PREFIX, XML_BASE_ATTRIBUTE, XML_BASE_QNAME, XML_CDATA_END, XML_CHAR_AMP, XML_CHAR_APOS, XML_CHAR_GT, XML_CHAR_LT, XML_CHAR_QUOT, XML_CHAR_REF_PREFIX, XML_CHAR_REF_SUFFIX, XML_CLOSE_TAG_END, XML_CLOSE_TAG_START, XML_DEFAULT_VALUE, XML_DOUBLE_DASH, XML_DOUBLE_QUOTE, XML_ENTITY_AMP, XML_ENTITY_APOS, XML_ENTITY_GT, XML_ENTITY_LT, XML_ENTITY_QUOT, XML_EQUAL_QUOT, XML_EQUAL_SIGN, XML_EVENTS_EVENT_ATTRIBUTE, XML_EVENTS_NAMESPACE_URI, XML_ID_ATTRIBUTE, XML_ID_QNAME, XML_LANG_ATTRIBUTE, XML_LANG_QNAME, XML_NAMESPACE_URI, XML_OPEN_TAG_END_CHILDREN, XML_OPEN_TAG_END_NO_CHILDREN, XML_OPEN_TAG_START, XML_PREFIX, XML_PRESERVE_VALUE, XML_PROCESSING_INSTRUCTION_END, XML_SPACE, XML_SPACE_ATTRIBUTE, XML_SPACE_QNAME, XML_TAB, XML_VERSION_10, XML_VERSION_11, XMLNS_NAMESPACE_URI, XMLNS_PREFIX`

Constructor Summary
`protected` `JSVGCanvas.CanvasUserAgent()`

Method Summary
`void` `displayError(java.lang.Exception ex)` Displays an error resulting from the specified Exception.
`void` `displayError(java.lang.String message)` Displays an error message in the User Agent interface.
`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.
`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.
`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.
`void` `removeToolTip(org.w3c.dom.Element elt)`
`protected void` `replace(java.lang.StringBuffer sb, char c, java.lang.String r)`
`void` `setToolTip(org.w3c.dom.Element elt, java.lang.String toolTip)` Sets the tool tip on the input element.
`java.lang.String` `toFormattedHTML(java.lang.String str)` Converts line breaks to HTML breaks and encodes special entities.

Methods inherited from class org.apache.batik.swing.svg.AbstractJSVGComponent.BridgeUserAgent

`checkLoadExternalResource, checkLoadScript, deselectAll, displayMessage, fireLinkActivatedEvent, getAlternateStyleSheet, getBolderFontWeight, getBrokenLinkDocument, getClientAreaLocationOnScreen, getDefaultFontFamily, getEventDispatcher, getExternalResourceSecurity, getLanguages, getLighterFontWeight, getMedia, getMediumFontSize, getPixelToMM, getPixelUnitToMillimeter, getScriptSecurity, getTransform, getUserStyleSheetURI, getViewportSize, getXMLParserClassName, hasFeature, isXMLParserValidating, openLink, registerExtension, setSVGCursor, setTextSelection, setTransform, showAlert, showConfirm, showPrompt, showPrompt, supportExtension`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### JSVGCanvas.CanvasUserAgent

    protected JSVGCanvas.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 `AbstractJSVGComponent.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)

### displayError

    public void displayError(java.lang.String message)

  Displays an error message in the User Agent interface.

  Overrides:
    `displayError` in class `AbstractJSVGComponent.BridgeUserAgent`

### displayError

    public void displayError(java.lang.Exception ex)

  Displays an error resulting from the specified Exception.

  Specified by:
    `displayError` in interface `UserAgent`
  Overrides:
    `displayError` in class `AbstractJSVGComponent.BridgeUserAgent`

Copyright © 2008 Apache Software Foundation. All Rights Reserved.