You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by cf...@apache.org on 2012/10/25 21:01:49 UTC
svn commit: r1402274 [21/31] - in
/incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext:
./ awt/ awt/color/ awt/font/ awt/g2d/ awt/geom/ awt/image/ awt/image/codec/
awt/image/codec/jpeg/ awt/image/codec/p...
Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/AffineRable8Bit.java
URL: http://svn.apache.org/viewvc/incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/AffineRable8Bit.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/AffineRable8Bit.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/AffineRable8Bit.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,149 @@
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+
+ */
+package org.apache.flex.forks.batik.ext.awt.image.renderable;
+
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.Shape;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.NoninvertibleTransformException;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.RenderedImage;
+import java.awt.image.renderable.RenderContext;
+
+import org.apache.flex.forks.batik.ext.awt.image.GraphicsUtil;
+
+/**
+ * Concrete implementation of the AffineRable interface.
+ * This adjusts the input images coordinate system by a general affine
+ *
+ * @author <a href="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
+ * @version $Id: AffineRable8Bit.java 475477 2006-11-15 22:44:28Z cam $
+ */
+public class AffineRable8Bit
+ extends AbstractRable
+ implements AffineRable, PaintRable {
+
+ AffineTransform affine;
+ AffineTransform invAffine;
+
+ public AffineRable8Bit(Filter src, AffineTransform affine) {
+ init(src);
+ setAffine(affine);
+ }
+
+ public Rectangle2D getBounds2D() {
+ Filter src = getSource();
+ Rectangle2D r = src.getBounds2D();
+ return affine.createTransformedShape(r).getBounds2D();
+ }
+ /**
+ * Returns the source to be affine.
+ */
+ public Filter getSource() {
+ return (Filter)srcs.get(0);
+ }
+
+ /**
+ * Sets the source to be affine.
+ * @param src image to affine.
+ */
+ public void setSource(Filter src) {
+ init(src);
+ }
+
+ /**
+ * Set the affine transform.
+ * @param affine the new Affine transform to apply.
+ */
+ public void setAffine(AffineTransform affine) {
+ touch();
+ this.affine = affine;
+ try {
+ invAffine = affine.createInverse();
+ } catch (NoninvertibleTransformException e) {
+ invAffine = null;
+ }
+ }
+
+ /**
+ * Get the Affine.
+ * @return the Affine transform currently in effect.
+ */
+ public AffineTransform getAffine() {
+ return (AffineTransform)affine.clone();
+ }
+
+ /**
+ * Should perform the equivilent action as
+ * createRendering followed by drawing the RenderedImage.
+ *
+ * @param g2d The Graphics2D to draw to.
+ * @return true if the paint call succeeded, false if
+ * for some reason the paint failed (in which
+ * case a createRendering should be used).
+ */
+ public boolean paintRable(Graphics2D g2d) {
+ AffineTransform at = g2d.getTransform();
+
+ g2d.transform(getAffine());
+ GraphicsUtil.drawImage(g2d, getSource());
+
+ g2d.setTransform(at);
+
+ return true;
+ }
+
+
+ public RenderedImage createRendering(RenderContext rc) {
+ // Degenerate Affine no output image..
+ if (invAffine == null) return null;
+
+ // Just copy over the rendering hints.
+ RenderingHints rh = rc.getRenderingHints();
+ if (rh == null) rh = new RenderingHints(null);
+
+ // Map the area of interest to our input...
+ Shape aoi = rc.getAreaOfInterest();
+ if (aoi != null)
+ aoi = invAffine.createTransformedShape(aoi);
+
+ // update the current affine transform
+ AffineTransform at = rc.getTransform();
+ at.concatenate(affine);
+
+ // Return what our input creates (it should factor in our affine).
+ return getSource().createRendering(new RenderContext(at, aoi, rh));
+ }
+
+ public Shape getDependencyRegion(int srcIndex, Rectangle2D outputRgn) {
+ if (srcIndex != 0)
+ throw new IndexOutOfBoundsException("Affine only has one input");
+ if (invAffine == null)
+ return null;
+ return invAffine.createTransformedShape(outputRgn);
+ }
+
+ public Shape getDirtyRegion(int srcIndex, Rectangle2D inputRgn) {
+ if (srcIndex != 0)
+ throw new IndexOutOfBoundsException("Affine only has one input");
+ return affine.createTransformedShape(inputRgn);
+ }
+
+}
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/AffineRable8Bit.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ClipRable.java
URL: http://svn.apache.org/viewvc/incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ClipRable.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ClipRable.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ClipRable.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,71 @@
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+
+ */
+package org.apache.flex.forks.batik.ext.awt.image.renderable;
+
+import java.awt.Shape;
+
+/**
+ * Implements a clip operation. This is similar to the mask operation
+ * except it uses a '1 bit' mask (it's normally anti-aliased, but
+ * shouldn't have any fluctions in side the outline of the shape.).
+ *
+ * @author <a href="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
+ * @version $Id: ClipRable.java 478276 2006-11-22 18:33:37Z dvholten $ */
+public interface ClipRable extends Filter {
+
+ /**
+ * Set the default behaviour of anti-aliased clipping.
+ * for this clip object.
+ */
+ void setUseAntialiasedClip(boolean useAA);
+
+ /**
+ * Resturns true if the default behaviour should be to use
+ * anti-aliased clipping.
+ */
+ boolean getUseAntialiasedClip();
+
+
+ /**
+ * The source to be clipped by the outline of the clip node.
+ * @param src The Image to be clipped.
+ */
+ void setSource(Filter src);
+
+ /**
+ * This returns the current image being clipped by the clip node.
+ * @return The image to clip
+ */
+ Filter getSource();
+
+ /**
+ * Set the clip path to use.
+ * The path will be filled with opaque white, to define the
+ * the clipping mask.
+ * @param clipPath The clip path to use
+ */
+ void setClipPath(Shape clipPath);
+
+ /**
+ * Returns the Shape that the Clip will use to
+ * define the clip path.
+ * @return The shape that defines the clip path.
+ */
+ Shape getClipPath();
+}
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ClipRable.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ClipRable8Bit.java
URL: http://svn.apache.org/viewvc/incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ClipRable8Bit.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ClipRable8Bit.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ClipRable8Bit.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,193 @@
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+
+ */
+package org.apache.flex.forks.batik.ext.awt.image.renderable;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.Rectangle;
+import java.awt.RenderingHints;
+import java.awt.Shape;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.RenderedImage;
+import java.awt.image.renderable.RenderContext;
+
+import org.apache.flex.forks.batik.ext.awt.image.GraphicsUtil;
+import org.apache.flex.forks.batik.ext.awt.image.PadMode;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.BufferedImageCachableRed;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.CachableRed;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.MultiplyAlphaRed;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.PadRed;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.RenderedImageCachableRed;
+
+/**
+ * ClipRable implementation
+ *
+ * @author <a href="mailto:Thomas.DeWeese@Kodak.com">Thomas DeWeese</a>
+ * @version $Id: ClipRable8Bit.java 478276 2006-11-22 18:33:37Z dvholten $
+ */
+public class ClipRable8Bit
+ extends AbstractRable
+ implements ClipRable {
+
+ protected boolean useAA;
+
+ /**
+ * The node who's outline specifies our mask.
+ */
+ protected Shape clipPath;
+
+ public ClipRable8Bit(Filter src, Shape clipPath) {
+ super(src, null);
+ setClipPath(clipPath);
+ setUseAntialiasedClip(false);
+ }
+
+ public ClipRable8Bit(Filter src, Shape clipPath, boolean useAA) {
+ super(src, null);
+ setClipPath(clipPath);
+ setUseAntialiasedClip(useAA);
+ }
+
+ /**
+ * The source to be masked by the mask node.
+ * @param src The Image to be masked.
+ */
+ public void setSource(Filter src) {
+ init(src, null);
+ }
+
+ /**
+ * This returns the current image being masked by the mask node.
+ * @return The image to mask
+ */
+ public Filter getSource() {
+ return (Filter)getSources().get(0);
+ }
+
+ /**
+ * Set the default behaviour of anti-aliased clipping.
+ * for this clip object.
+ */
+ public void setUseAntialiasedClip(boolean useAA) {
+ touch();
+ this.useAA = useAA;
+ }
+
+ /**
+ * Resturns true if the default behaviour should be to use
+ * anti-aliased clipping.
+ */
+ public boolean getUseAntialiasedClip() {
+ return useAA;
+ }
+
+
+ /**
+ * Set the clip path to use.
+ * The path will be filled with opaque white.
+ * @param clipPath The clip path to use
+ */
+ public void setClipPath(Shape clipPath) {
+ touch();
+ this.clipPath = clipPath;
+ }
+
+ /**
+ * Returns the Shape that the cliprable will use to
+ * define the clip path.
+ * @return The shape that defines the clip path.
+ */
+ public Shape getClipPath() {
+ return clipPath;
+ }
+
+ /**
+ * Pass-through: returns the source's bounds
+ */
+ public Rectangle2D getBounds2D(){
+ return getSource().getBounds2D();
+ }
+
+ public RenderedImage createRendering(RenderContext rc) {
+
+ AffineTransform usr2dev = rc.getTransform();
+
+ // Just copy over the rendering hints.
+ RenderingHints rh = rc.getRenderingHints();
+ if (rh == null) rh = new RenderingHints(null);
+
+ Shape aoi = rc.getAreaOfInterest();
+ if (aoi == null) aoi = getBounds2D();
+
+ Rectangle2D rect = getBounds2D();
+ Rectangle2D clipRect = clipPath.getBounds2D();
+ Rectangle2D aoiRect = aoi.getBounds2D();
+
+ if ( ! rect.intersects(clipRect) )
+ return null;
+ Rectangle2D.intersect(rect, clipRect, rect);
+
+
+ if ( ! rect.intersects(aoiRect) )
+ return null;
+ Rectangle2D.intersect(rect, aoi.getBounds2D(), rect);
+
+ Rectangle devR = usr2dev.createTransformedShape(rect).getBounds();
+
+ if ((devR.width == 0) || (devR.height == 0))
+ return null;
+
+ BufferedImage bi = new BufferedImage(devR.width, devR.height,
+ BufferedImage.TYPE_BYTE_GRAY);
+
+ Shape devShape = usr2dev.createTransformedShape(getClipPath());
+ Rectangle devAOIR;
+ devAOIR = usr2dev.createTransformedShape(aoi).getBounds();
+
+ Graphics2D g2d = GraphicsUtil.createGraphics(bi, rh);
+
+ if (false) {
+ java.util.Set s = rh.keySet();
+ java.util.Iterator i = s.iterator();
+ while (i.hasNext()) {
+ Object o = i.next();
+ System.out.println("XXX: " + o + " -> " + rh.get(o));
+ }
+ }
+ g2d.translate(-devR.x, -devR.y);
+ g2d.setPaint(Color.white);
+ g2d.fill(devShape);
+ g2d.dispose();
+
+ RenderedImage ri;
+ ri = getSource().createRendering(new RenderContext(usr2dev, rect, rh));
+
+ CachableRed cr, clipCr;
+ cr = RenderedImageCachableRed.wrap(ri);
+ clipCr = new BufferedImageCachableRed(bi, devR.x, devR.y);
+ CachableRed ret = new MultiplyAlphaRed(cr, clipCr);
+
+ // Pad back out to the proper size...
+ ret = new PadRed(ret, devAOIR, PadMode.ZERO_PAD, rh);
+
+ return ret;
+ }
+}
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ClipRable8Bit.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ColorMatrixRable.java
URL: http://svn.apache.org/viewvc/incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ColorMatrixRable.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ColorMatrixRable.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ColorMatrixRable.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,62 @@
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+
+ */
+package org.apache.flex.forks.batik.ext.awt.image.renderable;
+
+/**
+ * Defines the interface expected from a color matrix
+ * operation
+ *
+ * @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
+ * @version $Id: ColorMatrixRable.java 478276 2006-11-22 18:33:37Z dvholten $
+ */
+public interface ColorMatrixRable extends FilterColorInterpolation {
+
+ /**
+ * Identifier used to refer to predefined matrices
+ */
+ int TYPE_MATRIX = 0;
+ int TYPE_SATURATE = 1;
+ int TYPE_HUE_ROTATE = 2;
+ int TYPE_LUMINANCE_TO_ALPHA = 3;
+
+ /**
+ * Returns the source to be offset.
+ */
+ Filter getSource();
+
+ /**
+ * Sets the source to be offset.
+ * @param src image to offset.
+ */
+ void setSource(Filter src);
+
+ /**
+ * Returns the type of this color matrix.
+ * @return one of TYPE_MATRIX, TYPE_SATURATE, TYPE_HUE_ROTATE,
+ * TYPE_LUMINANCE_TO_ALPHA
+ */
+ int getType();
+
+ /**
+ * Returns the rows of the color matrix. This uses
+ * the same convention as BandCombineOp.
+ */
+ float[][] getMatrix();
+
+}
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ColorMatrixRable.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ColorMatrixRable8Bit.java
URL: http://svn.apache.org/viewvc/incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ColorMatrixRable8Bit.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ColorMatrixRable8Bit.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ColorMatrixRable8Bit.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,215 @@
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+
+ */
+package org.apache.flex.forks.batik.ext.awt.image.renderable;
+
+import java.awt.image.RenderedImage;
+import java.awt.image.renderable.RenderContext;
+
+import org.apache.flex.forks.batik.ext.awt.image.rendered.ColorMatrixRed;
+
+/**
+ * Implements the interface expected from a color matrix
+ * operation
+ *
+ * @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
+ * @version $Id: ColorMatrixRable8Bit.java 478276 2006-11-22 18:33:37Z dvholten $
+ */
+public class ColorMatrixRable8Bit
+ extends AbstractColorInterpolationRable
+ implements ColorMatrixRable {
+ /**
+ * Predefined luminanceToAlpha matrix
+ */
+ private static float[][] MATRIX_LUMINANCE_TO_ALPHA
+ = {
+ {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0},
+ {0.2125f, 0.7154f, 0.0721f, 0, 0}
+ };
+
+ /**
+ * This matrix type
+ */
+ private int type;
+
+ /**
+ * The matrix
+ */
+ private float[][] matrix;
+
+ /**
+ * Sets the source of the blur operation
+ */
+ public void setSource(Filter src){
+ init(src, null);
+ }
+
+ /**
+ * Returns the source of the blur operation
+ */
+ public Filter getSource(){
+ return (Filter)getSources().get(0);
+ }
+
+ /**
+ * Returns the type of this color matrix.
+ * @return one of TYPE_MATRIX, TYPE_SATURATE, TYPE_HUE_ROTATE,
+ * TYPE_LUMINANCE_TO_ALPHA
+ */
+ public int getType(){
+ return type;
+ }
+
+ /**
+ * Returns the rows of the color matrix. This uses
+ * the same convention as BandCombineOp.
+ */
+ public float[][] getMatrix(){
+ return matrix;
+ }
+
+ /**
+ * Instances should be built through the static
+ * factory methods
+ */
+ private ColorMatrixRable8Bit(){
+ }
+
+ /**
+ * Builds a TYPE_MATRIX instance
+ */
+ public static ColorMatrixRable buildMatrix(float[][] matrix){
+ if(matrix == null){
+ throw new IllegalArgumentException();
+ }
+
+ if(matrix.length != 4){
+ throw new IllegalArgumentException();
+ }
+
+ float[][] newMatrix = new float[4][];
+
+ for(int i=0; i<4; i++){
+ float[] m = matrix[i];
+ if(m == null){
+ throw new IllegalArgumentException();
+ }
+ if(m.length != 5){
+ throw new IllegalArgumentException();
+ }
+ newMatrix[i] = new float[5];
+ for(int j=0; j<5; j++){
+ newMatrix[i][j] = m[j];
+ }
+ }
+
+ /*for(int i=0; i<4; i++){
+ for(int j=0; j<5; j++)
+ System.out.print(newMatrix[i][j] + " ");
+ System.out.println();
+ }*/
+
+ ColorMatrixRable8Bit filter
+ = new ColorMatrixRable8Bit();
+ filter.type = TYPE_MATRIX;
+ filter.matrix = newMatrix;
+ return filter;
+ }
+
+ /**
+ * Builds a TYPE_SATURATE instance
+ */
+ public static ColorMatrixRable buildSaturate(float s){
+ ColorMatrixRable8Bit filter
+ = new ColorMatrixRable8Bit();
+ filter.type = TYPE_SATURATE;
+ filter.matrix = new float[][] {
+ { 0.213f+0.787f*s, 0.715f-0.715f*s, 0.072f-0.072f*s, 0, 0 },
+ { 0.213f-0.213f*s, 0.715f+0.285f*s, 0.072f-0.072f*s, 0, 0 },
+ { 0.213f-0.213f*s, 0.715f-0.715f*s, 0.072f+0.928f*s, 0, 0 },
+ { 0, 0, 0, 1, 0 }
+ };
+ return filter;
+ }
+
+ /**
+ * Builds a TYPE_HUE_ROTATE instance.
+ * @param a angle, in radian
+ */
+ public static ColorMatrixRable buildHueRotate(float a){
+ ColorMatrixRable8Bit filter
+ = new ColorMatrixRable8Bit();
+ filter.type = TYPE_HUE_ROTATE;
+
+ float cos = (float)Math.cos(a);
+ float sin = (float)Math.sin(a);
+
+ // System.out.println("sin : " + sin + " cos : " + cos);
+
+ float a00 = 0.213f + cos*0.787f - sin*0.213f;
+ float a10 = 0.213f - cos*0.212f + sin*0.143f;
+ float a20 = 0.213f - cos*0.213f - sin*0.787f;
+
+ float a01 = 0.715f - cos*0.715f - sin*0.715f;
+ float a11 = 0.715f + cos*0.285f + sin*0.140f;
+ float a21 = 0.715f - cos*0.715f + sin*0.715f;
+
+ float a02 = 0.072f - cos*0.072f + sin*0.928f;
+ float a12 = 0.072f - cos*0.072f - sin*0.283f;
+ float a22 = 0.072f + cos*0.928f + sin*0.072f;
+
+ filter.matrix = new float[][] {
+ { a00, a01, a02, 0, 0 },
+ { a10, a11, a12, 0, 0 },
+ { a20, a21, a22, 0, 0 },
+ { 0, 0, 0, 1, 0 }};
+
+ /*for(int i=0; i<4; i++){
+ for(int j=0; j<5; j++)
+ System.out.print(filter.matrix[i][j] + " ");
+ System.out.println();
+ }*/
+
+ return filter;
+ }
+
+ /**
+ * Builds a TYPE_LUMINANCE_TO_ALPHA instance
+ */
+ public static ColorMatrixRable buildLuminanceToAlpha(){
+ ColorMatrixRable8Bit filter
+ = new ColorMatrixRable8Bit();
+ filter.type = TYPE_LUMINANCE_TO_ALPHA;
+ filter.matrix = MATRIX_LUMINANCE_TO_ALPHA;
+ return filter;
+ }
+
+ public RenderedImage createRendering(RenderContext rc) {
+ //
+ // Get source's rendered image
+ //
+ RenderedImage srcRI = getSource().createRendering(rc);
+
+ if(srcRI == null)
+ return null;
+
+ return new ColorMatrixRed(convertSourceCS(srcRI), matrix);
+ }
+}
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ColorMatrixRable8Bit.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ComponentTransferRable.java
URL: http://svn.apache.org/viewvc/incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ComponentTransferRable.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ComponentTransferRable.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ComponentTransferRable.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,82 @@
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+
+ */
+package org.apache.flex.forks.batik.ext.awt.image.renderable;
+
+import org.apache.flex.forks.batik.ext.awt.image.ComponentTransferFunction;
+
+/**
+ * Defines the interface expected from a component
+ * transfer operation.
+ *
+ * @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
+ * @version $Id: ComponentTransferRable.java 478276 2006-11-22 18:33:37Z dvholten $
+ */
+public interface ComponentTransferRable extends FilterColorInterpolation {
+
+ /**
+ * Returns the source to be offset.
+ */
+ Filter getSource();
+
+ /**
+ * Sets the source to be offset.
+ * @param src image to offset.
+ */
+ void setSource(Filter src);
+
+ /**
+ * Returns the transfer function for the alpha channel
+ */
+ ComponentTransferFunction getAlphaFunction();
+
+ /**
+ * Sets the transfer function for the alpha channel
+ */
+ void setAlphaFunction(ComponentTransferFunction alphaFunction);
+
+ /**
+ * Returns the transfer function for the red channel
+ */
+ ComponentTransferFunction getRedFunction();
+
+ /**
+ * Sets the transfer function for the red channel
+ */
+ void setRedFunction(ComponentTransferFunction redFunction);
+
+ /**
+ * Returns the transfer function for the green channel
+ */
+ ComponentTransferFunction getGreenFunction();
+
+ /**
+ * Sets the transfer function for the green channel
+ */
+ void setGreenFunction(ComponentTransferFunction greenFunction);
+
+ /**
+ * Returns the transfer function for the blue channel
+ */
+ ComponentTransferFunction getBlueFunction();
+
+ /**
+ * Sets the transfer function for the blue channel
+ */
+ void setBlueFunction(ComponentTransferFunction blueFunction);
+}
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ComponentTransferRable.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ComponentTransferRable8Bit.java
URL: http://svn.apache.org/viewvc/incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ComponentTransferRable8Bit.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ComponentTransferRable8Bit.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ComponentTransferRable8Bit.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,248 @@
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+
+ */
+package org.apache.flex.forks.batik.ext.awt.image.renderable;
+
+import java.awt.image.RenderedImage;
+import java.awt.image.renderable.RenderContext;
+
+import org.apache.flex.forks.batik.ext.awt.image.ComponentTransferFunction;
+import org.apache.flex.forks.batik.ext.awt.image.DiscreteTransfer;
+import org.apache.flex.forks.batik.ext.awt.image.GammaTransfer;
+import org.apache.flex.forks.batik.ext.awt.image.IdentityTransfer;
+import org.apache.flex.forks.batik.ext.awt.image.LinearTransfer;
+import org.apache.flex.forks.batik.ext.awt.image.TableTransfer;
+import org.apache.flex.forks.batik.ext.awt.image.TransferFunction;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.ComponentTransferRed;
+
+/**
+ * This class implements the interface expected from a component
+ * transfer operation.
+ *
+ * @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
+ * @version $Id: ComponentTransferRable8Bit.java 478276 2006-11-22 18:33:37Z dvholten $
+ */
+public class ComponentTransferRable8Bit
+ extends AbstractColorInterpolationRable
+ implements ComponentTransferRable {
+
+ public static final int ALPHA = 0;
+ public static final int RED = 1;
+ public static final int GREEN = 2;
+ public static final int BLUE = 3;
+
+ /**
+ * Array of transfer functions. There are four
+ * elements. Elements may be null.
+ */
+ private ComponentTransferFunction[]
+ functions = new ComponentTransferFunction[4];
+
+ /**
+ * Array of transfer functions. Elements are computed
+ * lazily.
+ */
+ private TransferFunction[]
+ txfFunc = new TransferFunction[4];
+
+ public ComponentTransferRable8Bit(Filter src,
+ ComponentTransferFunction alphaFunction,
+ ComponentTransferFunction redFunction,
+ ComponentTransferFunction greenFunction,
+ ComponentTransferFunction blueFunction){
+ super(src, null);
+ setAlphaFunction(alphaFunction);
+ setRedFunction(redFunction);
+ setGreenFunction(greenFunction);
+ setBlueFunction(blueFunction);
+ }
+
+ /**
+ * Sets the source of the blur operation
+ */
+ public void setSource(Filter src){
+ init(src, null);
+ }
+
+ /**
+ * Returns the source of the blur operation
+ */
+ public Filter getSource(){
+ return (Filter)getSources().get(0);
+ }
+
+ /**
+ * Returns the transfer function for the alpha channel
+ */
+ public ComponentTransferFunction getAlphaFunction(){
+ return functions[ALPHA];
+ }
+
+ /**
+ * Sets the transfer function for the alpha channel
+ */
+ public void setAlphaFunction(ComponentTransferFunction alphaFunction){
+ touch();
+ functions[ALPHA] = alphaFunction;
+ txfFunc[ALPHA] = null;
+ }
+
+ /**
+ * Returns the transfer function for the red channel
+ */
+ public ComponentTransferFunction getRedFunction(){
+ return functions[RED];
+ }
+
+ /**
+ * Sets the transfer function for the red channel
+ */
+ public void setRedFunction(ComponentTransferFunction redFunction){
+ touch();
+ functions[RED] = redFunction;
+ txfFunc[RED] = null;
+ }
+
+ /**
+ * Returns the transfer function for the green channel
+ */
+ public ComponentTransferFunction getGreenFunction(){
+ return functions[GREEN];
+ }
+
+ /**
+ * Sets the transfer function for the green channel
+ */
+ public void setGreenFunction(ComponentTransferFunction greenFunction){
+ touch();
+ functions[GREEN] = greenFunction;
+ txfFunc[GREEN] = null;
+ }
+
+ /**
+ * Returns the transfer function for the blue channel
+ */
+ public ComponentTransferFunction getBlueFunction(){
+ return functions[BLUE];
+ }
+
+ /**
+ * Sets the transfer function for the blue channel
+ */
+ public void setBlueFunction(ComponentTransferFunction blueFunction){
+ touch();
+ functions[BLUE] = blueFunction;
+ txfFunc[BLUE] = null;
+ }
+
+ public RenderedImage createRendering(RenderContext rc){
+ //
+ // Get source's rendered image
+ //
+ RenderedImage srcRI = getSource().createRendering(rc);
+
+ if(srcRI == null)
+ return null;
+
+ return new ComponentTransferRed(convertSourceCS(srcRI),
+ getTransferFunctions(),
+ rc.getRenderingHints());
+ }
+
+ /**
+ * Builds an array of transfer functions for the
+ * ComponentTransferOp.
+ */
+ private TransferFunction[] getTransferFunctions(){
+ //
+ // Copy array to avoid multi-thread conflicts on
+ // array access.
+ //
+ TransferFunction[] txfFunc = new TransferFunction[4];
+ System.arraycopy(this.txfFunc, 0, txfFunc, 0, 4);
+
+ ComponentTransferFunction[] functions;
+ functions = new ComponentTransferFunction[4];
+ System.arraycopy(this.functions, 0, functions, 0, 4);
+
+ for(int i=0; i<4; i++){
+ if(txfFunc[i] == null){
+ txfFunc[i] = getTransferFunction(functions[i]);
+ synchronized(this.functions){
+ if(this.functions[i] == functions[i]){
+ this.txfFunc[i] = txfFunc[i];
+ }
+ }
+ }
+ }
+
+ return txfFunc;
+ }
+
+ /**
+ * Converts a ComponentTransferFunction to a TransferFunction
+ */
+ private static TransferFunction getTransferFunction
+ (ComponentTransferFunction function){
+
+ TransferFunction txfFunc = null;
+ if(function == null){
+ txfFunc = new IdentityTransfer();
+ }
+ else{
+ switch(function.getType()){
+ case ComponentTransferFunction.IDENTITY:
+ txfFunc = new IdentityTransfer();
+ break;
+ case ComponentTransferFunction.TABLE:
+ txfFunc = new TableTransfer(tableFloatToInt(function.getTableValues()));
+ break;
+ case ComponentTransferFunction.DISCRETE:
+ txfFunc = new DiscreteTransfer(tableFloatToInt(function.getTableValues()));
+ break;
+ case ComponentTransferFunction.LINEAR:
+ txfFunc = new LinearTransfer(function.getSlope(),
+ function.getIntercept());
+ break;
+ case ComponentTransferFunction.GAMMA:
+ txfFunc = new GammaTransfer(function.getAmplitude(),
+ function.getExponent(),
+ function.getOffset());
+ break;
+ default:
+ // Should never happen
+ throw new Error();
+ }
+ }
+
+ return txfFunc;
+ }
+
+ /**
+ * Converts a intensity values (0-1) to code values (0-255)
+ */
+ private static int[] tableFloatToInt(float[] tableValues){
+ int[] values = new int[tableValues.length];
+ for(int i=0; i<tableValues.length; i++){
+ values[i] = (int)(tableValues[i]*255f);
+ }
+
+ return values;
+ }
+
+}
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ComponentTransferRable8Bit.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/CompositeRable.java
URL: http://svn.apache.org/viewvc/incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/CompositeRable.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/CompositeRable.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/CompositeRable.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,51 @@
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+
+ */
+package org.apache.flex.forks.batik.ext.awt.image.renderable;
+
+import java.util.List;
+
+import org.apache.flex.forks.batik.ext.awt.image.CompositeRule;
+
+/**
+ * Composites a list of images according to a single composite rule.
+ * the image are applied in the order they are in the List given.
+ *
+ * @author <a href="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
+ * @version $Id: CompositeRable.java 478276 2006-11-22 18:33:37Z dvholten $
+ */
+public interface CompositeRable extends FilterColorInterpolation {
+
+ /**
+ * The sources to be composited togeather.
+ * @param srcs The list of images to be composited by the composite rule.
+ */
+ void setSources(List srcs);
+
+ /**
+ * Set the composite rule to use for combining the sources.
+ * @param cr Composite rule to use.
+ */
+ void setCompositeRule(CompositeRule cr);
+
+ /**
+ * Get the composite rule in use for combining the sources.
+ * @return Composite rule currently in use.
+ */
+ CompositeRule getCompositeRule();
+}
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/CompositeRable.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/CompositeRable8Bit.java
URL: http://svn.apache.org/viewvc/incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/CompositeRable8Bit.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/CompositeRable8Bit.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/CompositeRable8Bit.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,202 @@
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+
+ */
+package org.apache.flex.forks.batik.ext.awt.image.renderable;
+
+import java.awt.Composite;
+import java.awt.Graphics2D;
+import java.awt.Rectangle;
+import java.awt.RenderingHints;
+import java.awt.Shape;
+import java.awt.color.ColorSpace;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.RenderedImage;
+import java.awt.image.renderable.RenderContext;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ArrayList;
+
+import org.apache.flex.forks.batik.ext.awt.image.CompositeRule;
+import org.apache.flex.forks.batik.ext.awt.image.GraphicsUtil;
+import org.apache.flex.forks.batik.ext.awt.image.SVGComposite;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.CachableRed;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.CompositeRed;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.FloodRed;
+
+/**
+ * Composites a list of images according to a single composite rule.
+ * the image are applied in the order they are in the List given.
+ *
+ * @author <a href="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
+ * @version $Id: CompositeRable8Bit.java 489226 2006-12-21 00:05:36Z cam $
+ */
+public class CompositeRable8Bit
+ extends AbstractColorInterpolationRable
+ implements CompositeRable, PaintRable {
+
+ protected CompositeRule rule;
+
+ public CompositeRable8Bit(List srcs,
+ CompositeRule rule,
+ boolean csIsLinear) {
+ super(srcs);
+
+ setColorSpaceLinear(csIsLinear);
+
+ this.rule = rule;
+ }
+
+ /**
+ * The sources to be composited togeather.
+ * @param srcs The list of images to be composited by the composite rule.
+ */
+ public void setSources(List srcs) {
+ init(srcs, null);
+ }
+
+ /**
+ * Set the composite rule to use for combining the sources.
+ * @param cr Composite rule to use.
+ */
+ public void setCompositeRule(CompositeRule cr) {
+ touch();
+ this.rule = cr;
+ }
+
+ /**
+ * Get the composite rule in use for combining the sources.
+ * @return Composite rule currently in use.
+ */
+ public CompositeRule getCompositeRule() {
+ return this.rule;
+ }
+
+ /**
+ * Should perform the equivilent action as
+ * createRendering followed by drawing the RenderedImage to
+ * Graphics2D, or return false.
+ *
+ * @param g2d The Graphics2D to draw to.
+ * @return true if the paint call succeeded, false if
+ * for some reason the paint failed (in which
+ * case a createRendering should be used).
+ */
+ public boolean paintRable(Graphics2D g2d) {
+ // This optimization only apply if we are using
+ // SrcOver. Otherwise things break...
+ Composite c = g2d.getComposite();
+ if (!SVGComposite.OVER.equals(c))
+ return false;
+
+ // For the over mode we can just draw them in order...
+ if (getCompositeRule() != CompositeRule.OVER)
+ return false;
+
+ ColorSpace crCS = getOperationColorSpace();
+ ColorSpace g2dCS = GraphicsUtil.getDestinationColorSpace(g2d);
+ if ((g2dCS == null) || (g2dCS != crCS)) {
+ return false;
+ }
+
+ // System.out.println("drawImage : " + g2dCS +
+ // crCS);
+ Iterator i = getSources().iterator();
+ while (i.hasNext()) {
+ GraphicsUtil.drawImage(g2d, (Filter)i.next());
+ }
+ return true;
+ }
+
+ public RenderedImage createRendering(RenderContext rc) {
+ if (srcs.size() == 0)
+ return null;
+
+ // Just copy over the rendering hints.
+ RenderingHints rh = rc.getRenderingHints();
+ if (rh == null) rh = new RenderingHints(null);
+
+ // update the current affine transform
+ AffineTransform at = rc.getTransform();
+
+ Shape aoi = rc.getAreaOfInterest();
+ Rectangle2D aoiR;
+ if (aoi == null)
+ aoiR = getBounds2D();
+ else {
+ aoiR = aoi.getBounds2D();
+ Rectangle2D bounds2d = getBounds2D();
+ if ( ! bounds2d.intersects(aoiR) )
+ return null;
+
+ Rectangle2D.intersect(aoiR, bounds2d, aoiR);
+ }
+
+ Rectangle devRect = at.createTransformedShape(aoiR).getBounds();
+
+ rc = new RenderContext(at, aoiR, rh);
+
+ // note: this hides a member in a superclass!
+ List srcs = new ArrayList();
+
+ Iterator i = getSources().iterator();
+ while (i.hasNext()) {
+ // Get the source to work with...
+ Filter filt = (Filter)i.next();
+
+ // Get our sources image...
+ RenderedImage ri = filt.createRendering(rc);
+ if (ri != null) {
+ CachableRed cr;
+ cr = convertSourceCS(ri);
+ srcs.add(cr);
+ } else {
+
+ // Blank image...
+ switch (rule.getRule()) {
+ case CompositeRule.RULE_IN:
+ // For Mode IN One blank image kills all output
+ // (including any "future" images to be drawn).
+ return null;
+
+ case CompositeRule.RULE_OUT:
+ // For mode OUT blank image clears output
+ // up to this point, so ignore inputs to this point.
+ srcs.clear();
+ break;
+
+ case CompositeRule.RULE_ARITHMETIC:
+ srcs.add(new FloodRed(devRect));
+ break;
+
+ default:
+ // All other cases we simple pretend the image didn't
+ // exist (fully transparent image has no affect).
+ break;
+ }
+ }
+ }
+
+ if (srcs.size() == 0)
+ return null;
+
+ // System.out.println("Done General: " + rule);
+ CachableRed cr = new CompositeRed(srcs, rule);
+ return cr;
+ }
+}
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/CompositeRable8Bit.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ConvolveMatrixRable.java
URL: http://svn.apache.org/viewvc/incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ConvolveMatrixRable.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ConvolveMatrixRable.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ConvolveMatrixRable.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,112 @@
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+
+ */
+package org.apache.flex.forks.batik.ext.awt.image.renderable;
+
+import java.awt.Point;
+import java.awt.image.Kernel;
+
+import org.apache.flex.forks.batik.ext.awt.image.PadMode;
+
+/**
+ * Convolves an image with a convolution matrix.
+ *
+ * @author <a href="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
+ * @version $Id: ConvolveMatrixRable.java 478276 2006-11-22 18:33:37Z dvholten $
+ */
+public interface ConvolveMatrixRable extends FilterColorInterpolation {
+
+ /**
+ * Returns the source to be Convolved
+ */
+ Filter getSource();
+
+ /**
+ * Sets the source to be Convolved
+ * @param src image to Convolved.
+ */
+ void setSource(Filter src);
+
+
+ /**
+ * Returns the Convolution Kernel in use
+ */
+ Kernel getKernel();
+
+ /**
+ * Sets the Convolution Kernel to use.
+ * @param k Kernel to use for convolution.
+ */
+ void setKernel(Kernel k);
+
+ /**
+ * Returns the target point of the kernel (what pixel under the kernel
+ * should be set to the result of convolution).
+ */
+ Point getTarget();
+
+ /**
+ * Sets the target point of the kernel (what pixel under the kernel
+ * should be set to the result of the convolution).
+ */
+ void setTarget(Point pt);
+
+ /**
+ * Returns the shift value to apply to the result of convolution
+ */
+ double getBias();
+
+ /**
+ * Sets the shift value to apply to the result of convolution
+ */
+ void setBias(double bias);
+
+ /**
+ * Returns the current edge handling mode.
+ */
+ PadMode getEdgeMode();
+
+ /**
+ * Sets the current edge handling mode.
+ */
+ void setEdgeMode(PadMode edgeMode);
+
+ /**
+ * Returns the [x,y] distance in user space between kernel values
+ */
+ double [] getKernelUnitLength();
+
+ /**
+ * Sets the [x,y] distance in user space between kernel values
+ * If set to zero then one pixel in device space will be used.
+ */
+ void setKernelUnitLength(double [] kernelUnitLength);
+
+ /**
+ * Returns false if the convolution should affect the Alpha channel
+ */
+ boolean getPreserveAlpha();
+
+ /**
+ * Sets Alpha channel handling.
+ * A value of False indicates that the convolution should apply to
+ * the Alpha Channel
+ */
+ void setPreserveAlpha(boolean preserveAlpha);
+}
+
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ConvolveMatrixRable.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ConvolveMatrixRable8Bit.java
URL: http://svn.apache.org/viewvc/incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ConvolveMatrixRable8Bit.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ConvolveMatrixRable8Bit.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ConvolveMatrixRable8Bit.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,501 @@
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+
+ */
+package org.apache.flex.forks.batik.ext.awt.image.renderable;
+
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.RenderingHints;
+import java.awt.Shape;
+import java.awt.color.ColorSpace;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.BufferedImageOp;
+import java.awt.image.ColorModel;
+import java.awt.image.ConvolveOp;
+import java.awt.image.DataBuffer;
+import java.awt.image.DataBufferInt;
+import java.awt.image.DirectColorModel;
+import java.awt.image.Kernel;
+import java.awt.image.Raster;
+import java.awt.image.RenderedImage;
+import java.awt.image.SinglePixelPackedSampleModel;
+import java.awt.image.WritableRaster;
+import java.awt.image.renderable.RenderContext;
+
+import org.apache.flex.forks.batik.ext.awt.image.GraphicsUtil;
+import org.apache.flex.forks.batik.ext.awt.image.PadMode;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.AffineRed;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.BufferedImageCachableRed;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.CachableRed;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.PadRed;
+
+/**
+ * Convolves an image with a convolution matrix.
+ *
+ * Known limitations:
+ * Does not support bias other than zero - pending 16bit pathway
+ * Does not support edgeMode="wrap" - pending Tile code.
+ *
+ * @author <a href="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
+ * @version $Id: ConvolveMatrixRable8Bit.java 478363 2006-11-22 23:01:13Z dvholten $
+ */
+public class ConvolveMatrixRable8Bit
+ extends AbstractColorInterpolationRable
+ implements ConvolveMatrixRable {
+
+ Kernel kernel;
+ Point target;
+ float bias;
+ boolean kernelHasNegValues;
+ PadMode edgeMode;
+ float [] kernelUnitLength = new float[2];
+
+ boolean preserveAlpha = false;
+
+ public ConvolveMatrixRable8Bit(Filter source) {
+ super(source);
+ }
+
+ public Filter getSource() {
+ return (Filter)getSources().get(0);
+ }
+
+ public void setSource(Filter src) {
+ init(src);
+ }
+
+
+ /**
+ * Returns the Convolution Kernel in use
+ */
+ public Kernel getKernel() {
+ return kernel;
+ }
+
+ /**
+ * Sets the Convolution Kernel to use.
+ * @param k Kernel to use for convolution.
+ */
+ public void setKernel(Kernel k) {
+ touch();
+ this.kernel = k;
+ kernelHasNegValues = false;
+ float [] kv = k.getKernelData(null);
+ for (int i=0; i<kv.length; i++)
+ if (kv[i] < 0) {
+ kernelHasNegValues = true;
+ break;
+ }
+ }
+
+ public Point getTarget() {
+ return (Point)target.clone();
+ }
+
+ public void setTarget(Point pt) {
+ touch();
+ this.target = (Point)pt.clone();
+ }
+
+ /**
+ * Returns the shift value to apply to the result of convolution
+ */
+ public double getBias() {
+ return bias;
+ }
+
+ /**
+ * Returns the shift value to apply to the result of convolution
+ */
+ public void setBias(double bias) {
+ touch();
+ this.bias = (float)bias;
+ }
+
+ /**
+ * Returns the current edge handling mode.
+ */
+ public PadMode getEdgeMode() {
+ return edgeMode;
+ }
+
+ /**
+ * Sets the current edge handling mode.
+ */
+ public void setEdgeMode(PadMode edgeMode) {
+ touch();
+ this.edgeMode = edgeMode;
+ }
+
+ /**
+ * Returns the [x,y] distance in user space between kernel values
+ */
+ public double [] getKernelUnitLength() {
+ if (kernelUnitLength == null)
+ return null;
+
+ double [] ret = new double[2];
+ ret[0] = kernelUnitLength[0];
+ ret[1] = kernelUnitLength[1];
+ return ret;
+ }
+
+ /**
+ * Sets the [x,y] distance in user space between kernel values
+ * If set to zero then device space will be used.
+ */
+ public void setKernelUnitLength(double [] kernelUnitLength) {
+ touch();
+ if (kernelUnitLength == null) {
+ this.kernelUnitLength = null;
+ return;
+ }
+
+ if (this.kernelUnitLength == null)
+ this.kernelUnitLength = new float[2];
+
+ this.kernelUnitLength[0] = (float)kernelUnitLength[0];
+ this.kernelUnitLength[1] = (float)kernelUnitLength[1];
+ }
+
+ /**
+ * Returns false if the convolution should affect the Alpha channel
+ */
+ public boolean getPreserveAlpha() {
+ return preserveAlpha;
+ }
+
+ /**
+ * Sets Alpha channel handling.
+ * A value of False indicates that the convolution should apply to
+ * the Alpha Channel
+ */
+ public void setPreserveAlpha(boolean preserveAlpha) {
+ touch();
+ this.preserveAlpha = preserveAlpha;
+ }
+
+
+ public void fixAlpha(BufferedImage bi) {
+ if ((!bi.getColorModel().hasAlpha()) ||
+ (!bi.isAlphaPremultiplied()))
+ // No need to fix alpha if it isn't premultiplied...
+ return;
+ if (GraphicsUtil.is_INT_PACK_Data(bi.getSampleModel(), true))
+ fixAlpha_INT_PACK(bi.getRaster());
+ else
+ fixAlpha_FALLBACK(bi.getRaster());
+ }
+
+ public void fixAlpha_INT_PACK(WritableRaster wr) {
+ SinglePixelPackedSampleModel sppsm;
+ sppsm = (SinglePixelPackedSampleModel)wr.getSampleModel();
+
+ final int width = wr.getWidth();
+
+ final int scanStride = sppsm.getScanlineStride();
+ DataBufferInt db = (DataBufferInt)wr.getDataBuffer();
+ final int base
+ = (db.getOffset() +
+ sppsm.getOffset(wr.getMinX()-wr.getSampleModelTranslateX(),
+ wr.getMinY()-wr.getSampleModelTranslateY()));
+ // Access the pixel data array
+ final int[] pixels = db.getBankData()[0];
+ for (int y=0; y<wr.getHeight(); y++) {
+ int sp = base + y*scanStride;
+ final int end = sp + width;
+ while (sp < end) {
+ int pixel = pixels[sp];
+ int a = pixel>>>24;
+ int v = (pixel>>16)&0xFF;
+ if (a < v) a = v;
+ v = (pixel>> 8)&0xFF;
+ if (a < v) a = v;
+ v = (pixel )&0xFF;
+ if (a < v) a = v;
+ pixels[sp] = (pixel&0x00FFFFFF) | (a << 24);
+ sp++;
+ }
+ }
+ }
+
+ public void fixAlpha_FALLBACK(WritableRaster wr) {
+ int x0=wr.getMinX();
+ int w =wr.getWidth();
+ int y0=wr.getMinY();
+ int y1=y0 + wr.getHeight()-1;
+ int bands = wr.getNumBands();
+ int a, x, y, b, i;
+ int [] pixel = null;
+ for (y=y0; y<=y1; y++) {
+ pixel = wr.getPixels(x0, y, w, 1, pixel);
+ i=0;
+ for (x=0; x<w; x++) {
+ a=pixel[i];
+ for (b=1; b<bands; b++)
+ if (pixel[i+b] > a) a = pixel[i+b];
+ pixel[i+bands-1] = a;
+ i+=bands;
+ }
+ wr.setPixels(x0, y, w, 1, pixel);
+ }
+ }
+
+ public RenderedImage createRendering(RenderContext rc) {
+ // Just copy over the rendering hints.
+ RenderingHints rh = rc.getRenderingHints();
+ if (rh == null) rh = new RenderingHints(null);
+
+ // update the current affine transform
+ AffineTransform at = rc.getTransform();
+
+
+ // This splits out the scale and applies it
+ // prior to the Gaussian. Then after appying the gaussian
+ // it applies the shear (rotation) and translation components.
+ double sx = at.getScaleX();
+ double sy = at.getScaleY();
+
+ double shx = at.getShearX();
+ double shy = at.getShearY();
+
+ double tx = at.getTranslateX();
+ double ty = at.getTranslateY();
+
+ // The Scale is the "hypotonose" of the matrix vectors. This
+ // represents the complete scaling value from user to an
+ // intermediate space that is scaled similarly to device
+ // space.
+ double scaleX = Math.sqrt(sx*sx + shy*shy);
+ double scaleY = Math.sqrt(sy*sy + shx*shx);
+
+ // These values represent the scale factor to the intermediate
+ // coordinate system where we will apply our convolution.
+ if (kernelUnitLength != null) {
+ if (kernelUnitLength[0] > 0.0)
+ scaleX = 1/kernelUnitLength[0];
+
+ if (kernelUnitLength[1] > 0.0)
+ scaleY = 1/kernelUnitLength[1];
+ }
+
+ Shape aoi = rc.getAreaOfInterest();
+ if(aoi == null)
+ aoi = getBounds2D();
+
+ Rectangle2D r = aoi.getBounds2D();
+
+ int kw = kernel.getWidth();
+ int kh = kernel.getHeight();
+ int kx = target.x;
+ int ky = target.y;
+
+ // Grow the region in usr space.
+ {
+ double rx0 = r.getX() -(kx/scaleX);
+ double ry0 = r.getY() -(ky/scaleY);
+ double rx1 = rx0 + r.getWidth() + (kw-1)/scaleX;
+ double ry1 = ry0 + r.getHeight() + (kh-1)/scaleY;
+ r = new Rectangle2D.Double(Math.floor(rx0),
+ Math.floor(ry0),
+ Math.ceil (rx1-Math.floor(rx0)),
+ Math.ceil (ry1-Math.floor(ry0)));
+ }
+ // This will be the affine transform between our usr space and
+ // an intermediate space which is scaled according to
+ // kernelUnitLength and is axially aligned with our user
+ // space.
+ AffineTransform srcAt
+ = AffineTransform.getScaleInstance(scaleX, scaleY);
+
+ // This is the affine transform between our intermediate
+ // coordinate space (where the convolution takes place) and
+ // the real device space, or null (if we don't need an
+ // intermediate space).
+
+ // The shear/rotation simply divides out the
+ // common scale factor in the matrix.
+ AffineTransform resAt = new AffineTransform(sx/scaleX, shy/scaleX,
+ shx/scaleY, sy/scaleY,
+ tx, ty);
+
+ RenderedImage ri;
+ ri = getSource().createRendering(new RenderContext(srcAt, r, rh));
+ if (ri == null)
+ return null;
+
+ // org.apache.flex.forks.batik.test.gvt.ImageDisplay.printImage
+ // ("Padded Image", ri,
+ // new Rectangle(ri.getMinX()+22,ri.getMinY()+38,5,5));
+
+ CachableRed cr = convertSourceCS(ri);
+
+ Shape devShape = srcAt.createTransformedShape(aoi);
+ Rectangle2D devRect = devShape.getBounds2D();
+ r = devRect;
+ r = new Rectangle2D.Double(Math.floor(r.getX()-kx),
+ Math.floor(r.getY()-ky),
+ Math.ceil (r.getX()+r.getWidth())-
+ Math.floor(r.getX())+(kw-1),
+ Math.ceil (r.getY()+r.getHeight())-
+ Math.floor(r.getY())+(kh-1));
+
+ if (!r.getBounds().equals(cr.getBounds())) {
+ if (edgeMode == PadMode.WRAP)
+ throw new IllegalArgumentException
+ ("edgeMode=\"wrap\" is not supported by ConvolveMatrix.");
+ cr = new PadRed(cr, r.getBounds(), edgeMode, rh);
+ }
+
+ // org.apache.flex.forks.batik.test.gvt.ImageDisplay.printImage
+ // ("Padded Image", cr,
+ // new Rectangle(cr.getMinX()+23,cr.getMinY()+39,5,5));
+
+ if (bias != 0.0)
+ throw new IllegalArgumentException
+ ("Only bias equal to zero is supported in ConvolveMatrix.");
+
+ BufferedImageOp op = new ConvolveOp(kernel,
+ ConvolveOp.EDGE_NO_OP,
+ rh);
+
+ ColorModel cm = cr.getColorModel();
+
+ // OK this is a bit of a cheat. We Pull the DataBuffer out of
+ // The read-only raster that getData gives us. And use it to
+ // build a WritableRaster. This avoids a copy of the data.
+ Raster rr = cr.getData();
+ WritableRaster wr = GraphicsUtil.makeRasterWritable(rr, 0, 0);
+
+ // Here we update the translate to account for the phase shift
+ // (if any) introduced by setting targetX, targetY in SVG.
+ int phaseShiftX = target.x - kernel.getXOrigin();
+ int phaseShiftY = target.y - kernel.getYOrigin();
+ int destX = (int)(r.getX() + phaseShiftX);
+ int destY = (int)(r.getY() + phaseShiftY);
+
+ BufferedImage destBI;
+ if (!preserveAlpha) {
+ // Force the data to be premultiplied since often the JDK
+ // code doesn't properly premultiply the values...
+ cm = GraphicsUtil.coerceData(wr, cm, true);
+
+ BufferedImage srcBI;
+ srcBI = new BufferedImage(cm, wr, cm.isAlphaPremultiplied(), null);
+
+ // Easy case just apply the op...
+ destBI = op.filter(srcBI, null);
+
+ if (kernelHasNegValues) {
+ // When the kernel has negative values it's possible
+ // for the resultant image to have alpha values less
+ // than the associated color values this will lead to
+ // problems later when we try to display the image so
+ // we fix this here.
+ fixAlpha(destBI);
+ }
+
+ } else {
+ BufferedImage srcBI;
+ srcBI = new BufferedImage(cm, wr, cm.isAlphaPremultiplied(), null);
+
+ // Construct a linear sRGB cm without alpha...
+ cm = new DirectColorModel(ColorSpace.getInstance
+ (ColorSpace.CS_LINEAR_RGB), 24,
+ 0x00FF0000, 0x0000FF00,
+ 0x000000FF, 0x0, false,
+ DataBuffer.TYPE_INT);
+
+
+
+ // Create an image with that color model
+ BufferedImage tmpSrcBI = new BufferedImage
+ (cm, cm.createCompatibleWritableRaster(wr.getWidth(),
+ wr.getHeight()),
+ cm.isAlphaPremultiplied(), null);
+
+ // Copy the color data (no alpha) to that image
+ // (dividing out alpha if needed).
+ GraphicsUtil.copyData(srcBI, tmpSrcBI);
+
+ // org.apache.flex.forks.batik.test.gvt.ImageDisplay.showImage
+ // ("tmpSrcBI: ", tmpSrcBI);
+
+ // Get a linear sRGB Premult ColorModel
+ ColorModel dstCM = GraphicsUtil.Linear_sRGB_Unpre;
+ // Construct out output image around that ColorModel
+ destBI = new BufferedImage
+ (dstCM, dstCM.createCompatibleWritableRaster(wr.getWidth(),
+ wr.getHeight()),
+ dstCM.isAlphaPremultiplied(), null);
+
+ // Construct another image on the same data buffer but without
+ // an alpha channel.
+
+ // Create the Raster (note we are using 'cm' again).
+ WritableRaster dstWR =
+ Raster.createWritableRaster
+ (cm.createCompatibleSampleModel(wr.getWidth(), wr.getHeight()),
+ destBI.getRaster().getDataBuffer(),
+ new Point(0,0));
+
+ // Create the BufferedImage.
+ BufferedImage tmpDstBI = new BufferedImage
+ (cm, dstWR, cm.isAlphaPremultiplied(), null);
+
+ // Filter between the two image without alpha.
+ tmpDstBI = op.filter(tmpSrcBI, tmpDstBI);
+
+ // org.apache.flex.forks.batik.test.gvt.ImageDisplay.showImage
+ // ("tmpDstBI: ", tmpDstBI);
+
+ // Copy the alpha channel into the result (note the color
+ // channels are still unpremult.
+ Rectangle srcRect = wr.getBounds();
+ Rectangle dstRect = new Rectangle(srcRect.x-phaseShiftX,
+ srcRect.y-phaseShiftY,
+ srcRect.width, srcRect.height);
+ GraphicsUtil.copyBand(wr, srcRect, wr.getNumBands()-1,
+ destBI.getRaster(), dstRect,
+ destBI.getRaster().getNumBands()-1);
+ }
+
+ // Wrap it as a CachableRed
+ cr = new BufferedImageCachableRed(destBI, destX, destY);
+
+ // org.apache.flex.forks.batik.test.gvt.ImageDisplay.printImage
+ // ("Cropped Image", cr,
+ // new Rectangle(cr.getMinX()+22,cr.getMinY()+38,5,5));
+ // org.apache.flex.forks.batik.test.gvt.ImageDisplay.printImage
+ // ("Cropped sRGB", GraphicsUtil.convertTosRGB(cr),
+ // new Rectangle(cr.getMinX()+22,cr.getMinY()+38,5,5));
+
+ // Make sure to crop junk from edges.
+ cr = new PadRed(cr, devRect.getBounds(), PadMode.ZERO_PAD, rh);
+
+ // If we need to scale/rotate/translate the result do so now...
+ if (!resAt.isIdentity())
+ cr = new AffineRed(cr, resAt, null);
+
+ // return the result.
+ return cr;
+ }
+
+}
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ConvolveMatrixRable8Bit.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/DeferRable.java
URL: http://svn.apache.org/viewvc/incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/DeferRable.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/DeferRable.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/DeferRable.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,218 @@
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+
+ */
+package org.apache.flex.forks.batik.ext.awt.image.renderable;
+
+import java.awt.RenderingHints;
+import java.awt.Shape;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.RenderedImage;
+import java.awt.image.renderable.RenderContext;
+import java.util.Map;
+import java.util.Vector;
+
+/**
+ * This class allows for the return of a proxy object quickly, while a
+ * heavy weight object is constrcuted in a background Thread. This
+ * proxy object will then block if any methods are called on it that
+ * require talking to the source object.
+ *
+ * This is actually a particular instance of a very general pattern
+ * this is probably best represented using the Proxy class in the
+ * Reflection APIs.
+ *
+ * @version $Id: DeferRable.java 478363 2006-11-22 23:01:13Z dvholten $
+ */
+public class DeferRable implements Filter {
+ Filter src;
+ Rectangle2D bounds;
+ Map props;
+ /**
+ * Constructor takes nothing
+ */
+ public DeferRable() {
+ }
+
+ /**
+ * Key method that blocks if the src has not yet been provided.
+ */
+ public synchronized Filter getSource() {
+ while (src == null) {
+ try {
+ // Wait for someone to set src.
+ wait();
+ }
+ catch(InterruptedException ie) {
+ // Loop around again see if src is set now...
+ }
+ }
+ return src;
+ }
+
+ /**
+ * Key method that sets the src. The source can only
+ * be set once (this makes sense given the intent of the
+ * class is to stand in for a real object, so swaping that
+ * object isn't a good idea.
+ *
+ * This will wake all the threads that might be waiting for
+ * the source to be set.
+ */
+ public synchronized void setSource(Filter src) {
+ // Only let them set Source once.
+ if (this.src != null) return;
+ this.src = src;
+ this.bounds = src.getBounds2D();
+ notifyAll();
+ }
+
+ public synchronized void setBounds(Rectangle2D bounds) {
+ if (this.bounds != null) return;
+ this.bounds = bounds;
+ notifyAll();
+ }
+
+ public synchronized void setProperties(Map props) {
+ this.props = props;
+ notifyAll();
+ }
+
+ public long getTimeStamp() {
+ return getSource().getTimeStamp();
+ }
+
+ public Vector getSources() {
+ return getSource().getSources();
+ }
+
+ /**
+ * Forward the call (blocking until source is set if need be).
+ */
+ public boolean isDynamic() {
+ return getSource().isDynamic();
+ }
+
+ /**
+ * Implement the baseclass method to call getSource() so
+ * it will block until we have a real source.
+ */
+ public Rectangle2D getBounds2D() {
+ synchronized(this) {
+ while ((src == null) && (bounds == null)) {
+ try {
+ // Wait for someone to set bounds.
+ wait();
+ }
+ catch(InterruptedException ie) {
+ // Loop around again see if src is set now...
+ }
+ }
+ }
+ if (src != null)
+ return src.getBounds2D();
+ return bounds;
+ }
+
+ public float getMinX() {
+ return (float)getBounds2D().getX();
+ }
+ public float getMinY() {
+ return (float)getBounds2D().getY();
+ }
+ public float getWidth() {
+ return (float)getBounds2D().getWidth();
+ }
+ public float getHeight() {
+ return (float)getBounds2D().getHeight();
+ }
+
+ /**
+ * Forward the call (blocking until source is set if need be).
+ */
+ public Object getProperty(String name) {
+ synchronized (this) {
+ while ((src == null) && (props == null)) {
+ try {
+ // Wait for someone to set src | props
+ wait();
+ } catch(InterruptedException ie) { }
+ }
+ }
+ if (src != null)
+ return src.getProperty(name);
+ return props.get(name);
+ }
+
+ /**
+ * Forward the call (blocking until source is set if need be).
+ */
+ public String [] getPropertyNames() {
+ synchronized (this) {
+ while ((src == null) && (props == null)) {
+ try {
+ // Wait for someone to set src | props
+ wait();
+ } catch(InterruptedException ie) { }
+ }
+ }
+ if (src != null)
+ return src.getPropertyNames();
+
+ String [] ret = new String[props.size()];
+ props.keySet().toArray(ret);
+ return ret;
+ }
+
+ /**
+ * Forward the call (blocking until source is set if need be).
+ */
+ public RenderedImage createDefaultRendering() {
+ return getSource().createDefaultRendering();
+ }
+
+ /**
+ * Forward the call (blocking until source is set if need be).
+ */
+ public RenderedImage createScaledRendering(int w, int h,
+ RenderingHints hints) {
+ return getSource().createScaledRendering(w, h, hints);
+ }
+
+ /**
+ * Forward the call (blocking until source is set if need be).
+ */
+ public RenderedImage createRendering(RenderContext rc) {
+ return getSource().createRendering(rc);
+ }
+
+ /**
+ * Forward the call (blocking until source is set if need be).
+ */
+ public Shape getDependencyRegion(int srcIndex,
+ Rectangle2D outputRgn) {
+ return getSource().getDependencyRegion(srcIndex, outputRgn);
+ }
+
+ /**
+ * Forward the call (blocking until source is set if need be).
+ */
+ public Shape getDirtyRegion(int srcIndex,
+ Rectangle2D inputRgn) {
+ return getSource().getDirtyRegion(srcIndex, inputRgn);
+ }
+}
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/DeferRable.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/DiffuseLightingRable.java
URL: http://svn.apache.org/viewvc/incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/DiffuseLightingRable.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/DiffuseLightingRable.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/DiffuseLightingRable.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,101 @@
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+
+ */
+package org.apache.flex.forks.batik.ext.awt.image.renderable;
+
+import java.awt.geom.Rectangle2D;
+
+import org.apache.flex.forks.batik.ext.awt.image.Light;
+
+/**
+ * This filter primitive lights an image using the alpha channel as a bump map.
+ * The resulting image is an RGBA opaque image based on the light color
+ * with alpha = 1.0 everywhere. The lighting calculation follows the standard diffuse
+ * component of the Phong lighting model. The resulting image depends on the light color,
+ * light position and surface geometry of the input bump map.
+ *
+ * This filter follows the specification of the feDiffuseLighting filter in
+ * the SVG 1.0 specification.
+ *
+ * @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
+ * @version $Id: DiffuseLightingRable.java 478276 2006-11-22 18:33:37Z dvholten $
+ */
+public interface DiffuseLightingRable extends FilterColorInterpolation {
+ /**
+ * Returns the source to be filtered
+ */
+ Filter getSource();
+
+ /**
+ * Sets the source to be filtered
+ */
+ void setSource(Filter src);
+
+ /**
+ * @return Light object used for the diffuse lighting
+ */
+ Light getLight();
+
+ /**
+ * @param light New Light object
+ */
+ void setLight(Light light);
+
+ /**
+ * @return surfaceScale
+ */
+ double getSurfaceScale();
+
+ /**
+ * Sets the surface scale
+ */
+ void setSurfaceScale(double surfaceScale);
+
+ /**
+ * @return diffuse constant, or kd.
+ */
+ double getKd();
+
+ /**
+ * Sets the diffuse constant, or kd
+ */
+ void setKd(double kd);
+
+ /**
+ * @return the litRegion for this filter
+ */
+ Rectangle2D getLitRegion();
+
+ /**
+ * Sets the litRegion for this filter
+ */
+ void setLitRegion(Rectangle2D litRegion);
+
+ /**
+ * Returns the min [dx,dy] distance in user space for evalutation of
+ * the sobel gradient.
+ */
+ double [] getKernelUnitLength();
+
+ /**
+ * Sets the min [dx,dy] distance in user space for evaluation of the
+ * sobel gradient. If set to zero or null then device space will be used.
+ */
+ void setKernelUnitLength(double [] kernelUnitLength);
+}
+
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/DiffuseLightingRable.java
------------------------------------------------------------------------------
svn:eol-style = native