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 2001/03/29 15:52:32 UTC

cvs commit: xml-batik/sources/org/apache/batik/ext/awt/image/renderable AbstractColorInterpRable.java FilterColorInterp.java CompositeRable.java CompositeRable8Bit.java

deweese     01/03/29 05:52:32

  Modified:    sources/org/apache/batik/apps/svgbrowser Main.java
               sources/org/apache/batik/ext/awt/image/renderable
                        CompositeRable.java CompositeRable8Bit.java
  Added:       sources/org/apache/batik/ext/awt/image/renderable
                        AbstractColorInterpRable.java
                        FilterColorInterp.java
  Log:
  1) Fixed a bug in command line handling in the svgbrowser app.
  
  2) Started adding support for color-interpolation-filters in the
     Renderable chain.
  
  Revision  Changes    Path
  1.4       +21 -5     xml-batik/sources/org/apache/batik/apps/svgbrowser/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/apps/svgbrowser/Main.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Main.java	2001/03/28 18:30:46	1.3
  +++ Main.java	2001/03/29 13:52:32	1.4
  @@ -37,7 +37,7 @@
    * This class contains the main method of an SVG viewer.
    *
    * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
  - * @version $Id: Main.java,v 1.3 2001/03/28 18:30:46 deweese Exp $
  + * @version $Id: Main.java,v 1.4 2001/03/29 13:52:32 deweese Exp $
    */
   public class Main implements Application {
   
  @@ -142,10 +142,26 @@
                   oh.handleOption();
                   index++;
               }
  -            createAndShowJSVGViewerFrame();
  -            if (index < arguments.length) {
  -                mainFrame.getJSVGCanvas().loadSVGDocument
  -                    (new File(arguments[index]).toURL().toString());
  +            JSVGViewerFrame frame = createAndShowJSVGViewerFrame();
  +            while (index < arguments.length) {
  +                if (arguments[index].length() == 0) {
  +                    index++;
  +                    continue;
  +                }
  +
  +                File file = new File(arguments[index]);
  +                if (file.canRead()) {
  +                    if (frame == null) 
  +                        frame = createAndShowJSVGViewerFrame();
  +                    
  +                    frame.getJSVGCanvas().loadSVGDocument
  +                        (file.toURL().toString());
  +                    frame = null;
  +                } else {
  +                    // Should let the user know that we are
  +                    // skipping this file...
  +                }
  +                index++;
               }
           } catch (Exception e) {
               e.printStackTrace();
  
  
  
  1.4       +2 -15     xml-batik/sources/org/apache/batik/ext/awt/image/renderable/CompositeRable.java
  
  Index: CompositeRable.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/ext/awt/image/renderable/CompositeRable.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- CompositeRable.java	2001/03/26 21:27:31	1.3
  +++ CompositeRable.java	2001/03/29 13:52:32	1.4
  @@ -18,9 +18,9 @@
    * the image are applied in the order they are in the List given.
    *
    * @author <a href="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
  - * @version $Id: CompositeRable.java,v 1.3 2001/03/26 21:27:31 deweese Exp $
  + * @version $Id: CompositeRable.java,v 1.4 2001/03/29 13:52:32 deweese Exp $
    */
  -public interface CompositeRable extends Filter {
  +public interface CompositeRable extends FilterColorInterp {
         /**
          * The sources to be composited togeather.
          * @param srcs The list of images to be composited by the composite rule.
  @@ -38,17 +38,4 @@
          * @return Composite rule currently in use.
          */
       public CompositeRule getCompositeRule();
  -
  -      /**
  -       * Set the colorspace to perform compositing in
  -       * @param cs ColorSpace to use.
  -       */
  -    public void setCompositeColorSpace(ColorSpace cs);
  -
  -      /**
  -       * Get the colorspace to that compositing will be performed in
  -       * @return ColorSpace for compositing.
  -       */
  -    public ColorSpace getCompositeColorSpace();
  -
   }
  
  
  
  1.9       +6 -42     xml-batik/sources/org/apache/batik/ext/awt/image/renderable/CompositeRable8Bit.java
  
  Index: CompositeRable8Bit.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/ext/awt/image/renderable/CompositeRable8Bit.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- CompositeRable8Bit.java	2001/03/26 21:27:31	1.8
  +++ CompositeRable8Bit.java	2001/03/29 13:52:32	1.9
  @@ -39,27 +39,22 @@
    * the image are applied in the order they are in the List given.
    *
    * @author <a href="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
  - * @version $Id: CompositeRable8Bit.java,v 1.8 2001/03/26 21:27:31 deweese Exp $
  + * @version $Id: CompositeRable8Bit.java,v 1.9 2001/03/29 13:52:32 deweese Exp $
    */
   public class CompositeRable8Bit
  -    extends    AbstractRable
  +    extends    AbstractColorInterpRable
       implements CompositeRable, PaintRable {
   
       protected CompositeRule rule;
  -    protected ColorSpace    colorspace;
  -    protected boolean       csIsLinear;
   
       public CompositeRable8Bit(List srcs,
                                 CompositeRule rule,
                                 boolean csIsLinear) {
           super(srcs);
   
  +        setCSLinear(csIsLinear);
  +
           this.rule = rule;
  -        this.csIsLinear = csIsLinear;
  -        if (csIsLinear)
  -            colorspace = ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB);
  -        else
  -            colorspace = ColorSpace.getInstance(ColorSpace.CS_sRGB);
       }
   
         /**
  @@ -87,30 +82,6 @@
           return this.rule;
       }
   
  -      /**
  -       * Set the colorspace to perform compositing in
  -       * @param cs ColorSpace to use.
  -       */
  -    public void setCompositeColorSpace(ColorSpace cs) {
  -        touch();
  -        if (cs == ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB))
  -            csIsLinear = true;
  -        else if (cs == ColorSpace.getInstance(ColorSpace.CS_sRGB))
  -            csIsLinear = false;
  -        else
  -            throw new IllegalArgumentException
  -                ("Unsupported ColorSpace for Composite: " + cs);
  -        this.colorspace = cs;
  -    }
  -
  -      /**
  -       * Get the colorspace to that compositing will be performed in
  -       * @return ColorSpace for compositing.
  -       */
  -    public ColorSpace getCompositeColorSpace() {
  -        return this.colorspace;
  -    }
  -
       /**
        * Should perform the equivilent action as 
        * createRendering followed by drawing the RenderedImage to 
  @@ -132,7 +103,7 @@
           if (getCompositeRule() != CompositeRule.OVER) 
               return false;
   
  -        ColorSpace crCS = getCompositeColorSpace();
  +        ColorSpace crCS = getOperationColorSpace();
           ColorSpace g2dCS = GraphicsUtil.getDestinationColorSpace(g2d);
           if ((g2dCS == null) || (g2dCS != crCS))
               return false;
  @@ -185,15 +156,8 @@
               RenderedImage ri = filt.createRendering(rc);
               if (ri != null) {
                   CachableRed cr;
  -                cr = GraphicsUtil.wrap(ri);
  -
  -                if (csIsLinear)
  -                    cr = GraphicsUtil.convertToLsRGB(cr);
  -                else
  -                    cr = GraphicsUtil.convertTosRGB(cr);
  -
  +                cr = convertSourceCS(ri);
                   srcs.add(cr);
  -                
               } else {
                   
                   // Blank image...
  
  
  
  1.1                  xml-batik/sources/org/apache/batik/ext/awt/image/renderable/AbstractColorInterpRable.java
  
  Index: AbstractColorInterpRable.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.ext.awt.image.renderable;
  
  import java.util.List;
  import java.util.Map;
  import java.awt.color.ColorSpace;
  import java.awt.image.RenderedImage;
  
  import org.apache.batik.ext.awt.image.GraphicsUtil;
  import org.apache.batik.ext.awt.image.rendered.CachableRed;
  
  /**
   * This is an abstract base class that adds the ability to specify the
   * Color Space that the operation should take place in (linear sRGB or 
   * gamma corrected sRBG).
   *
   * @author <a href="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
   * @version $Id: AbstractColorInterpRable.java,v 1.1 2001/03/29 13:52:32 deweese Exp $
   */
  public abstract class AbstractColorInterpRable extends AbstractRable {
  
      /**
       * Indicates if the operation should be done in linear or gamma
       * corrected sRGB.
       */
      protected boolean csLinear = true;
  
      /**
       * void constructor. The subclass must call one of the
       * flavors of init before the object becomes usable.
       * This is useful when the proper parameters to the init
       * method need to be computed in the subclasses constructor.  */
      protected AbstractColorInterpRable() {
          super();
      }
  
      /**
       * Construct an Abstract Rable from src.
       * @param src will be the first (and only) member of the srcs
       * Vector. The bounds of src are also used to set the bounds of
       * this renderable.
       */
      protected AbstractColorInterpRable(Filter src) {
          super(src);
      }
  
      /**
       * Construct an Abstract Rable from src and props.
       * @param src will also be set as the first (and only) member of
       * the srcs Vector.
       * @param props use to initialize the properties on this renderable image.
       */
      protected AbstractColorInterpRable(Filter src, Map props) {
          super(src, props);
      }
  
      /**
       * Construct an Abstract Rable from a list of sources.
       * @param srcs This is used to initialize the srcs Vector.
       * The bounds of this renderable will be the union of the bounds
       * of all the sources in srcs.  All the members of srcs must be
       * CachableRable otherwise an error will be thrown.
       */
      protected AbstractColorInterpRable(List srcs) {
          super(srcs);
      }
  
      /**
       * Construct an Abstract Rable from a list of sources, and bounds.
       * @param srcs This is used to initialize the srcs Vector.  All
       * the members of srcs must be CachableRable otherwise an error
       * will be thrown.
       * @param props use to initialize the properties on this renderable image.
       */
      protected AbstractColorInterpRable(List srcs, Map props) {
          super(srcs, props);
      }
  
      /**
       * Returns true if this operation is to be performed in
       * the linear sRGB colorspace, returns false if the
       * operation is performed in gamma corrected sRGB.
       */
      public boolean isCSLinear() { return csLinear; }
  
      /**
       * Sets the colorspace the operation will be performed in.
       * @param csLinear if true this operation will be performed in the
       * linear sRGB colorspace, if false the operation will be performed in
       * gamma corrected sRGB.  
       */
      public void setCSLinear(boolean csLinear) {
          touch();
          this.csLinear = csLinear;
      }
  
      public ColorSpace getOperationColorSpace() {
          if (csLinear) 
              return ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB);
          else 
              return ColorSpace.getInstance(ColorSpace.CS_sRGB);
      }
  
      protected CachableRed convertSourceCS(CachableRed cr) {
          if (csLinear)
              return GraphicsUtil.convertToLsRGB(cr);
          else
              return GraphicsUtil.convertTosRGB(cr);
      }
  
      protected CachableRed convertSourceCS(RenderedImage ri) {
          return convertSourceCS(GraphicsUtil.wrap(ri));
      }
  }
  
  
  
  1.1                  xml-batik/sources/org/apache/batik/ext/awt/image/renderable/FilterColorInterp.java
  
  Index: FilterColorInterp.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.ext.awt.image.renderable;
  
  import java.awt.color.ColorSpace;
  
  /**
   * This is an extension of our Filter interface that adds support for
   * a color-interpolation specification which indicates what colorspace the
   * operation should take place in.
   *
   * @author <a href="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
   * @version $Id: FilterColorInterp.java,v 1.1 2001/03/29 13:52:32 deweese Exp $
   */
  public interface FilterColorInterp extends Filter{
  
      /**
       * Returns true if this operation is to be performed in
       * the linear sRGB colorspace, returns false if the
       * operation is performed in gamma corrected sRGB.
       */
      public boolean isCSLinear();
  
      /**
       * Sets the colorspace the operation will be performed in.
       * @param csLinear if true this operation will be performed in the
       * linear sRGB colorspace, if false the operation will be performed in
       * gamma corrected sRGB.  
       */
      public void setCSLinear(boolean csLinear);
  
      /**
       * Returns the ColorSpace that the object will perform
       * it's work in.
       */
      public ColorSpace getOperationColorSpace();
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org