You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by de...@apache.org on 2003/08/14 02:53:52 UTC
cvs commit: xml-batik/test-resources/org/apache/batik/test samplesRendering.xml
deweese 2003/08/13 17:53:52
Modified: sources/org/apache/batik/apps/svgbrowser
JSVGViewerFrame.java ThumbnailDialog.java
sources/org/apache/batik/bridge BridgeContext.java
ScriptingEnvironment.java
sources/org/apache/batik/css/engine CSSEngine.java
sources/org/apache/batik/css/engine/value/css2
SrcManager.java
sources/org/apache/batik/css/parser Parser.java
sources/org/apache/batik/swing JSVGCanvas.java
sources/org/apache/batik/swing/gvt JGVTComponent.java
sources/org/apache/batik/swing/svg JSVGComponent.java
sources/org/apache/batik/util SVGConstants.java
sources/org/apache/batik/util/gui/resource
ButtonFactory.java
test-resources/org/apache/batik/test samplesRendering.xml
Added: samples/tests/spec/scripting eventAttrAdd.svg
sources/org/apache/batik/css/engine CSSEngineUserAgent.java
Log:
1) Batik now passes all non SMIL-Animation tests from the SVG Working Group
beSuite.
a) zoomAndPand!=magnify now disables all transform controls in Squiggle
(zoom, pan, rotate, etc).
b) @font-face src property now supports format function.
c) Invalid CSS properties now signal the user but doesn't stop the
processing of the document.
2) The addition of event attributes is now handled properly.
The removal of any attribute no longer detaches all attribute event
handlers from the subtree.
Revision Changes Path
1.1 xml-batik/samples/tests/spec/scripting/eventAttrAdd.svg
Index: eventAttrAdd.svg
===================================================================
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<!--
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Batik" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
apache@apache.org.
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation. For more information on the
Apache Software Foundation, please see <http://www.apache.org/>.
-->
<!-- ====================================================================== -->
<!-- Test of adding/removing event attributes -->
<!-- -->
<!-- @author deweese@apache.org -->
<!-- @version $Id: eventAttrAdd.svg,v 1.1 2003/08/14 00:53:51 deweese Exp $ -->
<!-- ====================================================================== -->
<?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?>
<svg id="body" width="450" height="500" viewBox="0 0 450 500"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<script language="text/ecmascript"><![CDATA[
var root = document.getRootElement();
function adjust1 () {
// Ensure we can add event attr.
root.setAttributeNS(null, "onzoom", "setRect('a', 'lightblue')");
root.currentScale = 1.1;
setTimeout(adjust2, 500);
}
function adjust2() {
// Ensure we can modify event attr.
root.setAttributeNS(null, "onzoom", "setRect('b', 'lightblue')");
root.currentScale = 1.0;
setTimeout(adjust3, 500);
}
function adjust3() {
// Part 1 ensure we can remove event attr.
root.setAttributeNS(null, "onzoom", "setRect('c', 'lightblue')");
root.currentScale = 1.1;
setTimeout(adjust4, 500);
}
function adjust4() {
// Part 2 ensure we can remove event attr.
root.removeAttributeNS(null, "onzoom");
setRect('c', 'gold'); // It should stay gold.
root.currentScale = 1.0;
if (inRegard)
regardTestInstance.scriptDone();
}
function setRect(id, color) {
var elem = document.getElementById(id);
elem.setAttributeNS(null, "fill", color);
}
var inRegard = false;
function regardStart() {
inRegard = true;
adjust1();
}
]]></script>
<title>Addtion/Modification/Removal of event attributes.</title>
<text class="title" x="50%" y="40" text-anchor="middle"
>Addtion/Modification/Removal of event attributes.</text>
<text x="50%" y="55" text-anchor="middle"
>Click Rect to start test</text>
<g id="test-content" onclick="adjust1()" text-anchor="middle">
<rect id="a" x="50" y="100" width="250" height="50" fill="crimson"/>
<rect x="310" y="100" width="25" height="50" fill="lightblue"/>
<text x="175" y="130">Event Attr Add</text>
<rect id="b" x="50" y="175" width="250" height="50" fill="crimson"/>
<rect x="310" y="175" width="25" height="50" fill="lightblue"/>
<text x="175" y="205">Event Attr Modify</text>
<rect id="c" x="50" y="250" width="250" height="50" fill="crimson"/>
<rect x="310" y="250" width="25" height="50" fill="gold"/>
<text x="175" y="285">Event Attr Remove</text>
</g>
</svg>
1.100 +15 -1 xml-batik/sources/org/apache/batik/apps/svgbrowser/JSVGViewerFrame.java
Index: JSVGViewerFrame.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/apps/svgbrowser/JSVGViewerFrame.java,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -r1.99 -r1.100
--- JSVGViewerFrame.java 9 Aug 2003 16:58:44 -0000 1.99
+++ JSVGViewerFrame.java 14 Aug 2003 00:53:51 -0000 1.100
@@ -588,6 +588,18 @@
JSVGViewerFrame.this.pack();
}
}
+
+ public void setDisableInteractions(boolean b) {
+ super.setDisableInteractions(b);
+
+ // Disable/Enable all our different ways to adjust the
+ // rendering transform (menus, toolbar, thumbnail, keyboard).
+
+ ((Action)listeners.get(SET_TRANSFORM_ACTION)) .setEnabled(!b);
+
+ if (thumbnailDialog != null)
+ thumbnailDialog.setInteractionEnabled(!b);
+ }
};
javax.swing.ActionMap map = svgCanvas.getActionMap();
@@ -1786,6 +1798,8 @@
thumbnailDialog.setLocation(fr.x + (fr.width - td.width) / 2,
fr.y + (fr.height - td.height) / 2);
}
+ thumbnailDialog.setInteractionEnabled
+ (!svgCanvas.getDisableInteractions());
thumbnailDialog.show();
}
}
1.12 +27 -6 xml-batik/sources/org/apache/batik/apps/svgbrowser/ThumbnailDialog.java
Index: ThumbnailDialog.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/apps/svgbrowser/ThumbnailDialog.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- ThumbnailDialog.java 8 Aug 2003 11:38:50 -0000 1.11
+++ ThumbnailDialog.java 14 Aug 2003 00:53:51 -0000 1.12
@@ -131,6 +131,11 @@
/** The overlay used to display the area of interest. */
protected AreaOfInterestOverlay overlay;
+ /** The overlay used to display the area of interest. */
+ protected AreaOfInterestListener aoiListener;
+
+ protected boolean interactionEnabled = true;
+
/**
* Constructs a new <tt>ThumbnailDialog</tt> for the specified canvas.
*
@@ -144,8 +149,8 @@
// register listeners to maintain consistency
this.svgCanvas = svgCanvas;
svgCanvas.addGVTTreeRendererListener(new ThumbnailGVTListener());
- svgCanvas.addSVGDocumentLoaderListener(new ThumbnailDocumentListener()); svgCanvas.addComponentListener(new ThumbnailCanvasComponentListener());
-
+ svgCanvas.addSVGDocumentLoaderListener(new ThumbnailDocumentListener());
+ svgCanvas.addComponentListener(new ThumbnailCanvasComponentListener());
// create the thumbnail
svgThumbnailCanvas = new JGVTComponent();
@@ -153,10 +158,26 @@
svgThumbnailCanvas.getOverlays().add(overlay);
svgThumbnailCanvas.setPreferredSize(new Dimension(150, 150));
svgThumbnailCanvas.addComponentListener(new ThumbnailComponentListener());
- AreaOfInterestListener listener = new AreaOfInterestListener();
- svgThumbnailCanvas.addMouseListener(listener);
- svgThumbnailCanvas.addMouseMotionListener(listener);
+ aoiListener = new AreaOfInterestListener();
+ svgThumbnailCanvas.addMouseListener(aoiListener);
+ svgThumbnailCanvas.addMouseMotionListener(aoiListener);
getContentPane().add(svgThumbnailCanvas, BorderLayout.CENTER);
+ }
+
+ public void setInteractionEnabled(boolean b) {
+ if (b == interactionEnabled) return;
+ interactionEnabled = b;
+ if (b) {
+ svgThumbnailCanvas.addMouseListener (aoiListener);
+ svgThumbnailCanvas.addMouseMotionListener(aoiListener);
+ } else {
+ svgThumbnailCanvas.removeMouseListener (aoiListener);
+ svgThumbnailCanvas.removeMouseMotionListener(aoiListener);
+ }
+ }
+
+ public boolean getInteractionEnabled() {
+ return interactionEnabled;
}
/**
1.71 +22 -2 xml-batik/sources/org/apache/batik/bridge/BridgeContext.java
Index: BridgeContext.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/BridgeContext.java,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -r1.70 -r1.71
--- BridgeContext.java 9 Aug 2003 16:58:37 -0000 1.70
+++ BridgeContext.java 14 Aug 2003 00:53:51 -0000 1.71
@@ -70,6 +70,7 @@
import org.apache.batik.css.engine.CSSEngine;
import org.apache.batik.css.engine.CSSEngineEvent;
import org.apache.batik.css.engine.CSSEngineListener;
+import org.apache.batik.css.engine.CSSEngineUserAgent;
import org.apache.batik.css.engine.SystemColorSupport;
import org.apache.batik.css.engine.value.Value;
import org.apache.batik.dom.svg.SVGContext;
@@ -281,6 +282,7 @@
SVGDOMImplementation impl;
impl = (SVGDOMImplementation)doc.getImplementation();
eng = impl.createCSSEngine(doc, this);
+ eng.setCSSEngineUserAgent(new CSSEngineUserAgentWrapper(userAgent));
doc.setCSSEngine(eng);
eng.setMedia(userAgent.getMedia());
String uri = userAgent.getUserStyleSheetURI();
@@ -1431,5 +1433,23 @@
}
return extensions;
}
- }
+
+ public static class CSSEngineUserAgentWrapper implements CSSEngineUserAgent {
+ UserAgent ua;
+ CSSEngineUserAgentWrapper(UserAgent ua) {
+ this.ua = ua;
+ }
+
+ /**
+ * Displays an error resulting from the specified Exception.
+ */
+ public void displayError(Exception ex) { ua.displayError(ex); }
+
+ /**
+ * Displays a message in the User Agent interface.
+ */
+ public void displayMessage(String message) { ua.displayMessage(message); }
+ }
+
+}
1.42 +139 -9 xml-batik/sources/org/apache/batik/bridge/ScriptingEnvironment.java
Index: ScriptingEnvironment.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/ScriptingEnvironment.java,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- ScriptingEnvironment.java 9 Aug 2003 16:58:37 -0000 1.41
+++ ScriptingEnvironment.java 14 Aug 2003 00:53:51 -0000 1.42
@@ -57,6 +57,8 @@
import java.io.StringReader;
import java.io.StringWriter;
import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
@@ -71,12 +73,14 @@
import org.apache.batik.util.RunnableQueue;
import org.apache.batik.util.SVGConstants;
import org.apache.batik.util.XMLResourceDescriptor;
+
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.events.Event;
import org.w3c.dom.events.EventListener;
import org.w3c.dom.events.EventTarget;
+import org.w3c.dom.events.MutationEvent;
import org.w3c.dom.svg.SVGDocument;
/**
@@ -100,6 +104,60 @@
protected final static String FRAGMENT_SUFFIX =
"</svg>";
+ public final static String [] SVG_EVENT_ATTRS = {
+ "onabort", // SVG element
+ "onerror", // SVG element
+ "onresize", // SVG element
+ "onscroll", // SVG element
+ "onunload", // SVG element
+ "onzoom", // SVG element
+
+ "onbegin", // SMIL
+ "onend", // SMIL
+ "onrepeat", // SMIL
+
+ "onfocusin", // UI Events
+ "onfocusout", // UI Events
+ "onactivate", // UI Events
+ "onclick", // UI Events
+
+ "onmousedown", // UI Events
+ "onmouseup", // UI Events
+ "onmouseover", // UI Events
+ "onmouseout", // UI Events
+ "onmousemove", // UI Events
+
+ "onkeypress", // UI Events
+ "onkeydown", // UI Events
+ "onkeyup" // UI Events
+ };
+
+ public final static String [] SVG_DOM_EVENT = {
+ "SVGAbort", // SVG element
+ "SVGError", // SVG element
+ "SVGResize", // SVG element
+ "SVGScroll", // SVG element
+ "SVGUnload", // SVG element
+ "SVGZoom", // SVG element
+
+ "beginEvent", // SMIL
+ "endEvent", // SMIL
+ "repeatEvent", // SMIL
+
+ "DOMFocusIn", // UI Events
+ "DOMFocusOut", // UI Events
+ "DOMActivate", // UI Events
+ "click", // UI Events
+ "mousedown", // UI Events
+ "mouseup", // UI Events
+ "mouseover", // UI Events
+ "mouseout", // UI Events
+ "mousemove", // UI Events
+ "keypress", // UI Events
+ "keydown", // UI Events
+ "keyup" // UI Events
+ };
+
/**
* The timer for periodic or delayed tasks.
*/
@@ -118,12 +176,20 @@
/**
* The DOMNodeInserted event listener.
*/
- protected EventListener domNodeInsertedListener;
+ protected EventListener domNodeInsertedListener
+ = new DOMNodeInsertedListener();
/**
* The DOMNodeRemoved event listener.
*/
- protected EventListener domNodeRemovedListener;
+ protected EventListener domNodeRemovedListener
+ = new DOMNodeRemovedListener();
+
+ /**
+ * The DOMAttrModified event listener.
+ */
+ protected EventListener domAttrModifiedListener
+ = new DOMAttrModifiedListener();
/**
* The SVGAbort event listener.
@@ -251,7 +317,43 @@
protected EventListener keyupListener =
new ScriptingEventListener("onkeyup");
-
+
+ protected EventListener [] listeners = {
+ svgAbortListener,
+ svgErrorListener,
+ svgResizeListener,
+ svgScrollListener,
+ svgUnloadListener,
+ svgZoomListener,
+
+ beginListener,
+ endListener,
+ repeatListener,
+
+ focusinListener,
+ focusoutListener,
+ activateListener,
+ clickListener,
+
+ mousedownListener,
+ mouseupListener,
+ mouseoverListener,
+ mouseoutListener,
+ mousemoveListener,
+
+ keypressListener,
+ keydownListener,
+ keyupListener
+ };
+
+ Map attrToDOMEvent = new HashMap(SVG_EVENT_ATTRS.length);
+ Map attrToListener = new HashMap(SVG_EVENT_ATTRS.length);
+ {
+ for (int i=0; i<SVG_EVENT_ATTRS.length; i++) {
+ attrToDOMEvent.put(SVG_EVENT_ATTRS[i], SVG_DOM_EVENT[i]);
+ attrToListener.put(SVG_EVENT_ATTRS[i], listeners[i]);
+ }
+ }
/**
* Creates a new ScriptingEnvironment.
@@ -267,14 +369,15 @@
// Add the listeners responsible of updating the event attributes
EventTarget et = (EventTarget)document;
- domNodeInsertedListener = new DOMNodeInsertedListener();
et.addEventListener("DOMNodeInserted",
domNodeInsertedListener,
false);
- domNodeRemovedListener = new DOMNodeRemovedListener();
- et.addEventListener("DOMAttrRemoved",
+ et.addEventListener("DOMNodeRemoved",
domNodeRemovedListener,
false);
+ et.addEventListener("DOMAttrModified",
+ domAttrModifiedListener,
+ false);
}
/**
@@ -322,9 +425,12 @@
et.removeEventListener("DOMNodeInserted",
domNodeInsertedListener,
false);
- et.removeEventListener("DOMAttrRemoved",
+ et.removeEventListener("DOMNodeRemoved",
domNodeRemovedListener,
false);
+ et.removeEventListener("DOMAttrModified",
+ domAttrModifiedListener,
+ false);
}
/**
@@ -502,6 +608,21 @@
}
/**
+ * Updates the registration of a listener on the given element.
+ */
+ protected void updateScriptingListeners(Element elt, String attr) {
+ String domEvt = (String) attrToDOMEvent.get(attr);
+ if (domEvt == null) return; // Not an event attr.
+ EventListener listener = (EventListener)attrToListener.get(attr);
+ EventTarget target = (EventTarget) elt;
+ if (elt.hasAttributeNS(null, attr))
+ target.addEventListener(domEvt, listener, false);
+ else
+ target.removeEventListener(domEvt, listener, false);
+ }
+
+
+ /**
* To interpret a script.
*/
protected class EvaluateRunnable implements Runnable {
@@ -720,7 +841,7 @@
* org.apache.batik.script.Window#parseXML(String,Document)}.
*/
public Node parseXML(String text, Document doc) {
- // System.out.println("Text: " + text);
+ // System.err.println("Text: " + text);
// Try and parse it as an SVGDocument
SAXSVGDocumentFactory df = new SAXSVGDocumentFactory
(XMLResourceDescriptor.getXMLParserClassName());
@@ -942,6 +1063,15 @@
protected class DOMNodeRemovedListener implements EventListener {
public void handleEvent(Event evt) {
removeScriptingListeners((Node)evt.getTarget());
+ }
+ }
+
+ protected class DOMAttrModifiedListener implements EventListener {
+ public void handleEvent (Event evt) {
+ MutationEvent me = (MutationEvent)evt;
+ if (me.getAttrChange() != MutationEvent.MODIFICATION)
+ updateScriptingListeners((Element)me.getTarget(),
+ me.getAttrName());
}
}
1.31 +58 -20 xml-batik/sources/org/apache/batik/css/engine/CSSEngine.java
Index: CSSEngine.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/css/engine/CSSEngine.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- CSSEngine.java 10 Aug 2003 18:03:16 -0000 1.30
+++ CSSEngine.java 14 Aug 2003 00:53:51 -0000 1.31
@@ -108,6 +108,8 @@
*/
public List getFontFaces() { return fontFaces; }
+ CSSEngineUserAgent userAgent = null;
+
/**
* Returns the next stylable parent of the given element.
*/
@@ -493,6 +495,7 @@
* Disposes the CSSEngine and all the attached resources.
*/
public void dispose() {
+ setCSSEngineUserAgent(null);
disposeStyleMaps(document.getDocumentElement());
if (document instanceof EventTarget) {
// Detach the mutation events listeners.
@@ -595,6 +598,14 @@
return valueManagers[idx].getPropertyName();
}
+ public void setCSSEngineUserAgent(CSSEngineUserAgent userAgent) {
+ this.userAgent = userAgent;
+ }
+
+ public CSSEngineUserAgent getCSSEngineUserAgent() {
+ return userAgent;
+ }
+
/**
* Sets the user agent style-sheet.
*/
@@ -733,7 +744,9 @@
String s = Messages.formatMessage
("property.syntax.error.at",
new Object[] { u, an, attr.getNodeValue(),m});
- throw new DOMException(DOMException.SYNTAX_ERR, s);
+ DOMException de = new DOMException(DOMException.SYNTAX_ERR, s);
+ if (userAgent == null) throw de;
+ userAgent.displayError(de);
}
}
}
@@ -779,7 +792,9 @@
String s = Messages.formatMessage
("style.syntax.error.at",
new Object[] { u, styleLocalName, style, m});
- throw new DOMException(DOMException.SYNTAX_ERR, s);
+ DOMException de = new DOMException(DOMException.SYNTAX_ERR, s);
+ if (userAgent == null) throw de;
+ userAgent.displayError(de);
}
}
}
@@ -915,12 +930,13 @@
*/
public Value parsePropertyValue(CSSStylableElement elt,
String prop, String value) {
+ int idx = getPropertyIndex(prop);
+ if (idx == -1) return null;
+ ValueManager vm = valueManagers[idx];
try {
element = elt;
LexicalUnit lu;
- int idx = getPropertyIndex(prop);
lu = parser.parsePropertyValue(value);
- ValueManager vm = valueManagers[idx];
return vm.createValue(lu, this);
} catch (Exception e) {
String m = e.getMessage();
@@ -930,12 +946,14 @@
String s = Messages.formatMessage
("property.syntax.error.at",
new Object[] { u, prop, value, m});
- throw new DOMException(DOMException.SYNTAX_ERR, s);
+ DOMException de = new DOMException(DOMException.SYNTAX_ERR, s);
+ if (userAgent == null) throw de;
+ userAgent.displayError(de);
} finally {
element = null;
cssBaseURI = null;
}
-
+ return vm.getDefaultValue();
}
/**
@@ -944,14 +962,13 @@
*/
public StyleDeclaration parseStyleDeclaration(CSSStylableElement elt,
String value) {
+ styleDeclarationBuilder.styleDeclaration = new StyleDeclaration();
try {
+ element = elt;
parser.setSelectorFactory(CSSSelectorFactory.INSTANCE);
parser.setConditionFactory(cssConditionFactory);
- element = elt;
- styleDeclarationBuilder.styleDeclaration = new StyleDeclaration();
parser.setDocumentHandler(styleDeclarationBuilder);
parser.parseStyleDeclaration(value);
- return styleDeclarationBuilder.styleDeclaration;
} catch (Exception e) {
String m = e.getMessage();
if (m == null) m = "";
@@ -959,11 +976,14 @@
documentURI.toString());
String s = Messages.formatMessage
("syntax.error.at", new Object[] { u, m });
- throw new DOMException(DOMException.SYNTAX_ERR, s);
+ DOMException de = new DOMException(DOMException.SYNTAX_ERR, s);
+ if (userAgent == null) throw de;
+ userAgent.displayError(de);
} finally {
element = null;
cssBaseURI = null;
}
+ return styleDeclarationBuilder.styleDeclaration;
}
/**
@@ -983,7 +1003,10 @@
documentURI.toString());
String s = Messages.formatMessage
("syntax.error.at", new Object[] { u, m });
- throw new DOMException(DOMException.SYNTAX_ERR, s);
+ DOMException de = new DOMException(DOMException.SYNTAX_ERR, s);
+ if (userAgent == null) throw de;
+ userAgent.displayError(de);
+ return ss;
}
parseStyleSheet(ss, uri);
return ss;
@@ -1008,7 +1031,9 @@
documentURI.toString());
String s = Messages.formatMessage
("syntax.error.at", new Object[] { u, m });
- throw new DOMException(DOMException.SYNTAX_ERR, s);
+ DOMException de = new DOMException(DOMException.SYNTAX_ERR, s);
+ if (userAgent == null) throw de;
+ userAgent.displayError(de);
}
return ss;
}
@@ -1023,7 +1048,10 @@
String s = Messages.formatMessage
("syntax.error.at",
new Object[] { "Null Document reference", "" });
- throw new DOMException(DOMException.SYNTAX_ERR, s);
+ DOMException de = new DOMException(DOMException.SYNTAX_ERR, s);
+ if (userAgent == null) throw de;
+ userAgent.displayError(de);
+ return;
}
try {
@@ -1043,7 +1071,9 @@
if (m == null) m = "";
String s = Messages.formatMessage
("syntax.error.at", new Object[] { uri.toString(), m });
- throw new DOMException(DOMException.SYNTAX_ERR, s);
+ DOMException de = new DOMException(DOMException.SYNTAX_ERR, s);
+ if (userAgent == null) throw de;
+ userAgent.displayError(de);
}
}
@@ -1065,7 +1095,10 @@
documentURI.toString());
String s = Messages.formatMessage
("syntax.error.at", new Object[] { u, m });
- throw new DOMException(DOMException.SYNTAX_ERR, s);
+ DOMException de = new DOMException(DOMException.SYNTAX_ERR, s);
+ if (userAgent == null) throw de;
+ userAgent.displayError(de);
+ return ss;
}
parseStyleSheet(ss, rules, uri);
return ss;
@@ -1088,7 +1121,9 @@
String s = Messages.formatMessage
("stylesheet.syntax.error",
new Object[] { uri.toString(), rules, m });
- throw new DOMException(DOMException.SYNTAX_ERR, s);
+ DOMException de = new DOMException(DOMException.SYNTAX_ERR, s);
+ if (userAgent == null) throw de;
+ userAgent.displayError(de);
}
}
@@ -1725,7 +1760,9 @@
String s = Messages.formatMessage
("style.syntax.error.at",
new Object[] { u, styleLocalName, decl, m });
- throw new DOMException(DOMException.SYNTAX_ERR, s);
+ DOMException de = new DOMException(DOMException.SYNTAX_ERR, s);
+ if (userAgent == null) throw de;
+ userAgent.displayError(de);
} finally {
element = null;
cssBaseURI = null;
@@ -1733,7 +1770,6 @@
}
// Fall through
-
case MutationEvent.REMOVAL:
boolean removed = false;
@@ -2051,7 +2087,9 @@
String s = Messages.formatMessage
("property.syntax.error.at",
new Object[] { u, property, evt.getNewValue(), m });
- throw new DOMException(DOMException.SYNTAX_ERR, s);
+ DOMException de = new DOMException(DOMException.SYNTAX_ERR, s);
+ if (userAgent == null) throw de;
+ userAgent.displayError(de);
} finally {
element = null;
cssBaseURI = null;
1.1 xml-batik/sources/org/apache/batik/css/engine/CSSEngineUserAgent.java
Index: CSSEngineUserAgent.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Batik" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
apache@apache.org.
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation. For more information on the
Apache Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.batik.css.engine;
/**
* One line Class Desc
*
* Complete Class Desc
*
* @author <a href="mailto:deweese@apache.org>l449433</a>
* @version $Id: CSSEngineUserAgent.java,v 1.1 2003/08/14 00:53:51 deweese Exp $
*/
public interface CSSEngineUserAgent {
/**
* Displays an error resulting from the specified Exception.
*/
void displayError(Exception ex);
/**
* Displays a message in the User Agent interface.
*/
void displayMessage(String message);
};
1.4 +13 -1 xml-batik/sources/org/apache/batik/css/engine/value/css2/SrcManager.java
Index: SrcManager.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/css/engine/value/css2/SrcManager.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SrcManager.java 9 Aug 2003 16:58:44 -0000 1.3
+++ SrcManager.java 14 Aug 2003 00:53:51 -0000 1.4
@@ -141,8 +141,20 @@
case LexicalUnit.SAC_URI:
String uri = resolveURI(engine.getCSSBaseURI(),
lu.getStringValue());
+
result.append(new StringValue(CSSPrimitiveValue.CSS_URI, uri));
lu = lu.getNextLexicalUnit();
+ if ((lu != null) &&
+ (lu.getLexicalUnitType() == LexicalUnit.SAC_FUNCTION)) {
+ if (!lu.getFunctionName().equalsIgnoreCase("format")) {
+ break;
+ }
+ // Format really does us no good so just ignore it.
+
+ // TODO: Should probably turn this into a ListValue
+ // and append the format function CSS Value.
+ lu = lu.getNextLexicalUnit();
+ }
break;
case LexicalUnit.SAC_IDENT:
1.24 +7 -3 xml-batik/sources/org/apache/batik/css/parser/Parser.java
Index: Parser.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/css/parser/Parser.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- Parser.java 8 Aug 2003 11:38:57 -0000 1.23
+++ Parser.java 14 Aug 2003 00:53:51 -0000 1.24
@@ -371,10 +371,14 @@
throw e;
}
+ CSSParseException exception = null;
+ if (current != LexicalUnits.EOF)
+ exception = createCSSParseException("eof.expected");
+
scanner = null;
- if (current != LexicalUnits.EOF) {
- errorHandler.fatalError(createCSSParseException("eof.expected"));
+ if (exception != null) {
+ errorHandler.fatalError(exception);
}
return exp;
}
1.43 +22 -2 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.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- JSVGCanvas.java 9 Aug 2003 16:58:45 -0000 1.42
+++ JSVGCanvas.java 14 Aug 2003 00:53:51 -0000 1.43
@@ -277,7 +277,27 @@
actionMap.put(RESET_TRANSFORM_ACTION, new ResetTransformAction());
}
- /**
+ public void setDisableInteractions(boolean b) {
+ super.setDisableInteractions(b);
+ ActionMap actionMap = getActionMap();
+
+ actionMap.get(SCROLL_RIGHT_ACTION) .setEnabled(!b);
+ actionMap.get(SCROLL_LEFT_ACTION) .setEnabled(!b);
+ actionMap.get(SCROLL_UP_ACTION) .setEnabled(!b);
+ actionMap.get(SCROLL_DOWN_ACTION) .setEnabled(!b);
+
+ actionMap.get(FAST_SCROLL_RIGHT_ACTION).setEnabled(!b);
+ actionMap.get(FAST_SCROLL_LEFT_ACTION) .setEnabled(!b);
+ actionMap.get(FAST_SCROLL_UP_ACTION) .setEnabled(!b);
+ actionMap.get(FAST_SCROLL_DOWN_ACTION) .setEnabled(!b);
+
+ actionMap.get(ZOOM_IN_ACTION) .setEnabled(!b);
+ actionMap.get(ZOOM_OUT_ACTION) .setEnabled(!b);
+ actionMap.get(RESET_TRANSFORM_ACTION) .setEnabled(!b);
+ }
+
+
+ /**
* Builds the InputMap of this canvas with a set of predefined
* <tt>Action</tt>s.
*/
1.40 +10 -2 xml-batik/sources/org/apache/batik/swing/gvt/JGVTComponent.java
Index: JGVTComponent.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/swing/gvt/JGVTComponent.java,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- JGVTComponent.java 13 Aug 2003 11:01:16 -0000 1.39
+++ JGVTComponent.java 14 Aug 2003 00:53:51 -0000 1.40
@@ -211,7 +211,7 @@
protected boolean suspendInteractions;
/**
- * Whether to inconditionally disable interactions.
+ * Whether to unconditionally disable interactions.
*/
protected boolean disableInteractions;
@@ -250,6 +250,14 @@
}
});
+ }
+
+ public void setDisableInteractions(boolean b) {
+ disableInteractions = b;
+ }
+
+ public boolean getDisableInteractions() {
+ return disableInteractions;
}
/**
1.81 +3 -2 xml-batik/sources/org/apache/batik/swing/svg/JSVGComponent.java
Index: JSVGComponent.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/swing/svg/JSVGComponent.java,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -r1.80 -r1.81
--- JSVGComponent.java 13 Aug 2003 11:01:17 -0000 1.80
+++ JSVGComponent.java 14 Aug 2003 00:53:52 -0000 1.81
@@ -745,7 +745,8 @@
Element root = doc.getDocumentElement();
String znp = root.getAttributeNS
(null, SVGConstants.SVG_ZOOM_AND_PAN_ATTRIBUTE);
- disableInteractions = !znp.equals(SVGConstants.SVG_MAGNIFY_VALUE);
+
+ setDisableInteractions(!znp.equals(SVGConstants.SVG_MAGNIFY_VALUE));
bridgeContext = createBridgeContext();
nextGVTTreeBuilder = new GVTTreeBuilder(doc, bridgeContext);
1.71 +2 -3 xml-batik/sources/org/apache/batik/util/SVGConstants.java
Index: SVGConstants.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/util/SVGConstants.java,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -r1.70 -r1.71
--- SVGConstants.java 13 Aug 2003 11:01:17 -0000 1.70
+++ SVGConstants.java 14 Aug 2003 00:53:52 -0000 1.71
@@ -874,8 +874,7 @@
String SVG_EVENT_KEYUP = "keyup";
String SVG_EVENT_MOUSEDOWN = "mousedown";
String SVG_EVENT_MOUSEMOVE = "mousemove";
- String SVG_EVENT_MOUSEOVER = "mouseover";
String SVG_EVENT_MOUSEOUT = "mouseout";
+ String SVG_EVENT_MOUSEOVER = "mouseover";
String SVG_EVENT_MOUSEUP = "mouseup";
-
}
1.5 +16 -15 xml-batik/sources/org/apache/batik/util/gui/resource/ButtonFactory.java
Index: ButtonFactory.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/util/gui/resource/ButtonFactory.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ButtonFactory.java 8 Aug 2003 11:39:27 -0000 1.4
+++ ButtonFactory.java 14 Aug 2003 00:53:52 -0000 1.5
@@ -218,6 +218,21 @@
*/
private void initializeButton(AbstractButton b, String name)
throws ResourceFormatException, MissingListenerException {
+ // Action
+ try {
+ Action a = actions.getAction(getString(name+ACTION_SUFFIX));
+ if (a == null) {
+ throw new MissingListenerException("", "Action",
+ name+ACTION_SUFFIX);
+ }
+ b.setAction(a);
+ b.setText(getString(name+TEXT_SUFFIX));
+ if (a instanceof JComponentModifier) {
+ ((JComponentModifier)a).addJComponent(b);
+ }
+ } catch (MissingResourceException e) {
+ }
+
// Icon
try {
String s = getString(name+ICON_SUFFIX);
@@ -237,20 +252,6 @@
throw new ResourceFormatException("Malformed mnemonic",
bundle.getClass().getName(),
name+MNEMONIC_SUFFIX);
- }
- } catch (MissingResourceException e) {
- }
-
- // Action
- try {
- Action a = actions.getAction(getString(name+ACTION_SUFFIX));
- if (a == null) {
- throw new MissingListenerException("", "Action",
- name+ACTION_SUFFIX);
- }
- b.addActionListener(a);
- if (a instanceof JComponentModifier) {
- ((JComponentModifier)a).addJComponent(b);
}
} catch (MissingResourceException e) {
}
1.111 +2 -1 xml-batik/test-resources/org/apache/batik/test/samplesRendering.xml
Index: samplesRendering.xml
===================================================================
RCS file: /home/cvs/xml-batik/test-resources/org/apache/batik/test/samplesRendering.xml,v
retrieving revision 1.110
retrieving revision 1.111
diff -u -r1.110 -r1.111
--- samplesRendering.xml 8 Aug 2003 11:39:46 -0000 1.110
+++ samplesRendering.xml 14 Aug 2003 00:53:52 -0000 1.111
@@ -409,6 +409,7 @@
<testGroup id="updateTests" name="Dynamic Update Tests"
class="org.apache.batik.test.svg.JSVGRenderingAccuracyTest">
<test id="samples/tests/spec/scripting/boundsTransformChange.svg" />
+ <test id="samples/tests/spec/scripting/eventAttrAdd.svg" />
<test id="samples/tests/spec/scripting/rootSizeChange.svg" />
<test id="samples/tests/spec/scripting/rectResizeOnClick.svg" />
<test id="samples/tests/spec/scripting/setProperty.svg" />
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org