deweese     01/10/16 16:25:31

  Modified:    sources/org/apache/batik/dom/svg SAXSVGDocumentFactory.java
               sources/org/apache/batik/extension/svg
                        BatikBridgeExtension.java BatikDomExtension.java
                        BatikExtConstants.java
               sources/org/apache/batik/svggen SVGGraphics2DUnitTester.java
  Added:       samples/extensions solidColor.svg
               sources/org/apache/batik/extension/svg SolidColorBridge.java
                        SolidColorElement.java
  Log:
  1) SAXSVGDocumentFactory & SVGGraphics2DUnitTester now use
     ExtensibleDomImplementation which may fix event problems for
     extension elements but defininately solves some problems for my
     solid color Paint Server.
  2) Added another example SVG extension which is a solid color paint server.
  
  Revision  Changes    Path
  1.1                  xml-batik/samples/extensions/solidColor.svg
  
  Index: solidColor.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";>
  
  <!-- ====================================================================== -->
  <!-- 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.                                     -->
  <!-- ====================================================================== -->
  
  <!-- ====================================================================== -->
  <!-- regularPoly extension tag test                                         -->
  <!--                                                                        -->
  <!-- @author [EMAIL PROTECTED]                                       -->
  <!-- @version $Id: solidColor.svg,v 1.1 2001/10/16 23:25:31 deweese Exp $ -->
  <!-- ====================================================================== -->
  
  <?xml-stylesheet type="text/css" href="extension.css" ?>
  
  <svg id="body" width="450" height="500" xml:space="preserve" 
       viewBox="0 0 450 500"
       xmlns:svg="http://www.w3.org/2000/svg";
       xmlns:batik="http://xml.apache.org/batik/ext";>
  
      <title>Star Extension Tag</title>
    
      <!-- ============================================================= -->
      <!-- Test content                                                  -->
      <!-- ============================================================= -->
      <g id="testContent" class="legend" style="text-anchor:middle">
          <text x="225" y="40" class="title">
              Solid Color Paint Server
          </text>
    
          <switch>
            <g requiredExtensions="http://xml.apache.org/batik/ext/solidColor/1.0";
               fill="#0D0" stroke="#88F" stroke-width="2">
  
              <batik:solidColor id="TransPurple" color="#FF00FF" opacity=".5"/>
              <batik:solidColor id="SolidPurple" color="#FF00FF" />
              <batik:solidColor id="orange"      color="orange" opacity="1"/>
  
              <circle fill="url(#SolidPurple)"   cx="85"  cy="135" r="50"/>
              <circle fill="url(#TransPurple)"   cx="225" cy="135" r="50"/>
              <circle fill="url(#orange)"        cx="365" cy="135" r="50"/>
                                              
              <circle stroke="url(#SolidPurple)" cx="85"  cy="275" r="50"/>
              <circle stroke="url(#TransPurple)" cx="225" cy="275" r="50"/>
              <circle stroke="url(#orange)"      cx="365" cy="275" r="50"/>
  
              <circle fill="url(#SolidPurple)"  opacity="0.5" 
                      cx="85"  cy="415" r="50"/>
              <circle fill="url(#TransPurple)"  opacity="0.5" 
                      cx="225" cy="415" r="50"/>
              <circle fill="url(#orange)"       opacity="0.5" 
                      cx="365" cy="415" r="50"/>
            </g>
           
            <g fill="red">
              <circle cx="85"  cy="135" r="50"/>
              <circle cx="225" cy="135" r="50"/>
              <circle cx="365" cy="135" r="50"/>
                                              
              <circle cx="85"  cy="275" r="50"/>
              <circle cx="225" cy="275" r="50"/>
              <circle cx="365" cy="275" r="50"/>
        
              <circle cx="85"  cy="415" r="50"/>
              <circle cx="225" cy="415" r="50"/>
              <circle cx="365" cy="415" r="50"/>
            </g>
          </switch>
      </g>
  
      <!-- ============================================================= -->
      <!-- Batik sample mark                                             -->
      <!-- ============================================================= -->
      <use xlink:href="../batikLogo.svg#Batik_Tag_Box" />
  </svg>
  
  
  
  1.11      +3 -3      
