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 2003/09/25 02:45:11 UTC

cvs commit: xml-batik/sources/org/apache/batik/transcoder/image PNGTranscoder.java

deweese     2003/09/24 17:45:11

  Modified:    sources/org/apache/batik/bridge FontFace.java
                        SVGFilterElementBridge.java
                        SVGImageElementBridge.java UpdateManager.java
               sources/org/apache/batik/ext/awt/image/renderable
                        FilterChainRable8Bit.java
               sources/org/apache/batik/ext/awt/image/rendered
                        SpecularLightingRed.java
               sources/org/apache/batik/gvt/font FontFamilyResolver.java
                        GVTFontFace.java
               sources/org/apache/batik/transcoder/image PNGTranscoder.java
  Added:       sources/org/apache/batik/bridge UpdateManagerAdapter.java
               sources/org/apache/batik/swing/svg SVGUserAgentAdapter.java
                        SVGUserAgentGUIAdapter.java
  Log:
  1) Refactored font resolution code so it's centralized in
     batik.gvt.font.FontFamilyResolver.
  2) Fixed a bug in error handling of 'bad' filters.
  3) Refactored code for ImageElementBridge - may help Fop add
     back JPEG optimization.
  4) Refactored code in UpdateManager mostly to hide a bunch of
     internal methods.  Made the 'repaint' method more thread safe.
  
  Revision  Changes    Path
  1.6       +13 -18    xml-batik/sources/org/apache/batik/bridge/FontFace.java
  
  Index: FontFace.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/FontFace.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- FontFace.java	16 Sep 2003 01:12:52 -0000	1.5
  +++ FontFace.java	25 Sep 2003 00:45:11 -0000	1.6
  @@ -68,6 +68,7 @@
   import org.apache.batik.gvt.font.GVTFontFamily;
   import org.apache.batik.gvt.font.GVTFontFace;
   import org.apache.batik.gvt.font.AWTFontFamily;
  +import org.apache.batik.gvt.font.FontFamilyResolver;
   
   /**
    * This class represents a <font-face> element or @font-face rule
  @@ -78,17 +79,6 @@
   public abstract class FontFace extends GVTFontFace
       implements ErrorConstants  {
   
  -    static Set fontSet;
  -    static {
  -        GraphicsEnvironment ge;
  -        ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
  -        String [] fonts = ge.getAvailableFontFamilyNames();
  -        fontSet = new HashSet(fonts.length);
  -        for(int i=0; i<fonts.length; i++) {
  -            fontSet.add(fonts[i]);
  -        }
  -    }
  -
       /**
        * List of ParsedURL's referencing SVGFonts or TrueType fonts,
        * or Strings naming locally installed fonts.
  @@ -118,8 +108,7 @@
       /**
        * Constructes an SVGFontFace with the specfied fontName.
        */
  -    protected FontFace
  -        (String familyName) {
  +    protected FontFace(String familyName) {
           super(familyName);
       }
   
  @@ -139,16 +128,22 @@
        * Returns the font associated with this rule or element.
        */
       public GVTFontFamily getFontFamily(BridgeContext ctx) {
  -        if (fontSet.contains(familyName)) {
  -            return new AWTFontFamily(this);
  +        String name = FontFamilyResolver.lookup(familyName);
  +        if (name != null) {
  +            GVTFontFace ff = createFontFace(name, this);
  +            return new AWTFontFamily(ff);
           }
   
           Iterator iter = srcs.iterator(); 
           while (iter.hasNext()) {
               Object o = iter.next();
               if (o instanceof String) {
  -                if (fontSet.contains(o))
  -                    return new AWTFontFamily(createFontFace((String)o, this));
  +                String str = (String)o;
  +                name = FontFamilyResolver.lookup(str);
  +                if (name != null) {
  +                    GVTFontFace ff = createFontFace(str, this);
  +                    return new AWTFontFamily(ff);
  +                }
               } else if (o instanceof ParsedURL) {
                   try {
                       GVTFontFamily ff = getFontFamily(ctx, (ParsedURL)o);
  
  
  
  1.18      +2 -2      xml-batik/sources/org/apache/batik/bridge/SVGFilterElementBridge.java
  
  Index: SVGFilterElementBridge.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGFilterElementBridge.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- SVGFilterElementBridge.java	8 Aug 2003 11:38:51 -0000	1.17
  +++ SVGFilterElementBridge.java	25 Sep 2003 00:45:11 -0000	1.18
  @@ -135,7 +135,7 @@
                                             sourceGraphic,
                                             filterNodeMap,
                                             ctx);
  -        if (in == sourceGraphic) {
  +        if ((in == null) || (in == sourceGraphic)) {
               return null; // no filter primitives found, disable the filter.
           } else {
               filterChain.setSource(in);
  
  
  
  1.62      +20 -8     xml-batik/sources/org/apache/batik/bridge/SVGImageElementBridge.java
  
  Index: SVGImageElementBridge.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGImageElementBridge.java,v
  retrieving revision 1.61
  retrieving revision 1.62
  diff -u -r1.61 -r1.62
  --- SVGImageElementBridge.java	11 Sep 2003 10:40:24 -0000	1.61
  +++ SVGImageElementBridge.java	25 Sep 2003 00:45:11 -0000	1.62
  @@ -179,10 +179,7 @@
                                         new Object[] {"xlink:href", uriStr});
           }
   
  -        // try to load the image as an svg document
  -        SVGDocument svgDoc = (SVGDocument)e.getOwnerDocument();
  -
  -        // try to load an SVG document
  +        // Build the URL.
           String baseURI = XMLBaseSupport.getCascadedXMLBase(e);
           ParsedURL purl;
           if (baseURI == null)
  @@ -190,6 +187,21 @@
           else
               purl = new ParsedURL(baseURI, uriStr);
   
  +        return createImageGraphicsNode(ctx, e, purl);
  +    }
  +
  +    protected GraphicsNode createImageGraphicsNode(BridgeContext ctx, 
  +                                                   Element e,
  +                                                   ParsedURL purl)
  +    {
  +        Rectangle2D bounds = getImageBounds(ctx, e);
  +        if ((bounds.getWidth() == 0) || (bounds.getHeight() == 0)) {
  +            ShapeNode sn = new ShapeNode();
  +            sn.setShape(bounds);
  +            return sn;
  +        }
  +
  +        SVGDocument svgDoc = (SVGDocument)e.getOwnerDocument();
           String docURL = svgDoc.getURL();
           ParsedURL pDocURL = null;
           if (docURL != null)
  @@ -201,7 +213,7 @@
               userAgent.checkLoadExternalResource(purl, pDocURL);
           } catch (SecurityException ex) {
               throw new BridgeException(e, ERR_URI_UNSECURE,
  -                                      new Object[] {uriStr});
  +                                      new Object[] {purl});
           }
   
           DocumentLoader loader = ctx.getDocumentLoader();
  @@ -244,7 +256,7 @@
               reference = openStream(e, purl);
           } catch (SecurityException ex) {
               throw new BridgeException(e, ERR_URI_UNSECURE,
  -                                      new Object[] {uriStr});
  +                                      new Object[] {purl});
           }
   
           {
  @@ -281,7 +293,7 @@
               throw ex;
           } catch (SecurityException ex) {
               throw new BridgeException(e, ERR_URI_UNSECURE,
  -                                      new Object[] {uriStr});
  +                                      new Object[] {purl});
           } catch (Exception ex) {
               /* Nothing to do */
           } 
  
  
  
  1.26      +60 -47    xml-batik/sources/org/apache/batik/bridge/UpdateManager.java
  
  Index: UpdateManager.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/UpdateManager.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- UpdateManager.java	16 Sep 2003 01:12:52 -0000	1.25
  +++ UpdateManager.java	25 Sep 2003 00:45:11 -0000	1.26
  @@ -76,7 +76,7 @@
    * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
    * @version $Id$
    */
  -public class UpdateManager implements RunnableQueue.RunHandler {
  +public class UpdateManager  {
   
       static final long MIN_REPAINT_TIME;
       static {
  @@ -169,7 +169,8 @@
           document = doc;
   
           updateRunnableQueue = RunnableQueue.createRunnableQueue();
  -        updateRunnableQueue.setRunHandler(this);
  +        RunnableQueue.RunHandler runHandler = createRunHandler();
  +        updateRunnableQueue.setRunHandler(runHandler);
   
           graphicsNode = gn;
   
  @@ -361,7 +362,8 @@
       }
   
       /**
  -     * Updates the rendering buffer.
  +     * Updates the rendering buffer.  Only to be called from the
  +     * update thread.
        * @param u2d The user to device transform.
        * @param dbr Whether the double buffering should be used.
        * @param aoi The area of interest in the renderer space units.
  @@ -382,7 +384,7 @@
        * Updates the rendering buffer.
        * @param aoi The area of interest in the renderer space units.
        */
  -    public void updateRendering(List areas) {
  +    protected void updateRendering(List areas) {
           try {
               fireEvent(updateStartedDispatcher,new UpdateManagerEvent
                         (this, repaintManager.getOffScreen(), null));
  @@ -406,12 +408,14 @@
       /**
        * Repaints the dirty areas, if needed.
        */
  -    public void repaint() {
  +    protected void repaint() {
  +        if (!updateTracker.hasChanged()) 
  +            return;
           long ctime = System.currentTimeMillis();
  -        if (updateTracker.hasChanged()) {
  -            if (ctime-lastRepaint < MIN_REPAINT_TIME) {
  -                // We very recently did a repaint check if other 
  -                // repaint runnables are pending.
  +        if (ctime-lastRepaint < MIN_REPAINT_TIME) {
  +            // We very recently did a repaint check if other 
  +            // repaint runnables are pending.
  +            synchronized (updateRunnableQueue.getIteratorLock()) {
                   Iterator i = updateRunnableQueue.iterator();
                   while (i.hasNext())
                       if (!(i.next() instanceof NoRepaintRunnable))
  @@ -419,15 +423,16 @@
                           // will skip this repaint and we will let 
                           // the next one pick it up.
                           return;
  +                
               }
  -               
  -            List dirtyAreas = updateTracker.getDirtyAreas();
  -            if (dirtyAreas != null) {
  -                updateRendering(dirtyAreas);
  -            }
  -            updateTracker.clear();
  -            lastRepaint = System.currentTimeMillis();
           }
  +        
  +        List dirtyAreas = updateTracker.getDirtyAreas();
  +        updateTracker.clear();
  +        if (dirtyAreas != null) {
  +            updateRendering(dirtyAreas);
  +        }
  +        lastRepaint = System.currentTimeMillis();
       }
   
   
  @@ -445,7 +450,7 @@
           listeners.remove(l);
       }
   
  -    public void fireEvent(Dispatcher dispatcher, Object event) {
  +    protected void fireEvent(Dispatcher dispatcher, Object event) {
           EventDispatcher.fireEvent(dispatcher, listeners, event, false);
       }
   
  @@ -535,39 +540,47 @@
           };
   
   
  -    // RunnableQueue.RunHandler /////////////////////////////////////////
   
  -    /**
  -     * Called when the given Runnable has just been invoked and
  -     * has returned.
  -     */
  -    public void runnableInvoked(RunnableQueue rq, Runnable r) {
  -        if (running && !(r instanceof NoRepaintRunnable)) {
  -            repaint();
  -        }
  -    }
  -
  -    /**
  -     * Called when the execution of the queue has been suspended.
  -     */
  -    public void executionSuspended(RunnableQueue rq) {
  -        if (suspendCalled) {
  -            running = false;
  -            fireEvent(suspendedDispatcher, 
  -                      new UpdateManagerEvent(this, null, null));
  -        }
  +    // RunnableQueue.RunHandler /////////////////////////////////////////
  +    protected RunnableQueue.RunHandler createRunHandler() {
  +        return new UpdateManagerRunHander();
       }
   
  -    /**
  -     * Called when the execution of the queue has been resumed.
  -     */
  -    public void executionResumed(RunnableQueue rq) {
  -        if (suspendCalled && !running) {
  -            running = true;
  +    protected class UpdateManagerRunHander 
  +        implements RunnableQueue.RunHandler {
   
  -            suspendCalled = false;
  -            fireEvent(resumedDispatcher, 
  -                      new UpdateManagerEvent(this, null, null));
  +        /**
  +         * Called when the given Runnable has just been invoked and
  +         * has returned.
  +         */
  +        public void runnableInvoked(RunnableQueue rq, Runnable r) {
  +            if (running && !(r instanceof NoRepaintRunnable)) {
  +                repaint();
  +            }
  +        }
  +        
  +        /**
  +         * Called when the execution of the queue has been suspended.
  +         */
  +        public void executionSuspended(RunnableQueue rq) {
  +            if (suspendCalled) {
  +                running = false;
  +                fireEvent(suspendedDispatcher, 
  +                          new UpdateManagerEvent(this, null, null));
  +            }
  +        }
  +        
  +        /**
  +         * Called when the execution of the queue has been resumed.
  +         */
  +        public void executionResumed(RunnableQueue rq) {
  +            if (suspendCalled && !running) {
  +                running = true;
  +                
  +                suspendCalled = false;
  +                fireEvent(resumedDispatcher, 
  +                          new UpdateManagerEvent(this, null, null));
  +            }
           }
       }
   }
  
  
  
  1.1                  xml-batik/sources/org/apache/batik/bridge/UpdateManagerAdapter.java
  
  Index: UpdateManagerAdapter.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Batik" and  "Apache Software Foundation" must  not  be
      used to  endorse or promote  products derived from  this software without
      prior written permission. For written permission, please contact
      apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.batik.bridge;
  
  /**
   * This is an adapter for the UpdateManagerListener interface.
   * It's methods do nothing.
   *
   * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
   * @version $Id: UpdateManagerAdapter.java,v 1.1 2003/09/25 00:45:11 deweese Exp $
   */
  public class UpdateManagerAdapter implements UpdateManagerListener {
  
      /**
       * Called when the manager was started.
       */
      public void managerStarted(UpdateManagerEvent e) { }
  
      /**
       * Called when the manager was suspended.
       */
      public void managerSuspended(UpdateManagerEvent e) { }
      
      /**
       * Called when the manager was resumed.
       */
      public void managerResumed(UpdateManagerEvent e) { }
  
      /**
       * Called when the manager was stopped.
       */
      public void managerStopped(UpdateManagerEvent e) { }
  
      /**
       * Called when an update started.
       */
      public void updateStarted(UpdateManagerEvent e) { }
  
      /**
       * Called when an update was completed.
       */
      public void updateCompleted(UpdateManagerEvent e) { }
  
      /**
       * Called when an update failed.
       */
      public void updateFailed(UpdateManagerEvent e) { }
  
  }
  
  
  
  1.7       +2 -2      xml-batik/sources/org/apache/batik/ext/awt/image/renderable/FilterChainRable8Bit.java
  
  Index: FilterChainRable8Bit.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/ext/awt/image/renderable/FilterChainRable8Bit.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- FilterChainRable8Bit.java	8 Aug 2003 11:39:06 -0000	1.6
  +++ FilterChainRable8Bit.java	25 Sep 2003 00:45:11 -0000	1.7
  @@ -243,7 +243,7 @@
        */
       public void setSource(Filter chainSource) {
           if(chainSource == null){
  -            throw new IllegalArgumentException();
  +            throw new IllegalArgumentException("Null Source for Filter Chain");
           }
           touch();
           this.chainSource = chainSource;
  
  
  
  1.15      +2 -2      xml-batik/sources/org/apache/batik/ext/awt/image/rendered/SpecularLightingRed.java
  
  Index: SpecularLightingRed.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/ext/awt/image/rendered/SpecularLightingRed.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- SpecularLightingRed.java	9 Aug 2003 16:58:42 -0000	1.14
  +++ SpecularLightingRed.java	25 Sep 2003 00:45:11 -0000	1.15
  @@ -142,7 +142,7 @@
       }
   
       public void genRect(WritableRaster wr) {
  -        // Copy variable on stack for faster access in thight loop
  +        // Copy variable on stack for faster access in tight loop
           final double scaleX = this.scaleX;
           final double scaleY = this.scaleY;
   
  
  
  
  1.12      +48 -20    xml-batik/sources/org/apache/batik/gvt/font/FontFamilyResolver.java
  
  Index: FontFamilyResolver.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/font/FontFamilyResolver.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- FontFamilyResolver.java	8 Aug 2003 11:39:16 -0000	1.11
  +++ FontFamilyResolver.java	25 Sep 2003 00:45:11 -0000	1.12
  @@ -145,43 +145,71 @@
        */
       protected static Map resolvedFontFamilies;
   
  +    /**
  +     * Looks up a font family name and returns the platform name
  +     * for the font.
  +     *
  +     * @param familyName The Font Family name to resolve
  +     *
  +     * @return The platform name for the font or null if it can't be found.
  +     */
  +    public static String lookup(String familyName) {
  +        return (String)fonts.get(familyName.toLowerCase());
  +    }
   
       /**
  -     * Resolves an UnresolvedFontFamily into a GVTFontFamily. If the font
  +     * Resolves a font family name into a GVTFontFamily. If the font
        * family cannot be resolved then null will be returned.
        *
  -     * @param fontFamily The UnresolvedFontFamily to resolve
  -     * @param textAttributes The attributes of the font that will be derived
  -     * from the resolved font family.
  +     * @param familyName The Font Family name to resolve
        *
        * @return A resolved GVTFontFamily or null if the font family could not
        * be resolved.
        */
  -    public static GVTFontFamily resolve(UnresolvedFontFamily fontFamily) {
  -
  +    public static GVTFontFamily resolve(String familyName) {
           if (resolvedFontFamilies == null) {
               resolvedFontFamilies = new HashMap();
           }
   
           // first see if this font family has already been resolved
  -        String familyName = fontFamily.getFamilyName();
  -        GVTFontFamily resolvedFontFamily = (GVTFontFamily)resolvedFontFamilies.get(familyName.toLowerCase());
  +        GVTFontFamily resolvedFF = 
  +            (GVTFontFamily)resolvedFontFamilies.get(familyName.toLowerCase());
   
  -        if (resolvedFontFamily == null) { // hasn't been resolved yet
  -            // try to find a matching family name in the list of available fonts
  -            String awtFamilyName = (String) fonts.get(familyName.toLowerCase());
  +        if (resolvedFF == null) { // hasn't been resolved yet
  +            // try to find a matching family name in the list of
  +            // available fonts
  +            String awtFamilyName = (String)fonts.get(familyName.toLowerCase());
               if (awtFamilyName != null) {
  -                resolvedFontFamily = new AWTFontFamily(awtFamilyName);
  +                resolvedFF = new AWTFontFamily(awtFamilyName);
               }
   
  -            resolvedFontFamilies.put(familyName.toLowerCase(), resolvedFontFamily);
  +            resolvedFontFamilies.put(familyName.toLowerCase(), resolvedFF);
           }
  -      //  if (resolvedFontFamily != null) {
  -      //      System.out.println("resolved " + fontFamily.getFamilyName() + " to " + resolvedFontFamily.getFamilyName());
  -      //  } else {
  -      //      System.out.println("could not resolve " + fontFamily.getFamilyName());
  -      //  }
  -        return resolvedFontFamily;
  +
  +        //  if (resolvedFF != null) {
  +        //      System.out.println("resolved " + fontFamily.getFamilyName() + 
  +        //                         " to " + resolvedFF.getFamilyName());
  +        //  } else {
  +        //      System.out.println("could not resolve " + 
  +        //                         fontFamily.getFamilyName());
  +        //  }
  +        return resolvedFF;
  +    }
  +
  +    /**
  +     * Resolves an UnresolvedFontFamily into a GVTFontFamily. If the font
  +     * family cannot be resolved then null will be returned.
  +     *
  +     * @param fontFamily The UnresolvedFontFamily to resolve
  +     * @param textAttributes The attributes of the font that will be derived
  +     * from the resolved font family.
  +     *
  +     * @return A resolved GVTFontFamily or null if the font family could not
  +     * be resolved.
  +     */
  +    public static GVTFontFamily resolve(UnresolvedFontFamily fontFamily) {
  +
  +        return resolve(fontFamily.getFamilyName());
       }
   
       public static GVTFontFamily getFamilyThatCanDisplay(char c) {
  
  
  
  1.4       +2 -2      xml-batik/sources/org/apache/batik/gvt/font/GVTFontFace.java
  
  Index: GVTFontFace.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/font/GVTFontFace.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- GVTFontFace.java	9 Aug 2003 16:58:43 -0000	1.3
  +++ GVTFontFace.java	25 Sep 2003 00:45:11 -0000	1.4
  @@ -79,7 +79,7 @@
       protected float overlineThickness;
   
       /**
  -     * Constructes an SVGFontFace with the specfied font-face attributes.
  +     * Constructes an GVTFontFace with the specfied font-face attributes.
        */
       public GVTFontFace
           (String familyName, float unitsPerEm, String fontWeight,
  
  
  
  1.1                  xml-batik/sources/org/apache/batik/swing/svg/SVGUserAgentAdapter.java
  
  Index: SVGUserAgentAdapter.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Batik" and  "Apache Software Foundation" must  not  be
      used to  endorse or promote  products derived from  this software without
      prior written permission. For written permission, please contact
      apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.batik.swing.svg;
  
  import org.apache.batik.util.XMLResourceDescriptor;
  
  import org.apache.batik.bridge.ExternalResourceSecurity;
  import org.apache.batik.bridge.RelaxedExternalResourceSecurity;
  import org.apache.batik.bridge.RelaxedScriptSecurity;
  import org.apache.batik.bridge.ScriptSecurity;
  import org.apache.batik.util.ParsedURL;
  import org.w3c.dom.Element;
  
  /*
  import org.apache.batik.bridge.DefaultExternalResourceSecurity;
  import org.apache.batik.bridge.DefaultScriptSecurity;
  import org.apache.batik.bridge.EmbededExternalResourceSecurity;
  import org.apache.batik.bridge.EmbededScriptSecurity;
  import org.apache.batik.bridge.ExternalResourceSecurity;
  import org.apache.batik.bridge.NoLoadExternalResourceSecurity;
  import org.apache.batik.bridge.NoLoadScriptSecurity;
  */
  
  /**
   * This Implements the SVGUserAgent interface to provide a very simple
   * version of client services to the JSVGComponent.
   *
   * This implementation does not require any GUI interaction to work.
   * This implementation is particularly bad about user interaction
   * most of the alert,prompt,etc methods are totally useless.
   * In a GUI environment you probably want to use SVGUserAgentGUIAdapter.
   *
   * @author <a href="mailto:deweese@apache.org>deweese</a>
   * @version $Id: SVGUserAgentAdapter.java,v 1.1 2003/09/25 00:45:11 deweese Exp $
   */
  public class SVGUserAgentAdapter implements SVGUserAgent {
      public SVGUserAgentAdapter() { }
  
      /**
       * Displays an error message.
       */
      public void displayError(String message) {
          System.err.println(message);
      }
  
      /**
       * Displays an error resulting from the specified Exception.
       */
      public void displayError(Exception ex) {
          ex.printStackTrace();
      }
  
      /**
       * Displays a message in the User Agent interface.
       * The given message is typically displayed in a status bar.
       */
      public void displayMessage(String message) {
          System.out.println(message);
      }
  
      /**
       * Shows an alert dialog box.
       */
      public void showAlert(String message) {
          System.err.println(message);
      }
  
      /**
       * Shows a prompt dialog box.
       */
      public String showPrompt(String message) {
          return "";
      }
  
      /**
       * Shows a prompt dialog box.
       */
      public String showPrompt(String message, String defaultValue) {
          return defaultValue;
      }
  
      /**
       * Shows a confirm dialog box.
       */
      public boolean showConfirm(String message) {
          return false;
      }
  
      /**
       * Returns the size of a px CSS unit in millimeters.
       */
      public float getPixelUnitToMillimeter() {
          return 0.26458333333333333333333333333333f; // 96dpi
      }
          
      /**
       * Returns the size of a px CSS unit in millimeters.
       * This will be removed after next release.
       * @see #getPixelUnitToMillimeter()
       */
      public float getPixelToMM() {
          return getPixelUnitToMillimeter();
              
      }
  
      /**
       * Returns the default font family.
       */
      public String getDefaultFontFamily() {
          return "Serif";
      }
  
      /** 
       * Returns the  medium font size. 
       */
      public float getMediumFontSize() {
          // 9pt (72pt == 1in)
          return 9f * 25.4f / (72f * getPixelUnitToMillimeter());
      }
  
      /**
       * Returns a lighter font-weight.
       */
      public float getLighterFontWeight(float f) {
          // Round f to nearest 100...
          int weight = ((int)((f+50)/100))*100;
          switch (weight) {
          case 100: return 100;
          case 200: return 100;
          case 300: return 200;
          case 400: return 300;
          case 500: return 400;
          case 600: return 400;
          case 700: return 400;
          case 800: return 400;
          case 900: return 400;
          default:
              throw new IllegalArgumentException("Bad Font Weight: " + f);
          }
      }
  
      /**
       * Returns a bolder font-weight.
       */
      public float getBolderFontWeight(float f) {
          // Round f to nearest 100...
          int weight = ((int)((f+50)/100))*100;
          switch (weight) {
          case 100: return 600;
          case 200: return 600;
          case 300: return 600;
          case 400: return 600;
          case 500: return 600;
          case 600: return 700;
          case 700: return 800;
          case 800: return 900;
          case 900: return 900;
          default:
              throw new IllegalArgumentException("Bad Font Weight: " + f);
          }
      }
  
  
      /**
       * Returns the language settings.
       */
      public String getLanguages() {
          return "en";
      }
  
      /**
       * Returns the user stylesheet uri.
       * @return null if no user style sheet was specified.
       */
      public String getUserStyleSheetURI() {
          return null;
      }
  
      /**
       * Returns the class name of the XML parser.
       */
      public String getXMLParserClassName() {
          return XMLResourceDescriptor.getXMLParserClassName();
      }
  
      /**
       * Returns true if the XML parser must be in validation mode, false
       * otherwise.
       */
      public boolean isXMLParserValidating() {
          return false;
      }
  
      /**
       * Returns this user agent's CSS media.
       */
      public String getMedia() {
          return "screen";
      }
  
      /**
       * Returns this user agent's alternate style-sheet title.
       */
      public String getAlternateStyleSheet() {
          return null;
      }
  
      /**
       * Opens a link.
       * @param uri The document URI.
       * @param newc Whether the link should be activated in a new component.
       */
      public void openLink(String uri, boolean newc) {
      }
  
      /**
       * Tells whether the given extension is supported by this
       * user agent.
       */
      public boolean supportExtension(String s) {
          return false;
      }
  
      public void handleElement(Element elt, Object data){
      }
  
      /**
       * Returns the security settings for the given script
       * type, script url and document url
       * 
       * @param scriptType type of script, as found in the 
       *        type attribute of the &lt;script&gt; element.
       * @param scriptURL url for the script, as defined in
       *        the script's xlink:href attribute. If that
       *        attribute was empty, then this parameter should
       *        be null
       * @param docURL url for the document into which the 
       *        script was found.
       */
      public ScriptSecurity getScriptSecurity(String scriptType,
                                              ParsedURL scriptURL,
                                              ParsedURL docURL){
          return new RelaxedScriptSecurity(scriptType,
                                           scriptURL,
                                           docURL);
          /*
          return new DefaultScriptSecurity(scriptType,
                                           scriptURL,
                                           docURL);
          return new EmbededScriptSecurity(scriptType,
                                           scriptURL,
                                           docURL);
          return new NoLoadScriptSecurity(scriptType);
          */
      }
  
      /**
       * This method throws a SecurityException if the script
       * of given type, found at url and referenced from docURL
       * should not be loaded.
       * 
       * This is a convenience method to call checkLoadScript
       * on the ScriptSecurity strategy returned by 
       * getScriptSecurity.
       *
       * @param scriptType type of script, as found in the 
       *        type attribute of the &lt;script&gt; element.
       * @param scriptURL url for the script, as defined in
       *        the script's xlink:href attribute. If that
       *        attribute was empty, then this parameter should
       *        be null
       * @param docURL url for the document into which the 
       *        script was found.
       */
      public void checkLoadScript(String scriptType,
                                  ParsedURL scriptURL,
                                  ParsedURL docURL) throws SecurityException {
          ScriptSecurity s = getScriptSecurity(scriptType,
                                               scriptURL,
                                               docURL);
  
          if (s != null) {
              s.checkLoadScript();
          } 
      }
  
      /**
       * Returns the security settings for the given 
       * resource url and document url
       * 
       * @param resourceURL url for the resource, as defined in
       *        the resource's xlink:href attribute. If that
       *        attribute was empty, then this parameter should
       *        be null
       * @param docURL url for the document into which the 
       *        resource was found.
       */
      public ExternalResourceSecurity 
          getExternalResourceSecurity(ParsedURL resourceURL,
                                      ParsedURL docURL){
          return new RelaxedExternalResourceSecurity(resourceURL,
                                                     docURL);
          /*
          return new DefaultExternalResourceSecurity(resourceURL,
                                                     docURL);
          return new EmbededExternalResourceSecurity(resourceURL);
          return new NoLoadExternalResourceSecurity();
          */
      }
  
      /**
       * This method throws a SecurityException if the resource
       * found at url and referenced from docURL
       * should not be loaded.
       * 
       * This is a convenience method to call checkLoadExternalResource
       * on the ExternalResourceSecurity strategy returned by 
       * getExternalResourceSecurity.
       *
       * @param scriptURL url for the script, as defined in
       *        the script's xlink:href attribute. If that
       *        attribute was empty, then this parameter should
       *        be null
       * @param docURL url for the document into which the 
       *        script was found.
       */
      public void 
          checkLoadExternalResource(ParsedURL resourceURL,
                                    ParsedURL docURL) throws SecurityException {
          ExternalResourceSecurity s 
              =  getExternalResourceSecurity(resourceURL, docURL);
              
          if (s != null) {
              s.checkLoadExternalResource();
          }
      }
  };
  
  
  
  1.1                  xml-batik/sources/org/apache/batik/swing/svg/SVGUserAgentGUIAdapter.java
  
  Index: SVGUserAgentGUIAdapter.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Batik" and  "Apache Software Foundation" must  not  be
      used to  endorse or promote  products derived from  this software without
      prior written permission. For written permission, please contact
      apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.batik.swing.svg;
  
  import java.awt.Component;
  import javax.swing.JDialog;
  import javax.swing.JOptionPane;
  import org.apache.batik.util.gui.JErrorPane;
  
  /**
   * One line Class Desc
   *
   * Methods users may want to implement:
   *    displayMessage
   *
   * @author <a href="mailto:deweese@apache.org>deweese</a>
   * @version $Id: SVGUserAgentGUIAdapter.java,v 1.1 2003/09/25 00:45:11 deweese Exp $
   */
  public class SVGUserAgentGUIAdapter extends SVGUserAgentAdapter{
      public Component parentComponent;
      public SVGUserAgentGUIAdapter(Component parentComponent) {
          this.parentComponent = parentComponent;
      }
  
      /**
       * Displays an error message.
       */
      public void displayError(String message) {
          JOptionPane pane = new JOptionPane(message, JOptionPane.ERROR_MESSAGE);
          JDialog dialog = pane.createDialog(parentComponent, "ERROR");
          dialog.setModal(false);
          dialog.show();
      }
  
      /**
       * Displays an error resulting from the specified Exception.
       */
      public void displayError(Exception ex) {
          JErrorPane pane = new JErrorPane(ex, JOptionPane.ERROR_MESSAGE);
          JDialog dialog = pane.createDialog(parentComponent, "ERROR");
          dialog.setModal(false);
          dialog.show();
      }
  
      /**
       * Displays a message in the User Agent interface.
       * The given message is typically displayed in a status bar.
       */
      public void displayMessage(String message) {
          // Can't do anything don't have a status bar...
      }
  
      /**
       * Shows an alert dialog box.
       */
      public void showAlert(String message) {
          String str = "Script alert:\n" + message;
          JOptionPane.showMessageDialog(parentComponent, str);
      }
  
      /**
       * Shows a prompt dialog box.
       */
      public String showPrompt(String message) {
          String str = "Script prompt:\n" + message;
          return JOptionPane.showInputDialog(parentComponent, str);
      }
      
      /**
       * Shows a prompt dialog box.
       */
      public String showPrompt(String message, String defaultValue) {
          String str = "Script prompt:\n" + message;
          return (String)JOptionPane.showInputDialog
              (parentComponent, str, null,
               JOptionPane.PLAIN_MESSAGE,
               null, null, defaultValue);
      }
  
      /**
       * Shows a confirm dialog box.
       */
      public boolean showConfirm(String message) {
          String str = "Script confirm:\n" + message;
          return JOptionPane.showConfirmDialog
              (parentComponent, str, 
               "Confirm", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION;
      }
  };
  
  
  
  1.20      +3 -3      xml-batik/sources/org/apache/batik/transcoder/image/PNGTranscoder.java
  
  Index: PNGTranscoder.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/transcoder/image/PNGTranscoder.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- PNGTranscoder.java	16 Sep 2003 01:12:53 -0000	1.19
  +++ PNGTranscoder.java	25 Sep 2003 00:45:11 -0000	1.20
  @@ -216,8 +216,8 @@
        * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Description: </TH>
        * <TD VALIGN="TOP">Controls the gamma correction of the png image. 
        *                  A value of zero for gamma disables the generation 
  -     *                  of a gamma chunk.  No value or a value of 2.2
  -     *                  also causes an sRGB chunk to be generated.</TD>
  +     *                  of a gamma chunk.  No value causes an sRGB chunk 
  +     *                  to be generated.</TD>
        * </TR>
        * </TABLE>
        */
  
  
  

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