deweese     2004/08/26 17:42:07

  Modified:    .        build.xml
               lib      pdf-transcoder.jar
               sources/org/apache/batik/dom/svg SAXSVGDocumentFactory.java
               sources/org/apache/batik/ext/awt/image GraphicsUtil.java
               sources/org/apache/batik/script InterpreterFactory.java
                        InterpreterPool.java
               sources/org/apache/batik/script/jacl
                        JaclInterpreterFactory.java
               sources/org/apache/batik/script/jpython
                        JPythonInterpreterFactory.java
               sources/org/apache/batik/script/rhino
                        RhinoInterpreterFactory.java
               sources/org/apache/batik/svggen/font/table CmapFormat4.java
               sources/org/apache/batik/util Service.java
  Added:       resources/META-INF/services
                        org.apache.batik.script.InterpreterFactory
  Log:
  1) ScriptFactorys now loaded via Services interface.
  2) JavaDoc will now reference W3 and JDK docs
  3) SAXSVGDocumentFactory now uses getResource as Stream instead of
     Resource bundles to get dtdids properties (doesn't really need to
     be localized now does it...).
  4) DrawImage now defaults color model to sRGB_Unpre if the destination
     doesn't include alpha.
  5) CmapFormat4 now clips charCode 0->65534.
  6) Services interface now uses a list instead of vector.
  
  Revision  Changes    Path
  1.152     +5 -1      xml-batik/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/xml-batik/build.xml,v
  retrieving revision 1.151
  retrieving revision 1.152
  diff -u -r1.151 -r1.152
  --- build.xml 18 Aug 2004 07:11:27 -0000      1.151
  +++ build.xml 27 Aug 2004 00:42:05 -0000      1.152
  @@ -695,6 +695,7 @@
         </fileset>
         <fileset dir="${resources}" excludes="${resources}/**/CVS">
           <include name="${package-prefix}/script/**/resources/*"/>
  +        <include 
name="META-INF/services/org.apache.batik.script.InterpreterFactory"/>
         </fileset>
       </jar>
     </target>
  @@ -754,6 +755,7 @@
       <jar jarfile="${build}/lib/${project}-extension.jar">
         <fileset dir="${resources}" excludes="${resources}/**/CVS">
           <include name="META-INF/services/*"/>
  +        <exclude 
name="META-INF/services/org.apache.batik.script.InterpreterFactory"/>
         </fileset>
         <fileset dir="${dest}">
           <include name="${package-prefix}/extension/**/*.class"/>
  @@ -1250,6 +1252,8 @@
                doctitle="${Project} API Specification 
${version}${revisionType}${revisionNumber}"
                bottom="Copyright &#169; ${year} Apache Software Foundation. All 
Rights Reserved.">
         <classpath refid="libs-classpath"/>
  +      <link href="http://www.w3.org/2003/01/dom2-javadoc/"/>
  +      <link href="http://java.sun.com/j2se/1.3/docs/api/"/>
       </javadoc>
     </target>
   
  
  
  
  1.6       +596 -820  xml-batik/lib/pdf-transcoder.jar
  
        <<Binary file>>
  
  
  1.1                  