xml-batik/sources/org/apache/batik/dom/svg/SAXSVGDocumentFactory.java
  
  Index: SAXSVGDocumentFactory.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/dom/svg/SAXSVGDocumentFactory.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- SAXSVGDocumentFactory.java        2001/09/10 13:17:20     1.10
  +++ SAXSVGDocumentFactory.java        2001/10/16 23:25:31     1.11
  @@ -36,7 +36,7 @@
    * from an URI using SAX2.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
  - * @version $Id: SAXSVGDocumentFactory.java,v 1.10 2001/09/10 13:17:20 hillion Exp $
  + * @version $Id: SAXSVGDocumentFactory.java,v 1.11 2001/10/16 23:25:31 deweese Exp $
    */
   public class SAXSVGDocumentFactory
       extends    SAXDocumentFactory
  @@ -63,7 +63,7 @@
        * @param parser The SAX2 parser classname.
        */
       public SAXSVGDocumentFactory(String parser) {
  -        super(SVGDOMImplementation.getDOMImplementation(), parser);
  +        super(ExtensibleSVGDOMImplementation.getDOMImplementation(), parser);
       }
   
       /**
  @@ -72,7 +72,7 @@
        * @param dd Whether a document descriptor must be generated.
        */
       public SAXSVGDocumentFactory(String parser, boolean dd) {
  -        super(SVGDOMImplementation.getDOMImplementation(), parser, dd);
  +        super(ExtensibleSVGDOMImplementation.getDOMImplementation(), parser, dd);
       }
   
       /**
  
  
  
  1.3       +2 -0      
xml-batik/sources/org/apache/batik/extension/svg/BatikBridgeExtension.java
  
  Index: BatikBridgeExtension.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/extension/svg/BatikBridgeExtension.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BatikBridgeExtension.java 2001/08/30 17:14:01     1.2
  +++ BatikBridgeExtension.java 2001/10/16 23:25:31     1.3
  @@ -40,6 +40,7 @@
               "http://xml.apache.org/batik/ext/poly/1.0"; ,
               "http://xml.apache.org/batik/ext/star/1.0"; ,
               "http://xml.apache.org/batik/ext/histogramNormalization/1.0"; ,
  +            "http://xml.apache.org/batik/ext/solidColor/1.0"; ,
           };
           Vector v = new Vector(extensions.length);
           for (int i=0; i<extensions.length; i++) {
  @@ -92,5 +93,6 @@
           ctx.putBridge(new BatikRegularPolygonElementBridge());
           ctx.putBridge(new BatikStarElementBridge());
           ctx.putBridge(new BatikHistogramNormalizationElementBridge());
  +        ctx.putBridge(new SolidColorBridge());
       }
   }
  
  
  
  1.4       +21 -0     
xml-batik/sources/org/apache/batik/extension/svg/BatikDomExtension.java
  
  Index: BatikDomExtension.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/extension/svg/BatikDomExtension.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- BatikDomExtension.java    2001/08/30 17:14:01     1.3
  +++ BatikDomExtension.java    2001/10/16 23:25:31     1.4
  @@ -86,6 +86,11 @@
               (BATIK_EXT_NAMESPACE_URI,
                BATIK_EXT_HISTOGRAM_NORMALIZATION_TAG,
                new BatikHistogramNormalizationElementFactory());
  +
  +        di.registerCustomElementFactory
  +            (BATIK_EXT_NAMESPACE_URI,
  +             BATIK_EXT_SOLID_COLOR_TAG,
  +             new SolidColorElementFactory());
       }
   
       /**
  @@ -130,6 +135,22 @@
           public Element create(String prefix, Document doc) {
               return new BatikHistogramNormalizationElement
                   (prefix, (AbstractDocument)doc);
  +        }
  +    }
  +
  +    /**
  +     * To create a 'solidColor' element.
  +     */
  +    protected static class SolidColorElementFactory 
  +        implements SVGDOMImplementation.ElementFactory {
  +        public SolidColorElementFactory() {
  +            System.out.println("FActory created");
  +        }
  +        /**
  +         * Creates an instance of the associated element type.
  +         */
  +        public Element create(String prefix, Document doc) {
  +            return new SolidColorElement(prefix, (AbstractDocument)doc);
           }
       }
   
  
  
  
  1.3       +12 -0     
