tkormann 02/04/23 10:10:14 Modified: resources/org/apache/batik/dom/svg/resources Messages.properties sources/org/apache/batik/bridge AbstractGraphicsNodeBridge.java sources/org/apache/batik/dom/svg SVGContext.java SVGLocatableSupport.java SVGOMElement.java sources/org/apache/batik/util SVGConstants.java Log: - implement getTransformToElement, getNearestViewportElement, and getFarthestViewportElement Revision Changes Path 1.4 +4 -0 xml-batik/resources/org/apache/batik/dom/svg/resources/Messages.properties Index: Messages.properties =================================================================== RCS file: /home/cvs/xml-batik/resources/org/apache/batik/dom/svg/resources/Messages.properties,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Messages.properties 18 Mar 2002 10:28:19 -0000 1.3 +++ Messages.properties 23 Apr 2002 17:10:13 -0000 1.4 @@ -25,3 +25,7 @@ css.parser.access = \ The CSS parser class '{0}' cannot be accessed. + +noninvertiblematrix = \ +The matrix is not invertible. + 1.23 +9 -1 xml-batik/sources/org/apache/batik/bridge/AbstractGraphicsNodeBridge.java Index: AbstractGraphicsNodeBridge.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/AbstractGraphicsNodeBridge.java,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- AbstractGraphicsNodeBridge.java 22 Apr 2002 14:59:44 -0000 1.22 +++ AbstractGraphicsNodeBridge.java 23 Apr 2002 17:10:13 -0000 1.23 @@ -44,7 +44,7 @@ * </ul> * * @author <a href="mailto:[EMAIL PROTECTED]">Thierry Kormann</a> - * @version $Id: AbstractGraphicsNodeBridge.java,v 1.22 2002/04/22 14:59:44 tkormann Exp $ + * @version $Id: AbstractGraphicsNodeBridge.java,v 1.23 2002/04/23 17:10:13 tkormann Exp $ */ public abstract class AbstractGraphicsNodeBridge extends AbstractSVGBridge implements SVGContext, @@ -294,6 +294,14 @@ } } return ctm; + } + + /** + * Returns the global transformation matrix from the current + * element to the root. + */ + public AffineTransform getGlobalTransform() { + return node.getGlobalTransform(); } /** 1.8 +7 -1 xml-batik/sources/org/apache/batik/dom/svg/SVGContext.java Index: SVGContext.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/svg/SVGContext.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- SVGContext.java 15 Apr 2002 10:16:12 -0000 1.7 +++ SVGContext.java 23 Apr 2002 17:10:14 -0000 1.8 @@ -15,7 +15,7 @@ * This interface is the placeholder for SVG application informations. * * @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a> - * @version $Id: SVGContext.java,v 1.7 2002/04/15 10:16:12 hillion Exp $ + * @version $Id: SVGContext.java,v 1.8 2002/04/23 17:10:14 tkormann Exp $ */ public interface SVGContext { @@ -38,6 +38,12 @@ * the viewport coordinate system for the nearestViewportElement. */ AffineTransform getCTM(); + + /** + * Returns the global transformation matrix from the current + * element to the root. + */ + AffineTransform getGlobalTransform(); /** * Returns the width of the viewport which directly contains the 1.4 +44 -7 xml-batik/sources/org/apache/batik/dom/svg/SVGLocatableSupport.java Index: SVGLocatableSupport.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/svg/SVGLocatableSupport.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- SVGLocatableSupport.java 15 Apr 2002 10:16:12 -0000 1.3 +++ SVGLocatableSupport.java 23 Apr 2002 17:10:14 -0000 1.4 @@ -9,11 +9,16 @@ package org.apache.batik.dom.svg; import java.awt.geom.AffineTransform; +import java.awt.geom.NoninvertibleTransformException; + +import org.apache.batik.css.engine.SVGCSSEngine; import org.w3c.dom.DOMException; import org.w3c.dom.Element; + import org.w3c.dom.svg.SVGElement; import org.w3c.dom.svg.SVGException; +import org.w3c.dom.svg.SVGFitToViewBox; import org.w3c.dom.svg.SVGMatrix; import org.w3c.dom.svg.SVGRect; @@ -21,7 +26,7 @@ * This class provides support for the SVGLocatable interface. * * @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a> - * @version $Id: SVGLocatableSupport.java,v 1.3 2002/04/15 10:16:12 hillion Exp $ + * @version $Id: SVGLocatableSupport.java,v 1.4 2002/04/23 17:10:14 tkormann Exp $ */ public class SVGLocatableSupport { /** @@ -34,8 +39,15 @@ * To implement {@link * org.w3c.dom.svg.SVGLocatable#getNearestViewportElement()}. */ - public static SVGElement getNearestViewportElement(Element elt) { - throw new RuntimeException(" !!! TODO: getNearestViewportElement()"); + public static SVGElement getNearestViewportElement(Element e) { + Element elt = e; + while (elt != null) { + elt = SVGCSSEngine.getParentCSSStylableElement(elt); + if (elt instanceof SVGFitToViewBox) { + break; + } + } + return (SVGElement)elt; } /** @@ -43,7 +55,7 @@ * org.w3c.dom.svg.SVGLocatable#getFarthestViewportElement()}. */ public static SVGElement getFarthestViewportElement(Element elt) { - throw new RuntimeException(" !!! TODO: getFarthestViewportElement()"); + return (SVGElement)elt.getOwnerDocument().getDocumentElement(); } /** @@ -93,8 +105,8 @@ return new AbstractSVGMatrix() { protected AffineTransform getAffineTransform() { return svgelt.getSVGContext().getCTM(); - } - }; + } + }; } /** @@ -112,6 +124,31 @@ public static SVGMatrix getTransformToElement(Element elt, SVGElement element) throws SVGException { - throw new RuntimeException(" !!! TODO: getTransformToElement()"); + final SVGOMElement currentElt = (SVGOMElement)elt; + final SVGOMElement targetElt = (SVGOMElement)element; + return new AbstractSVGMatrix() { + protected AffineTransform getAffineTransform() { + AffineTransform cat = + currentElt.getSVGContext().getGlobalTransform(); + if (cat == null) { + cat = new AffineTransform(); + } + AffineTransform tat = + targetElt.getSVGContext().getGlobalTransform(); + if (tat == null) { + tat = new AffineTransform(); + } + AffineTransform at = new AffineTransform(cat); + try { + at.preConcatenate(tat.createInverse()); + return at; + } catch (NoninvertibleTransformException ex) { + throw currentElt.createSVGException + (SVGException.SVG_MATRIX_NOT_INVERTABLE, + "noninvertiblematrix", + null); + } + } + }; } } 1.13 +16 -1 xml-batik/sources/org/apache/batik/dom/svg/SVGOMElement.java Index: SVGOMElement.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/svg/SVGOMElement.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- SVGOMElement.java 15 Apr 2002 10:16:13 -0000 1.12 +++ SVGOMElement.java 23 Apr 2002 17:10:14 -0000 1.13 @@ -27,6 +27,7 @@ import org.w3c.dom.svg.SVGAnimatedNumber; import org.w3c.dom.svg.SVGAnimatedString; import org.w3c.dom.svg.SVGElement; +import org.w3c.dom.svg.SVGException; import org.w3c.dom.svg.SVGFitToViewBox; import org.w3c.dom.svg.SVGSVGElement; @@ -34,7 +35,7 @@ * This class implements the {@link SVGElement} interface. * * @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a> - * @version $Id: SVGOMElement.java,v 1.12 2002/04/15 10:16:13 hillion Exp $ + * @version $Id: SVGOMElement.java,v 1.13 2002/04/23 17:10:14 tkormann Exp $ */ public abstract class SVGOMElement extends AbstractElement @@ -188,6 +189,20 @@ } // ExtendedNode ////////////////////////////////////////////////// + + /** + * Creates an SVGException with the appropriate error message. + */ + public SVGException createSVGException(short type, + String key, + Object [] args) { + try { + return new SVGOMException + (type, getCurrentDocument().formatMessage(key, args)); + } catch (Exception e) { + return new SVGOMException(type, key); + } + } /** * Tests whether this node is readonly. 1.64 +199 -20 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.63 retrieving revision 1.64 diff -u -r1.63 -r1.64 --- SVGConstants.java 15 Apr 2002 10:16:17 -0000 1.63 +++ SVGConstants.java 23 Apr 2002 17:10:14 -0000 1.64 @@ -14,7 +14,7 @@ * @author <a href="mailto:[EMAIL PROTECTED]">Thierry Kormann</a> * @author <a href="[EMAIL PROTECTED]">Vincent Hardy</a> * @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a> - * @version $Id: SVGConstants.java,v 1.63 2002/04/15 10:16:17 hillion Exp $ + * @version $Id: SVGConstants.java,v 1.64 2002/04/23 17:10:14 tkormann Exp $ */ public interface SVGConstants extends CSSConstants { @@ -34,6 +34,204 @@ String SVG_VERSION = "1.0"; + ////////////////////////////////////////////////////////////////////////// + // Events type and attributes + ////////////////////////////////////////////////////////////////////////// + + /** + * The event type for MouseEvent. + */ + String SVG_MOUSEEVENTS_EVENT_TYPE = "MouseEvents"; + + /** + * The event type for UIEvent. + */ + String SVG_UIEVENTS_EVENT_TYPE = "UIEvents"; + + /** + * The event type for SVGEvent. + */ + String SVG_SVGEVENTS_EVENT_TYPE = "SVGEvents"; + + // --------------------------------------------------------------------- + + /** + * The event type for 'click' MouseEvent. + */ + String SVG_CLICK_EVENT_TYPE = "click"; + + /** + * The event type for 'mouseup' MouseEvent. + */ + String SVG_MOUSEUP_EVENT_TYPE = "mouseup"; + + /** + * The event type for 'mousedown' MouseEvent. + */ + String SVG_MOUSEDOWN_EVENT_TYPE = "mousedown"; + + /** + * The event type for 'mousemove' MouseEvent. + */ + String SVG_MOUSEMOVE_EVENT_TYPE = "mousemove"; + + /** + * The event type for 'mouseout' MouseEvent. + */ + String SVG_MOUSEOUT_EVENT_TYPE = "mouseout"; + + /** + * The event type for 'mouseover' MouseEvent. + */ + String SVG_MOUSEOVER_EVENT_TYPE = "mouseover"; + + /** + * The event type for 'DOMFocusIn' UIEvent. + */ + String SVG_DOMFOCUSIN_EVENT_TYPE = "DOMFocusIn"; + + /** + * The event type for 'DOMFocusOut' UIEvent. + */ + String SVG_DOMFOCUSOUT_EVENT_TYPE = "DOMFocusOut"; + + /** + * The event type for 'DOMActivate' UIEvent. + */ + String SVG_DOMACTIVATE_EVENT_TYPE = "DOMActivate"; + + /** + * The event type for 'SVGLoad' SVGEvent. + */ + String SVG_SVGLOAD_EVENT_TYPE = "SVGLoad"; + + /** + * The event type for 'SVGUnload' SVGEvent. + */ + String SVG_SVGUNLOAD_EVENT_TYPE = "SVGUnload"; + + /** + * The event type for 'SVGAbort' SVGEvent. + */ + String SVG_SVGABORT_EVENT_TYPE = "SVGAbort"; + + /** + * The event type for 'SVGError' SVGEvent. + */ + String SVG_SVGERROR_EVENT_TYPE = "SVGError"; + + /** + * The event type for 'SVGResize' SVGEvent. + */ + String SVG_SVGRESIZE_EVENT_TYPE = "SVGResize"; + + /** + * The event type for 'SVGScroll' SVGEvent. + */ + String SVG_SVGSCROLL_EVENT_TYPE = "SVGScroll"; + + /** + * The event type for 'SVGZoom' SVGEvent. + */ + String SVG_SVGZOOM_EVENT_TYPE = "SVGZoom"; + + // --------------------------------------------------------------------- + + /** + * The 'onabort' attribute name of type SVGEvents. + */ + String SVG_ONABORT_ATTRIBUTE = "onabort"; + + /** + * The 'onabort' attribute name of type SVGEvents. + */ + String SVG_ONACTIVATE_ATTRIBUTE = "onactivate"; + + /** + * The 'onbegin' attribute name of type SVGEvents. + */ + String SVG_ONBEGIN_ATTRIBUTE = "onbegin"; + + /** + * The 'onclick' attribute name of type MouseEvents. + */ + String SVG_ONCLICK_ATTRIBUTE = "onclick"; + + /** + * The 'onend' attribute name of type SVGEvents. + */ + String SVG_ONEND_ATTRIBUTE = "onend"; + + /** + * The 'onerror' attribute name of type SVGEvents. + */ + String SVG_ONERROR_ATTRIBUTE = "onerror"; + + /** + * The 'onfocusin' attribute name of type UIEvents. + */ + String SVG_ONFOCUSIN_ATTRIBUTE = "onfocusin"; + + /** + * The 'onfocusout' attribute name of type UIEvents. + */ + String SVG_ONFOCUSOUT_ATTRIBUTE = "onfocusout"; + + /** + * The 'onload' attribute name of type SVGEvents. + */ + String SVG_ONLOAD_ATTRIBUTE = "onload"; + + /** + * The 'onmousedown' attribute name of type MouseEvents. + */ + String SVG_ONMOUSEDOWN_ATTRIBUTE = "onmousedown"; + + /** + * The 'onmousemove' attribute name of type MouseEvents. + */ + String SVG_ONMOUSEMOVE_ATTRIBUTE = "onmousemove"; + + /** + * The 'onmouseout' attribute name of type MouseEvents. + */ + String SVG_ONMOUSEOUT_ATTRIBUTE = "onmouseout"; + + /** + * The 'onmouseover' attribute name of type MouseEvents. + */ + String SVG_ONMOUSEOVER_ATTRIBUTE = "onmouseover"; + + /** + * The 'onmouseup' attribute name of type MouseEvents. + */ + String SVG_ONMOUSEUP_ATTRIBUTE = "onmouseup"; + + /** + * The 'onrepeat' attribute name of type SVGEvents. + */ + String SVG_ONREPEAT_ATTRIBUTE = "onrepeat"; + + /** + * The 'onresize' attribute name of type SVGEvents. + */ + String SVG_ONRESIZE_ATTRIBUTE = "onresize"; + + /** + * The 'onscroll' attribute name of type SVGEvents. + */ + String SVG_ONSCROLL_ATTRIBUTE = "onscroll"; + + /** + * The 'onunload' attribute name of type SVGEvents. + */ + String SVG_ONUNLOAD_ATTRIBUTE = "onunload"; + + /** + * The 'onzoom' attribute name of type SVGEvents. + */ + String SVG_ONZOOM_ATTRIBUTE = "onzoom"; + ///////////////////////////////////////////////////////////////////////// // SVG features ///////////////////////////////////////////////////////////////////////// @@ -225,25 +423,6 @@ String SVG_OFFSET_ATTRIBUTE = "offset"; String SVG_OPACITY_ATTRIBUTE = CSS_OPACITY_PROPERTY; String SVG_OPERATOR_ATTRIBUTE = "operator"; - String SVG_ONABORT_ATTRIBUTE = "onabort"; - String SVG_ONACTIVATE_ATTRIBUTE = "onactivate"; - String SVG_ONBEGIN_ATTRIBUTE = "onbegin"; - String SVG_ONCLICK_ATTRIBUTE = "onclick"; - String SVG_ONEND_ATTRIBUTE = "onend"; - String SVG_ONERROR_ATTRIBUTE = "onerror"; - String SVG_ONFOCUSIN_ATTRIBUTE = "onfocusin"; - String SVG_ONFOCUSOUT_ATTRIBUTE = "onfocusout"; - String SVG_ONLOAD_ATTRIBUTE = "onload"; - String SVG_ONMOUSEDOWN_ATTRIBUTE = "onmousedown"; - String SVG_ONMOUSEMOVE_ATTRIBUTE = "onmousemove"; - String SVG_ONMOUSEOUT_ATTRIBUTE = "onmouseout"; - String SVG_ONMOUSEOVER_ATTRIBUTE = "onmouseover"; - String SVG_ONMOUSEUP_ATTRIBUTE = "onmouseup"; - String SVG_ONREPEAT_ATTRIBUTE = "onrepeat"; - String SVG_ONRESIZE_ATTRIBUTE = "onresize"; - String SVG_ONSCROLL_ATTRIBUTE = "onscroll"; - String SVG_ONUNLOAD_ATTRIBUTE = "onunload"; - String SVG_ONZOOM_ATTRIBUTE = "onzoom"; String SVG_ORDER_ATTRIBUTE = "order"; String SVG_ORDER_X_ATTRIBUTE = "orderX"; String SVG_ORDER_Y_ATTRIBUTE = "orderY";
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]