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 hi...@apache.org on 2001/07/05 18:59:07 UTC
cvs commit: xml-batik/sources/org/apache/batik/dom/svg SVGDOMImplementation.java
hillion 01/07/05 09:59:07
Modified: sources/org/apache/batik/bridge BridgeEventSupport.java
sources/org/apache/batik/dom AbstractDOMImplementation.java
AbstractDocument.java
sources/org/apache/batik/dom/events EventSupport.java
sources/org/apache/batik/dom/svg SVGDOMImplementation.java
Added: sources/org/apache/batik/dom/events DOMEvent.java
DocumentEventSupport.java
Log:
Bug #1815 fixed.
Revision Changes Path
1.12 +3 -5 xml-batik/sources/org/apache/batik/bridge/BridgeEventSupport.java
Index: BridgeEventSupport.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/BridgeEventSupport.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- BridgeEventSupport.java 2001/05/15 13:54:56 1.11
+++ BridgeEventSupport.java 2001/07/05 16:58:59 1.12
@@ -49,7 +49,7 @@
* on the GVT root to propagate GVT events to the DOM.
* @author <a href="mailto:cjolif@ilog.fr>Christophe Jolif</a>
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
- * @version $Id: BridgeEventSupport.java,v 1.11 2001/05/15 13:54:56 deweese Exp $
+ * @version $Id: BridgeEventSupport.java,v 1.12 2001/07/05 16:58:59 hillion Exp $
*/
class BridgeEventSupport implements SVGConstants {
private static final String[] EVENT_ATTRIBUTES_GRAPHICS = {
@@ -404,11 +404,9 @@
else
if ((evt.BUTTON3_MASK & evt.getModifiers()) != 0)
button = 2;
- MouseEvent mevent =
+ MouseEvent mevent = (MouseEvent)
// DOM Level 2 6.5 cast from Document to DocumentEvent is ok
- (MouseEvent)org.apache.batik.dom.events.EventSupport.
- createEvent(org.apache.batik.dom.events.EventSupport.
- MOUSE_EVENT_TYPE);
+ ((DocumentEvent)elmt.getOwnerDocument()).createEvent("MouseEvents");
// deal with the related node/target
node = evt.getRelatedNode();
EventTarget relatedTarget =
1.6 +10 -1 xml-batik/sources/org/apache/batik/dom/AbstractDOMImplementation.java
Index: AbstractDOMImplementation.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/AbstractDOMImplementation.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- AbstractDOMImplementation.java 2001/05/17 16:44:26 1.5
+++ AbstractDOMImplementation.java 2001/07/05 16:59:01 1.6
@@ -8,7 +8,9 @@
package org.apache.batik.dom;
+import org.apache.batik.dom.events.DocumentEventSupport;
import org.apache.batik.dom.util.HashTable;
+
import org.w3c.dom.DOMImplementation;
/**
@@ -16,7 +18,7 @@
* {@link org.w3c.dom.css.DOMImplementationCSS} interfaces.
*
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
- * @version $Id: AbstractDOMImplementation.java,v 1.5 2001/05/17 16:44:26 hillion Exp $
+ * @version $Id: AbstractDOMImplementation.java,v 1.6 2001/07/05 16:59:01 hillion Exp $
*/
public abstract class AbstractDOMImplementation implements DOMImplementation {
@@ -69,5 +71,12 @@
}
return false;
}
+ }
+
+ /**
+ * Creates an DocumentEventSupport object suitable for use with this implementation.
+ */
+ public DocumentEventSupport createDocumentEventSupport() {
+ return new DocumentEventSupport();
}
}
1.7 +13 -4 xml-batik/sources/org/apache/batik/dom/AbstractDocument.java
Index: AbstractDocument.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/AbstractDocument.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- AbstractDocument.java 2001/05/31 12:40:00 1.6
+++ AbstractDocument.java 2001/07/05 16:59:01 1.7
@@ -17,7 +17,7 @@
import java.util.Locale;
import java.util.MissingResourceException;
-import org.apache.batik.dom.events.EventSupport;
+import org.apache.batik.dom.events.DocumentEventSupport;
import org.apache.batik.dom.traversal.TraversalSupport;
import org.apache.batik.i18n.Localizable;
import org.apache.batik.i18n.LocalizableSupport;
@@ -40,7 +40,7 @@
* This class implements the {@link org.w3c.dom.Document} interface.
*
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
- * @version $Id: AbstractDocument.java,v 1.6 2001/05/31 12:40:00 hillion Exp $
+ * @version $Id: AbstractDocument.java,v 1.7 2001/07/05 16:59:01 hillion Exp $
*/
public abstract class AbstractDocument
extends AbstractParentNode
@@ -72,9 +72,14 @@
protected transient TraversalSupport traversalSupport;
/**
+ * The DocumentEventSupport.
+ */
+ protected transient DocumentEventSupport documentEventSupport;
+
+ /**
* Whether the event dispatching must be done.
*/
- protected boolean eventsEnabled;
+ protected transient boolean eventsEnabled;
/**
* Creates a new document.
@@ -249,7 +254,11 @@
* org.w3c.dom.events.DocumentEvent#createEvent(String)}.
*/
public Event createEvent(String eventType) throws DOMException {
- return EventSupport.createEvent(eventType);
+ if (documentEventSupport == null) {
+ documentEventSupport =
+ ((AbstractDOMImplementation)implementation).createDocumentEventSupport();
+ }
+ return documentEventSupport.createEvent(eventType);
}
// DocumentTraversal /////////////////////////////////////////////////////
1.4 +0 -118 xml-batik/sources/org/apache/batik/dom/events/EventSupport.java
Index: EventSupport.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/events/EventSupport.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- EventSupport.java 2000/10/23 09:44:45 1.3
+++ EventSupport.java 2001/07/05 16:59:05 1.4
@@ -23,31 +23,6 @@
public class EventSupport {
/**
- * The MutationEvent type.
- */
- public static final String MUTATION_EVENT_TYPE = "MutationEvents";
-
- /**
- * The MouseEvent type.
- */
- public static final String MOUSE_EVENT_TYPE = "MouseEvents";
-
- /**
- * The UIEvent type.
- */
- public static final String UI_EVENT_TYPE = "UIEvents";
-
- /**
- * The event factories table.
- */
- protected static HashTable eventFactories = new HashTable();
- {
- eventFactories.put(MUTATION_EVENT_TYPE, new MutationEventFactory());
- eventFactories.put(MOUSE_EVENT_TYPE, new MouseEventFactory());
- eventFactories.put(UI_EVENT_TYPE, new UIEventFactory());
- }
-
- /**
* The capturing listeners table.
*/
protected HashTable capturingListeners;
@@ -58,53 +33,6 @@
protected HashTable bubblingListeners;
/**
- * Creates a new Event depending on the specified parameter.
- *
- * @param eventType The <code>eventType</code> parameter specifies the
- * type of <code>Event</code> interface to be created. If the
- * <code>Event</code> interface specified is supported by the
- * implementation this method will return a new <code>Event</code> of
- * the interface type requested. If the <code>Event</code> is to be
- * dispatched via the <code>dispatchEvent</code> method the
- * appropriate event init method must be called after creation in order
- * to initialize the <code>Event</code>'s values. As an example, a
- * user wishing to synthesize some kind of <code>UIEvent</code> would
- * call <code>createEvent</code> with the parameter "UIEvent". The
- * <code>initUIEvent</code> method could then be called on the newly
- * created <code>UIEvent</code> to set the specific type of UIEvent to
- * be dispatched and set its context information.The
- * <code>createEvent</code> method is used in creating
- * <code>Event</code>s when it is either inconvenient or unnecessary
- * for the user to create an <code>Event</code> themselves. In cases
- * where the implementation provided <code>Event</code> is
- * insufficient, users may supply their own <code>Event</code>
- * implementations for use with the <code>dispatchEvent</code> method.
- *
- * @return The newly created <code>Event</code>
- *
- * @exception DOMException
- * NOT_SUPPORTED_ERR: Raised if the implementation does not support the
- * type of <code>Event</code> interface requested
- */
- public static Event createEvent(String eventType)
- throws DOMException {
- EventFactory ef = (EventFactory)eventFactories.get(eventType);
- if (ef == null) {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
- "Bad event type: " + eventType);
- }
- return ef.createEvent();
- }
-
- /**
- * Registers a new EventFactory object.
- */
- public static void registerEventFactory(String eventType,
- EventFactory factory) {
- eventFactories.put(eventType, factory);
- }
-
- /**
* This method allows the registration of event listeners on the
* event target. If an <code>EventListener</code> is added to an
* <code>EventTarget</code> which is currently processing an event
@@ -342,51 +270,5 @@
private static EventException createUnspecifiedEventTypeErr(String s) {
return createEventException(EventException.UNSPECIFIED_EVENT_TYPE_ERR,
s);
- }
-
- /**
- * This interface represents an event factory.
- */
- public interface EventFactory {
- /**
- * Creates a new Event object.
- */
- Event createEvent();
- }
-
- /**
- * To create a mutation event.
- */
- protected static class MutationEventFactory implements EventFactory {
- /**
- * Creates a new Event object.
- */
- public Event createEvent() {
- return new DOMMutationEvent();
- }
- }
-
- /**
- * To create a mouse event.
- */
- protected static class MouseEventFactory implements EventFactory {
- /**
- * Creates a new Event object.
- */
- public Event createEvent() {
- return new DOMMouseEvent();
- }
- }
-
- /**
- * To create a UI event.
- */
- protected static class UIEventFactory implements EventFactory {
- /**
- * Creates a new Event object.
- */
- public Event createEvent() {
- return new DOMUIEvent();
- }
}
}
1.1 xml-batik/sources/org/apache/batik/dom/events/DOMEvent.java
Index: DOMEvent.java
===================================================================
/*****************************************************************************
* Copyright (C) The Apache Software Foundation. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Apache Software License *
* version 1.1, a copy of which has been included with this distribution in *
* the LICENSE file. *
*****************************************************************************/
package org.apache.batik.dom.events;
/**
* A simple event.
*
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
* @version $Id: DOMEvent.java,v 1.1 2001/07/05 16:59:04 hillion Exp $
*/
public class DOMEvent extends AbstractEvent {
}
1.1 xml-batik/sources/org/apache/batik/dom/events/DocumentEventSupport.java
Index: DocumentEventSupport.java
===================================================================
/*****************************************************************************
* Copyright (C) The Apache Software Foundation. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Apache Software License *
* version 1.1, a copy of which has been included with this distribution in *
* the LICENSE file. *
*****************************************************************************/
package org.apache.batik.dom.events;
import org.apache.batik.dom.util.*;
import org.w3c.dom.*;
import org.w3c.dom.events.*;
/**
* This class implements the behavior of DocumentEvent.
*
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
* @version $Id: DocumentEventSupport.java,v 1.1 2001/07/05 16:59:04 hillion Exp $
*/
public class DocumentEventSupport {
/**
* The Event type.
*/
public static final String EVENT_TYPE = "Events";
/**
* The MutationEvent type.
*/
public static final String MUTATION_EVENT_TYPE = "MutationEvents";
/**
* The MouseEvent type.
*/
public static final String MOUSE_EVENT_TYPE = "MouseEvents";
/**
* The UIEvent type.
*/
public static final String UI_EVENT_TYPE = "UIEvents";
/**
* The event factories table.
*/
protected HashTable eventFactories = new HashTable();
{
eventFactories.put(EVENT_TYPE.toLowerCase(),
new SimpleEventFactory());
eventFactories.put(MUTATION_EVENT_TYPE.toLowerCase(),
new MutationEventFactory());
eventFactories.put(MOUSE_EVENT_TYPE.toLowerCase(),
new MouseEventFactory());
eventFactories.put(UI_EVENT_TYPE.toLowerCase(),
new UIEventFactory());
}
/**
* Creates a new Event depending on the specified parameter.
*
* @param eventType The <code>eventType</code> parameter specifies the
* type of <code>Event</code> interface to be created. If the
* <code>Event</code> interface specified is supported by the
* implementation this method will return a new <code>Event</code> of
* the interface type requested. If the <code>Event</code> is to be
* dispatched via the <code>dispatchEvent</code> method the
* appropriate event init method must be called after creation in order
* to initialize the <code>Event</code>'s values. As an example, a
* user wishing to synthesize some kind of <code>UIEvent</code> would
* call <code>createEvent</code> with the parameter "UIEvent". The
* <code>initUIEvent</code> method could then be called on the newly
* created <code>UIEvent</code> to set the specific type of UIEvent to
* be dispatched and set its context information.The
* <code>createEvent</code> method is used in creating
* <code>Event</code>s when it is either inconvenient or unnecessary
* for the user to create an <code>Event</code> themselves. In cases
* where the implementation provided <code>Event</code> is
* insufficient, users may supply their own <code>Event</code>
* implementations for use with the <code>dispatchEvent</code> method.
*
* @return The newly created <code>Event</code>
*
* @exception DOMException
* NOT_SUPPORTED_ERR: Raised if the implementation does not support the
* type of <code>Event</code> interface requested
*/
public Event createEvent(String eventType)
throws DOMException {
EventFactory ef = (EventFactory)eventFactories.get(eventType.toLowerCase());
if (ef == null) {
throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
"Bad event type: " + eventType);
}
return ef.createEvent();
}
/**
* Registers a new EventFactory object.
*/
public void registerEventFactory(String eventType,
EventFactory factory) {
eventFactories.put(eventType.toLowerCase(), factory);
}
/**
* This interface represents an event factory.
*/
public interface EventFactory {
/**
* Creates a new Event object.
*/
Event createEvent();
}
/**
* To create a simple event.
*/
protected static class SimpleEventFactory implements EventFactory {
/**
* Creates a new Event object.
*/
public Event createEvent() {
return new DOMEvent();
}
}
/**
* To create a mutation event.
*/
protected static class MutationEventFactory implements EventFactory {
/**
* Creates a new Event object.
*/
public Event createEvent() {
return new DOMMutationEvent();
}
}
/**
* To create a mouse event.
*/
protected static class MouseEventFactory implements EventFactory {
/**
* Creates a new Event object.
*/
public Event createEvent() {
return new DOMMouseEvent();
}
}
/**
* To create a UI event.
*/
protected static class UIEventFactory implements EventFactory {
/**
* Creates a new Event object.
*/
public Event createEvent() {
return new DOMUIEvent();
}
}
}
1.11 +16 -11 xml-batik/sources/org/apache/batik/dom/svg/SVGDOMImplementation.java
Index: SVGDOMImplementation.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/svg/SVGDOMImplementation.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- SVGDOMImplementation.java 2001/05/17 16:36:53 1.10
+++ SVGDOMImplementation.java 2001/07/05 16:59:06 1.11
@@ -18,7 +18,7 @@
import org.apache.batik.dom.AbstractDOMImplementation;
import org.apache.batik.dom.AbstractNode;
import org.apache.batik.dom.StyleSheetFactory;
-import org.apache.batik.dom.events.EventSupport;
+import org.apache.batik.dom.events.DocumentEventSupport;
import org.apache.batik.dom.util.CSSStyleDeclarationFactory;
import org.apache.batik.dom.util.DOMUtilities;
import org.apache.batik.dom.util.HashTable;
@@ -40,7 +40,7 @@
* This class implements the {@link org.w3c.dom.DOMImplementation} interface.
*
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
- * @version $Id: SVGDOMImplementation.java,v 1.10 2001/05/17 16:36:53 hillion Exp $
+ * @version $Id: SVGDOMImplementation.java,v 1.11 2001/07/05 16:59:06 hillion Exp $
*/
public class SVGDOMImplementation
extends AbstractDOMImplementation
@@ -59,15 +59,6 @@
protected final static DOMImplementation DOM_IMPLEMENTATION =
new SVGDOMImplementation();
- static {
- EventSupport.registerEventFactory("SVGEvents",
- new EventSupport.EventFactory() {
- public Event createEvent() {
- return new SVGOMEvent();
- }
- });
- }
-
{
registerFeature("CSS", "2.0");
registerFeature("StyleSheets", "2.0");
@@ -212,5 +203,19 @@
}
//throw new RuntimeException("'" + type + "' not supported");
return null;
+ }
+
+ /**
+ * Creates an DocumentEventSupport object suitable for use with this implementation.
+ */
+ public DocumentEventSupport createDocumentEventSupport() {
+ DocumentEventSupport result = new DocumentEventSupport();
+ result.registerEventFactory("SVGEvents",
+ new DocumentEventSupport.EventFactory() {
+ public Event createEvent() {
+ return new SVGOMEvent();
+ }
+ });
+ return result;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org