tkormann 01/10/17 04:40:29
Modified: sources/org/apache/batik/swing JSVGCanvas.java
Log:
- remove the tooltip when loading another document
- bug fix: empty title or desc element does not cause the canvas to crash
anymore
Revision Changes Path
1.28 +42 -7 xml-batik/sources/org/apache/batik/swing/JSVGCanvas.java
Index: JSVGCanvas.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/swing/JSVGCanvas.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- JSVGCanvas.java 2001/09/10 15:23:33 1.27
+++ JSVGCanvas.java 2001/10/17 11:40:29 1.28
@@ -35,13 +35,14 @@
import org.apache.batik.bridge.UserAgent;
-import org.apache.batik.swing.gvt.Interactor;
import org.apache.batik.swing.gvt.AbstractImageZoomInteractor;
import org.apache.batik.swing.gvt.AbstractPanInteractor;
import org.apache.batik.swing.gvt.AbstractResetTransformInteractor;
import org.apache.batik.swing.gvt.AbstractRotateInteractor;
import org.apache.batik.swing.gvt.AbstractZoomInteractor;
+import org.apache.batik.swing.gvt.Interactor;
import org.apache.batik.swing.svg.JSVGComponent;
+import org.apache.batik.swing.svg.SVGDocumentLoaderEvent;
import org.apache.batik.swing.svg.SVGUserAgent;
import org.apache.batik.util.SVGConstants;
@@ -65,7 +66,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Thierry Kormann</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a>
- * @version $Id: JSVGCanvas.java,v 1.27 2001/09/10 15:23:33 tkormann Exp $
+ * @version $Id: JSVGCanvas.java,v 1.28 2001/10/17 11:40:29 tkormann Exp $
*/
public class JSVGCanvas extends JSVGComponent {
@@ -467,6 +468,27 @@
return new CanvasUserAgent();
}
+ /**
+ * Creates an instance of Listener.
+ */
+ protected Listener createListener() {
+ return new CanvasSVGListener();
+ }
+
+ /**
+ * To hide the listener methods. This class just reset the tooltip.
+ */
+ protected class CanvasSVGListener extends JSVGComponent.SVGListener {
+
+ /**
+ * Called when the loading of a document was started.
+ */
+ public void documentLoadingStarted(SVGDocumentLoaderEvent e) {
+ JSVGCanvas.this.setToolTipText(null);
+ }
+
+ }
+
// ----------------------------------------------------------------------
// Actions
// ----------------------------------------------------------------------
@@ -719,25 +741,38 @@
// If there is a <desc> peer, do nothing as the tooltip will
// be handled when handleElement is invoked for the <desc>
// peer.
- if (hasPeerWithTag(elt,
- SVGConstants.SVG_NAMESPACE_URI,
- SVGConstants.SVG_DESC_TAG)){
+ if (hasPeerWithTag
+ (elt,
+ SVGConstants.SVG_NAMESPACE_URI,
+ SVGConstants.SVG_DESC_TAG)){
return;
}
elt.normalize();
+ if (elt.getFirstChild() == null) {
+ return;
+ }
String toolTip = elt.getFirstChild().getNodeValue();
+ if (toolTip == null || toolTip.length() == 0) {
+ return;
+ }
toolTip = Messages.formatMessage
(TOOLTIP_TITLE_ONLY,
new Object[]{toFormattedHTML(toolTip)});
setToolTip((Element)(elt.getParentNode()), toolTip);
- }
- else if (elt.getLocalName().equals(SVGConstants.SVG_DESC_TAG)) {
+ } else if (elt.getLocalName().equals
+ (SVGConstants.SVG_DESC_TAG)) {
// If there is a <title> peer, prepend its content to the
// content of the <desc> element.
elt.normalize();
+ if (elt.getFirstChild() == null) {
+ return;
+ }
String toolTip = elt.getFirstChild().getNodeValue();
+ if (toolTip == null || toolTip.length() == 0) {
+ return;
+ }
Element titlePeer =
getPeerWithTag(elt,
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]