You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-commits@xmlgraphics.apache.org by ca...@apache.org on 2006/03/08 01:04:03 UTC
svn commit: r384062 [6/6] - in /xmlgraphics/batik/branches/anim: ./ lib/
resources/META-INF/services/
resources/org/apache/batik/apps/rasterizer/resources/
resources/org/apache/batik/apps/svgbrowser/resources/
resources/org/apache/batik/dom/svg/resourc...
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/svggen/CachedImageHandlerBase64Encoder.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/svggen/CachedImageHandlerBase64Encoder.java?rev=384062&r1=384061&r2=384062&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/svggen/CachedImageHandlerBase64Encoder.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/svggen/CachedImageHandlerBase64Encoder.java Tue Mar 7 16:03:46 2006
@@ -1,6 +1,6 @@
/*
- Copyright 2001-2003 The Apache Software Foundation
+ Copyright 2001-2003,2006 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.
@@ -22,8 +22,8 @@
import java.io.IOException;
import java.io.OutputStream;
-import org.apache.batik.ext.awt.image.codec.ImageEncoder;
-import org.apache.batik.ext.awt.image.codec.PNGImageEncoder;
+import org.apache.batik.ext.awt.image.spi.ImageWriter;
+import org.apache.batik.ext.awt.image.spi.ImageWriterRegistry;
import org.apache.batik.util.Base64EncoderStream;
import org.w3c.dom.Element;
@@ -104,8 +104,9 @@
public void encodeImage(BufferedImage buf, OutputStream os)
throws IOException {
Base64EncoderStream b64Encoder = new Base64EncoderStream(os);
- ImageEncoder encoder = new PNGImageEncoder(b64Encoder, null);
- encoder.encode(buf);
+ ImageWriter writer = ImageWriterRegistry.getInstance()
+ .getWriterFor("image/png");
+ writer.writeImage(buf, b64Encoder);
b64Encoder.close();
}
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/svggen/CachedImageHandlerJPEGEncoder.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/svggen/CachedImageHandlerJPEGEncoder.java?rev=384062&r1=384061&r2=384062&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/svggen/CachedImageHandlerJPEGEncoder.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/svggen/CachedImageHandlerJPEGEncoder.java Tue Mar 7 16:03:46 2006
@@ -1,6 +1,6 @@
/*
- Copyright 2001,2003 The Apache Software Foundation
+ Copyright 2001,2003,2006 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.
@@ -21,9 +21,9 @@
import java.io.IOException;
import java.io.OutputStream;
-import com.sun.image.codec.jpeg.JPEGCodec;
-import com.sun.image.codec.jpeg.JPEGEncodeParam;
-import com.sun.image.codec.jpeg.JPEGImageEncoder;
+import org.apache.batik.ext.awt.image.spi.ImageWriter;
+import org.apache.batik.ext.awt.image.spi.ImageWriterParams;
+import org.apache.batik.ext.awt.image.spi.ImageWriterRegistry;
/**
* GenericImageHandler which caches JPEG images.
@@ -56,11 +56,12 @@
* Uses JPEG encoding.
*/
public void encodeImage(BufferedImage buf, OutputStream os)
- throws IOException {
- JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(os);
- JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(buf);
- param.setQuality(1, false);
- encoder.encode(buf, param);
+ throws IOException {
+ ImageWriter writer = ImageWriterRegistry.getInstance()
+ .getWriterFor("image/jpeg");
+ ImageWriterParams params = new ImageWriterParams();
+ params.setJPEGQuality(1, false);
+ writer.writeImage(buf, os, params);
}
public int getBufferedImageType(){
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/svggen/CachedImageHandlerPNGEncoder.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/svggen/CachedImageHandlerPNGEncoder.java?rev=384062&r1=384061&r2=384062&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/svggen/CachedImageHandlerPNGEncoder.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/svggen/CachedImageHandlerPNGEncoder.java Tue Mar 7 16:03:46 2006
@@ -1,6 +1,6 @@
/*
- Copyright 2001,2003 The Apache Software Foundation
+ Copyright 2001,2003,2006 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.
@@ -21,8 +21,9 @@
import java.io.IOException;
import java.io.OutputStream;
-import org.apache.batik.ext.awt.image.codec.ImageEncoder;
-import org.apache.batik.ext.awt.image.codec.PNGImageEncoder;
+import org.apache.batik.ext.awt.image.spi.ImageWriter;
+import org.apache.batik.ext.awt.image.spi.ImageWriterParams;
+import org.apache.batik.ext.awt.image.spi.ImageWriterRegistry;
/**
* GenericImageHandler which caches PNG images.
@@ -57,8 +58,10 @@
*/
public void encodeImage(BufferedImage buf, OutputStream os)
throws IOException {
- ImageEncoder encoder = new PNGImageEncoder(os, null);
- encoder.encode(buf);
+ ImageWriter writer = ImageWriterRegistry.getInstance()
+ .getWriterFor("image/png");
+ ImageWriterParams params = new ImageWriterParams();
+ writer.writeImage(buf, os);
}
public int getBufferedImageType(){
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/svggen/ImageHandlerBase64Encoder.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/svggen/ImageHandlerBase64Encoder.java?rev=384062&r1=384061&r2=384062&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/svggen/ImageHandlerBase64Encoder.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/svggen/ImageHandlerBase64Encoder.java Tue Mar 7 16:03:46 2006
@@ -1,6 +1,6 @@
/*
- Copyright 2001,2003 The Apache Software Foundation
+ Copyright 2001,2003,2006 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.
@@ -27,8 +27,8 @@
import java.io.IOException;
import java.io.OutputStream;
-import org.apache.batik.ext.awt.image.codec.ImageEncoder;
-import org.apache.batik.ext.awt.image.codec.PNGImageEncoder;
+import org.apache.batik.ext.awt.image.spi.ImageWriter;
+import org.apache.batik.ext.awt.image.spi.ImageWriterRegistry;
import org.apache.batik.util.Base64EncoderStream;
import org.w3c.dom.Element;
@@ -151,8 +151,9 @@
public void encodeImage(RenderedImage buf, OutputStream os)
throws SVGGraphics2DIOException {
try{
- ImageEncoder encoder = new PNGImageEncoder(os, null);
- encoder.encode(buf);
+ ImageWriter writer = ImageWriterRegistry.getInstance()
+ .getWriterFor("image/png");
+ writer.writeImage(buf, os);
} catch(IOException e) {
// We are doing in-memory processing. This should not happen.
throw new SVGGraphics2DIOException(ERR_UNEXPECTED);
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/svggen/ImageHandlerJPEGEncoder.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/svggen/ImageHandlerJPEGEncoder.java?rev=384062&r1=384061&r2=384062&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/svggen/ImageHandlerJPEGEncoder.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/svggen/ImageHandlerJPEGEncoder.java Tue Mar 7 16:03:46 2006
@@ -1,6 +1,6 @@
/*
- Copyright 2001,2003 The Apache Software Foundation
+ Copyright 2001,2003,2006 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.
@@ -24,9 +24,9 @@
import java.io.IOException;
import java.io.OutputStream;
-import com.sun.image.codec.jpeg.JPEGCodec;
-import com.sun.image.codec.jpeg.JPEGEncodeParam;
-import com.sun.image.codec.jpeg.JPEGImageEncoder;
+import org.apache.batik.ext.awt.image.spi.ImageWriter;
+import org.apache.batik.ext.awt.image.spi.ImageWriterParams;
+import org.apache.batik.ext.awt.image.spi.ImageWriterRegistry;
/**
* This implementation of the abstract AbstractImageHandlerEncoder
@@ -77,12 +77,16 @@
throws SVGGraphics2DIOException {
try{
OutputStream os = new FileOutputStream(imageFile);
- JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(os);
- JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(buf);
- param.setQuality(1, false);
- encoder.encode(buf, param);
- os.flush();
- os.close();
+ try {
+ ImageWriter writer = ImageWriterRegistry.getInstance()
+ .getWriterFor("image/jpeg");
+ ImageWriterParams params = new ImageWriterParams();
+ params.setJPEGQuality(1, false);
+ writer.writeImage(buf, os, params);
+
+ } finally {
+ os.close();
+ }
} catch(IOException e) {
throw new SVGGraphics2DIOException(ERR_WRITE+imageFile.getName());
}
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/svggen/ImageHandlerPNGEncoder.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/svggen/ImageHandlerPNGEncoder.java?rev=384062&r1=384061&r2=384062&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/svggen/ImageHandlerPNGEncoder.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/svggen/ImageHandlerPNGEncoder.java Tue Mar 7 16:03:46 2006
@@ -1,6 +1,6 @@
/*
- Copyright 2001,2003 The Apache Software Foundation
+ Copyright 2001,2003,2006 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.
@@ -24,8 +24,8 @@
import java.io.IOException;
import java.io.OutputStream;
-import org.apache.batik.ext.awt.image.codec.ImageEncoder;
-import org.apache.batik.ext.awt.image.codec.PNGImageEncoder;
+import org.apache.batik.ext.awt.image.spi.ImageWriter;
+import org.apache.batik.ext.awt.image.spi.ImageWriterRegistry;
/**
* This implementation of the abstract AbstractImageHandlerEncoder
@@ -76,9 +76,14 @@
throws SVGGraphics2DIOException {
try {
OutputStream os = new FileOutputStream(imageFile);
- ImageEncoder encoder = new PNGImageEncoder(os, null);
- encoder.encode(buf);
- os.close();
+ try {
+ ImageWriter writer = ImageWriterRegistry.getInstance()
+ .getWriterFor("image/png");
+ writer.writeImage(buf, os);
+
+ } finally {
+ os.close();
+ }
} catch (IOException e) {
throw new SVGGraphics2DIOException(ERR_WRITE+imageFile.getName());
}
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/swing/gvt/AbstractImageZoomInteractor.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/swing/gvt/AbstractImageZoomInteractor.java?rev=384062&r1=384061&r2=384062&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/swing/gvt/AbstractImageZoomInteractor.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/swing/gvt/AbstractImageZoomInteractor.java Tue Mar 7 16:03:46 2006
@@ -106,20 +106,22 @@
* bounds of the component).
*/
public void mouseDragged(MouseEvent e) {
+ AffineTransform at;
JGVTComponent c = (JGVTComponent)e.getSource();
xCurrent = e.getX();
yCurrent = e.getY();
- AffineTransform at = AffineTransform.getTranslateInstance(xStart, yStart);
+ at = AffineTransform.getTranslateInstance(xStart, yStart);
int dy = yCurrent - yStart;
+ double s;
if (dy < 0) {
- dy = (dy > -5) ? 15 : dy - 10;
+ dy -= 10;
+ s = (dy > -15) ? 1.0 : -15.0/dy;
} else {
- dy = (dy < 5) ? 15 : dy + 10;
+ dy += 10;
+ s = (dy < 15) ? 1.0 : dy/15.0;
}
- double s = dy / 15.0;
- s = (s > 0) ? s : -1 / s;
at.scale(s, s);
at.translate(-xStart, -yStart);
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/swing/gvt/AbstractJGVTComponent.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/swing/gvt/AbstractJGVTComponent.java?rev=384062&r1=384061&r2=384062&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/swing/gvt/AbstractJGVTComponent.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/swing/gvt/AbstractJGVTComponent.java Tue Mar 7 16:03:46 2006
@@ -592,7 +592,7 @@
public void setRenderingTransform(AffineTransform at,
boolean performRedraw) {
- renderingTransform = at;
+ renderingTransform = new AffineTransform(at);
suspendInteractions = true;
if (eventDispatcher != null) {
try {
@@ -620,14 +620,14 @@
* Returns the initial transform.
*/
public AffineTransform getInitialTransform() {
- return initialTransform;
+ return new AffineTransform(initialTransform);
}
/**
* Returns the current rendering transform.
*/
public AffineTransform getRenderingTransform() {
- return renderingTransform;
+ return new AffineTransform(renderingTransform);
}
/**
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/swing/svg/AbstractJSVGComponent.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/swing/svg/AbstractJSVGComponent.java?rev=384062&r1=384061&r2=384062&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/swing/svg/AbstractJSVGComponent.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/swing/svg/AbstractJSVGComponent.java Tue Mar 7 16:03:46 2006
@@ -3496,7 +3496,7 @@
* for content referenced by images so you can't actually see
* the info).
*
- * @param e The <image> element that can't be loaded.
+ * @param e The <image> element that can't be loaded.
* @param url The resolved url that can't be loaded.
* @param message As best as can be determined the reason it can't be
* loaded (not available, corrupt, unknown format,...).
@@ -3504,12 +3504,12 @@
public SVGDocument getBrokenLinkDocument(Element e,
String url,
String message) {
- Class cls = JSVGComponent.class;
- URL blURL = cls.getResource("BrokenLink.svg");
+ Class cls = AbstractJSVGComponent.class;
+ URL blURL = cls.getResource("resources/BrokenLink.svg");
if (blURL == null)
throw new BridgeException
(e, ErrorConstants.ERR_URI_IMAGE_BROKEN,
- new Object[] {url, message });
+ new Object[] { url, message });
DocumentLoader loader = bridgeContext.getDocumentLoader();
SVGDocument doc = null;
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/transcoder/SVGAbstractTranscoder.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/transcoder/SVGAbstractTranscoder.java?rev=384062&r1=384061&r2=384062&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/transcoder/SVGAbstractTranscoder.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/transcoder/SVGAbstractTranscoder.java Tue Mar 7 16:03:46 2006
@@ -1,6 +1,6 @@
/*
- Copyright 2002-2004 The Apache Software Foundation
+ Copyright 2002-2004,2006 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.
@@ -38,6 +38,7 @@
import org.apache.batik.bridge.UserAgent;
import org.apache.batik.bridge.UserAgentAdapter;
import org.apache.batik.bridge.ViewBox;
+import org.apache.batik.bridge.svg12.SVG12BridgeContext;
import org.apache.batik.dom.svg.SAXSVGDocumentFactory;
import org.apache.batik.dom.svg.SVGDOMImplementation;
import org.apache.batik.dom.svg.SVGOMDocument;
@@ -70,7 +71,8 @@
* </ul>
*
* @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
- * @version $Id$ */
+ * @version $Id$
+ */
public abstract class SVGAbstractTranscoder extends XMLAbstractTranscoder {
/**
* Value used as a default for the default font-family hint
@@ -185,17 +187,16 @@
}
}
- ctx = createBridgeContext();
SVGOMDocument svgDoc = (SVGOMDocument)document;
SVGSVGElement root = svgDoc.getRootElement();
+ ctx = createBridgeContext(svgDoc);
// build the GVT tree
builder = new GVTBuilder();
// flag that indicates if the document is dynamic
boolean isDynamic =
- (hints.containsKey(KEY_EXECUTE_ONLOAD) &&
- ((Boolean)hints.get(KEY_EXECUTE_ONLOAD)).booleanValue() &&
- ctx.isDynamicDocument(svgDoc));
+ hints.containsKey(KEY_EXECUTE_ONLOAD) &&
+ ((Boolean)hints.get(KEY_EXECUTE_ONLOAD)).booleanValue();
GraphicsNode gvtRoot;
try {
@@ -293,7 +294,10 @@
* BridgeContext so subclasses can insert new/modified
* bridges in the context.
*/
- protected BridgeContext createBridgeContext() {
+ protected BridgeContext createBridgeContext(SVGOMDocument doc) {
+ if (doc.isSVG12()) {
+ return new SVG12BridgeContext(userAgent);
+ }
return new BridgeContext(userAgent);
}
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/transcoder/image/ImageTranscoder.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/transcoder/image/ImageTranscoder.java?rev=384062&r1=384061&r2=384062&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/transcoder/image/ImageTranscoder.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/transcoder/image/ImageTranscoder.java Tue Mar 7 16:03:46 2006
@@ -1,6 +1,6 @@
/*
- Copyright 2001-2004 The Apache Software Foundation
+ Copyright 2001-2006 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.
@@ -24,6 +24,8 @@
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
+import java.awt.image.DataBufferInt;
+import java.awt.image.SinglePixelPackedSampleModel;
import org.apache.batik.ext.awt.image.GraphicsUtil;
import org.apache.batik.gvt.renderer.ConcreteImageRendererFactory;
@@ -129,6 +131,47 @@
writeImage(dest, output);
} catch (Exception ex) {
throw new TranscoderException(ex);
+ }
+ }
+
+ /**
+ * Converts an image so that viewers which do not support the alpha channel will
+ * see a white background (and not a black one).
+ * @param img the image to convert
+ * @param sppsm
+ */
+ protected void forceTransparentWhite(BufferedImage img, SinglePixelPackedSampleModel sppsm) {
+ //
+ // This is a trick so that viewers which do not support
+ // the alpha channel will see a white background (and not
+ // a black one).
+ //
+ int w = img.getWidth();
+ int h = img.getHeight();
+ DataBufferInt biDB=(DataBufferInt)img.getRaster().getDataBuffer();
+ int scanStride = sppsm.getScanlineStride();
+ int dbOffset = biDB.getOffset();
+ int pixels[] = biDB.getBankData()[0];
+ int p = dbOffset;
+ int adjust = scanStride - w;
+ int a=0, r=0, g=0, b=0, pel=0;
+ for(int i=0; i<h; i++){
+ for(int j=0; j<w; j++){
+ pel = pixels[p];
+ a = (pel >> 24) & 0xff;
+ r = (pel >> 16) & 0xff;
+ g = (pel >> 8 ) & 0xff;
+ b = pel & 0xff;
+ r = (255*(255 -a) + a*r)/255;
+ g = (255*(255 -a) + a*g)/255;
+ b = (255*(255 -a) + a*b)/255;
+ pixels[p++] =
+ (a<<24 & 0xff000000) |
+ (r<<16 & 0xff0000) |
+ (g<<8 & 0xff00) |
+ (b & 0xff);
+ }
+ p += adjust;
}
}
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/transcoder/image/JPEGTranscoder.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/transcoder/image/JPEGTranscoder.java?rev=384062&r1=384061&r2=384062&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/transcoder/image/JPEGTranscoder.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/transcoder/image/JPEGTranscoder.java Tue Mar 7 16:03:46 2006
@@ -1,6 +1,6 @@
/*
- Copyright 2001,2003 The Apache Software Foundation
+ Copyright 2001,2003,2006 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.
@@ -22,15 +22,14 @@
import java.io.IOException;
import java.io.OutputStream;
+import org.apache.batik.ext.awt.image.spi.ImageWriter;
+import org.apache.batik.ext.awt.image.spi.ImageWriterParams;
+import org.apache.batik.ext.awt.image.spi.ImageWriterRegistry;
import org.apache.batik.transcoder.TranscoderException;
import org.apache.batik.transcoder.TranscoderOutput;
import org.apache.batik.transcoder.TranscodingHints;
import org.apache.batik.transcoder.image.resources.Messages;
-import com.sun.image.codec.jpeg.JPEGCodec;
-import com.sun.image.codec.jpeg.JPEGEncodeParam;
-import com.sun.image.codec.jpeg.JPEGImageEncoder;
-
/**
* This class is an <tt>ImageTranscoder</tt> that produces a JPEG image.
*
@@ -86,18 +85,14 @@
quality = .75f;
}
- JPEGImageEncoder jpegEncoder;
- JPEGEncodeParam params;
- jpegEncoder = JPEGCodec.createJPEGEncoder(ostream);
- params = JPEGCodec.getDefaultJPEGEncodeParam(img);
- params.setQuality(quality, true);
-
+ ImageWriter writer = ImageWriterRegistry.getInstance()
+ .getWriterFor("image/jpeg");
+ ImageWriterParams params = new ImageWriterParams();
+ params.setJPEGQuality(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);
+ int PixSzInch = (int)(25.4 / PixSzMM + 0.5);
+ params.setResolution(PixSzInch);
+ writer.writeImage(img, ostream, params);
ostream.flush();
} catch (IOException ex) {
throw new TranscoderException(ex);
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/transcoder/image/PNGTranscoder.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/transcoder/image/PNGTranscoder.java?rev=384062&r1=384061&r2=384062&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/transcoder/image/PNGTranscoder.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/transcoder/image/PNGTranscoder.java Tue Mar 7 16:03:46 2006
@@ -1,6 +1,6 @@
/*
- Copyright 2001-2003 The Apache Software Foundation
+ Copyright 2001-2003,2005-2006 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.
@@ -18,14 +18,10 @@
package org.apache.batik.transcoder.image;
import java.awt.image.BufferedImage;
-import java.awt.image.DataBufferInt;
import java.awt.image.SinglePixelPackedSampleModel;
-import java.io.IOException;
import java.io.OutputStream;
-import org.apache.batik.ext.awt.image.codec.PNGEncodeParam;
-import org.apache.batik.ext.awt.image.codec.PNGImageEncoder;
-import org.apache.batik.ext.awt.image.rendered.IndexImage;
+import org.apache.batik.bridge.UserAgent;
import org.apache.batik.transcoder.TranscoderException;
import org.apache.batik.transcoder.TranscoderOutput;
import org.apache.batik.transcoder.TranscodingHints;
@@ -48,6 +44,11 @@
hints.put(KEY_FORCE_TRANSPARENT_WHITE, Boolean.FALSE);
}
+ /** @return the transcoder's user agent */
+ public UserAgent getUserAgent() {
+ return this.userAgent;
+ }
+
/**
* Creates a new ARGB image with the specified dimension.
* @param width the image width in pixels
@@ -57,6 +58,21 @@
return new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
}
+ private WriteAdapter getWriteAdapter(String className) {
+ WriteAdapter adapter;
+ try {
+ Class clazz = Class.forName(className);
+ adapter = (WriteAdapter)clazz.newInstance();
+ return adapter;
+ } catch (ClassNotFoundException e) {
+ return null;
+ } catch (InstantiationException e) {
+ return null;
+ } catch (IllegalAccessException e) {
+ return null;
+ }
+ }
+
/**
* Writes the specified image to the specified output.
* @param img the image to write
@@ -78,86 +94,55 @@
//
boolean forceTransparentWhite = false;
- if (hints.containsKey(KEY_FORCE_TRANSPARENT_WHITE)) {
+ if (hints.containsKey(PNGTranscoder.KEY_FORCE_TRANSPARENT_WHITE)) {
forceTransparentWhite =
((Boolean)hints.get
- (KEY_FORCE_TRANSPARENT_WHITE)).booleanValue();
+ (PNGTranscoder.KEY_FORCE_TRANSPARENT_WHITE)).booleanValue();
}
if (forceTransparentWhite) {
- int w = img.getWidth(), h = img.getHeight();
- DataBufferInt biDB = (DataBufferInt)img.getRaster().getDataBuffer();
- int scanStride = ((SinglePixelPackedSampleModel)
- img.getSampleModel()).getScanlineStride();
- int dbOffset = biDB.getOffset();
- int pixels[] = biDB.getBankData()[0];
- int p = dbOffset;
- int adjust = scanStride - w;
- int a=0, r=0, g=0, b=0, pel=0;
- for(int i=0; i<h; i++){
- for(int j=0; j<w; j++){
- pel = pixels[p];
- a = (pel >> 24) & 0xff;
- r = (pel >> 16) & 0xff;
- g = (pel >> 8 ) & 0xff;
- b = pel & 0xff;
- r = (255*(255 -a) + a*r)/255;
- g = (255*(255 -a) + a*g)/255;
- b = (255*(255 -a) + a*b)/255;
- pixels[p++] =
- (a<<24 & 0xff000000) |
- (r<<16 & 0xff0000) |
- (g<<8 & 0xff00) |
- (b & 0xff);
- }
- p += adjust;
- }
- }
-
- int n=-1;
- if (hints.containsKey(KEY_INDEXED)) {
- n=((Integer)hints.get(KEY_INDEXED)).intValue();
- if (n==1||n==2||n==4||n==8)
- //PNGEncodeParam.Palette can handle these numbers only.
- img = IndexImage.getIndexedImage(img,1<<n);
- }
-
- PNGEncodeParam params = PNGEncodeParam.getDefaultEncodeParam(img);
- if (params instanceof PNGEncodeParam.RGB) {
- ((PNGEncodeParam.RGB)params).setBackgroundRGB
- (new int [] { 255, 255, 255 });
- }
-
- // If they specify GAMMA key with a value of '0' then omit
- // gamma chunk. If they do not provide a GAMMA then just
- // generate an sRGB chunk. Otherwise supress the sRGB chunk
- // and just generate gamma and chroma chunks.
- if (hints.containsKey(KEY_GAMMA)) {
- float gamma = ((Float)hints.get(KEY_GAMMA)).floatValue();
- if (gamma > 0) {
- params.setGamma(gamma);
- }
- params.setChromaticity(DEFAULT_CHROMA);
- } else {
- // We generally want an sRGB chunk and our encoding intent
- // is perceptual
- params.setSRGBIntent(PNGEncodeParam.INTENT_PERCEPTUAL);
- }
-
-
- float PixSzMM = userAgent.getPixelUnitToMillimeter();
- // num Pixs in 1 Meter
- int numPix = (int)((1000/PixSzMM)+0.5);
- params.setPhysicalDimension(numPix, numPix, 1); // 1 means 'pix/meter'
+ SinglePixelPackedSampleModel sppsm;
+ sppsm = (SinglePixelPackedSampleModel)img.getSampleModel();
+ forceTransparentWhite(img, sppsm);
+ }
- try {
- PNGImageEncoder pngEncoder = new PNGImageEncoder(ostream, params);
- pngEncoder.encode(img);
- ostream.flush();
- } catch (IOException ex) {
- throw new TranscoderException(ex);
+ WriteAdapter adapter = getWriteAdapter(
+ "org.apache.batik.ext.awt.image.codec.png.PNGTranscoderInternalCodecWriteAdapter");
+ if (adapter == null) {
+ adapter = getWriteAdapter(
+ "org.apache.batik.transcoder.image.PNGTranscoderImageIOWriteAdapter");
}
+ if (adapter == null) {
+ throw new TranscoderException(
+ "Could not write PNG file because no WriteAdapter is availble");
+ }
+ adapter.writeImage(this, img, output);
+ }
+
+ // --------------------------------------------------------------------
+ // PNG specific interfaces
+ // --------------------------------------------------------------------
+
+ /**
+ * This interface is used by <tt>PNGTranscoder</tt> to write PNG images
+ * through different codecs.
+ *
+ * @version $Id$
+ */
+ public interface WriteAdapter {
+
+ /**
+ * Writes the specified image to the specified output.
+ * @param transcoder the calling PNGTranscoder
+ * @param img the image to write
+ * @param output the output where to store the image
+ * @throws TranscoderException if an error occured while storing the image
+ */
+ void writeImage(PNGTranscoder transcoder, BufferedImage img,
+ TranscoderOutput output) throws TranscoderException;
+
}
+
// --------------------------------------------------------------------
// Keys definition
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/transcoder/image/TIFFTranscoder.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/transcoder/image/TIFFTranscoder.java?rev=384062&r1=384061&r2=384062&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/transcoder/image/TIFFTranscoder.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/transcoder/image/TIFFTranscoder.java Tue Mar 7 16:03:46 2006
@@ -1,6 +1,6 @@
/*
- Copyright 1999-2003 The Apache Software Foundation
+ Copyright 1999-2003,2006 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.
@@ -19,25 +19,13 @@
package org.apache.batik.transcoder.image;
import java.awt.image.BufferedImage;
-import java.awt.image.DataBuffer;
-import java.awt.image.DataBufferInt;
-import java.awt.image.PixelInterleavedSampleModel;
-import java.awt.image.RenderedImage;
-import java.awt.image.SampleModel;
import java.awt.image.SinglePixelPackedSampleModel;
-import java.io.IOException;
-import java.io.OutputStream;
-import org.apache.batik.ext.awt.image.GraphicsUtil;
-import org.apache.batik.ext.awt.image.codec.tiff.TIFFEncodeParam;
-import org.apache.batik.ext.awt.image.codec.tiff.TIFFField;
-import org.apache.batik.ext.awt.image.codec.tiff.TIFFImageDecoder;
-import org.apache.batik.ext.awt.image.codec.tiff.TIFFImageEncoder;
-import org.apache.batik.ext.awt.image.rendered.FormatRed;
+import org.apache.batik.bridge.UserAgent;
import org.apache.batik.transcoder.TranscoderException;
import org.apache.batik.transcoder.TranscoderOutput;
import org.apache.batik.transcoder.TranscodingHints;
-import org.apache.batik.transcoder.image.resources.Messages;
+import org.apache.batik.transcoder.keys.StringKey;
/**
@@ -55,6 +43,11 @@
hints.put(KEY_FORCE_TRANSPARENT_WHITE, Boolean.FALSE);
}
+ /** @return the transcoder's user agent */
+ public UserAgent getUserAgent() {
+ return this.userAgent;
+ }
+
/**
* Creates a new ARGB image with the specified dimension.
* @param width the image width in pixels
@@ -64,6 +57,21 @@
return new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
}
+ private WriteAdapter getWriteAdapter(String className) {
+ WriteAdapter adapter;
+ try {
+ Class clazz = Class.forName(className);
+ adapter = (WriteAdapter)clazz.newInstance();
+ return adapter;
+ } catch (ClassNotFoundException e) {
+ return null;
+ } catch (InstantiationException e) {
+ return null;
+ } catch (IllegalAccessException e) {
+ return null;
+ }
+ }
+
/**
* Writes the specified image to the specified output.
* @param img the image to write
@@ -73,100 +81,61 @@
public void writeImage(BufferedImage img, TranscoderOutput output)
throws TranscoderException {
- OutputStream ostream = output.getOutputStream();
- if (ostream == null) {
- throw new TranscoderException(
- Messages.formatMessage("tiff.badoutput", null));
- }
-
- TIFFEncodeParam params = new TIFFEncodeParam();
-
- float PixSzMM = userAgent.getPixelUnitToMillimeter();
- // num Pixs in 100 Meters
- int numPix = (int)(((1000*100)/PixSzMM)+0.5);
- int denom = 100*100; // Centimeters per 100 Meters;
- long [] rational = {numPix, denom};
- TIFFField [] fields = {
- new TIFFField(TIFFImageDecoder.TIFF_RESOLUTION_UNIT,
- TIFFField.TIFF_SHORT, 1,
- new char [] { (char)3 }),
- new TIFFField(TIFFImageDecoder.TIFF_X_RESOLUTION,
- TIFFField.TIFF_RATIONAL, 1,
- new long [][] { rational }),
- new TIFFField(TIFFImageDecoder.TIFF_Y_RESOLUTION,
- TIFFField.TIFF_RATIONAL, 1,
- new long [][] { rational })
- };
-
- params.setExtraFields(fields);
-
//
// This is a trick so that viewers which do not support the alpha
// channel will see a white background (and not a black one).
//
boolean forceTransparentWhite = false;
- if (hints.containsKey(KEY_FORCE_TRANSPARENT_WHITE)) {
+ if (hints.containsKey(PNGTranscoder.KEY_FORCE_TRANSPARENT_WHITE)) {
forceTransparentWhite =
((Boolean)hints.get
- (KEY_FORCE_TRANSPARENT_WHITE)).booleanValue();
+ (PNGTranscoder.KEY_FORCE_TRANSPARENT_WHITE)).booleanValue();
}
- int w = img.getWidth();
- int h = img.getHeight();
- SinglePixelPackedSampleModel sppsm;
- sppsm = (SinglePixelPackedSampleModel)img.getSampleModel();
-
if (forceTransparentWhite) {
- //
- // This is a trick so that viewers which do not support
- // the alpha channel will see a white background (and not
- // a black one).
- //
- DataBufferInt biDB=(DataBufferInt)img.getRaster().getDataBuffer();
- int scanStride = sppsm.getScanlineStride();
- int dbOffset = biDB.getOffset();
- int pixels[] = biDB.getBankData()[0];
- int p = dbOffset;
- int adjust = scanStride - w;
- int a=0, r=0, g=0, b=0, pel=0;
- for(int i=0; i<h; i++){
- for(int j=0; j<w; j++){
- pel = pixels[p];
- a = (pel >> 24) & 0xff;
- r = (pel >> 16) & 0xff;
- g = (pel >> 8 ) & 0xff;
- b = pel & 0xff;
- r = (255*(255 -a) + a*r)/255;
- g = (255*(255 -a) + a*g)/255;
- b = (255*(255 -a) + a*b)/255;
- pixels[p++] =
- (a<<24 & 0xff000000) |
- (r<<16 & 0xff0000) |
- (g<<8 & 0xff00) |
- (b & 0xff);
- }
- p += adjust;
- }
+ SinglePixelPackedSampleModel sppsm;
+ sppsm = (SinglePixelPackedSampleModel)img.getSampleModel();
+ forceTransparentWhite(img, sppsm);
}
- try {
- TIFFImageEncoder tiffEncoder =
- new TIFFImageEncoder(ostream, params);
- int bands = sppsm.getNumBands();
- int [] off = new int[bands];
- for (int i=0; i<bands; i++)
- off[i] = i;
- SampleModel sm = new PixelInterleavedSampleModel
- (DataBuffer.TYPE_BYTE, w, h, bands, w*bands, off);
-
- RenderedImage rimg = new FormatRed(GraphicsUtil.wrap(img), sm);
- tiffEncoder.encode(rimg);
- } catch (IOException ex) {
- throw new TranscoderException(ex);
+ WriteAdapter adapter = getWriteAdapter(
+ "org.apache.batik.ext.awt.image.codec.tiff.TIFFTranscoderInternalCodecWriteAdapter");
+ if (adapter == null) {
+ adapter = getWriteAdapter(
+ "org.apache.batik.transcoder.image.TIFFTranscoderImageIOWriteAdapter");
+ }
+ if (adapter == null) {
+ throw new TranscoderException(
+ "Could not write TIFF file because no WriteAdapter is availble");
}
+ adapter.writeImage(this, img, output);
}
+
+ // --------------------------------------------------------------------
+ // TIFF specific interfaces
+ // --------------------------------------------------------------------
+
+ /**
+ * This interface is used by <tt>TIFFTranscoder</tt> to write TIFF images
+ * through different codecs.
+ *
+ * @version $Id$
+ */
+ public interface WriteAdapter {
+
+ /**
+ * Writes the specified image to the specified output.
+ * @param transcoder the calling PNGTranscoder
+ * @param img the image to write
+ * @param output the output where to store the image
+ * @throws TranscoderException if an error occured while storing the image
+ */
+ void writeImage(TIFFTranscoder transcoder, BufferedImage img,
+ TranscoderOutput output) throws TranscoderException;
+ }
+
// --------------------------------------------------------------------
// Keys definition
@@ -205,4 +174,27 @@
public static final TranscodingHints.Key KEY_FORCE_TRANSPARENT_WHITE
= ImageTranscoder.KEY_FORCE_TRANSPARENT_WHITE;
+ /**
+ * The compression method for the image.
+ * <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1">
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Key: </TH>
+ * <TD VALIGN="TOP">KEY_COMPRESSION_METHOD</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Value: </TH>
+ * <TD VALIGN="TOP">String ("none", "packbits", "jpeg" etc.)</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Default: </TH>
+ * <TD VALIGN="TOP">"none" (no compression)</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Required: </TH>
+ * <TD VALIGN="TOP">Recommended</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Description: </TH>
+ * <TD VALIGN="TOP">Specify the compression method used to encode the image.</TD></TR>
+ * </TABLE>
+ */
+ public static final TranscodingHints.Key KEY_COMPRESSION_METHOD
+ = new StringKey();
+
}
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/transcoder/wmf/WMFConstants.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/transcoder/wmf/WMFConstants.java?rev=384062&r1=384061&r2=384062&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/transcoder/wmf/WMFConstants.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/transcoder/wmf/WMFConstants.java Tue Mar 7 16:03:46 2006
@@ -100,29 +100,29 @@
public static final int META_CREATEBRUSHINDIRECT = 0x02FC;
public static final int META_CREATEREGION = 0x06FF;
public static final int META_POLYBEZIER16 = 0x1000;
- public static final int META_CREATEBRUSH = 0x00F8;
- public static final int META_CREATEBITMAPINDIRECT = 0x02FD;
- public static final int META_CREATEBITMAP = 0x06FE;
+ public static final int META_CREATEBRUSH = 0x00F8;
+ public static final int META_CREATEBITMAPINDIRECT = 0x02FD;
+ public static final int META_CREATEBITMAP = 0x06FE;
- public static final int META_OBJ_WHITE_BRUSH = 0;
- public static final int META_OBJ_LTGRAY_BRUSH = 1;
- public static final int META_OBJ_GRAY_BRUSH = 2;
- public static final int META_OBJ_DKGRAY_BRUSH = 3;
- public static final int META_OBJ_BLACK_BRUSH = 4;
- public static final int META_OBJ_NULL_BRUSH = 5;
- public static final int META_OBJ_HOLLOW_BRUSH = 5;
- public static final int META_OBJ_WHITE_PEN = 6;
- public static final int META_OBJ_BLACK_PEN = 7;
- public static final int META_OBJ_NULL_PEN = 8;
- public static final int META_OBJ_OEM_FIXED_FONT = 10;
- public static final int META_OBJ_ANSI_FIXED_FONT = 11;
- public static final int META_OBJ_ANSI_VAR_FONT = 12;
- public static final int META_OBJ_SYSTEM_FONT = 13;
+ public static final int META_OBJ_WHITE_BRUSH = 0;
+ public static final int META_OBJ_LTGRAY_BRUSH = 1;
+ public static final int META_OBJ_GRAY_BRUSH = 2;
+ public static final int META_OBJ_DKGRAY_BRUSH = 3;
+ public static final int META_OBJ_BLACK_BRUSH = 4;
+ public static final int META_OBJ_NULL_BRUSH = 5;
+ public static final int META_OBJ_HOLLOW_BRUSH = 5;
+ public static final int META_OBJ_WHITE_PEN = 6;
+ public static final int META_OBJ_BLACK_PEN = 7;
+ public static final int META_OBJ_NULL_PEN = 8;
+ public static final int META_OBJ_OEM_FIXED_FONT = 10;
+ public static final int META_OBJ_ANSI_FIXED_FONT = 11;
+ public static final int META_OBJ_ANSI_VAR_FONT = 12;
+ public static final int META_OBJ_SYSTEM_FONT = 13;
public static final int META_OBJ_DEVICE_DEFAULT_FONT = 14;
- public static final int META_OBJ_DEFAULT_PALETTE = 15;
- public static final int META_OBJ_SYSTEM_FIXED_FONT = 16;
+ public static final int META_OBJ_DEFAULT_PALETTE = 15;
+ public static final int META_OBJ_SYSTEM_FIXED_FONT = 16;
-/* New StretchBlt() Modes */
+ /* New StretchBlt() Modes */
public static final int STRETCH_BLACKONWHITE = 1;
public static final int STRETCH_WHITEONBLACK = 2;
public static final int STRETCH_COLORONCOLOR = 3;
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/util/SVGConstants.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/util/SVGConstants.java?rev=384062&r1=384061&r2=384062&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/util/SVGConstants.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/util/SVGConstants.java Tue Mar 7 16:03:46 2006
@@ -379,7 +379,10 @@
String SVG_ASCENT_ATTRIBUTE = "ascent";
String SVG_AZIMUTH_ATTRIBUTE = "azimuth";
String SVG_ALPHABETIC_ATTRIBUTE = "alphabetic";
+ String SVG_ATTRIBUTE_NAME_ATTRIBUTE = "attributeName";
+ String SVG_ATTRIBUTE_TYPE_ATTRIBUTE = "attributeType";
String SVG_BASE_FREQUENCY_ATTRIBUTE = "baseFrequency";
+ String SVG_BEGIN_ATTRIBUTE = "begin";
String SVG_BBOX_ATTRIBUTE = "bbox";
String SVG_BIAS_ATTRIBUTE = "bias";
String SVG_CALC_MODE_ATTRIBUTE = "calcMode";
@@ -396,12 +399,14 @@
String SVG_DESCENT_ATTRIBUTE = "descent";
String SVG_DIFFUSE_CONSTANT_ATTRIBUTE = "diffuseConstant";
String SVG_DIVISOR_ATTRIBUTE = "divisor";
+ String SVG_DUR_ATTRIBUTE = "dur";
String SVG_DX_ATTRIBUTE = "dx";
String SVG_DY_ATTRIBUTE = "dy";
String SVG_D_ATTRIBUTE = "d";
String SVG_EDGE_MODE_ATTRIBUTE = "edgeMode";
String SVG_ELEVATION_ATTRIBUTE = "elevation";
String SVG_ENABLE_BACKGROUND_ATTRIBUTE = CSS_ENABLE_BACKGROUND_PROPERTY;
+ String SVG_END_ATTRIBUTE = "end";
String SVG_EXPONENT_ATTRIBUTE = "exponent";
String SVG_EXTERNAL_RESOURCES_REQUIRED_ATTRIBUTE = "externalResourcesRequired";
String SVG_FILL_ATTRIBUTE = CSS_FILL_PROPERTY;
@@ -419,6 +424,7 @@
String SVG_FONT_STYLE_ATTRIBUTE = CSS_FONT_STYLE_PROPERTY;
String SVG_FONT_VARIANT_ATTRIBUTE = CSS_FONT_VARIANT_PROPERTY;
String SVG_FONT_WEIGHT_ATTRIBUTE = CSS_FONT_WEIGHT_PROPERTY;
+ String SVG_FROM_ATTRIBUTE = "from";
String SVG_FX_ATTRIBUTE = "fx";
String SVG_FY_ATTRIBUTE = "fy";
String SVG_G1_ATTRIBUTE = "g1";
@@ -538,6 +544,7 @@
String SVG_TEXT_LENGTH_ATTRIBUTE = "textLength";
String SVG_TEXT_RENDERING_ATTRIBUTE = CSS_TEXT_RENDERING_PROPERTY;
String SVG_TITLE_ATTRIBUTE = "title";
+ String SVG_TO_ATTRIBUTE = "to";
String SVG_TRANSFORM_ATTRIBUTE = "transform";
String SVG_TYPE_ATTRIBUTE = "type";
String SVG_U1_ATTRIBUTE = "u1";
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/util/Service.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/util/Service.java?rev=384062&r1=384061&r2=384062&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/util/Service.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/util/Service.java Tue Mar 7 16:03:46 2006
@@ -125,6 +125,8 @@
}
} catch (Exception ex) {
// Just try the next file...
+ } catch (LinkageError le) {
+ // Just try the next file...
}
}
return l.iterator();
Modified: xmlgraphics/batik/branches/anim/test-references/samples/extensions/flowTextAlign.png
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/test-references/samples/extensions/flowTextAlign.png?rev=384062&r1=384061&r2=384062&view=diff
==============================================================================
Binary files - no diff available.
Modified: xmlgraphics/batik/branches/anim/test-resources/org/apache/batik/bridge/IWasLoaded.jar
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/test-resources/org/apache/batik/bridge/IWasLoaded.jar?rev=384062&r1=384061&r2=384062&view=diff
==============================================================================
Binary files - no diff available.
Modified: xmlgraphics/batik/branches/anim/test-resources/org/apache/batik/bridge/unitTesting.xml
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/test-resources/org/apache/batik/bridge/unitTesting.xml?rev=384062&r1=384061&r2=384062&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/test-resources/org/apache/batik/bridge/unitTesting.xml (original)
+++ xmlgraphics/batik/branches/anim/test-resources/org/apache/batik/bridge/unitTesting.xml Tue Mar 7 16:03:46 2006
@@ -179,7 +179,7 @@
<property name="ExpectedErrorCode" class="java.lang.String"
value="css.uri.badTarget" />
</test>
- <!-- No longer generats exception - just user warning
+ <!-- No longer generates exception - just user warning
<test id="bridge/error/css-invalid">
<property name="ExpectedExceptionClass" class="java.lang.String"
value="org.w3c.dom.DOMException" />
Modified: xmlgraphics/batik/branches/anim/test-resources/org/apache/batik/ext/awt/image/codec/unitTesting.xml
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/test-resources/org/apache/batik/ext/awt/image/codec/unitTesting.xml?rev=384062&r1=384061&r2=384062&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/test-resources/org/apache/batik/ext/awt/image/codec/unitTesting.xml (original)
+++ xmlgraphics/batik/branches/anim/test-resources/org/apache/batik/ext/awt/image/codec/unitTesting.xml Tue Mar 7 16:03:46 2006
@@ -22,6 +22,6 @@
<!-- ========================================================================== -->
<!-- Validates that PNGEncoding is operating as expected -->
<!-- ========================================================================== -->
- <test id="PNGEncoderTest" class="org.apache.batik.ext.awt.image.codec.PNGEncoderTest" />
- <test id="Base64PNGEncoderTest" class="org.apache.batik.ext.awt.image.codec.Base64PNGEncoderTest" />
+ <test id="PNGEncoderTest" class="org.apache.batik.ext.awt.image.codec.png.PNGEncoderTest" />
+ <test id="Base64PNGEncoderTest" class="org.apache.batik.ext.awt.image.codec.png.Base64PNGEncoderTest" />
</testSuite>
Modified: xmlgraphics/batik/branches/anim/test-resources/org/apache/batik/swing/unitTesting.xml
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/test-resources/org/apache/batik/swing/unitTesting.xml?rev=384062&r1=384061&r2=384062&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/test-resources/org/apache/batik/swing/unitTesting.xml (original)
+++ xmlgraphics/batik/branches/anim/test-resources/org/apache/batik/swing/unitTesting.xml Tue Mar 7 16:03:46 2006
@@ -1,5 +1,5 @@
<!--
- Copyright 1999-2003,2005 The Apache Software Foundation.
+ Copyright 1999-2003,2005-2006 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.
@@ -24,6 +24,8 @@
class="org.apache.batik.swing.JSVGMemoryLeakTest">
<test id="samples/anne.svg" />
<test id="samples/tests/spec/scripting/memoryLeak1.svg"/>
+ <test id="samples/tests/spec/scripting/primaryDoc.svg"/>
+ <test id="samples/tests/spec/scripting/resourceDocDynamic11.svg"/>
</testGroup>
<!--test id="NullURITest"
Modified: xmlgraphics/batik/branches/anim/test-resources/org/apache/batik/test/samplesRendering.xml
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/test-resources/org/apache/batik/test/samplesRendering.xml?rev=384062&r1=384061&r2=384062&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/test-resources/org/apache/batik/test/samplesRendering.xml (original)
+++ xmlgraphics/batik/branches/anim/test-resources/org/apache/batik/test/samplesRendering.xml Tue Mar 7 16:03:46 2006
@@ -53,10 +53,10 @@
<test id="samples/textRotateShadows.svg" />
</testGroup>
- <testGroup id="svg1.2" name="SVG Version 1.2 functionality tests">
+ <testGroup id="tests.spec12" name="SVG Version 1.2 functionality tests">
<test id="samples/tests/spec12/text/flowBidi.svg" >
<property name="Validating" class="java.lang.Boolean" value="false" />
- </test>
+ </test>
<test id="samples/tests/spec12/text/flowText.svg" >
<property name="Validating" class="java.lang.Boolean" value="false" />
</test>
Propchange: xmlgraphics/batik/branches/anim/test-sources/org/apache/batik/ext/awt/image/codec/png/Base64PNGEncoderTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/batik/branches/anim/test-sources/org/apache/batik/ext/awt/image/codec/png/Base64PNGEncoderTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: xmlgraphics/batik/branches/anim/test-sources/org/apache/batik/ext/awt/image/codec/png/PNGEncoderTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/batik/branches/anim/test-sources/org/apache/batik/ext/awt/image/codec/png/PNGEncoderTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: xmlgraphics/batik/branches/anim/test-sources/org/apache/batik/swing/JSVGMemoryLeakTest.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/test-sources/org/apache/batik/swing/JSVGMemoryLeakTest.java?rev=384062&r1=384061&r2=384062&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/test-sources/org/apache/batik/swing/JSVGMemoryLeakTest.java (original)
+++ xmlgraphics/batik/branches/anim/test-sources/org/apache/batik/swing/JSVGMemoryLeakTest.java Tue Mar 7 16:03:46 2006
@@ -28,6 +28,7 @@
import org.apache.batik.bridge.BridgeContext;
import org.apache.batik.bridge.UpdateManager;
import org.apache.batik.dom.svg.SVGContext;
+import org.apache.batik.dom.svg.SVGOMDocument;
import org.apache.batik.dom.svg.SVGOMElement;
import org.apache.batik.gvt.GraphicsNode;
import org.apache.batik.test.DefaultTestReport;
@@ -125,8 +126,25 @@
if (e instanceof SVGOMElement) {
SVGOMElement svge = (SVGOMElement)e;
SVGContext svgctx = svge.getSVGContext();
- if (svgctx != null)
+ if (svgctx != null) {
registerObjectDesc(svgctx, desc+"_CTX");
+ }
+ }
+ }
+
+ public void registerResourceContext(String uriSubstring, String desc) {
+ UpdateManager um = theCanvas.getUpdateManager();
+ BridgeContext bc = um.getBridgeContext();
+ BridgeContext[] ctxs = bc.getChildContexts();
+ for (int i = 0; i < ctxs.length; i++) {
+ bc = ctxs[i];
+ if (bc == null) {
+ continue;
+ }
+ String url = ((SVGOMDocument) bc.getDocument()).getURL();
+ if (url.indexOf(uriSubstring) != -1) {
+ registerObjectDesc(ctxs[i], desc);
+ }
}
}
@@ -155,7 +173,21 @@
public void canvasRendered(JSVGCanvas canvas) {
// System.err.println("Rendered");
registerObjectDesc(canvas.getGraphicsNode(), "GVT");
- registerObjectDesc(canvas.getUpdateManager(), "updateManager");
+ UpdateManager um = canvas.getUpdateManager();
+ if (um == null) {
+ return;
+ }
+ BridgeContext bc = um.getBridgeContext();
+ registerObjectDesc(um, "updateManager");
+ registerObjectDesc(bc, "bridgeContext");
+ BridgeContext[] subCtxs = bc.getChildContexts();
+ for (int i = 0; i < subCtxs.length; i++) {
+ if (subCtxs[i] != null) {
+ SVGOMDocument doc = (SVGOMDocument) subCtxs[i].getDocument();
+ registerObjectDesc(subCtxs[i], "BridgeContext_" + doc.getURL());
+ System.err.println("found subctx for " + doc.getURL());
+ }
+ }
}
public boolean canvasUpdated(JSVGCanvas canvas) {
Modified: xmlgraphics/batik/branches/anim/test-sources/org/apache/batik/test/svg/AbstractRenderingAccuracyTest.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/test-sources/org/apache/batik/test/svg/AbstractRenderingAccuracyTest.java?rev=384062&r1=384061&r2=384062&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/test-sources/org/apache/batik/test/svg/AbstractRenderingAccuracyTest.java (original)
+++ xmlgraphics/batik/branches/anim/test-sources/org/apache/batik/test/svg/AbstractRenderingAccuracyTest.java Tue Mar 7 16:03:46 2006
@@ -1,6 +1,6 @@
/*
- Copyright 2003 The Apache Software Foundation
+ Copyright 2003,2005 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.
@@ -43,11 +43,10 @@
import org.apache.batik.ext.awt.image.GraphicsUtil;
import org.apache.batik.ext.awt.image.spi.ImageTagRegistry;
+import org.apache.batik.ext.awt.image.spi.ImageWriter;
+import org.apache.batik.ext.awt.image.spi.ImageWriterRegistry;
import org.apache.batik.ext.awt.image.renderable.Filter;
-import org.apache.batik.ext.awt.image.codec.PNGImageEncoder;
-import org.apache.batik.ext.awt.image.codec.PNGEncodeParam;
-
import org.apache.batik.util.ParsedURL;
import org.apache.batik.test.AbstractTest;
@@ -635,18 +634,22 @@
if(!imgFile.exists()){
imgFile.createNewFile();
}
- saveImage(img, new FileOutputStream(imgFile));
+ OutputStream out = new FileOutputStream(imgFile);
+ try {
+ saveImage(img, out);
+ } finally {
+ out.close();
+ }
}
/**
* Saves an image in a given File
*/
protected void saveImage(BufferedImage img, OutputStream os)
- throws IOException {
- PNGImageEncoder encoder = new PNGImageEncoder
- (os, PNGEncodeParam.getDefaultEncodeParam(img));
-
- encoder.encode(img);
+ throws IOException {
+ ImageWriter writer = ImageWriterRegistry.getInstance()
+ .getWriterFor("image/png");
+ writer.writeImage(img, os);
}
/**
@@ -784,11 +787,7 @@
imageFile.deleteOnExit();
- PNGImageEncoder encoder = new PNGImageEncoder
- (new FileOutputStream(imageFile),
- PNGEncodeParam.getDefaultEncodeParam(img));
-
- encoder.encode(img);
+ saveImage(img, imageFile);
return imageFile;
}
Modified: xmlgraphics/batik/branches/anim/test-sources/org/apache/batik/test/util/ImageCompareTest.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/test-sources/org/apache/batik/test/util/ImageCompareTest.java?rev=384062&r1=384061&r2=384062&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/test-sources/org/apache/batik/test/util/ImageCompareTest.java (original)
+++ xmlgraphics/batik/branches/anim/test-sources/org/apache/batik/test/util/ImageCompareTest.java Tue Mar 7 16:03:46 2006
@@ -27,14 +27,15 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URL;
import org.apache.batik.ext.awt.image.GraphicsUtil;
-import org.apache.batik.ext.awt.image.codec.PNGEncodeParam;
-import org.apache.batik.ext.awt.image.codec.PNGImageEncoder;
import org.apache.batik.ext.awt.image.renderable.Filter;
import org.apache.batik.ext.awt.image.spi.ImageTagRegistry;
+import org.apache.batik.ext.awt.image.spi.ImageWriter;
+import org.apache.batik.ext.awt.image.spi.ImageWriterRegistry;
import org.apache.batik.test.AbstractTest;
import org.apache.batik.test.TestReport;
import org.apache.batik.util.ParsedURL;
@@ -257,11 +258,14 @@
File imageFile = makeRandomFileName(imageType);
imageFile.deleteOnExit();
- PNGImageEncoder encoder
- = new PNGImageEncoder(new FileOutputStream(imageFile),
- PNGEncodeParam.getDefaultEncodeParam(img));
-
- encoder.encode(img);
+ ImageWriter writer = ImageWriterRegistry.getInstance()
+ .getWriterFor("image/png");
+ OutputStream out = new FileOutputStream(imageFile);
+ try {
+ writer.writeImage(img, out);
+ } finally {
+ out.close();
+ }
return imageFile;
Modified: xmlgraphics/batik/branches/anim/test-sources/org/apache/batik/transcoder/TranscoderInputTest.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/test-sources/org/apache/batik/transcoder/TranscoderInputTest.java?rev=384062&r1=384061&r2=384062&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/test-sources/org/apache/batik/transcoder/TranscoderInputTest.java (original)
+++ xmlgraphics/batik/branches/anim/test-sources/org/apache/batik/transcoder/TranscoderInputTest.java Tue Mar 7 16:03:46 2006
@@ -24,6 +24,9 @@
import java.io.StringWriter;
import java.net.URL;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
@@ -56,7 +59,11 @@
// XMLReader
{
- XMLReader xmlReader = XMLReaderFactory.createXMLReader();
+ SAXParserFactory saxFactory = SAXParserFactory.newInstance();
+ saxFactory.setValidating(false);
+ SAXParser parser = saxFactory.newSAXParser();
+ XMLReader xmlReader = parser.getXMLReader();
+ //XMLReader xmlReader = XMLReaderFactory.createXMLReader();
TranscoderInput ti = new TranscoderInput(xmlReader);
ti.setURI(TEST_URI);
t.transcode(ti, out);
Modified: xmlgraphics/batik/branches/anim/test-sources/org/apache/batik/transcoder/image/AbstractImageTranscoderTest.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/test-sources/org/apache/batik/transcoder/image/AbstractImageTranscoderTest.java?rev=384062&r1=384061&r2=384062&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/test-sources/org/apache/batik/transcoder/image/AbstractImageTranscoderTest.java (original)
+++ xmlgraphics/batik/branches/anim/test-sources/org/apache/batik/transcoder/image/AbstractImageTranscoderTest.java Tue Mar 7 16:03:46 2006
@@ -1,6 +1,6 @@
/*
- Copyright 2001-2003 The Apache Software Foundation
+ Copyright 2001-2003,2005 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.
@@ -26,6 +26,7 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
@@ -35,11 +36,10 @@
import java.util.Map;
import org.apache.batik.ext.awt.image.spi.ImageTagRegistry;
+import org.apache.batik.ext.awt.image.spi.ImageWriter;
+import org.apache.batik.ext.awt.image.spi.ImageWriterRegistry;
import org.apache.batik.ext.awt.image.renderable.Filter;
-import org.apache.batik.ext.awt.image.codec.PNGImageEncoder;
-import org.apache.batik.ext.awt.image.codec.PNGEncodeParam;
-
import org.apache.batik.transcoder.TranscoderException;
import org.apache.batik.transcoder.TranscoderInput;
import org.apache.batik.transcoder.TranscoderOutput;
@@ -283,11 +283,14 @@
String s = new File(filename).getName();
s = ("test-references/org/apache/batik/transcoder/image/"+
"candidate-variation/"+s);
- PNGImageEncoder encoder
- = new PNGImageEncoder
- (new FileOutputStream(s),
- PNGEncodeParam.getDefaultEncodeParam(diff));
- encoder.encode(diff);
+ ImageWriter writer = ImageWriterRegistry.getInstance()
+ .getWriterFor("image/png");
+ OutputStream out = new FileOutputStream(s);
+ try {
+ writer.writeImage(diff, out);
+ } finally {
+ out.close();
+ }
report.addDescriptionEntry(DIFFERENCE_IMAGE,new File(s));
} catch (Exception e) { }
}