xml-batik/resources/META-INF/services/org.apache.batik.script.InterpreterFactory
  
  Index: org.apache.batik.script.InterpreterFactory
  ===================================================================
  #############################################################################
  #    Copyright 2004  The Apache Software Foundation 
  # 
  #    Licensed under the Apache License, Version 2.0 (the "License");
  #    you may not use this file except in compliance with the License.
  #    You may obtain a copy of the License at
  # 
  #        http://www.apache.org/licenses/LICENSE-2.0
  # 
  #    Unless required by applicable law or agreed to in writing, software
  #    distributed under the License is distributed on an "AS IS" BASIS,
  #    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  #    See the License for the specific language governing permissions and
  #    limitations under the License.
  #############################################################################
  
  # This file registers the interpreter factories for the
  # script languages that Batik understands.
  
  # ECMAScript
  org.apache.batik.script.rhino.RhinoInterpreterFactory
  # TCL
  #org.apache.batik.script.jacl.JaclInterpreterFactory
  # Python
  #org.apache.batik.script.jacl.JPythonInterpreterFactory
  
  
  
  1.24      +48 -29    
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.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- SAXSVGDocumentFactory.java        18 Aug 2004 07:13:13 -0000      1.23
  +++ SAXSVGDocumentFactory.java        27 Aug 2004 00:42:06 -0000      1.24
  @@ -27,6 +27,8 @@
   import java.util.MissingResourceException;
   import java.util.ResourceBundle;
   
  +import java.util.Properties;
  +
   import org.apache.batik.dom.util.SAXDocumentFactory;
   import org.apache.batik.dom.util.XLinkSupport;
   import org.apache.batik.util.MimeTypeConstants;
  @@ -47,6 +49,8 @@
       extends    SAXDocumentFactory
       implements SVGDocumentFactory {
   
  +    public static final Object LOCK = new Object();
  +
       /**
        * Key used for public identifiers
        */
  @@ -96,7 +100,7 @@
       /**
        * The ResourceBunder for the public and system ids
        */
  -    protected static ResourceBundle rb;
  +    protected static Properties dtdProps;
   
       /**
        * Creates a new SVGDocumentFactory object.
  @@ -319,36 +323,51 @@
       public InputSource resolveEntity(String publicId, String systemId)
           throws SAXException {
           try {
  -            if (rb == null)
  -                rb = ResourceBundle.getBundle(DTDIDS, Locale.getDefault());
  +            synchronized (LOCK) {
  +                // Bootstrap if needed - move to a static block???
  +                if (dtdProps == null) {
  +                    dtdProps = new Properties();
  +                    try { 
  +                        Class cls = SAXSVGDocumentFactory.class;
  +                        InputStream is = cls.getResourceAsStream
  +                            ("resources/dtdids.properties");
  +                        dtdProps.load(is);
  +                    } catch (IOException ioe) { 
  +                        throw new SAXException(ioe);
  +                    }
  +                }
   
  -            if (dtdids == null)
  -                dtdids = rb.getString(KEY_PUBLIC_IDS);
  +                if (dtdids == null)
  +                    dtdids = dtdProps.getProperty(KEY_PUBLIC_IDS);
   
  -            if (skippable_dtdids == null)
  -                skippable_dtdids = rb.getString(KEY_SKIPPABLE_PUBLIC_IDS);
  -            if (skip_dtd == null)
  -                skip_dtd = rb.getString(KEY_SKIP_DTD);
  -
  -            if (publicId != null){
  -                if (!isValidating && 
  -                    (skippable_dtdids.indexOf(publicId) != -1)) {
  -                    // We are not validating and this is a DTD we can
  -                    // safely skip so do it...  Here we provide just enough
  -                    // of the DTD to keep stuff running (set svg and
  -                    // xlink namespaces).
  -                    return new InputSource(new StringReader(skip_dtd));
  -                }
  +                if (skippable_dtdids == null)
  +                    skippable_dtdids = 
  +                        dtdProps.getProperty(KEY_SKIPPABLE_PUBLIC_IDS);
   
  -                if (dtdids.indexOf(publicId) != -1) {
  -                    String localSystemId = 
  -                        rb.getString(KEY_SYSTEM_ID + 
  -                                     publicId.replace(' ', '_'));
  -
  -                    if (localSystemId != null && !"".equals(localSystemId)){
  -                        return new InputSource
  -                            (getClass().getResource(localSystemId).toString());
  -                    }
  +                if (skip_dtd == null)
  +                    skip_dtd = dtdProps.getProperty(KEY_SKIP_DTD);
  +            }
  +
  +            if (publicId == null)
  +                return null; // Let SAX Parser find it.
  +
  +            if (!isValidating && 
  +                (skippable_dtdids.indexOf(publicId) != -1)) {
  +                // We are not validating and this is a DTD we can
  +                // safely skip so do it...  Here we provide just enough
  +                // of the DTD to keep stuff running (set svg and
  +                // xlink namespaces).
  +                return new InputSource(new StringReader(skip_dtd));
  +            }
  +            
  +            if (dtdids.indexOf(publicId) != -1) {
  +                String localSystemId = 
  +                    dtdProps.getProperty(KEY_SYSTEM_ID + 
  +                                         publicId.replace(' ', '_'));
  +                
  +                if (localSystemId != null && !"".equals(localSystemId)) {
  +                    return new InputSource
  +                        (getClass().getResource(localSystemId).toString());
                   }
               }
           } catch (MissingResourceException e) {
  
  
  
  1.33      +8 -11     
xml-batik/sources/org/apache/batik/ext/awt/image/GraphicsUtil.java
  
  Index: GraphicsUtil.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/ext/awt/image/GraphicsUtil.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- GraphicsUtil.java 18 Aug 2004 07:13:48 -0000      1.32
  +++ GraphicsUtil.java 27 Aug 2004 00:42:06 -0000      1.33
  @@ -134,15 +134,11 @@
               // Assume device is sRGB
               g2dCS = ColorSpace.getInstance(ColorSpace.CS_sRGB);
           ColorModel drawCM = g2dCM;
  -        if (g2dCM == null) {
  -            // If we can't find out about our device assume
  -            // it's SRGB unpremultiplied (Just because this
  -            // seems to work for us).
  +        if ((g2dCM == null) || !g2dCM.hasAlpha()) {
  +            // If we can't find out about our device or the device
  +            // does not support alpha just use SRGB unpremultiplied
  +            // (Just because this seems to work for us).
               drawCM = sRGB_Unpre;
  -        } else if (drawCM.hasAlpha() && g2dCM.hasAlpha() &&
  -                   (drawCM.isAlphaPremultiplied() !=
  -                    g2dCM .isAlphaPremultiplied())) {
  -            drawCM = coerceColorModel(drawCM, g2dCM.isAlphaPremultiplied());
           }
   
           if (cr instanceof BufferedImageCachableRed) {
  @@ -281,8 +277,9 @@
                   Rectangle iR  = new Rectangle(0,0,0,0);
   
                   if (false) {
  -                    System.out.println("CR: " + cr);
  -                    System.out.println("CRR: " + crR + " TG: [" +
  +                    System.err.println("SrcCM: " + srcCM);
  +                    System.err.println("CR: " + cr);
  +                    System.err.println("CRR: " + crR + " TG: [" +
                                          xt0 +"," +
                                          yt0 +"," +
                                          xt1 +"," +
  
  
  
  1.6       +7 -1      
xml-batik/sources/org/apache/batik/script/InterpreterFactory.java
  
  Index: InterpreterFactory.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/script/InterpreterFactory.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- InterpreterFactory.java   18 Aug 2004 07:14:53 -0000      1.5
  +++ InterpreterFactory.java   27 Aug 2004 00:42:06 -0000      1.6
  @@ -27,6 +27,12 @@
    * @version $Id$
    */
   public interface InterpreterFactory {
  +
  +    /**
  +     * Returns the mime-type to register this interpereter with.
  +     */
  +    public String getMimeType();
  +
       /**
        * This method should create an instance of <code>Interpreter</code>
        * interface implementation.
  
  
  
  1.19      +10 -28    xml-batik/sources/org/apache/batik/script/InterpreterPool.java
  
  Index: InterpreterPool.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/script/InterpreterPool.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- InterpreterPool.java      18 Aug 2004 07:14:53 -0000      1.18
  +++ InterpreterPool.java      27 Aug 2004 00:42:06 -0000      1.19
  @@ -18,9 +18,12 @@
   package org.apache.batik.script;
   
   import java.util.HashMap;
  +import java.util.Iterator;
   import java.util.Map;
   
   import org.apache.batik.dom.svg.SVGOMDocument;
  +import org.apache.batik.util.Service;
  +
   import org.w3c.dom.Document;
   
   /**
  @@ -66,33 +69,12 @@
       protected Map factories = new HashMap(7);
   
       static {
  -        InterpreterFactory factory = null;
  -        try {
  -            factory =
  -                (InterpreterFactory)Class.forName(RHINO).newInstance();
  -            defaultFactories.put("text/ecmascript", factory);
  -        } catch (ThreadDeath td) {
  -            throw td;
  -        } catch (Throwable t1) {
  -            // may append if the class is not in the CLASSPATH
  -        }
  -        try {
  -            factory =
  -                (InterpreterFactory)Class.forName(JPYTHON).newInstance();
  -            defaultFactories.put("text/python", factory);
  -        } catch (ThreadDeath td) {
  -            throw td;
  -        } catch (Throwable t2) {
  -            // may append if the class is not in the CLASSPATH
  -        }
  -        try {
  -            factory =
  -                (InterpreterFactory)Class.forName(JACL).newInstance();
  -            defaultFactories.put("text/tcl", factory);
  -        } catch (ThreadDeath td) {
  -            throw td;
  -        } catch (Throwable t3) {
  -            // may append if the class is not in the CLASSPATH
  +        Iterator iter = Service.providers(InterpreterFactory.class);
  +        while (iter.hasNext()) {
  +            InterpreterFactory factory = null;
  +            factory = (InterpreterFactory)iter.next();
  +            // System.err.println("Factory : " + factory);
  +            defaultFactories.put(factory.getMimeType(), factory);
           }
       }
   
  
  
  
  1.7       +8 -1      
xml-batik/sources/org/apache/batik/script/jacl/JaclInterpreterFactory.java
  
  Index: JaclInterpreterFactory.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/script/jacl/JaclInterpreterFactory.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- JaclInterpreterFactory.java       18 Aug 2004 07:14:56 -0000      1.6
  +++ JaclInterpreterFactory.java       27 Aug 2004 00:42:07 -0000      1.7
  @@ -29,11 +29,18 @@
    */
   public class JaclInterpreterFactory implements InterpreterFactory {
   
  +    final static String TEXT_TCL = "text/tcl";
  +
       /**
        * Builds a <code>JaclInterpreterFactory</code>.
        */
       public JaclInterpreterFactory() {
       }
  +
  +    /**
  +     * Returns the mime-type to register this interpereter with.
  +     */
  +    public String getMimeType() { return TEXT_TCL; }
   
       /**
        * Creates an instance of <code>JaclInterpreter</code> class.
  
  
  
  1.7       +8 -1      
xml-batik/sources/org/apache/batik/script/jpython/JPythonInterpreterFactory.java
  
  Index: JPythonInterpreterFactory.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/script/jpython/JPythonInterpreterFactory.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- JPythonInterpreterFactory.java    18 Aug 2004 07:14:56 -0000      1.6
  +++ JPythonInterpreterFactory.java    27 Aug 2004 00:42:07 -0000      1.7
  @@ -29,11 +29,18 @@
    */
   public class JPythonInterpreterFactory implements InterpreterFactory {
   
  +    final static String TEXT_PYTHON = "text/python";
  +
       /**
        * Builds a <code>JPythonInterpreterFactory</code>.
        */
       public JPythonInterpreterFactory() {
       }
  +
  +    /**
  +     * Returns the mime-type to register this interpereter with.
  +     */
  +    public String getMimeType() { return TEXT_PYTHON; }
   
       /**
        * Creates an instance of <code>JPythonInterpreter</code> class.
  
  
  
  1.9       +9 -1      
xml-batik/sources/org/apache/batik/script/rhino/RhinoInterpreterFactory.java
  
  Index: RhinoInterpreterFactory.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/script/rhino/RhinoInterpreterFactory.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- RhinoInterpreterFactory.java      18 Aug 2004 07:14:57 -0000      1.8
  +++ RhinoInterpreterFactory.java      27 Aug 2004 00:42:07 -0000      1.9
  @@ -30,11 +30,19 @@
    * @version $Id$
    */
   public class RhinoInterpreterFactory implements InterpreterFactory {
  +
  +    final static String TEXT_ECMASCRIPT = "text/ecmascript";
  +
       /**
        * Builds a <code>RhinoInterpreterFactory</code>.
        */
       public RhinoInterpreterFactory() {
       }
  +
  +    /**
  +     * Returns the mime-type to register this interpereter with.
  +     */
  +    public String getMimeType() { return TEXT_ECMASCRIPT; }
   
       /**
        * Creates an instance of <code>RhinoInterpreter</code> class.
  
  
  
  1.5       +22 -2     
xml-batik/sources/org/apache/batik/svggen/font/table/CmapFormat4.java
  
  Index: CmapFormat4.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/svggen/font/table/CmapFormat4.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- CmapFormat4.java  18 Aug 2004 07:15:20 -0000      1.4
  +++ CmapFormat4.java  27 Aug 2004 00:42:07 -0000      1.5
  @@ -74,11 +74,31 @@
   
       public int mapCharCode(int charCode) {
           try {
  +            /*
  +              Quoting :
  +              
http://developer.apple.com/fonts/TTRefMan/RM06/Chap6cmap.html#Surrogates
  +               
  +              The original architecture of the Unicode Standard
  +              allowed for all encoded characters to be represented
  +              using sixteen bit code points. This allowed for up to
  +              65,354 characters to be encoded. (Unicode code points
  +              U+FFFE and U+FFFF are reserved and unavailable to
  +              represent characters. For more details, see The Unicode
  +              Standard.)
  +               
  +              My comment : Isn't there a typo here ? Shouldn't we
  +              rather read 65,534 ?
  +              */
  +            if ((charCode < 0) || (charCode >= 0xFFFE))
  +                return 0;
  +
               for (int i = 0; i < segCount; i++) {
                   if (endCode[i] >= charCode) {
                       if (startCode[i] <= charCode) {
                           if (idRangeOffset[i] > 0) {
  -                            return glyphIdArray[idRangeOffset[i]/2 + (charCode - 
startCode[i]) - (segCount - i)];
  +                            return glyphIdArray[idRangeOffset[i]/2 + 
  +                                                (charCode - startCode[i]) -
  +                                                (segCount - i)];
                           } else {
                               return (idDelta[i] + charCode) % 65536;
                           }
  
  
  
  1.7       +18 -16    xml-batik/sources/org/apache/batik/util/Service.java
  
  Index: Service.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/util/Service.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Service.java      18 Aug 2004 07:15:50 -0000      1.6
  +++ Service.java      27 Aug 2004 00:42:07 -0000      1.7
  @@ -23,10 +23,11 @@
   import java.io.InputStreamReader;
   import java.io.Reader;
   import java.net.URL;
  +import java.util.ArrayList;
   import java.util.Enumeration;
   import java.util.HashMap;
   import java.util.Iterator;
  -import java.util.Vector;
  +import java.util.List;
   
   /**
    * This class handles looking up service providers on the class path.
  @@ -56,6 +57,17 @@
        * @param cls The class/interface to search for providers of.
        */
       public static synchronized Iterator providers(Class cls) {
  +        String serviceFile = "META-INF/services/"+cls.getName();
  +
  +        // System.out.println("File: " + serviceFile);
  +
  +        List l = (List)providerMap.get(serviceFile);
  +        if (l != null)
  +            return l.iterator();
  +
  +        l = new ArrayList();
  +        providerMap.put(serviceFile, l);
  +
           ClassLoader cl = null;
           try {
               cl = cls.getClassLoader();
  @@ -65,24 +77,14 @@
           // Can always request your own class loader. But it might be 'null'.
           if (cl == null) cl = Service.class.getClassLoader();
   
  -        String serviceFile = "META-INF/services/"+cls.getName();
  -
  -        // System.out.println("File: " + serviceFile);
  -
  -        Vector v = (Vector)providerMap.get(serviceFile);
  -        if (v != null)
  -            return v.iterator();
  -
  -        v = new Vector();
  -        providerMap.put(serviceFile, v);
           // No class loader so we can't find 'serviceFile'.
  -        if (cl == null) return v.iterator();
  +        if (cl == null) return l.iterator();
   
           Enumeration e;
           try {
               e = cl.getResources(serviceFile);
           } catch (IOException ioe) {
  -            return v.iterator();
  +            return l.iterator();
           }
   
           while (e.hasMoreElements()) {
  @@ -115,7 +117,7 @@
                           // Try and load the class 
                           Object obj = cl.loadClass(line).newInstance();
                           // stick it into our vector...
  -                        v.add(obj);
  +                        l.add(obj);
                       } catch (Exception ex) {
                           // Just try the next line
                       }
  @@ -125,6 +127,6 @@
                   // Just try the next file...
               }
           }
  -        return v.iterator();
  +        return l.iterator();
       }
   }
  
  
  

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

Reply via email to