xml-batik/sources/org/apache/batik/extension/svg/BatikExtConstants.java
  
  Index: BatikExtConstants.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/extension/svg/BatikExtConstants.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BatikExtConstants.java    2001/08/30 17:14:01     1.2
  +++ BatikExtConstants.java    2001/10/16 23:25:31     1.3
  @@ -23,6 +23,10 @@
       public static final String BATIK_EXT_STAR_TAG = 
           "star";
   
  +    /** Tag name for Batik's regular poly extension. */
  +    public static final String BATIK_EXT_SOLID_COLOR_TAG = 
  +        "solidColor";
  +
       /** Tag name for Batik's star extension. */
       public static final String BATIK_EXT_HISTOGRAM_NORMALIZATION_TAG =
           "histogramNormalization";
  @@ -38,5 +42,13 @@
       /** Attribute name for trim percent attribute */
       public static final String BATIK_EXT_TRIM_ATTRIBUTE = 
           "trim";
  +
  +    /** Attribute name for color attribute */
  +    public static final String BATIK_EXT_COLOR_ATTRIBUTE = 
  +        "color";
  +
  +    /** Attribute name for opacity attribute */
  +    public static final String BATIK_EXT_OPACITY_ATTRIBUTE = 
  +        "opacity";
   
   }
  
  
  
  1.1                  
xml-batik/sources/org/apache/batik/extension/svg/SolidColorBridge.java
  
  Index: SolidColorBridge.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.extension.svg;
  
  import java.awt.Color;
  import java.awt.Paint;
  import java.util.Vector;
  
  import org.apache.batik.bridge.CSSUtilities;
  import org.apache.batik.bridge.BridgeContext;
  import org.apache.batik.bridge.AbstractSVGBridge;
  import org.apache.batik.bridge.PaintBridge;
  import org.apache.batik.bridge.PaintServer;
  import org.apache.batik.gvt.GraphicsNode;
  import org.apache.batik.css.CSSOMReadOnlyStyleDeclaration;
  import org.apache.batik.util.CSSConstants;
  import org.w3c.dom.css.CSSPrimitiveValue;
  import org.w3c.dom.css.CSSValue;
  import org.w3c.dom.Element;
  import org.w3c.dom.svg.SVGColor;
  
  /**
   * Bridge class for a regular polygon element.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Thomas Deweese</a>
   */
  public class SolidColorBridge 
      extends AbstractSVGBridge
      implements PaintBridge, BatikExtConstants, CSSConstants {
  
      /**
       * Constructs a new bridge for the &lt;rect> element.
       */
      public SolidColorBridge() { /* nothing */ }
  
      /**
       * Returns the SVG namespace URI.
       */
      public String getNamespaceURI() {
          return BATIK_EXT_NAMESPACE_URI;
      }
  
      /**
       * Returns 'rect'.
       */
      public String getLocalName() {
          return BATIK_EXT_SOLID_COLOR_TAG;
      }
  
      /**
       * Creates a <tt>Paint</tt> according to the specified parameters.
       *
       * @param ctx the bridge context to use
       * @param paintElement the element that defines a Paint
       * @param paintedElement the element referencing the paint
       * @param paintedNode the graphics node on which the Paint will be applied
       * @param opacity the opacity of the Paint to create
       */
      public Paint createPaint(BridgeContext ctx,
                               Element paintElement,
                               Element paintedElement,
                               GraphicsNode paintedNode,
                               float opacity) {
          CSSOMReadOnlyStyleDeclaration decl;
          decl = CSSUtilities.getComputedStyle(paintElement);
          float attr = PaintServer.convertOpacity
              (decl.getPropertyCSSValueInternal(CSS_OPACITY_PROPERTY));
          opacity *= attr;
  
          CSSValue colorDef
              = decl.getPropertyCSSValueInternal(CSS_COLOR_PROPERTY);
          Color ret = null;
          if (colorDef.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
              CSSPrimitiveValue v = (CSSPrimitiveValue)colorDef;
              ret = PaintServer.convertColor(v.getRGBColorValue(), opacity);
          } else {
              ret = PaintServer.convertRGBICCColor
                  (paintElement, (SVGColor)colorDef, opacity, ctx);
          }
          return ret;
      }
  }
  
  
  
  1.1                  
