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 [22/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/DiffuseLightingRable8Bit.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/DiffuseLightingRable8Bit.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/DiffuseLightingRable8Bit.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/DiffuseLightingRable8Bit.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,300 @@
+/*
+
+ 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.Rectangle;
+import java.awt.RenderingHints;
+import java.awt.Shape;
+import java.awt.geom.AffineTransform;
+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;
+import org.apache.flex.forks.batik.ext.awt.image.Light;
+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.BumpMap;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.CachableRed;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.DiffuseLightingRed;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.PadRed;
+
+/**
+ * Implementation of the DiffuseLightRable interface.
+ *
+ * @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
+ * @version $Id: DiffuseLightingRable8Bit.java 475477 2006-11-15 22:44:28Z cam $
+ */
+public class DiffuseLightingRable8Bit
+ extends AbstractColorInterpolationRable
+ implements DiffuseLightingRable {
+ /**
+ * Surface Scale
+ */
+ private double surfaceScale;
+
+ /**
+ * Diffuse constant
+ */
+ private double kd;
+
+ /**
+ * Light used for the diffuse lighting computations
+ */
+ private Light light;
+
+ /**
+ * Lit Area
+ */
+ private Rectangle2D litRegion;
+
+ /**
+ * The dx/dy to use in user space for the sobel gradient.
+ */
+ private float [] kernelUnitLength = null;
+
+ public DiffuseLightingRable8Bit(Filter src,
+ Rectangle2D litRegion,
+ Light light,
+ double kd,
+ double surfaceScale,
+ double [] kernelUnitLength) {
+ super(src, null);
+ setLight(light);
+ setKd(kd);
+ setSurfaceScale(surfaceScale);
+ setLitRegion(litRegion);
+ setKernelUnitLength(kernelUnitLength);
+ }
+
+ /**
+ * Returns the source to be filtered
+ */
+ public Filter getSource(){
+ return (Filter)getSources().get(0);
+ }
+
+ /**
+ * Sets the source to be filtered
+ */
+ public void setSource(Filter src){
+ init(src, null);
+ }
+
+ /**
+ * Returns this filter's bounds
+ */
+ public Rectangle2D getBounds2D(){
+ return (Rectangle2D)(litRegion.clone());
+ }
+
+ /**
+ * Returns this filter's litRegion
+ */
+ public Rectangle2D getLitRegion(){
+ return getBounds2D();
+ }
+
+ /**
+ * Set this filter's litRegion
+ */
+ public void setLitRegion(Rectangle2D litRegion){
+ touch();
+ this.litRegion = litRegion;
+ }
+
+ /**
+ * @return Light object used for the diffuse lighting
+ */
+ public Light getLight(){
+ return light;
+ }
+
+ /**
+ * @param light New Light object
+ */
+ public void setLight(Light light){
+ touch();
+ this.light = light;
+ }
+
+ /**
+ * @return surfaceScale
+ */
+ public double getSurfaceScale(){
+ return surfaceScale;
+ }
+
+ /**
+ * Sets the surface scale
+ */
+ public void setSurfaceScale(double surfaceScale){
+ touch();
+ this.surfaceScale = surfaceScale;
+ }
+
+ /**
+ * @return diffuse constant, or kd.
+ */
+ public double getKd(){
+ return kd;
+ }
+
+ /**
+ * Sets the diffuse constant, or kd
+ */
+ public void setKd(double kd){
+ touch();
+ this.kd = kd;
+ }
+
+ /**
+ * Returns the min [dx,dy] distance in user space for evalutation of
+ * the sobel gradient.
+ */
+ 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 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.
+ */
+ 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];
+ }
+
+ public RenderedImage createRendering(RenderContext rc) {
+ Shape aoi = rc.getAreaOfInterest();
+ if (aoi == null)
+ aoi = getBounds2D();
+
+ Rectangle2D aoiR = aoi.getBounds2D();
+ Rectangle2D.intersect(aoiR, getBounds2D(), aoiR);
+
+ AffineTransform at = rc.getTransform();
+ Rectangle devRect = at.createTransformedShape(aoiR).getBounds();
+
+ if(devRect.width == 0 || devRect.height == 0){
+ return null;
+ }
+
+ //
+ // DiffuseLightingRed only operates on a scaled space.
+ // The following extracts the scale portion of the
+ // user to device transform
+ //
+ // The source is rendered with the scale-only transform
+ // and the rendered result is used as a bumpMap for the
+ // DiffuseLightingRed filter.
+ //
+ 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.
+ double scaleX = Math.sqrt(sx*sx + shy*shy);
+ double scaleY = Math.sqrt(sy*sy + shx*shx);
+
+ if(scaleX == 0 || scaleY == 0){
+ // Non invertible transform
+ return null;
+ }
+
+ // These values represent the scale factor to the intermediate
+ // coordinate system where we will apply our convolution.
+ if (kernelUnitLength != null) {
+ if ((kernelUnitLength[0] > 0) &&
+ (scaleX > 1/kernelUnitLength[0]))
+ scaleX = 1/kernelUnitLength[0];
+
+ if ((kernelUnitLength[1] > 0) &&
+ (scaleY > 1/kernelUnitLength[1]))
+ scaleY = 1/kernelUnitLength[1];
+ }
+
+ AffineTransform scale =
+ AffineTransform.getScaleInstance(scaleX, scaleY);
+
+ devRect = scale.createTransformedShape(aoiR).getBounds();
+
+ // Grow for surround needs of bump map.
+ aoiR.setRect(aoiR.getX() -(2/scaleX),
+ aoiR.getY() -(2/scaleY),
+ aoiR.getWidth() +(4/scaleX),
+ aoiR.getHeight()+(4/scaleY));
+
+
+ // Build texture from the source
+ rc = (RenderContext)rc.clone();
+ rc.setAreaOfInterest(aoiR);
+ rc.setTransform(scale);
+
+ // System.out.println("scaleX / scaleY : " + scaleX + "/" + scaleY);
+
+ CachableRed cr;
+ cr = GraphicsUtil.wrap(getSource().createRendering(rc));
+
+ BumpMap bumpMap = new BumpMap(cr, surfaceScale, scaleX, scaleY);
+
+ cr = new DiffuseLightingRed(kd, light, bumpMap,
+ devRect, 1/scaleX, 1/scaleY,
+ isColorSpaceLinear());
+
+ // Return sheared/rotated tiled image
+ AffineTransform shearAt =
+ new AffineTransform(sx/scaleX, shy/scaleX,
+ shx/scaleY, sy/scaleY,
+ tx, ty);
+
+ if(!shearAt.isIdentity()) {
+ RenderingHints rh = rc.getRenderingHints();
+ Rectangle padRect = new Rectangle(devRect.x-1, devRect.y-1,
+ devRect.width+2,
+ devRect.height+2);
+ cr = new PadRed(cr, padRect, PadMode.REPLICATE, rh);
+
+ cr = new AffineRed(cr, shearAt, rh);
+ }
+
+ return cr;
+ }
+}
+
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/DiffuseLightingRable8Bit.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/DisplacementMapRable.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/DisplacementMapRable.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/DisplacementMapRable.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/DisplacementMapRable.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,87 @@
+/*
+
+ 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.ARGBChannel;
+
+/**
+ * Implements a DisplacementMap operation, which takes pixel values from
+ * another image to spatially displace the input image
+ *
+ * @author <a href="mailto:sheng.pei@eng.sun.com">Sheng Pei</a>
+ * @version $Id: DisplacementMapRable.java 478276 2006-11-22 18:33:37Z dvholten $
+ */
+public interface DisplacementMapRable extends FilterColorInterpolation {
+
+ int CHANNEL_R = 1;
+ int CHANNEL_G = 2;
+ int CHANNEL_B = 3;
+ int CHANNEL_A = 4;
+
+ /**
+ * The sources to be used in the displacement operation
+ * The source at index 0 is displacement by the channels
+ * in source at index 1 defined by the xChannelSelector
+ * and the yChannelSelector. The displacement amount is
+ * defined by the scale attribute.
+ *
+ * @param srcs The list of images used in the operation.
+ */
+ void setSources(List srcs);
+
+ /**
+ * The displacement scale factor
+ * @param scale can be any number.
+ */
+ void setScale(double scale);
+
+ /**
+ * Returns the displacement scale factor
+ */
+ double getScale();
+
+ /**
+ * Select which component values will be used
+ * for displacement along the X axis
+ * @param xChannelSelector value is among R,
+ * G, B and A.
+ */
+ void setXChannelSelector(ARGBChannel xChannelSelector);
+
+ /**
+ * Returns the xChannelSelector
+ */
+ ARGBChannel getXChannelSelector();
+
+ /**
+ * Select which component values will be used
+ * for displacement along the Y axis
+ * @param yChannelSelector value is among R,
+ * G, B and A.
+ */
+ void setYChannelSelector(ARGBChannel yChannelSelector);
+
+ /**
+ * Returns the yChannelSelector
+ */
+ ARGBChannel getYChannelSelector();
+
+}
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/DisplacementMapRable.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/DisplacementMapRable8Bit.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/DisplacementMapRable8Bit.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/DisplacementMapRable8Bit.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/DisplacementMapRable8Bit.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,278 @@
+/*
+
+ 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.AffineTransform;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.RenderedImage;
+import java.awt.image.renderable.RenderContext;
+import java.util.List;
+
+import org.apache.flex.forks.batik.ext.awt.image.ARGBChannel;
+import org.apache.flex.forks.batik.ext.awt.image.GraphicsUtil;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.AffineRed;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.CachableRed;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.DisplacementMapRed;
+
+/**
+ * Implements a DisplacementMap operation, which takes pixel values from
+ * another image to spatially displace the input image
+ *
+ * @author <a href="mailto:sheng.pei@eng.sun.com">Sheng Pei</a>
+ * @version $Id: DisplacementMapRable8Bit.java 479564 2006-11-27 09:56:57Z dvholten $
+ */
+public class DisplacementMapRable8Bit
+ extends AbstractColorInterpolationRable
+ implements DisplacementMapRable {
+
+ /**
+ * Displacement scale factor
+ */
+ private double scale;
+
+ /**
+ * Defines which channel in the second source is used
+ * to displace along the x axis
+ */
+ private ARGBChannel xChannelSelector;
+
+ /**
+ * Defines which channel in the second source is used
+ * to displace along the y axis.
+ */
+ private ARGBChannel yChannelSelector;
+
+ public DisplacementMapRable8Bit(List sources,
+ double scale,
+ ARGBChannel xChannelSelector,
+ ARGBChannel yChannelSelector){
+ setSources(sources);
+ setScale(scale);
+ setXChannelSelector(xChannelSelector);
+ setYChannelSelector(yChannelSelector);
+ }
+
+ public Rectangle2D getBounds2D(){
+ return ((Filter)(getSources().get(0))).getBounds2D();
+ }
+
+ /**
+ * The displacement scale factor
+ * @param scale can be any number.
+ */
+ public void setScale(double scale){
+ touch();
+ this.scale = scale;
+ }
+
+ /**
+ * Returns the displacement scale factor
+ */
+ public double getScale(){
+ return scale;
+ }
+
+ /**
+ * Sets this filter sources.
+ */
+ public void setSources(List sources){
+ if(sources.size() != 2){
+ throw new IllegalArgumentException();
+ }
+ init(sources, null);
+ }
+
+ /**
+ * Select which component values will be used
+ * for displacement along the X axis
+ * @param xChannelSelector value is among R,
+ * G, B and A.
+ */
+ public void setXChannelSelector(ARGBChannel xChannelSelector){
+ if(xChannelSelector == null){
+ throw new IllegalArgumentException();
+ }
+ touch();
+ this.xChannelSelector = xChannelSelector;
+ }
+
+ /**
+ * Returns the xChannelSelector
+ */
+ public ARGBChannel getXChannelSelector(){
+ return xChannelSelector;
+ }
+
+ /**
+ * Select which component values will be used
+ * for displacement along the Y axis
+ * @param yChannelSelector value is among R,
+ * G, B and A.
+ */
+ public void setYChannelSelector(ARGBChannel yChannelSelector){
+ if(yChannelSelector == null){
+ throw new IllegalArgumentException();
+ }
+ touch();
+ this.yChannelSelector = yChannelSelector;
+ }
+
+ /**
+ * Returns the yChannelSelector
+ */
+ public ARGBChannel getYChannelSelector(){
+ return yChannelSelector;
+ }
+
+ public RenderedImage createRendering(RenderContext rc) {
+ // The source image to be displaced.
+ Filter displaced = (Filter)getSources().get(0);
+ // The map giving the displacement.
+ Filter map = (Filter)getSources().get(1);
+
+ 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 from the rest of
+ // the transformation.
+ 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.
+ double atScaleX = Math.sqrt(sx*sx + shy*shy);
+ double atScaleY = Math.sqrt(sy*sy + shx*shx);
+
+ // Now, apply the filter
+ //
+ float scaleX = (float)(scale*atScaleX);
+ float scaleY = (float)(scale*atScaleY);
+
+ // If both scale factors are zero then we don't
+ // affect the source image so just return it...
+ if ((scaleX == 0) && (scaleY == 0))
+ return displaced.createRendering(rc);
+
+ // if ((scaleX > 255) || (scaleY > 255)) {
+ // System.out.println("Scales: [" + scaleX + ", " + scaleY + "]");
+ // }
+
+ AffineTransform srcAt
+ = AffineTransform.getScaleInstance(atScaleX, atScaleY);
+
+ Shape origAOI = rc.getAreaOfInterest();
+ if (origAOI == null)
+ origAOI = getBounds2D();
+
+ Rectangle2D aoiR = origAOI.getBounds2D();
+
+ RenderContext srcRc = new RenderContext(srcAt, aoiR, rh);
+ RenderedImage mapRed = map.createRendering(srcRc);
+
+ if (mapRed == null) return null;
+
+ // Grow the area of interest in user space. to account for
+ // the max surround needs of displacement map.
+ aoiR = new Rectangle2D.Double(aoiR.getX() - scale/2,
+ aoiR.getY() - scale/2,
+ aoiR.getWidth() + scale,
+ aoiR.getHeight() + scale);
+
+ Rectangle2D displacedRect = displaced.getBounds2D();
+ if ( ! aoiR.intersects(displacedRect) )
+ return null;
+
+ aoiR = aoiR.createIntersection(displacedRect);
+ srcRc = new RenderContext(srcAt, aoiR, rh);
+ RenderedImage displacedRed = displaced.createRendering(srcRc);
+
+ if (displacedRed == null) return null;
+
+ mapRed = convertSourceCS(mapRed);
+
+ //
+ // Build a Displacement Map Red from the two sources
+ //
+
+ CachableRed cr = new DisplacementMapRed
+ (GraphicsUtil.wrap(displacedRed),
+ GraphicsUtil.wrap(mapRed),
+ xChannelSelector, yChannelSelector,
+ scaleX, scaleY, rh);
+ //
+ // Apply the non scaling part of the transform now,
+ // if different from identity.
+ //
+ AffineTransform resAt
+ = new AffineTransform(sx/atScaleX, shy/atScaleX,
+ shx/atScaleY, sy/atScaleY,
+ tx, ty);
+
+ if(!resAt.isIdentity())
+ cr = new AffineRed(cr, resAt, rh);
+
+ return cr;
+ }
+
+ /**
+ * Returns the region of input data is is required to generate
+ * outputRgn.
+ * @param srcIndex The source to do the dependency calculation for.
+ * @param outputRgn The region of output you are interested in
+ * generating dependencies for. The is given in the user coordiate
+ * system for this node.
+ * @return The region of input required. This is in the user
+ * coordinate system for the source indicated by srcIndex.
+ */
+ public Shape getDependencyRegion(int srcIndex, Rectangle2D outputRgn){
+ // NOTE: This needs to grow the region!!!
+ // Morphology actually needs a larger area of input than
+ // it outputs.
+ return super.getDependencyRegion(srcIndex, outputRgn);
+ }
+
+ /**
+ * This calculates the region of output that is affected by a change
+ * in a region of input.
+ * @param srcIndex The input that inputRgn reflects changes in.
+ * @param inputRgn the region of input that has changed, used to
+ * calculate the returned shape. This is given in the user
+ * coordinate system of the source indicated by srcIndex.
+ * @return The region of output that would be invalid given
+ * a change to inputRgn of the source selected by srcIndex.
+ * this is in the user coordinate system of this node.
+ */
+ public Shape getDirtyRegion(int srcIndex, Rectangle2D inputRgn){
+ // NOTE: This needs to grow the region!!!
+ // Changes in the input region affect a larger area of
+ // output than the input.
+ return super.getDirtyRegion(srcIndex, inputRgn);
+ }
+
+}
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/DisplacementMapRable8Bit.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/Filter.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/Filter.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/Filter.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/Filter.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,74 @@
+/*
+
+ 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;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.renderable.RenderableImage;
+
+/**
+ * This is an extension of RenderableImage that adds some needed
+ * functionality for tracking dirty regions and determining image
+ * dependancies.
+ *
+ * @author <a href="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
+ * @version $Id: Filter.java 478276 2006-11-22 18:33:37Z dvholten $
+ */
+public interface Filter extends RenderableImage {
+
+ /**
+ * Returns the bounds of the current image.
+ * This should be 'in sync' with getMinX, getMinY, getWidth, getHeight
+ */
+ Rectangle2D getBounds2D();
+
+ /**
+ * Returns the current modification timestamp on this Renderable
+ * node. This value will change whenever cached output data becomes
+ * invalid.
+ * @return Current modification timestamp value.
+ */
+ long getTimeStamp();
+
+ /**
+ * Returns the region of input data is is required to generate
+ * outputRgn.
+ * @param srcIndex The source to do the dependency calculation for.
+ * @param outputRgn The region of output you are interested in
+ * generating dependencies for. The is given in the user coordiate
+ * system for this node.
+ * @return The region of input required. This is in the user
+ * coordinate system for the source indicated by srcIndex.
+ */
+ Shape getDependencyRegion(int srcIndex, Rectangle2D outputRgn);
+
+ /**
+ * This calculates the region of output that is affected by a change
+ * in a region of input.
+ * @param srcIndex The input that inputRgn reflects changes in.
+ * @param inputRgn the region of input that has changed, used to
+ * calculate the returned shape. This is given in the user
+ * coordinate system of the source indicated by srcIndex.
+ * @return The region of output that would be invalid given
+ * a change to inputRgn of the source selected by srcIndex.
+ * this is in the user coordinate system of this node.
+ */
+ Shape getDirtyRegion(int srcIndex, Rectangle2D inputRgn);
+}
+
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/Filter.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/FilterAlphaRable.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/FilterAlphaRable.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/FilterAlphaRable.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/FilterAlphaRable.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,94 @@
+/*
+
+ 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.AffineTransform;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.RenderedImage;
+import java.awt.image.renderable.RenderContext;
+
+import org.apache.flex.forks.batik.ext.awt.ColorSpaceHintKey;
+import org.apache.flex.forks.batik.ext.awt.RenderingHintsKeyExt;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.CachableRed;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.FilterAlphaRed;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.RenderedImageCachableRed;
+
+/**
+ * FilterAlphaRable implementation.
+ *
+ * This will take any source Filter and convert it to an alpha channel
+ * image according to the SVG SourceAlpha Filter description.
+ * This sets RGB to black and Alpha to the source image's alpha channel.
+ *
+ * @author <a href="mailto:Thomas.DeWeese@Kodak.com">Thomas DeWeese</a>
+ * @version $Id: FilterAlphaRable.java 475477 2006-11-15 22:44:28Z cam $
+ */
+public class FilterAlphaRable
+ extends AbstractRable {
+
+ public FilterAlphaRable(Filter src) {
+ super(src, null);
+ }
+
+ public Filter getSource() {
+ return (Filter)getSources().get(0);
+ }
+
+ /**
+ * Pass-through: returns the source's bounds
+ */
+ public Rectangle2D getBounds2D(){
+ return getSource().getBounds2D();
+ }
+
+ public RenderedImage createRendering(RenderContext rc) {
+ // Source gets my usr2dev transform
+ AffineTransform at = rc.getTransform();
+
+ // Just copy over the rendering hints.
+ RenderingHints rh = rc.getRenderingHints();
+ if (rh == null) rh = new RenderingHints(null);
+
+ // if we didn't have an aoi specify our bounds as the aoi.
+ Shape aoi = rc.getAreaOfInterest();
+ if (aoi == null)
+ aoi = getBounds2D();
+
+ // We only want it's alpha channel...
+ rh.put(RenderingHintsKeyExt.KEY_COLORSPACE,
+ ColorSpaceHintKey.VALUE_COLORSPACE_ALPHA);
+
+ RenderedImage ri;
+ ri = getSource().createRendering(new RenderContext(at, aoi, rh));
+
+ if(ri == null){
+ return null;
+ }
+
+ CachableRed cr = RenderedImageCachableRed.wrap(ri);
+
+ Object val = cr.getProperty(ColorSpaceHintKey.PROPERTY_COLORSPACE);
+ if (val == ColorSpaceHintKey.VALUE_COLORSPACE_ALPHA)
+ return cr; // It listened to us...
+
+ return new FilterAlphaRed(cr);
+ }
+}
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/FilterAlphaRable.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/FilterAsAlphaRable.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/FilterAsAlphaRable.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/FilterAsAlphaRable.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/FilterAsAlphaRable.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,91 @@
+/*
+
+ 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.AffineTransform;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.RenderedImage;
+import java.awt.image.renderable.RenderContext;
+
+import org.apache.flex.forks.batik.ext.awt.ColorSpaceHintKey;
+import org.apache.flex.forks.batik.ext.awt.RenderingHintsKeyExt;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.CachableRed;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.FilterAsAlphaRed;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.RenderedImageCachableRed;
+
+/**
+ * FilterAsAlphaRable implementation.
+ *
+ * This will take any source Filter and convert it to an alpha channel
+ * according the the SVG Mask operation.
+ *
+ * @author <a href="mailto:Thomas.DeWeese@Kodak.com">Thomas DeWeese</a>
+ * @version $Id: FilterAsAlphaRable.java 475477 2006-11-15 22:44:28Z cam $
+ */
+public class FilterAsAlphaRable
+ extends AbstractRable {
+
+ public FilterAsAlphaRable(Filter src) {
+ super(src, null);
+ }
+
+ public Filter getSource() {
+ return (Filter)getSources().get(0);
+ }
+
+ /**
+ * Pass-through: returns the source's bounds
+ */
+ public Rectangle2D getBounds2D(){
+ return getSource().getBounds2D();
+ }
+
+ public RenderedImage createRendering(RenderContext rc) {
+ // Source gets my usr2dev transform
+ AffineTransform at = rc.getTransform();
+
+ // Just copy over the rendering hints.
+ RenderingHints rh = rc.getRenderingHints();
+ if (rh == null) rh = new RenderingHints(null);
+
+ // if we didn't have an aoi specify our bounds as the aoi.
+ Shape aoi = rc.getAreaOfInterest();
+ if (aoi == null) {
+ aoi = getBounds2D();
+ }
+
+ rh.put(RenderingHintsKeyExt.KEY_COLORSPACE,
+ ColorSpaceHintKey.VALUE_COLORSPACE_ALPHA_CONVERT);
+
+ RenderedImage ri;
+ ri = getSource().createRendering(new RenderContext(at, aoi, rh));
+ if (ri == null)
+ return null;
+
+ CachableRed cr = RenderedImageCachableRed.wrap(ri);
+
+ Object val = cr.getProperty(ColorSpaceHintKey.PROPERTY_COLORSPACE);
+ if (val == ColorSpaceHintKey.VALUE_COLORSPACE_ALPHA_CONVERT)
+ return cr;
+
+ return new FilterAsAlphaRed(cr);
+ }
+}
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/FilterAsAlphaRable.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/FilterChainRable.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/FilterChainRable.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/FilterChainRable.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/FilterChainRable.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,73 @@
+/*
+
+ 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;
+
+/**
+ * Implements a filter operation.
+ *
+ * @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
+ * @version $Id: FilterChainRable.java 478276 2006-11-22 18:33:37Z dvholten $
+ */
+public interface FilterChainRable extends Filter {
+ /**
+ * Returns the resolution along the X axis.
+ */
+ int getFilterResolutionX();
+
+ /**
+ * Sets the resolution along the X axis, i.e., the maximum
+ * size for intermediate images along that axis.
+ * The value should be greater than zero to have an effect.
+ */
+ void setFilterResolutionX(int filterResolutionX);
+
+ /**
+ * Returns the resolution along the Y axis.
+ */
+ int getFilterResolutionY();
+
+ /**
+ * Sets the resolution along the Y axis, i.e., the maximum
+ * size for intermediate images along that axis.
+ * The value should be greater than zero to have an effect.
+ */
+ void setFilterResolutionY(int filterResolutionY);
+
+ /**
+ * Sets the filter output area, in user space.
+ */
+ void setFilterRegion(Rectangle2D filterRegion);
+
+ /**
+ * Returns the filter output area, in user space
+ */
+ Rectangle2D getFilterRegion();
+
+ /**
+ * Sets the source for this chain. Should not be null
+ */
+ void setSource(Filter src);
+
+ /**
+ * Returns this filter's source.
+ */
+ Filter getSource();
+}
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/FilterChainRable.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/FilterChainRable8Bit.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/FilterChainRable8Bit.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/FilterChainRable8Bit.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/FilterChainRable8Bit.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,259 @@
+/*
+
+ 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.geom.Rectangle2D;
+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.SVGComposite;
+
+/**
+ * Implements a filter chain. A filter chain is defined by its
+ * filter region (i.e., the bounding box of its input/output), its
+ * filter resolution and its source. Its source cannot be null,
+ * but its resolution can. <br />
+ * The filter chain decomposes as follows:
+ * <ul>
+ * <li>A pad operation that makes the input image a big as the
+ * filter region.</li>
+ * <li>If there is a filterResolution specified along at least
+ * one of the axis, a <tt>AffineRable</tt>
+ * </ul>
+ *
+ * @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
+ * @version $Id: FilterChainRable8Bit.java 594379 2007-11-13 01:08:28Z cam $
+ */
+public class FilterChainRable8Bit extends AbstractRable
+ implements FilterChainRable, PaintRable {
+ /**
+ * Resolution along the X axis
+ */
+ private int filterResolutionX;
+
+ /**
+ * Resolution along the Y axis
+ */
+ private int filterResolutionY;
+
+ /**
+ * The chain's source
+ */
+ private Filter chainSource;
+
+ /**
+ * Scale operation. May be null
+ */
+ private FilterResRable filterRes;
+
+ /**
+ * Crop operation.
+ */
+ private PadRable crop;
+
+ /**
+ * Filter region
+ */
+ private Rectangle2D filterRegion;
+
+ /**
+ * Default constructor.
+ */
+ public FilterChainRable8Bit(Filter source, Rectangle2D filterRegion){
+ if(source == null){
+ throw new IllegalArgumentException();
+ }
+ if(filterRegion == null){
+ throw new IllegalArgumentException();
+ }
+
+ // Build crop with chain source and dummy region (will be lazily evaluated
+ // later on).
+ Rectangle2D padRect = (Rectangle2D)filterRegion.clone();
+ crop = new PadRable8Bit(source, padRect,
+ PadMode.ZERO_PAD);
+
+ // Keep a reference to the chain source and filter
+ // regions.
+ this.chainSource = source;
+ this.filterRegion = filterRegion;
+
+ // crop is the real shource for this filter
+ // The filter chain is a simple passthrough to its
+ // crop node.
+ init(crop);
+
+ }
+
+ /**
+ * Returns the resolution along the X axis.
+ */
+ public int getFilterResolutionX(){
+ return filterResolutionX;
+ }
+
+ /**
+ * Sets the resolution along the X axis, i.e., the maximum
+ * size for intermediate images along that axis.
+ * If filterResolutionX is less than zero, no filter resolution
+ * is forced on the filter chain. If filterResolutionX is zero,
+ * then the filter returns null. If filterResolutionX is positive,
+ * then the filter resolution is applied.
+ */
+ public void setFilterResolutionX(int filterResolutionX){
+ touch();
+ this.filterResolutionX = filterResolutionX;
+
+ setupFilterRes();
+ }
+
+ /**
+ * Returns the resolution along the Y axis.
+ */
+ public int getFilterResolutionY(){
+ return filterResolutionY;
+ }
+
+ /**
+ * Sets the resolution along the Y axis, i.e., the maximum
+ * size for intermediate images along that axis.
+ * If filterResolutionY is zero or less, the value of
+ * filterResolutionX is used.
+ */
+ public void setFilterResolutionY(int filterResolutionY){
+ touch();
+ this.filterResolutionY = filterResolutionY;
+ setupFilterRes();
+ }
+
+ /**
+ * Implementation. Checks the current value of the
+ * filterResolutionX and filterResolutionY attribute and
+ * setup the filterRes operation accordingly.
+ */
+ private void setupFilterRes(){
+ if(filterResolutionX >=0){
+ if(filterRes == null){
+ filterRes = new FilterResRable8Bit();
+ filterRes.setSource(chainSource);
+ }
+
+ filterRes.setFilterResolutionX(filterResolutionX);
+ filterRes.setFilterResolutionY(filterResolutionY);
+ }
+ else{
+ // X is negative, this disables the resolution filter.
+ filterRes = null;
+ }
+
+ // Now, update the crop source to reflect the filterRes
+ // settings.
+ if(filterRes != null){
+ crop.setSource(filterRes);
+ }
+ else{
+ crop.setSource(chainSource);
+ }
+ }
+
+ /**
+ * Sets the filter output area, in user space.
+ * A null value is illegal.
+ */
+ public void setFilterRegion(Rectangle2D filterRegion){
+ if(filterRegion == null){
+ throw new IllegalArgumentException();
+ }
+ touch();
+ this.filterRegion = filterRegion;
+ }
+
+ /**
+ * Returns the filter output area, in user space
+ */
+ public Rectangle2D getFilterRegion(){
+ return filterRegion;
+ }
+
+ /**
+ * Returns the source of the chain. Note that a crop and
+ * affine operation may be inserted before the source,
+ * depending on the filterRegion and filterResolution
+ * parameters.
+ */
+ public Filter getSource() {
+ return crop;
+ }
+
+ /**
+ * Sets the source to be src.
+ * @param chainSource image to the chain.
+ */
+ public void setSource(Filter chainSource) {
+ if(chainSource == null){
+ throw new IllegalArgumentException("Null Source for Filter Chain");
+ }
+ touch();
+ this.chainSource = chainSource;
+
+ if(filterRes == null){
+ crop.setSource(chainSource);
+ }
+ else{
+ filterRes.setSource(chainSource);
+ }
+ }
+
+ /**
+ * Returns this filter's bounds
+ */
+ public Rectangle2D getBounds2D(){
+ return (Rectangle2D)filterRegion.clone();
+ }
+
+ /**
+ * 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;
+
+ GraphicsUtil.drawImage(g2d, getSource());
+
+ return true;
+ }
+
+ public RenderedImage createRendering(RenderContext context){
+ return crop.createRendering(context);
+ }
+}
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/FilterChainRable8Bit.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/FilterColorInterpolation.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/FilterColorInterpolation.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/FilterColorInterpolation.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/FilterColorInterpolation.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,53 @@
+/*
+
+ 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.ColorSpace;
+
+/**
+ * This is an extension of our Filter interface that adds support for
+ * a color-interpolation specification which indicates what colorspace the
+ * operation should take place in.
+ *
+ * @author <a href="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
+ * @version $Id: FilterColorInterpolation.java 478276 2006-11-22 18:33:37Z dvholten $
+ */
+public interface FilterColorInterpolation extends Filter {
+
+ /**
+ * Returns true if this operation is to be performed in
+ * the linear sRGB colorspace, returns false if the
+ * operation is performed in gamma corrected sRGB.
+ */
+ boolean isColorSpaceLinear();
+
+ /**
+ * Sets the colorspace the operation will be performed in.
+ * @param csLinear if true this operation will be performed in the
+ * linear sRGB colorspace, if false the operation will be performed in
+ * gamma corrected sRGB.
+ */
+ void setColorSpaceLinear(boolean csLinear);
+
+ /**
+ * Returns the ColorSpace that the object will perform
+ * it's work in.
+ */
+ ColorSpace getOperationColorSpace();
+}
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/FilterColorInterpolation.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/FilterResRable.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/FilterResRable.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/FilterResRable.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/FilterResRable.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,64 @@
+/*
+
+ 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;
+
+
+/**
+ * Interface for implementing filter resolution.
+ *
+ * @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
+ * @version $Id: FilterResRable.java 478276 2006-11-22 18:33:37Z dvholten $
+ */
+public interface FilterResRable extends Filter {
+ /**
+ * Returns the source to be cropped.
+ */
+ Filter getSource();
+
+ /**
+ * Sets the source to be cropped
+ * @param src image to offset.
+ */
+ void setSource(Filter src);
+
+ /**
+ * Returns the resolution along the X axis.
+ */
+ int getFilterResolutionX();
+
+ /**
+ * Sets the resolution along the X axis, i.e., the maximum
+ * size for intermediate images along that axis.
+ * The value should be greater than zero to have an effect.
+ */
+ void setFilterResolutionX(int filterResolutionX);
+
+ /**
+ * Returns the resolution along the Y axis.
+ */
+ int getFilterResolutionY();
+
+ /**
+ * Sets the resolution along the Y axis, i.e., the maximum
+ * size for intermediate images along that axis.
+ * The value should be greater than zero to have an effect.
+ */
+ void setFilterResolutionY(int filterResolutionY);
+
+}
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/FilterResRable.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/FilterResRable8Bit.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/FilterResRable8Bit.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/FilterResRable8Bit.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/FilterResRable8Bit.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,403 @@
+/*
+
+ 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.awt.image.renderable.RenderableImage;
+import java.lang.ref.Reference;
+import java.lang.ref.SoftReference;
+import java.util.Iterator;
+import java.util.ListIterator;
+import java.util.List;
+
+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.AffineRed;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.TileCacheRed;
+
+/**
+ * Interface for implementing filter resolution.
+ *
+ * @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
+ * @version $Id: FilterResRable8Bit.java 501844 2007-01-31 13:54:05Z dvholten $
+ */
+public class FilterResRable8Bit extends AbstractRable
+ implements FilterResRable, PaintRable {
+
+ /**
+ * Filter resolution along the x-axis
+ */
+ private int filterResolutionX = -1;
+
+ /**
+ * Filter resolution along the y-axis
+ */
+ private int filterResolutionY = -1;
+
+ public FilterResRable8Bit() {
+ // System.out.println("Using FilterResRable8bit...");
+ }
+
+
+ public FilterResRable8Bit(Filter src, int filterResX, int filterResY) {
+ init(src, null);
+ setFilterResolutionX(filterResX);
+ setFilterResolutionY(filterResY);
+ }
+
+ /**
+ * Returns the source to be cropped.
+ */
+ public Filter getSource() {
+ return (Filter)srcs.get(0);
+ }
+
+ /**
+ * Sets the source to be cropped
+ * @param src image to offset.
+ */
+ public void setSource(Filter src){
+ init(src, null);
+ }
+
+ /**
+ * Returns the resolution along the X axis.
+ */
+ public int getFilterResolutionX(){
+ return filterResolutionX;
+ }
+
+ /**
+ * Sets the resolution along the X axis, i.e., the maximum
+ * size for intermediate images along that axis.
+ * The value should be greater than zero to have an effect.
+ * Negative values are illegal.
+ */
+ public void setFilterResolutionX(int filterResolutionX){
+ if(filterResolutionX < 0){
+ throw new IllegalArgumentException();
+ }
+ touch();
+ this.filterResolutionX = filterResolutionX;
+ }
+
+ /**
+ * Returns the resolution along the Y axis.
+ */
+ public int getFilterResolutionY(){
+ return filterResolutionY;
+ }
+
+ /**
+ * Sets the resolution along the Y axis, i.e., the maximum
+ * size for intermediate images along that axis.
+ * If the Y-value is less than zero, the scale applied to
+ * the rendered images is computed to preserve the image's aspect ratio
+ */
+ public void setFilterResolutionY(int filterResolutionY){
+ touch();
+ this.filterResolutionY = filterResolutionY;
+ }
+
+
+ /**
+ * This returns true if <tt>ri</tt> and all of <tt>ri</tt>'s
+ * sources implement the PaintRable interface. This is used to
+ * indicate that the chain has a good potential for bypassing the
+ * filterRes operation entirely.
+ *
+ * Ideally there would be a checkPaintRable method in PaintRable
+ * that could be used to get a definate answer about a filters
+ * ability to draw directly to a Graphics2D (this can sometimes
+ * 'fail' because of the way the Graphics2D is currently
+ * configured).
+ */
+ public boolean allPaintRable(RenderableImage ri) {
+ if (!(ri instanceof PaintRable))
+ return false;
+
+ List v = ri.getSources();
+ // No sources and we are PaintRable so the chain is PaintRable.
+ if (v == null) return true;
+
+ Iterator i = v.iterator();
+ while (i.hasNext()) {
+ RenderableImage nri = (RenderableImage)i.next();
+ // A source is not paintRable so we are not 100% paintRable.
+ if (!allPaintRable(nri)) return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * This function attempts to distribute the filterRes operation
+ * across src. Right now it knows about two operations, pad and
+ * composite. It's main target is the composite but often pad
+ * operations are sprinked in the chain so it needs to know about
+ * them. This list could be extended however if it gets much
+ * longer it should probably be rolled into a new 'helper interface'
+ * like PaintRable.
+ *
+ * NOTE: This is essentially a bad hack, but it is a hack that is
+ * recomended by the SVG specification so I do it.
+ */
+ public boolean distributeAcross(RenderableImage src, Graphics2D g2d) {
+ boolean ret;
+ if (src instanceof PadRable) {
+ PadRable pad = (PadRable)src;
+ Shape clip = g2d.getClip();
+ g2d.clip(pad.getPadRect());
+ ret = distributeAcross(pad.getSource(), g2d);
+ g2d.setClip(clip);
+ return ret;
+ }
+
+ if (src instanceof CompositeRable) {
+ CompositeRable comp = (CompositeRable)src;
+ if (comp.getCompositeRule() != CompositeRule.OVER)
+ return false;
+
+ if (false) {
+ // To check colorspaces or to not check colorspaces
+ // _that_ is the question...
+ ColorSpace crCS = comp.getOperationColorSpace();
+ ColorSpace g2dCS = GraphicsUtil.getDestinationColorSpace(g2d);
+ if ((g2dCS == null) || (g2dCS != crCS))
+ return false;
+ }
+
+ List v = comp.getSources();
+ if (v == null) return true;
+ ListIterator li = v.listIterator(v.size());
+ while (li.hasPrevious()) {
+ RenderableImage csrc = (RenderableImage)li.previous();
+ if (!allPaintRable(csrc)) {
+ li.next();
+ break;
+ }
+ }
+
+ if (!li.hasPrevious()) {
+ // All inputs are PaintRable so just draw directly to
+ // the graphics ignore filter res all togeather...
+ GraphicsUtil.drawImage(g2d, comp);
+ return true;
+ }
+
+ if (!li.hasNext())
+ // None of the trailing inputs are PaintRable so we don't
+ // distribute across this at all.
+ return false;
+
+ // Now we are in the case where some are paintRable and
+ // some aren't. In this case we create a new
+ // CompositeRable with the first ones, to which we apply
+ // ourselves (limiting the resolution), and after that
+ // we simply draw the remainder...
+ int idx = li.nextIndex(); // index of first PaintRable...
+ Filter f = new CompositeRable8Bit(v.subList(0, idx),
+ comp.getCompositeRule(),
+ comp.isColorSpaceLinear());
+ f = new FilterResRable8Bit(f, getFilterResolutionX(),
+ getFilterResolutionY());
+ GraphicsUtil.drawImage(g2d, f);
+ while (li.hasNext()) {
+ PaintRable pr = (PaintRable)li.next();
+ if (!pr.paintRable(g2d)) {
+ // Ugg it failed to paint so we need to filterRes it...
+ Filter prf = (Filter)pr;
+ prf = new FilterResRable8Bit(prf, getFilterResolutionX(),
+ getFilterResolutionY());
+ GraphicsUtil.drawImage(g2d, prf);
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * 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) {
+ // This is a bit of a hack to implement the suggestion of SVG
+ // specification that if the last operation in a filter chain
+ // is a SRC_OVER composite and the source is SourceGraphic it
+ // should be rendered directly to the canvas (by passing
+ // filterRes). We are actually much more aggressive in
+ // implementing this suggestion since we will bypass filterRes
+ // for all the trailing elements in a SRC_OVER composite that
+ // can be drawn directly to the canvas.
+
+ // System.out.println("Calling FilterResRable paintRable");
+
+ // This optimization only apply if we are using
+ // SrcOver. Otherwise things break...
+ Composite c = g2d.getComposite();
+ if (!SVGComposite.OVER.equals(c))
+ return false;
+
+ Filter src = getSource();
+ return distributeAcross(src, g2d);
+ }
+
+ /**
+ * Cached Rendered image at filterRes.
+ */
+ Reference resRed = null;
+ float resScale = 0;
+
+ private float getResScale() {
+ return resScale;
+ }
+
+ private RenderedImage getResRed(RenderingHints hints) {
+ Rectangle2D imageRect = getBounds2D();
+ double resScaleX = getFilterResolutionX()/imageRect.getWidth();
+ double resScaleY = getFilterResolutionY()/imageRect.getHeight();
+
+
+ // System.out.println("filterRes X " + filterResolutionX +
+ // " Y : " + filterResolutionY);
+
+ float resScale = (float)Math.min(resScaleX, resScaleY);
+
+ RenderedImage ret;
+ if (resScale == this.resScale) {
+ // System.out.println("Matched");
+ ret = (RenderedImage)resRed.get();
+ if (ret != null)
+ return ret;
+ }
+
+ AffineTransform resUsr2Dev;
+ resUsr2Dev = AffineTransform.getScaleInstance(resScale, resScale);
+
+ //
+ // Create a new RenderingContext
+ //
+ RenderContext newRC = new RenderContext(resUsr2Dev, null, hints);
+
+ ret = getSource().createRendering(newRC);
+
+ // This is probably justified since the whole reason to use
+ // The filterRes attribute is because the filter chain is
+ // expensive, otherwise you should let it evaluate at
+ // screen resolution always - right?
+ ret = new TileCacheRed(GraphicsUtil.wrap(ret));
+ this.resScale = resScale;
+ this.resRed = new SoftReference(ret);
+
+ return ret;
+ }
+
+
+
+ /**
+ *
+ */
+ public RenderedImage createRendering(RenderContext renderContext) {
+ // Get user space to device space transform
+ AffineTransform usr2dev = renderContext.getTransform();
+ if(usr2dev == null){
+ usr2dev = new AffineTransform();
+ }
+
+ RenderingHints hints = renderContext.getRenderingHints();
+
+ // As per specification, a value of zero for the
+ // x-axis or y-axis causes the filter to produce
+ // nothing.
+ // The processing is done as follows:
+ // + if the x resolution is zero, this is a no-op
+ // else compute the x scale.
+ // + if the y resolution is zero, this is a no-op
+ // else compute the y resolution from the x scale
+ // and compute the corresponding y scale.
+ // + if the y or x scale is less than one, insert
+ // an AffineRable.
+ // Else, return the source as is.
+ int filterResolutionX = getFilterResolutionX();
+ int filterResolutionY = getFilterResolutionY();
+ // System.out.println("FilterResRable: " + filterResolutionX + "x" +
+ // filterResolutionY);
+
+ if ((filterResolutionX <= 0) || (filterResolutionY == 0))
+ return null;
+
+ // Find out the renderable area
+ Rectangle2D imageRect = getBounds2D();
+ Rectangle devRect;
+ devRect = usr2dev.createTransformedShape(imageRect).getBounds();
+
+ // Now, compare the devRect with the filter
+ // resolution hints
+ float scaleX = 1;
+ if(filterResolutionX < devRect.width)
+ scaleX = filterResolutionX / (float)devRect.width;
+
+ float scaleY = 1;
+ if(filterResolutionY < 0)
+ scaleY = scaleX;
+ else if(filterResolutionY < devRect.height)
+ scaleY = filterResolutionY / (float)devRect.height;
+
+ // Only resample if either scaleX or scaleY is
+ // smaller than 1
+ if ((scaleX >= 1) && (scaleY >= 1))
+ return getSource().createRendering(renderContext);
+
+ // System.out.println("Using Fixed Resolution...");
+
+ // Using fixed resolution image since we need an image larger
+ // than this.
+ RenderedImage resRed = getResRed(hints);
+ float resScale = getResScale();
+
+ AffineTransform residualAT;
+ residualAT = new AffineTransform(usr2dev.getScaleX()/resScale,
+ usr2dev.getShearY()/resScale,
+ usr2dev.getShearX()/resScale,
+ usr2dev.getScaleY()/resScale,
+ usr2dev.getTranslateX(),
+ usr2dev.getTranslateY());
+
+ // org.ImageDisplay.showImage("AT: " + newUsr2Dev, result);
+
+ return new AffineRed(GraphicsUtil.wrap(resRed), residualAT, hints);
+ }
+}
+
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/FilterResRable8Bit.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/FloodRable.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/FloodRable.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/FloodRable.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/FloodRable.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,56 @@
+/*
+
+ 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.Paint;
+import java.awt.geom.Rectangle2D;
+
+/**
+ * Fills the input image with a given paint
+ *
+ * @author <a href="mailto:dean@w3.org">Dean Jackson</a>
+ * @version $Id: FloodRable.java 478276 2006-11-22 18:33:37Z dvholten $
+ */
+
+public interface FloodRable extends Filter {
+ /**
+ * Set the flood paint.
+ * @param paint the flood paint to use when filling
+ */
+ void setFloodPaint(Paint paint);
+
+ /**
+ * Get the flood paint.
+ * @return The current flood paint for the filter
+ */
+ Paint getFloodPaint();
+
+ /**
+ * Sets the flood region
+ * @param floodRegion region to flood with floodPaint
+ */
+ void setFloodRegion(Rectangle2D floodRegion);
+
+ /**
+ * Get the flood region
+ */
+ Rectangle2D getFloodRegion();
+}
+
+
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/FloodRable.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/FloodRable8Bit.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/FloodRable8Bit.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/FloodRable8Bit.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/FloodRable8Bit.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,166 @@
+/*
+
+ 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.Paint;
+import java.awt.Rectangle;
+import java.awt.Shape;
+import java.awt.geom.AffineTransform;
+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.PadMode;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.CachableRed;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.FloodRed;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.PadRed;
+
+/**
+ * Concrete implementation of the FloodRable interface.
+ * This fills the input image with a given flood paint
+ *
+ * @author <a href="mailto:dean@w3.org">Dean Jackson</a>
+ * @version $Id: FloodRable8Bit.java 478276 2006-11-22 18:33:37Z dvholten $
+ */
+
+public class FloodRable8Bit extends AbstractRable
+ implements FloodRable {
+
+ /**
+ * Paint to use to flood the floodRegion
+ */
+ Paint floodPaint;
+
+ /**
+ * Region to fill with floodPaint
+ */
+ Rectangle2D floodRegion;
+
+ /**
+ * @param floodRegion region to be filled with floodPaint
+ * @param floodPaint paint to use to flood the floodRegion
+ */
+ public FloodRable8Bit(Rectangle2D floodRegion,
+ Paint floodPaint) {
+ setFloodPaint(floodPaint);
+ setFloodRegion(floodRegion);
+ }
+
+ /**
+ * Set the flood fill paint
+ * @param paint The paint to use when flood filling the input image
+ */
+ public void setFloodPaint(Paint paint) {
+ touch();
+ if (paint == null) {
+ // create a transparent flood fill
+ floodPaint = new Color(0, 0, 0, 0);
+ } else {
+ floodPaint = paint;
+ }
+ }
+
+ /**
+ * Get the flood fill paint.
+ * @return the paint used to flood fill the input image
+ */
+ public Paint getFloodPaint() {
+ // Paint is immutable, we can return it
+ return floodPaint;
+ }
+
+ public Rectangle2D getBounds2D() {
+
+ return (Rectangle2D)floodRegion.clone();
+ }
+
+ /**
+ * Returns the flood region
+ */
+ public Rectangle2D getFloodRegion(){
+ return (Rectangle2D)floodRegion.clone();
+ }
+
+ /**
+ * Sets the flood region
+ */
+ public void setFloodRegion(Rectangle2D floodRegion){
+ if(floodRegion == null){
+ throw new IllegalArgumentException();
+ }
+
+ touch();
+ this.floodRegion = floodRegion;
+ }
+
+ /**
+ * Create a RenderedImage that is filled with the current
+ * flood fill paint
+ * @param rc The current render context
+ * @return A RenderedImage with the flood fill
+ */
+
+ public RenderedImage createRendering(RenderContext rc) {
+ // Get user space to device space transform
+ AffineTransform usr2dev = rc.getTransform();
+ if (usr2dev == null) {
+ usr2dev = new AffineTransform();
+ }
+
+ Rectangle2D imageRect = getBounds2D();
+
+ // Now, take area of interest into account. It is
+ // defined in user space.
+ Rectangle2D userAOI;
+ Shape aoi = rc.getAreaOfInterest();
+ if (aoi == null) {
+ aoi = imageRect;
+ userAOI = imageRect;
+ } else {
+ userAOI = aoi.getBounds2D();
+
+ // No intersection with the area of interest so return null..
+ if ( ! imageRect.intersects(userAOI) )
+ return null;
+
+ // intersect the filter area and the AOI in user space
+ Rectangle2D.intersect(imageRect, userAOI, userAOI);
+ }
+
+ // The rendered area is the interesection of the
+ // user space renderable area and the user space AOI bounds
+ final Rectangle renderedArea
+ = usr2dev.createTransformedShape(userAOI).getBounds();
+
+ if ((renderedArea.width <= 0) || (renderedArea.height <= 0)) {
+ // If there is no intersection, return null
+ return null;
+ }
+
+ CachableRed cr;
+ cr = new FloodRed(renderedArea, getFloodPaint());
+ // We use a pad because while FloodRed will advertise it's
+ // bounds based on renderedArea it will actually provide the
+ // flood data anywhere.
+ cr = new PadRed(cr, renderedArea, PadMode.ZERO_PAD, null);
+
+ return cr;
+ }
+}
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/FloodRable8Bit.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/GaussianBlurRable.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/GaussianBlurRable.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/GaussianBlurRable.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/GaussianBlurRable.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;
+
+/**
+ * Implements a GaussianBlur operation, where the blur size is
+ * defined by standard deviations along the x and y axis.
+ *
+ * @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
+ * @version $Id: GaussianBlurRable.java 478276 2006-11-22 18:33:37Z dvholten $
+ */
+public interface GaussianBlurRable extends FilterColorInterpolation {
+
+ /**
+ * Returns the source to be Blurred
+ */
+ Filter getSource();
+
+ /**
+ * Sets the source to be blurred.
+ * @param src image to blurred.
+ */
+ void setSource(Filter src);
+
+ /**
+ * The deviation along the x axis, in user space.
+ * @param stdDeviationX should be greater than zero.
+ */
+ void setStdDeviationX(double stdDeviationX);
+
+ /**
+ * The deviation along the y axis, in user space.
+ * @param stdDeviationY should be greater than zero
+ */
+ void setStdDeviationY(double stdDeviationY);
+
+ /**
+ * Returns the deviation along the x-axis, in user space.
+ */
+ double getStdDeviationX();
+
+ /**
+ * Returns the deviation along the y-axis, in user space.
+ */
+ double getStdDeviationY();
+}
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/GaussianBlurRable.java
------------------------------------------------------------------------------
svn:eol-style = native