deweese 02/04/05 00:19:53 Modified: sources/org/apache/batik/ext/awt AreaOfInterestHintKey.java BufferedImageHintKey.java RenderingHintsKeyExt.java TranscodingHintKey.java sources/org/apache/batik/ext/awt/image/renderable FilterAlphaRable.java FilterAsAlphaRable.java sources/org/apache/batik/ext/awt/image/rendered Any2LumRed.java FilterAlphaRed.java FilterAsAlphaRed.java Added: sources/org/apache/batik/ext/awt ColorSpaceHintKey.java Log: Batik should no longer die if it is loaded multiple times into the same JVM through different class loaders. Revision Changes Path 1.2 +4 -4 xml-batik/sources/org/apache/batik/ext/awt/AreaOfInterestHintKey.java Index: AreaOfInterestHintKey.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/ext/awt/AreaOfInterestHintKey.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- AreaOfInterestHintKey.java 24 Jan 2001 05:39:28 -0000 1.1 +++ AreaOfInterestHintKey.java 5 Apr 2002 08:19:52 -0000 1.2 @@ -16,12 +16,12 @@ * <code>GraphicsNode</code>. * * @author <a href="mailto:[EMAIL PROTECTED]">Christophe Jolif</a> - * @version $Id: AreaOfInterestHintKey.java,v 1.1 2001/01/24 05:39:28 vhardy Exp $ + * @version $Id: AreaOfInterestHintKey.java,v 1.2 2002/04/05 08:19:52 deweese Exp $ */ final class AreaOfInterestHintKey extends RenderingHints.Key { - AreaOfInterestHintKey() { - super(1000); - } + + AreaOfInterestHintKey(int number) { super(number); } + public boolean isCompatibleValue(Object val) { boolean isCompatible = true; if ((val != null) && !(val instanceof Shape)) { 1.3 +3 -4 xml-batik/sources/org/apache/batik/ext/awt/BufferedImageHintKey.java Index: BufferedImageHintKey.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/ext/awt/BufferedImageHintKey.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- BufferedImageHintKey.java 19 Apr 2001 21:30:49 -0000 1.2 +++ BufferedImageHintKey.java 5 Apr 2002 08:19:52 -0000 1.3 @@ -18,12 +18,11 @@ * <code>GraphicsNode</code>. * * @author <a href="mailto:[EMAIL PROTECTED]">Christophe Jolif</a> - * @version $Id: BufferedImageHintKey.java,v 1.2 2001/04/19 21:30:49 deweese Exp $ + * @version $Id: BufferedImageHintKey.java,v 1.3 2002/04/05 08:19:52 deweese Exp $ */ final class BufferedImageHintKey extends RenderingHints.Key { - BufferedImageHintKey() { - super(1001); - } + BufferedImageHintKey(int number) { super(number); } + public boolean isCompatibleValue(Object val) { if (val == null) return true; 1.5 +42 -7 xml-batik/sources/org/apache/batik/ext/awt/RenderingHintsKeyExt.java Index: RenderingHintsKeyExt.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/ext/awt/RenderingHintsKeyExt.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- RenderingHintsKeyExt.java 29 Nov 2001 15:05:26 -0000 1.4 +++ RenderingHintsKeyExt.java 5 Apr 2002 08:19:52 -0000 1.5 @@ -15,14 +15,15 @@ * KEY_AREA_OF_INTEREST * * @author <a href="mailto:[EMAIL PROTECTED]">Vincent Hardy</a> - * @version $Id: RenderingHintsKeyExt.java,v 1.4 2001/11/29 15:05:26 deweese Exp $ + * @version $Id: RenderingHintsKeyExt.java,v 1.5 2002/04/05 08:19:52 deweese Exp $ */ public final class RenderingHintsKeyExt { + public static final int KEY_BASE; + /** * Hint as to the transcoding destination. */ - public static final RenderingHints.Key KEY_TRANSCODING = - new TranscodingHintKey(); + public static final RenderingHints.Key KEY_TRANSCODING; public static final String VALUE_TRANSCODING_PRINTING = new String("Printing"); @@ -31,8 +32,7 @@ * Key for the AOI hint. This hint is used to propagate the AOI to Paint * and PaintContext instances. */ - public static final RenderingHints.Key KEY_AREA_OF_INTEREST = - new AreaOfInterestHintKey(); + public static final RenderingHints.Key KEY_AREA_OF_INTEREST; /** * Hint for the destination of the rendering when it is a BufferedImage @@ -44,8 +44,43 @@ * create a Graphics2D from a BufferedImage, this will ensure that * the proper things are done in the processes of creating the * Graphics. */ - public static final RenderingHints.Key KEY_BUFFERED_IMAGE = - new BufferedImageHintKey(); + public static final RenderingHints.Key KEY_BUFFERED_IMAGE; + + /** + * Hint to source that we only want an alpha channel. + * The source should follow the SVG spec for how to + * convert ARGB, RGB, Grey and AGrey to just an Alpha channel. + */ + public static final RenderingHints.Key KEY_COLORSPACE; + + static { + int base = 10100; + RenderingHints.Key trans=null, aoi=null, bi=null, cs=null; + while (true) { + int val = base; + + try { + trans = new TranscodingHintKey (val++); + aoi = new AreaOfInterestHintKey(val++); + bi = new BufferedImageHintKey (val++); + cs = new ColorSpaceHintKey (val++); + } catch (Exception e) { + System.err.println + ("You have loaded the Batik jar files more than once\n" + + "in the same JVM this is likely a problem with the\n" + + "way you are loading the Batik jar files."); + + base = (int)(Math.random()*2000000); + continue; + } + break; + } + KEY_BASE = base; + KEY_TRANSCODING = trans; + KEY_AREA_OF_INTEREST = aoi; + KEY_BUFFERED_IMAGE = bi; + KEY_COLORSPACE = cs; + } /** * Do not authorize creation of instances of that class 1.2 +2 -4 xml-batik/sources/org/apache/batik/ext/awt/TranscodingHintKey.java Index: TranscodingHintKey.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/ext/awt/TranscodingHintKey.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- TranscodingHintKey.java 29 Nov 2001 15:05:26 -0000 1.1 +++ TranscodingHintKey.java 5 Apr 2002 08:19:52 -0000 1.2 @@ -15,13 +15,11 @@ * TranscodingHint as to what the destination of the drawing is. * * @author <a href="mailto:[EMAIL PROTECTED]">Thomas DeWeese</a> - * @version $Id: TranscodingHintKey.java,v 1.1 2001/11/29 15:05:26 deweese Exp $ + * @version $Id: TranscodingHintKey.java,v 1.2 2002/04/05 08:19:52 deweese Exp $ */ final class TranscodingHintKey extends RenderingHints.Key { - TranscodingHintKey() { - super(10100); - } + TranscodingHintKey(int number) { super(number); } public boolean isCompatibleValue(Object val) { boolean isCompatible = true; 1.1 xml-batik/sources/org/apache/batik/ext/awt/ColorSpaceHintKey.java Index: ColorSpaceHintKey.java =================================================================== /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of which has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.batik.ext.awt; import java.awt.RenderingHints; /** * TranscodingHint as to what the destination of the drawing is. * * @author <a href="mailto:[EMAIL PROTECTED]">Thomas DeWeese</a> * @version $Id: ColorSpaceHintKey.java,v 1.1 2002/04/05 08:19:52 deweese Exp $ */ public final class ColorSpaceHintKey extends RenderingHints.Key { /** * Notice to source that we prefer an Alpha RGB Image. */ public static Object VALUE_COLORSPACE_ARGB = new Object(); /** * Notice to source that we will not use Alpha Channel but * we still want RGB data. */ public static Object VALUE_COLORSPACE_RGB = new Object(); /** * Notice to source that we only want Greyscale data (no Alpha). */ public static Object VALUE_COLORSPACE_GREY = new Object(); /** * Notice to source that we only want Greyscale data with * an alpha channel. */ public static Object VALUE_COLORSPACE_AGREY = new Object(); /** * Notice to source that we only want an alpha channel. * The source should simply render alpha (no conversion) */ public static Object VALUE_COLORSPACE_ALPHA = new Object(); /** * Notice to source that we only want an alpha channel. * The source should follow the SVG spec for how to * convert ARGB, RGB, Grey and AGrey to just an Alpha channel. */ public static Object VALUE_COLORSPACE_ALPHA_CONVERT = new Object(); public static final String PROPERTY_COLORSPACE = "org.apache.batik.gvt.filter.Colorspace"; /** * Note that this is package private. */ ColorSpaceHintKey(int number) { super(number); } public boolean isCompatibleValue(Object val) { if (val == VALUE_COLORSPACE_ARGB) return true; if (val == VALUE_COLORSPACE_RGB) return true; if (val == VALUE_COLORSPACE_GREY) return true; if (val == VALUE_COLORSPACE_AGREY) return true; if (val == VALUE_COLORSPACE_ALPHA) return true; if (val == VALUE_COLORSPACE_ALPHA_CONVERT) return true; return false; } } 1.3 +7 -5 xml-batik/sources/org/apache/batik/ext/awt/image/renderable/FilterAlphaRable.java Index: FilterAlphaRable.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/ext/awt/image/renderable/FilterAlphaRable.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- FilterAlphaRable.java 12 Feb 2001 18:12:05 -0000 1.2 +++ FilterAlphaRable.java 5 Apr 2002 08:19:52 -0000 1.3 @@ -20,6 +20,8 @@ import java.awt.image.renderable.RenderContext; +import org.apache.batik.ext.awt.RenderingHintsKeyExt; +import org.apache.batik.ext.awt.ColorSpaceHintKey; import org.apache.batik.ext.awt.image.rendered.CachableRed; import org.apache.batik.ext.awt.image.rendered.RenderedImageCachableRed; import org.apache.batik.ext.awt.image.rendered.FilterAlphaRed; @@ -32,7 +34,7 @@ * This sets RGB to black and Alpha to the source image's alpha channel. * * @author <a href="mailto:[EMAIL PROTECTED]>Thomas DeWeese</a> - * @version $Id: FilterAlphaRable.java,v 1.2 2001/02/12 18:12:05 vhardy Exp $ + * @version $Id: FilterAlphaRable.java,v 1.3 2002/04/05 08:19:52 deweese Exp $ */ public class FilterAlphaRable extends AbstractRable { @@ -66,8 +68,8 @@ aoi = getBounds2D(); // We only want it's alpha channel... - rh.put(FilterAsAlphaRable.KEY_COLORSPACE, - FilterAsAlphaRable.VALUE_COLORSPACE_ALPHA); + rh.put(RenderingHintsKeyExt.KEY_COLORSPACE, + ColorSpaceHintKey.VALUE_COLORSPACE_ALPHA); RenderedImage ri; ri = getSource().createRendering(new RenderContext(at, aoi, rh)); @@ -78,8 +80,8 @@ CachableRed cr = RenderedImageCachableRed.wrap(ri); - Object val = cr.getProperty(FilterAsAlphaRable.PROPERTY_COLORSPACE); - if (val == FilterAsAlphaRable.VALUE_COLORSPACE_ALPHA) + Object val = cr.getProperty(ColorSpaceHintKey.PROPERTY_COLORSPACE); + if (val == ColorSpaceHintKey.VALUE_COLORSPACE_ALPHA) return cr; // It listened to us... return new FilterAlphaRed(cr); 1.3 +7 -55 xml-batik/sources/org/apache/batik/ext/awt/image/renderable/FilterAsAlphaRable.java Index: FilterAsAlphaRable.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/ext/awt/image/renderable/FilterAsAlphaRable.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- FilterAsAlphaRable.java 23 Feb 2001 20:29:29 -0000 1.2 +++ FilterAsAlphaRable.java 5 Apr 2002 08:19:52 -0000 1.3 @@ -20,6 +20,8 @@ import java.awt.image.renderable.RenderContext; +import org.apache.batik.ext.awt.ColorSpaceHintKey; +import org.apache.batik.ext.awt.RenderingHintsKeyExt; import org.apache.batik.ext.awt.image.rendered.CachableRed; import org.apache.batik.ext.awt.image.rendered.RenderedImageCachableRed; import org.apache.batik.ext.awt.image.rendered.FilterAsAlphaRed; @@ -31,62 +33,11 @@ * according the the SVG Mask operation. * * @author <a href="mailto:[EMAIL PROTECTED]>Thomas DeWeese</a> - * @version $Id: FilterAsAlphaRable.java,v 1.2 2001/02/23 20:29:29 deweese Exp $ + * @version $Id: FilterAsAlphaRable.java,v 1.3 2002/04/05 08:19:52 deweese Exp $ */ public class FilterAsAlphaRable extends AbstractRable { - /** - * Notice to source that we prefer an Alpha RGB Image. - */ - public static Object VALUE_COLORSPACE_ARGB = new Object(); - - /** - * Notice to source that we will not use Alpha Channel but - * we still want RGB data. - */ - public static Object VALUE_COLORSPACE_RGB = new Object(); - - /** - * Notice to source that we only want Greyscale data (no Alpha). - */ - public static Object VALUE_COLORSPACE_GREY = new Object(); - - /** - * Notice to source that we only want Greyscale data with - * an alpha channel. - */ - public static Object VALUE_COLORSPACE_AGREY = new Object(); - - /** - * Notice to source that we only want an alpha channel. - * The source should simply render alpha (no conversion) - */ - public static Object VALUE_COLORSPACE_ALPHA = new Object(); - - /** - * Notice to source that we only want an alpha channel. - * The source should follow the SVG spec for how to - * convert ARGB, RGB, Grey and AGrey to just an Alpha channel. - */ - public static Object VALUE_COLORSPACE_ALPHA_CONVERT = new Object(); - - public static RenderingHints.Key KEY_COLORSPACE = - new RenderingHints.Key(9876) { - public boolean isCompatibleValue(Object val) { - if (val == VALUE_COLORSPACE_ARGB) return true; - if (val == VALUE_COLORSPACE_RGB) return true; - if (val == VALUE_COLORSPACE_GREY) return true; - if (val == VALUE_COLORSPACE_AGREY) return true; - if (val == VALUE_COLORSPACE_ALPHA) return true; - if (val == VALUE_COLORSPACE_ALPHA_CONVERT) return true; - return false; - } - }; - - public static final String PROPERTY_COLORSPACE = - "org.apache.batik.gvt.filter.Colorspace"; - public FilterAsAlphaRable(Filter src) { super(src, null); } @@ -116,7 +67,8 @@ aoi = getBounds2D(); } - rh.put(KEY_COLORSPACE, VALUE_COLORSPACE_ALPHA_CONVERT); + rh.put(RenderingHintsKeyExt.KEY_COLORSPACE, + ColorSpaceHintKey.VALUE_COLORSPACE_ALPHA_CONVERT); RenderedImage ri; ri = getSource().createRendering(new RenderContext(at, aoi, rh)); @@ -125,8 +77,8 @@ CachableRed cr = RenderedImageCachableRed.wrap(ri); - Object val = cr.getProperty(PROPERTY_COLORSPACE); - if (val == VALUE_COLORSPACE_ALPHA_CONVERT) + Object val = cr.getProperty(ColorSpaceHintKey.PROPERTY_COLORSPACE); + if (val == ColorSpaceHintKey.VALUE_COLORSPACE_ALPHA_CONVERT) return cr; return new FilterAsAlphaRed(cr); 1.3 +4 -3 xml-batik/sources/org/apache/batik/ext/awt/image/rendered/Any2LumRed.java Index: Any2LumRed.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/ext/awt/image/rendered/Any2LumRed.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Any2LumRed.java 5 Jul 2001 16:54:42 -0000 1.2 +++ Any2LumRed.java 5 Apr 2002 08:19:53 -0000 1.3 @@ -28,6 +28,7 @@ import java.awt.image.PixelInterleavedSampleModel; import java.awt.image.WritableRaster; +import org.apache.batik.ext.awt.ColorSpaceHintKey; import org.apache.batik.ext.awt.image.renderable.FilterAsAlphaRable; /** @@ -36,7 +37,7 @@ * new image. * * @author <a href="mailto:[EMAIL PROTECTED]">Thomas DeWeese</a> - * @version $Id: Any2LumRed.java,v 1.2 2001/07/05 16:54:42 deweese Exp $ */ + * @version $Id: Any2LumRed.java,v 1.3 2002/04/05 08:19:53 deweese Exp $ */ public class Any2LumRed extends AbstractRed { /** @@ -52,8 +53,8 @@ src.getTileGridYOffset(), null); - props.put(FilterAsAlphaRable.PROPERTY_COLORSPACE, - FilterAsAlphaRable.VALUE_COLORSPACE_GREY); + props.put(ColorSpaceHintKey.PROPERTY_COLORSPACE, + ColorSpaceHintKey.VALUE_COLORSPACE_GREY); } public WritableRaster copyData(WritableRaster wr) { 1.3 +4 -3 xml-batik/sources/org/apache/batik/ext/awt/image/rendered/FilterAlphaRed.java Index: FilterAlphaRed.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/ext/awt/image/rendered/FilterAlphaRed.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- FilterAlphaRed.java 5 Dec 2001 13:46:05 -0000 1.2 +++ FilterAlphaRed.java 5 Apr 2002 08:19:53 -0000 1.3 @@ -28,13 +28,14 @@ import java.awt.image.ComponentColorModel; import java.awt.image.WritableRaster; +import org.apache.batik.ext.awt.ColorSpaceHintKey; import org.apache.batik.ext.awt.image.renderable.FilterAsAlphaRable; /** * This strips out the source alpha channel into a one band image. * * @author <a href="mailto:[EMAIL PROTECTED]">Thomas DeWeese</a> - * @version $Id: FilterAlphaRed.java,v 1.2 2001/12/05 13:46:05 deweese Exp $ */ + * @version $Id: FilterAlphaRed.java,v 1.3 2002/04/05 08:19:53 deweese Exp $ */ public class FilterAlphaRed extends AbstractRed { /** @@ -51,8 +52,8 @@ src.getTileGridYOffset(), null); - props.put(FilterAsAlphaRable.PROPERTY_COLORSPACE, - FilterAsAlphaRable.VALUE_COLORSPACE_ALPHA); + props.put(ColorSpaceHintKey.PROPERTY_COLORSPACE, + ColorSpaceHintKey.VALUE_COLORSPACE_ALPHA); } public WritableRaster copyData(WritableRaster wr) { 1.2 +4 -3 xml-batik/sources/org/apache/batik/ext/awt/image/rendered/FilterAsAlphaRed.java Index: FilterAsAlphaRed.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/ext/awt/image/rendered/FilterAsAlphaRed.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- FilterAsAlphaRed.java 24 Jan 2001 05:39:39 -0000 1.1 +++ FilterAsAlphaRed.java 5 Apr 2002 08:19:53 -0000 1.2 @@ -30,13 +30,14 @@ import java.awt.image.ComponentColorModel; import java.awt.image.WritableRaster; +import org.apache.batik.ext.awt.ColorSpaceHintKey; import org.apache.batik.ext.awt.image.renderable.FilterAsAlphaRable; /** * This converts any source into a mask according to the SVG masking rules. * * @author <a href="mailto:[EMAIL PROTECTED]">Thomas DeWeese</a> - * @version $Id: FilterAsAlphaRed.java,v 1.1 2001/01/24 05:39:39 vhardy Exp $ */ + * @version $Id: FilterAsAlphaRed.java,v 1.2 2002/04/05 08:19:53 deweese Exp $ */ public class FilterAsAlphaRed extends AbstractRed { /** @@ -62,8 +63,8 @@ src.getTileGridYOffset(), null); - props.put(FilterAsAlphaRable.PROPERTY_COLORSPACE, - FilterAsAlphaRable.VALUE_COLORSPACE_ALPHA); + props.put(ColorSpaceHintKey.PROPERTY_COLORSPACE, + ColorSpaceHintKey.VALUE_COLORSPACE_ALPHA); } public WritableRaster copyData(WritableRaster wr) {
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]