xml-batik/sources/org/apache/batik/extension/svg/SolidColorElement.java
  
  Index: SolidColorElement.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.extension.svg;
  
  import org.w3c.dom.Node;
  
  import org.apache.batik.dom.AbstractDocument;
  import org.apache.batik.extension.PrefixableStylableExtensionElement;
  
  /**
   * This class implements a regular polygon extension to SVG
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Thomas DeWeese</a>
   * @version $Id: SolidColorElement.java,v 1.1 2001/10/16 23:25:31 deweese Exp $
   */
  public class SolidColorElement
      extends    PrefixableStylableExtensionElement 
      implements BatikExtConstants {
  
      /**
       * Creates a new BatikRegularPolygonElement object.
       */
      protected SolidColorElement() {
      }
  
      /**
       * Creates a new BatikRegularPolygonElement object.
       * @param prefix The namespace prefix.
       * @param owner The owner document.
       */
      public SolidColorElement(String prefix, AbstractDocument owner) {
          super(prefix, owner);
      }
  
      /**
       * <b>DOM</b>: Implements {@link org.w3c.dom.Node#getLocalName()}.
       */
      public String getLocalName() {
          return BATIK_EXT_SOLID_COLOR_TAG;
      }
  
      /**
       * <b>DOM</b>: Implements {@link org.w3c.dom.Node#getNamespaceURI()}.
       */
      public String getNamespaceURI() {
          return BATIK_EXT_NAMESPACE_URI;
      }
  
      /**
       * Returns a new uninitialized instance of this object's class.
       */
      protected Node newNode() {
          return new SolidColorElement();
      }
  }
  
  
  
  1.9       +3 -3      
xml-batik/sources/org/apache/batik/svggen/SVGGraphics2DUnitTester.java
  
  Index: SVGGraphics2DUnitTester.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/svggen/SVGGraphics2DUnitTester.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- SVGGraphics2DUnitTester.java      2001/09/19 12:52:32     1.8
  +++ SVGGraphics2DUnitTester.java      2001/10/16 23:25:31     1.9
  @@ -13,7 +13,7 @@
   import java.lang.reflect.InvocationTargetException;
   import java.lang.reflect.Modifier;
   import org.w3c.dom.*;
  -import org.apache.batik.dom.svg.SVGDOMImplementation;
  +import org.apache.batik.dom.svg.ExtensibleSVGDOMImplementation;
   import org.apache.batik.dom.svg.SVGOMDocument;
   
   import org.apache.batik.util.SVGConstants;
  @@ -31,7 +31,7 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Christophe Jolif</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Vincent Hardy</a>
  - * @version $Id: SVGGraphics2DUnitTester.java,v 1.8 2001/09/19 12:52:32 cjolif Exp $
  + * @version $Id: SVGGraphics2DUnitTester.java,v 1.9 2001/10/16 23:25:31 deweese Exp 
$
    */
   public class SVGGraphics2DUnitTester implements SVGConstants {
       private String[] args;
  @@ -46,7 +46,7 @@
   
       protected Document getDocumentPrototype() {
           return new SVGOMDocument(null,
  -                                 SVGDOMImplementation.getDOMImplementation());
  +                                 
ExtensibleSVGDOMImplementation.getDOMImplementation());
       }
   
       protected SVGGeneratorContext getContext(Document domFactory) {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to