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/02/05 10:55:33 UTC

cvs commit: xml-batik/sources/org/apache/batik/css/svg MarkerShorthandFactory.java MarkerFactory.java SVGValueFactoryMap.java SVGViewCSS.java

hillion     01/02/05 01:55:32

  Modified:    resources/org/apache/batik/css/resources Messages.properties
               sources/org/apache/batik/bridge
                        SVGDecoratedShapeElementBridge.java
               sources/org/apache/batik/css CSSOMStyleDeclaration.java
               sources/org/apache/batik/css/svg MarkerFactory.java
                        SVGValueFactoryMap.java SVGViewCSS.java
  Added:       sources/org/apache/batik/css/svg MarkerShorthandFactory.java
  Log:
  Marker property now handled correctly.
  
  Revision  Changes    Path
  1.3       +3 -0      xml-batik/resources/org/apache/batik/css/resources/Messages.properties
  
  Index: Messages.properties
  ===================================================================
  RCS file: /home/cvs/xml-batik/resources/org/apache/batik/css/resources/Messages.properties,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Messages.properties	2000/11/27 05:48:57	1.2
  +++ Messages.properties	2001/02/05 09:55:27	1.3
  @@ -58,3 +58,6 @@
   
   unexpected.end.of.list = \
   The current list is too short.
  +
  +not.supported = \
  +This operation is not supported.
  
  
  
  1.3       +20 -50    xml-batik/sources/org/apache/batik/bridge/SVGDecoratedShapeElementBridge.java
  
  Index: SVGDecoratedShapeElementBridge.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGDecoratedShapeElementBridge.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SVGDecoratedShapeElementBridge.java	2001/02/01 17:16:39	1.2
  +++ SVGDecoratedShapeElementBridge.java	2001/02/05 09:55:29	1.3
  @@ -42,7 +42,7 @@
    * A factory for the SVG elements that represents a shape.
    *
    * @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
  - * @version $Id: SVGDecoratedShapeElementBridge.java,v 1.2 2001/02/01 17:16:39 vhardy Exp $
  + * @version $Id: SVGDecoratedShapeElementBridge.java,v 1.3 2001/02/05 09:55:29 hillion Exp $
    */
   public abstract class SVGDecoratedShapeElementBridge 
       extends SVGShapeElementBridge {
  @@ -84,58 +84,28 @@
           // Extract the marker properties
           //
           
  -        // 
  -        // <!> TO BE REMOVED WHEN marker IMPLEMENTED AS SHORT-HAND
  -        //
   
  -        // Start with marker, a short-hand for start/middle/end
  -        Marker marker = CSSUtilities.convertMarker(svgElement,
  -                                                   CSS_MARKER_PROPERTY,
  -                                                   ctx, cssDecl, uctx);
  -
  -        if(marker != null){
  -            node.setStartMarker(marker);
  -            node.setMiddleMarker(marker);
  -            node.setEndMarker(marker);
  -        }
  -        else{
  -
  -            // <!> END TO BE REMOVED
  -
  -            // Extract start, middle and end markers
  -            if(hasStartMarker()){
  -                Marker startMarker 
  -                    = CSSUtilities.convertMarker(svgElement,
  -                                                 CSS_MARKER_START_PROPERTY,
  -                                                 ctx, cssDecl, uctx);
  -                node.setStartMarker(startMarker);
  -            }
  -
  -            if(hasEndMarker()){
  -                Marker endMarker 
  -                    = CSSUtilities.convertMarker(svgElement,
  -                                                 CSS_MARKER_END_PROPERTY,
  -                                                 ctx, cssDecl, uctx);
  -                node.setEndMarker(endMarker);
  -            }
  -
  -            Marker middleMarker 
  -                = CSSUtilities.convertMarker(svgElement,
  -                                             CSS_MARKER_MID_PROPERTY,
  -                                             ctx, cssDecl, uctx);
  +        // Extract start, middle and end markers
  +        Marker startMarker 
  +            = CSSUtilities.convertMarker(svgElement,
  +                                         CSS_MARKER_START_PROPERTY,
  +                                         ctx, cssDecl, uctx);
  +        node.setStartMarker(startMarker);
  +        
  +        Marker endMarker 
  +            = CSSUtilities.convertMarker(svgElement,
  +                                         CSS_MARKER_END_PROPERTY,
  +                                         ctx, cssDecl, uctx);
  +        node.setEndMarker(endMarker);
  +        
  +        Marker middleMarker 
  +            = CSSUtilities.convertMarker(svgElement,
  +                                         CSS_MARKER_MID_PROPERTY,
  +                                         ctx, cssDecl, uctx);
  +        
  +        node.setMiddleMarker(middleMarker);
   
  -            node.setMiddleMarker(middleMarker);
  -        }
   
           super.buildGraphicsNode(gn, ctx, element);
       }
  -
  -    protected boolean hasStartMarker(){
  -        return true;
  -    }
  -
  -    protected boolean hasEndMarker(){
  -        return true;
  -    }
  -
   }
  
  
  
  1.2       +3 -3      xml-batik/sources/org/apache/batik/css/CSSOMStyleDeclaration.java
  
  Index: CSSOMStyleDeclaration.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/css/CSSOMStyleDeclaration.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CSSOMStyleDeclaration.java	2000/10/10 18:37:12	1.1
  +++ CSSOMStyleDeclaration.java	2001/02/05 09:55:30	1.2
  @@ -30,7 +30,7 @@
    * interface.
    *
    * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
  - * @version $Id: CSSOMStyleDeclaration.java,v 1.1 2000/10/10 18:37:12 hillion Exp $
  + * @version $Id: CSSOMStyleDeclaration.java,v 1.2 2001/02/05 09:55:30 hillion Exp $
    */
   public class CSSOMStyleDeclaration
       implements CSSStyleDeclaration,
  @@ -322,9 +322,9 @@
               f = factories.get(propertyName.toLowerCase().intern());
   	    InputSource is = new InputSource(new StringReader(value));
   	    LexicalUnit lu = parser.parsePropertyValue(is);
  -	    CSSOMValue   v = new CSSOMValue(f, f.createValue(lu));
  -	    setPropertyCSSValue(propertyName, v, prio);
  +	    f.createCSSValue(lu, this, prio);
   	} catch (Exception e) {
  +            e.printStackTrace();
   	    throw CSSDOMExceptionFactory.createDOMException
   		(DOMException.INVALID_ACCESS_ERR,
   		 "property.value",
  
  
  
  1.3       +2 -2      xml-batik/sources/org/apache/batik/css/svg/MarkerFactory.java
  
  Index: MarkerFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/css/svg/MarkerFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MarkerFactory.java	2000/11/27 05:49:02	1.2
  +++ MarkerFactory.java	2001/02/05 09:55:30	1.3
  @@ -18,10 +18,10 @@
   import org.w3c.dom.css.CSSPrimitiveValue;
   
   /**
  - * This class provides a factory for the 'marker' property values.
  + * This class provides a factory for the 'marker-*' property values.
    *
    * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
  - * @version $Id: MarkerFactory.java,v 1.2 2000/11/27 05:49:02 hillion Exp $
  + * @version $Id: MarkerFactory.java,v 1.3 2001/02/05 09:55:30 hillion Exp $
    */
   public class MarkerFactory extends AbstractValueFactory {
       /**
  
  
  
  1.5       +2 -2      xml-batik/sources/org/apache/batik/css/svg/SVGValueFactoryMap.java
  
  Index: SVGValueFactoryMap.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/css/svg/SVGValueFactoryMap.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SVGValueFactoryMap.java	2001/02/01 16:41:54	1.4
  +++ SVGValueFactoryMap.java	2001/02/05 09:55:31	1.5
  @@ -16,7 +16,7 @@
    * to contains factories for SVG CSS values.
    *
    * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
  - * @version $Id: SVGValueFactoryMap.java,v 1.4 2001/02/01 16:41:54 vhardy Exp $
  + * @version $Id: SVGValueFactoryMap.java,v 1.5 2001/02/05 09:55:31 hillion Exp $
    */
   public class SVGValueFactoryMap
       extends    CommonValueFactoryMap
  @@ -88,7 +88,7 @@
               new SimpleColorFactory(p, CSS_LIGHTING_COLOR_PROPERTY));
   
   	put(CSS_MARKER_PROPERTY,
  -            new MarkerFactory(p, CSS_MARKER_PROPERTY));
  +            new MarkerShorthandFactory(p));
   
   	put(CSS_MARKER_END_PROPERTY,
               new MarkerFactory(p, CSS_MARKER_END_PROPERTY));
  
  
  
  1.6       +1 -2      xml-batik/sources/org/apache/batik/css/svg/SVGViewCSS.java
  
  Index: SVGViewCSS.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/css/svg/SVGViewCSS.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- SVGViewCSS.java	2001/02/01 16:41:54	1.5
  +++ SVGViewCSS.java	2001/02/05 09:55:31	1.6
  @@ -16,7 +16,7 @@
    * the SVG CSS.
    *
    * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
  - * @version $Id: SVGViewCSS.java,v 1.5 2001/02/01 16:41:54 vhardy Exp $
  + * @version $Id: SVGViewCSS.java,v 1.6 2001/02/05 09:55:31 hillion Exp $
    */
   
   public class SVGViewCSS
  @@ -47,7 +47,6 @@
   	addRelativeValueResolver(new GlyphOrientationVerticalResolver());
   	addRelativeValueResolver(new ImageRenderingResolver());
   	addRelativeValueResolver(new LightingColorResolver());
  -	addRelativeValueResolver(new MarkerResolver(CSS_MARKER_PROPERTY));
   	addRelativeValueResolver(new MarkerResolver(CSS_MARKER_END_PROPERTY));
   	addRelativeValueResolver(new MarkerResolver(CSS_MARKER_MID_PROPERTY));
   	addRelativeValueResolver(new MarkerResolver(CSS_MARKER_START_PROPERTY));
  
  
  
  1.1                  xml-batik/sources/org/apache/batik/css/svg/MarkerShorthandFactory.java
  
  Index: MarkerShorthandFactory.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.css.svg;
  
  import org.apache.batik.css.CSSDOMExceptionFactory;
  import org.apache.batik.css.CSSOMStyleDeclaration;
  import org.apache.batik.css.CSSOMValue;
  import org.apache.batik.css.value.AbstractValueFactory;
  import org.apache.batik.css.value.ImmutableString;
  import org.apache.batik.css.value.ImmutableValue;
  import org.apache.batik.css.value.ValueFactory;
  
  import org.w3c.css.sac.LexicalUnit;
  import org.w3c.css.sac.Parser;
  import org.w3c.dom.DOMException;
  import org.w3c.dom.css.CSSPrimitiveValue;
  
  /**
   * This class provides a factory for the 'marker' property values.
   *
   * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
   * @version $Id: MarkerShorthandFactory.java,v 1.1 2001/02/05 09:55:31 hillion Exp $
   */
  public class MarkerShorthandFactory extends AbstractValueFactory {
  
      /**
       * The marker-end factory.
       */
      protected ValueFactory markerEndFactory =
          new MarkerFactory(parser, CSS_MARKER_END_PROPERTY);
      
      /**
       * The marker-mid factory.
       */
      protected ValueFactory markerMidFactory =
          new MarkerFactory(parser, CSS_MARKER_MID_PROPERTY);
      
      /**
       * The marker-start factory.
       */
      protected ValueFactory markerStartFactory =
          new MarkerFactory(parser, CSS_MARKER_START_PROPERTY);
      
      /**
       * Creates a new MarkerFactory.
       * @param p The CSS parser used to parse the CSS texts.
       */
      public MarkerShorthandFactory(Parser p) {
  	super(p);
      }
  
      /**
       * Returns the name of the property handled.
       */
      public String getPropertyName() {
  	return CSS_MARKER_PROPERTY;
      }
      
      /**
       * Creates a value from a lexical unit.
       * @param lu The SAC lexical unit used to create the value.
       */
      public ImmutableValue createValue(LexicalUnit lu) throws DOMException {
          throw CSSDOMExceptionFactory.createDOMException
              (DOMException.INVALID_ACCESS_ERR, "not.supported", null);
      }
  
      /**
       * Creates a value from a lexical unit and a style declaration.
       * This method must only be called for null values.
       * @param lu  The SAC lexical unit used to create the value.
       * @param d   The style declaration in which to add the created value.
       * @param imp The property priority.
       */
      public void createCSSValue(LexicalUnit          lu,
  			       CSSOMStyleDeclaration d,
  			       String               imp) throws DOMException {
          ImmutableValue val;
  	switch (lu.getLexicalUnitType()) {
  	case LexicalUnit.SAC_INHERIT:
  	    val = INHERIT;
              break;
  	case LexicalUnit.SAC_URI:
  	    val = new ImmutableString(CSSPrimitiveValue.CSS_URI,
                                        lu.getStringValue());
              break;
  	case LexicalUnit.SAC_IDENT:
  	    if (lu.getStringValue().equalsIgnoreCase(CSS_NONE_VALUE)) {
  		val = NONE_VALUE;
                  break;
  	    }
  	default:
              throw CSSDOMExceptionFactory.createDOMException
                  (DOMException.INVALID_ACCESS_ERR,
                   "invalid.lexical.unit",
                   new Object[] { new Integer(lu.getLexicalUnitType()) });
  	}
          d.setPropertyCSSValue(CSS_MARKER_END_PROPERTY,
                                new CSSOMValue(markerEndFactory, val), imp);
          d.setPropertyCSSValue(CSS_MARKER_MID_PROPERTY,
                                new CSSOMValue(markerMidFactory, val), imp);
          d.setPropertyCSSValue(CSS_MARKER_START_PROPERTY,
                                new CSSOMValue(markerStartFactory, val), imp);
      }
  }