org.apache.batik.swing

Class JSVGCanvas.CanvasUserAgent

protected class JSVGCanvas.CanvasUserAgent extends 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.
Method Summary
voiddisplayError(String message)
Displays an error message in the User Agent interface.
voiddisplayError(Exception ex)
Displays an error resulting from the specified Exception.
ElementgetPeerWithTag(Element parent, String nameSpaceURI, String localName)
Checks if there is a peer element of a given type.
voidhandleElement(Element elt, Object data)
The handleElement method builds a tool tip from the content of a <title> element, a <desc> element or both.
booleanhasPeerWithTag(Element elt, String nameSpaceURI, String localName)
Returns a boolean defining whether or not there is a peer of elt with the given qualified tag.
voidremoveToolTip(Element elt)
protected voidreplace(StringBuffer sb, char c, String r)
voidsetToolTip(Element elt, String toolTip)
Sets the tool tip on the input element.
StringtoFormattedHTML(String str)
Converts line breaks to HTML breaks and encodes special entities.

Method Detail

displayError

public void displayError(String message)
Displays an error message in the User Agent interface.

displayError

public void displayError(Exception ex)
Displays an error resulting from the specified Exception.

getPeerWithTag

public Element getPeerWithTag(Element parent, String nameSpaceURI, 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.

handleElement

public void handleElement(Element elt, 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:

hasPeerWithTag

public boolean hasPeerWithTag(Element elt, String nameSpaceURI, String localName)
Returns a boolean defining whether or not there is a peer of elt with the given qualified tag.

removeToolTip

public void removeToolTip(Element elt)

replace

protected void replace(StringBuffer sb, char c, String r)

setToolTip

public void setToolTip(Element elt, String toolTip)
Sets the tool tip on the input element.

toFormattedHTML

public String toFormattedHTML(String str)
Converts line breaks to HTML breaks and encodes special entities. Poor way of replacing '<', '>' and '&' in content.
Copyright B) 2008 Apache Software Foundation. All Rights Reserved.