xmlgraphics-batik-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dewe...@apache.org
Subject cvs commit: xml-batik/sources/org/apache/batik/util XMLResourceDescriptor.java
Date Thu, 23 Sep 2004 10:18:07 GMT
deweese     2004/09/23 03:18:07

  Modified:    sources/org/apache/batik/bridge BridgeEventSupport.java
               sources/org/apache/batik/dom/svg SAXSVGDocumentFactory.java
               sources/org/apache/batik/extension/svg
                        MultiResGraphicsNode.java
               sources/org/apache/batik/gvt CompositeGraphicsNode.java
               sources/org/apache/batik/transcoder/image
                        JPEGTranscoder.java PNGTranscoder.java
                        TIFFTranscoder.java
               sources/org/apache/batik/util XMLResourceDescriptor.java
  Log:
  1) DOM keypress events will now be generated for so called
     Java 'action' keyEvents (previously only keydown/up were
     generated).
  2) Parser Properties resource file is no longer loaded through
     the localization interfaces
  3) Some cleanup of stream handling in the Transcoders.
  
  Revision  Changes    Path
  1.55      +6 -1      xml-batik/sources/org/apache/batik/bridge/BridgeEventSupport.java
  
  Index: BridgeEventSupport.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/BridgeEventSupport.java,v
  retrieving revision 1.54
  retrieving revision 1.55
  diff -u -r1.54 -r1.55
  --- BridgeEventSupport.java	18 Aug 2004 07:12:30 -0000	1.54
  +++ BridgeEventSupport.java	23 Sep 2004 10:18:05 -0000	1.55
  @@ -124,6 +124,11 @@
                   isDown = true;
                   dispatchKeyEvent("keydown", evt);
               }
  +            if (evt.getKeyChar() == KeyEvent.CHAR_UNDEFINED) {
  +                // We will not get a KEY_TYPED event for this char
  +                // so generate a keypress event here.
  +                dispatchKeyEvent("keypress", evt);
  +            }
           }
   
           /**
  
  
  
  1.25      +1 -3      xml-batik/sources/org/apache/batik/dom/svg/SAXSVGDocumentFactory.java
  
  Index: SAXSVGDocumentFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/svg/SAXSVGDocumentFactory.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- SAXSVGDocumentFactory.java	27 Aug 2004 00:42:06 -0000	1.24
  +++ SAXSVGDocumentFactory.java	23 Sep 2004 10:18:06 -0000	1.25
  @@ -23,9 +23,7 @@
   import java.io.StringReader;
   import java.net.MalformedURLException;
   import java.net.URL;
  -import java.util.Locale;
   import java.util.MissingResourceException;
  -import java.util.ResourceBundle;
   
   import java.util.Properties;
   
  
  
  
  1.12      +4 -3      xml-batik/sources/org/apache/batik/extension/svg/MultiResGraphicsNode.java
  
  Index: MultiResGraphicsNode.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/extension/svg/MultiResGraphicsNode.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- MultiResGraphicsNode.java	18 Aug 2004 07:14:22 -0000	1.11
  +++ MultiResGraphicsNode.java	23 Sep 2004 10:18:06 -0000	1.12
  @@ -116,11 +116,13 @@
           if (idx == -1)
               idx = minIdx;
           gn = getGraphicsNode(idx);
  -
           if (gn == null) return;
  +
           // This makes sure that the image 'pushes out' to it's pixel
           // bounderies.
           Rectangle2D gnBounds = gn.getBounds();
  +        if (gnBounds == null) return;
  +
           double gnDevW = gnBounds.getWidth()*scx;
           double gnDevH = gnBounds.getHeight()*scy;
           double gnDevX = gnBounds.getX()*scx;
  @@ -212,7 +214,6 @@
       }
   
       public GraphicsNode getGraphicsNode(int idx) {
  -        // System.err.println("Getting: " + idx);
           if (srcs[idx] != null) {
               Object o = srcs[idx].get();
               if (o != null) 
  
  
  
  1.38      +28 -27    xml-batik/sources/org/apache/batik/gvt/CompositeGraphicsNode.java
  
  Index: CompositeGraphicsNode.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/CompositeGraphicsNode.java,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- CompositeGraphicsNode.java	18 Aug 2004 07:14:25 -0000	1.37
  +++ CompositeGraphicsNode.java	23 Sep 2004 10:18:06 -0000	1.38
  @@ -180,35 +180,36 @@
        * Returns the bounds of the area covered by this node's primitive paint.
        */
       public Rectangle2D getPrimitiveBounds() {
  -        if (primitiveBounds == null) {
  -            int i=0;
  -            Rectangle2D bounds = null;
  -            while ((bounds == null) && i < count) {
  -                bounds = children[i++].getTransformedBounds(IDENTITY);
  -            }
  -            if (bounds == null) return null;
  -            primitiveBounds = bounds;
  +        if (primitiveBounds != null) 
  +            return primitiveBounds;
   
  -            Rectangle2D ctb = null;
  -            while (i < count) {
  -                ctb = children[i++].getTransformedBounds(IDENTITY);
  -                if (ctb != null) {
  -                    if (primitiveBounds == null) {
  -                        // another thread has set the primitive bounds to null,
  -                        // need to recall this function
  -                        return null;
  -                    } else {
  -                        primitiveBounds.add(ctb);
  -                    }
  +        int i=0;
  +        Rectangle2D bounds = null;
  +        while ((bounds == null) && i < count) {
  +            bounds = children[i++].getTransformedBounds(IDENTITY);
  +        }
  +        if (bounds == null) return null;
  +        primitiveBounds = bounds;
  +        
  +        Rectangle2D ctb = null;
  +        while (i < count) {
  +            ctb = children[i++].getTransformedBounds(IDENTITY);
  +            if (ctb != null) {
  +                if (primitiveBounds == null) {
  +                    // another thread has set the primitive bounds to null,
  +                    // need to recall this function
  +                    return null;
  +                } else {
  +                    primitiveBounds.add(ctb);
                   }
               }
  -
  -            // Make sure we haven't been interrupted
  -            if (Thread.currentThread().isInterrupted()) {
  -                // The Thread has been interrupted.
  -                // Invalidate any cached values and proceed.
  -                invalidateGeometryCache();
  -            }
  +        }
  +        
  +        // Make sure we haven't been interrupted
  +        if (Thread.currentThread().isInterrupted()) {
  +            // The Thread has been interrupted.
  +            // Invalidate any cached values and proceed.
  +            invalidateGeometryCache();
           }
           return primitiveBounds;
       }
  
  
  
  1.10      +19 -11    xml-batik/sources/org/apache/batik/transcoder/image/JPEGTranscoder.java
  
  Index: JPEGTranscoder.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/transcoder/image/JPEGTranscoder.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- JPEGTranscoder.java	18 Aug 2004 07:15:43 -0000	1.9
  +++ JPEGTranscoder.java	23 Sep 2004 10:18:06 -0000	1.10
  @@ -73,24 +73,32 @@
               throw new TranscoderException(
                   Messages.formatMessage("jpeg.badoutput", null));
           }
  -        float quality;
  -        if (hints.containsKey(KEY_QUALITY)) {
  -            quality = ((Float)hints.get(KEY_QUALITY)).floatValue();
  -        } else {
  -            handler.error(new TranscoderException(
  -                Messages.formatMessage("jpeg.unspecifiedQuality", null)));
  -            quality = 1f;
  -        }
  +
           try {
  -            JPEGImageEncoder jpegEncoder = JPEGCodec.createJPEGEncoder(ostream);
  -            JPEGEncodeParam params = JPEGCodec.getDefaultJPEGEncodeParam(img);
  +            float quality;
  +            if (hints.containsKey(KEY_QUALITY)) {
  +                quality = ((Float)hints.get(KEY_QUALITY)).floatValue();
  +            } else {
  +                TranscoderException te;
  +                te = new TranscoderException
  +                    (Messages.formatMessage("jpeg.unspecifiedQuality", null));
  +                handler.error(te);
  +                quality = .75f;
  +            }
  +
  +            JPEGImageEncoder jpegEncoder;
  +            JPEGEncodeParam params;
  +            jpegEncoder = JPEGCodec.createJPEGEncoder(ostream);
  +            params      = JPEGCodec.getDefaultJPEGEncodeParam(img);
               params.setQuality(quality, true);
  +
               float PixSzMM = userAgent.getPixelUnitToMillimeter();
               int PixSzInch = (int)(25.4/PixSzMM+0.5);
               params.setDensityUnit(JPEGEncodeParam.DENSITY_UNIT_DOTS_INCH);
               params.setXDensity(PixSzInch);
               params.setYDensity(PixSzInch);
               jpegEncoder.encode(img, params);
  +            ostream.flush();
           } catch (IOException ex) {
               throw new TranscoderException(ex);
           }
  
  
  
  1.22      +2 -2      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.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- PNGTranscoder.java	18 Aug 2004 07:15:43 -0000	1.21
  +++ PNGTranscoder.java	23 Sep 2004 10:18:07 -0000	1.22
  @@ -153,7 +153,7 @@
           try {
               PNGImageEncoder pngEncoder = new PNGImageEncoder(ostream, params);
               pngEncoder.encode(img);
  -            ostream.close();
  +            ostream.flush();
           } catch (IOException ex) {
               throw new TranscoderException(ex);
           }
  
  
  
  1.8       +1 -2      xml-batik/sources/org/apache/batik/transcoder/image/TIFFTranscoder.java
  
  Index: TIFFTranscoder.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/transcoder/image/TIFFTranscoder.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- TIFFTranscoder.java	9 Aug 2003 16:58:45 -0000	1.7
  +++ TIFFTranscoder.java	23 Sep 2004 10:18:07 -0000	1.8
  @@ -195,7 +195,6 @@
               RenderedImage rimg = new FormatRed(GraphicsUtil.wrap(img), sm);
               tiffEncoder.encode(rimg);
           } catch (IOException ex) {
  -            ex.printStackTrace();
               throw new TranscoderException(ex);
           }
       }
  
  
  
  1.5       +24 -9     xml-batik/sources/org/apache/batik/util/XMLResourceDescriptor.java
  
  Index: XMLResourceDescriptor.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/util/XMLResourceDescriptor.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XMLResourceDescriptor.java	8 Aug 2003 11:39:26 -0000	1.4
  +++ XMLResourceDescriptor.java	23 Sep 2004 10:18:07 -0000	1.5
  @@ -50,8 +50,10 @@
   
   package org.apache.batik.util;
   
  -import java.util.Locale;
  -import java.util.ResourceBundle;
  +import java.io.InputStream;
  +import java.io.IOException;
  +import java.util.Properties;
  +import java.util.MissingResourceException;
   
   /**
    * This class describes the XML resources needed to use the various batik
  @@ -78,12 +80,12 @@
        * The resources file name
        */
       public final static String RESOURCES =
  -        "org.apache.batik.util.resources.XMLResourceDescriptor";
  +        "resources/XMLResourceDescriptor.properties";
   
       /**
        * The resource bundle
        */
  -    protected static ResourceBundle bundle;
  +    protected static Properties parserProps = null;;
   
       /**
        * The class name of the XML parser to use.
  @@ -95,8 +97,19 @@
        */
       protected static String cssParserClassName;
   
  -    static {
  -        bundle = ResourceBundle.getBundle(RESOURCES, Locale.getDefault());
  +    protected static synchronized Properties getParserProps() {
  +        if (parserProps != null) return parserProps;
  +
  +        parserProps = new Properties();
  +        try { 
  +            Class cls = XMLResourceDescriptor.class;
  +            InputStream is = cls.getResourceAsStream(RESOURCES);
  +            parserProps.load(is);
  +        } catch (IOException ioe) { 
  +            throw new MissingResourceException(ioe.getMessage(),
  +                                               RESOURCES, null); 
  +        }
  +        return parserProps;
       }
   
       /**
  @@ -109,7 +122,8 @@
        */
       public static String getXMLParserClassName() {
           if (xmlParserClassName == null) {
  -            xmlParserClassName = bundle.getString(XML_PARSER_CLASS_NAME_KEY);
  +            xmlParserClassName = getParserProps().getProperty
  +                (XML_PARSER_CLASS_NAME_KEY);
           }
           return xmlParserClassName;
       }
  @@ -135,7 +149,8 @@
        */
       public static String getCSSParserClassName() {
           if (cssParserClassName == null) {
  -            cssParserClassName = bundle.getString(CSS_PARSER_CLASS_NAME_KEY);
  +            cssParserClassName = getParserProps().getProperty
  +                (CSS_PARSER_CLASS_NAME_KEY);
           }
           return cssParserClassName;
       }
  
  
  

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


Mime
View raw message