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 [23/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/GaussianBlurRable8Bit.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/GaussianBlurRable8Bit.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/GaussianBlurRable8Bit.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/GaussianBlurRable8Bit.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,354 @@
+/*
+
+ 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.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.PadMode;
+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.GaussianBlurRed8Bit;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.PadRed;
+
+/**
+ * GaussianBlurRable implementation
+ *
+ * @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
+ * @version $Id: GaussianBlurRable8Bit.java 501495 2007-01-30 18:00:36Z dvholten $
+ */
+public class GaussianBlurRable8Bit
+ extends AbstractColorInterpolationRable
+ implements GaussianBlurRable {
+
+ /**
+ * Deviation along the x-axis
+ */
+ private double stdDeviationX;
+
+ /**
+ * Deviation along the y-axis
+ */
+ private double stdDeviationY;
+
+ public GaussianBlurRable8Bit(Filter src,
+ double stdevX, double stdevY) {
+ super(src, null);
+ setStdDeviationX(stdevX);
+ setStdDeviationY(stdevY);
+ }
+
+ /**
+ * The deviation along the x axis, in user space.
+ * @param stdDeviationX should be greater than zero.
+ */
+ public void setStdDeviationX(double stdDeviationX){
+ if(stdDeviationX < 0){
+ throw new IllegalArgumentException();
+ }
+
+ touch();
+ this.stdDeviationX = stdDeviationX;
+ }
+
+ /**
+ * The deviation along the y axis, in user space.
+ * @param stdDeviationY should be greater than zero
+ */
+ public void setStdDeviationY(double stdDeviationY){
+ if(stdDeviationY < 0){
+ throw new IllegalArgumentException();
+ }
+ touch();
+ this.stdDeviationY = stdDeviationY;
+ }
+
+ /**
+ * Returns the deviation along the x-axis, in user space.
+ */
+ public double getStdDeviationX(){
+ return stdDeviationX;
+ }
+
+ /**
+ * Returns the deviation along the y-axis, in user space.
+ */
+ public double getStdDeviationY(){
+ return stdDeviationY;
+ }
+
+ /**
+ * Sets the source of the blur operation
+ */
+ public void setSource(Filter src){
+ init(src, null);
+ }
+
+ /**
+ * Constant: 3*sqrt(2*PI)/4
+ */
+ static final double DSQRT2PI = (Math.sqrt(2*Math.PI)*3.0/4.0);
+
+ /**
+ * Grow the source's bounds
+ */
+ public Rectangle2D getBounds2D(){
+ Rectangle2D src = getSource().getBounds2D();
+ float dX = (float)(stdDeviationX*DSQRT2PI);
+ float dY = (float)(stdDeviationY*DSQRT2PI);
+ float radX = 3*dX/2;
+ float radY = 3*dY/2;
+ return new Rectangle2D.Float
+ ((float)(src.getMinX() -radX),
+ (float)(src.getMinY() -radY),
+ (float)(src.getWidth() +2*radX),
+ (float)(src.getHeight()+2*radY));
+ }
+
+ /**
+ * Returns the source of the blur operation
+ */
+ public Filter getSource(){
+ return (Filter)getSources().get(0);
+ }
+
+ public static final double eps = 0.0001;
+
+ public static boolean eps_eq(double f1, double f2) {
+ return ((f1 >= f2-eps) && (f1 <= f2+eps));
+ }
+ public static boolean eps_abs_eq(double f1, double f2) {
+ if (f1 <0) f1 = -f1;
+ if (f2 <0) f2 = -f2;
+ return eps_eq(f1, f2);
+ }
+
+ 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.
+ double scaleX = Math.sqrt(sx*sx + shy*shy);
+ double scaleY = Math.sqrt(sy*sy + shx*shx);
+
+ double sdx = stdDeviationX*scaleX;
+ double sdy = stdDeviationY*scaleY;
+
+ // This is the affine transform between our usr space and an
+ // intermediate space which is scaled similarly to our device
+ // space but is still axially aligned with our device space.
+ AffineTransform srcAt;
+
+ // This is the affine transform between our intermediate
+ // coordinate space and the real device space, or null (if
+ // we don't need an intermediate space).
+ AffineTransform resAt;
+
+ int outsetX, outsetY;
+ if ((sdx < 10) &&
+ (sdy < 10) &&
+ eps_eq (sdx, sdy) &&
+ eps_abs_eq(sx/scaleX, sy/scaleY)) {
+ // Ok we have a square Gaussian kernel which means it is
+ // circularly symetric, further our residual matrix (after
+ // removing scaling) is a rotation matrix (perhaps with
+ // mirroring), thus we can generate our source directly in
+ // device space and convolve there rather than going to an
+ // intermediate space (axially aligned with usr space) and
+ // then completing the requested rotation/shear, with an
+ // AffineRed...
+
+ srcAt = at;
+ resAt = null;
+ outsetX = 0;
+ outsetY = 0;
+ } else {
+
+ // Limit std dev to 10. Put any extra into our
+ // residual matrix. This will effectively linearly
+ // interpolate, but with such a large StdDev the
+ // function is fairly smooth anyway...
+ if (sdx > 10) {
+ scaleX = scaleX*10/sdx;
+ sdx = 10;
+ }
+ if (sdy > 10) {
+ scaleY = scaleY*10/sdy;
+ sdy = 10;
+ }
+
+ // Scale to device coords.
+ srcAt = AffineTransform.getScaleInstance(scaleX, scaleY);
+
+ // The shear/rotation simply divides out the
+ // common scale factor in the matrix.
+ resAt = new AffineTransform(sx/scaleX, shy/scaleX,
+ shx/scaleY, sy/scaleY,
+ tx, ty);
+ // Add a pixel all around for the affine to interpolate with.
+ outsetX = 1;
+ outsetY = 1;
+ }
+
+
+ Shape aoi = rc.getAreaOfInterest();
+ if(aoi == null)
+ aoi = getBounds2D();
+
+ Shape devShape = srcAt.createTransformedShape(aoi);
+ Rectangle devRect = devShape.getBounds();
+
+ outsetX += GaussianBlurRed8Bit.surroundPixels(sdx, rh);
+ outsetY += GaussianBlurRed8Bit.surroundPixels(sdy, rh);
+
+ devRect.x -= outsetX;
+ devRect.y -= outsetY;
+ devRect.width += 2*outsetX;
+ devRect.height += 2*outsetY;
+
+ Rectangle2D r;
+ try {
+ AffineTransform invSrcAt = srcAt.createInverse();
+ r = invSrcAt.createTransformedShape(devRect).getBounds2D();
+ } catch (NoninvertibleTransformException nte) {
+ // Grow the region in usr space.
+ r = aoi.getBounds2D();
+ r = new Rectangle2D.Double(r.getX()-outsetX/scaleX,
+ r.getY()-outsetY/scaleY,
+ r.getWidth() +2*outsetX/scaleX,
+ r.getHeight()+2*outsetY/scaleY);
+ }
+
+ RenderedImage ri;
+ ri = getSource().createRendering(new RenderContext(srcAt, r, rh));
+ if (ri == null)
+ return null;
+
+ CachableRed cr = convertSourceCS(ri);
+
+ // System.out.println("DevRect: " + devRect);
+
+ if (!devRect.equals(cr.getBounds())) {
+ // System.out.println("MisMatch Dev:" + devRect);
+ // System.out.println(" CR :" + cr.getBounds());
+ cr = new PadRed(cr, devRect, PadMode.ZERO_PAD, rh);
+ }
+
+ cr = new GaussianBlurRed8Bit(cr, sdx, sdy, rh);
+
+ if ((resAt != null) && (!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){
+ if(srcIndex != 0)
+ outputRgn = null;
+ else {
+ // There is only one source in GaussianBlur
+ float dX = (float)(stdDeviationX*DSQRT2PI);
+ float dY = (float)(stdDeviationY*DSQRT2PI);
+ float radX = 3*dX/2;
+ float radY = 3*dY/2;
+ outputRgn = new Rectangle2D.Float
+ ((float)(outputRgn.getMinX() -radX),
+ (float)(outputRgn.getMinY() -radY),
+ (float)(outputRgn.getWidth() +2*radX),
+ (float)(outputRgn.getHeight()+2*radY));
+
+ Rectangle2D bounds = getBounds2D();
+ if ( ! outputRgn.intersects(bounds) )
+ return new Rectangle2D.Float();
+ // Intersect with output region
+ outputRgn = outputRgn.createIntersection(bounds);
+ }
+
+ return 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){
+ Rectangle2D dirtyRegion = null;
+ if(srcIndex == 0){
+ float dX = (float)(stdDeviationX*DSQRT2PI);
+ float dY = (float)(stdDeviationY*DSQRT2PI);
+ float radX = 3*dX/2;
+ float radY = 3*dY/2;
+ inputRgn = new Rectangle2D.Float
+ ((float)(inputRgn.getMinX() -radX),
+ (float)(inputRgn.getMinY() -radY),
+ (float)(inputRgn.getWidth() +2*radX),
+ (float)(inputRgn.getHeight()+2*radY));
+
+ Rectangle2D bounds = getBounds2D();
+ if ( ! inputRgn.intersects(bounds) )
+ return new Rectangle2D.Float();
+ // Intersect with input region
+ dirtyRegion = inputRgn.createIntersection(bounds);
+ }
+
+ return dirtyRegion;
+ }
+
+
+}
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/GaussianBlurRable8Bit.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/MorphologyRable.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/MorphologyRable.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/MorphologyRable.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/MorphologyRable.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;
+
+/**
+ * Implements a Morphology operation, where the kernel size is
+ * defined by radius along the x and y axis.
+ *
+ * @author <a href="mailto:sheng.pei@eng.sun.com">Sheng Pei</a>
+ * @version $Id: MorphologyRable.java 478276 2006-11-22 18:33:37Z dvholten $
+ */
+public interface MorphologyRable extends Filter {
+ /**
+ * Returns the source to be offset.
+ */
+ Filter getSource();
+
+ /**
+ * Sets the source to be offset.
+ * @param src image to offset.
+ */
+ void setSource(Filter src);
+
+ /**
+ * The radius along the x axis, in user space.
+ * @param radiusX should be greater than zero.
+ */
+ void setRadiusX(double radiusX);
+
+ /**
+ * The radius along the y axis, in user space.
+ * @param radiusY should be greater than zero.
+ */
+ void setRadiusY(double radiusY);
+
+ /**
+ * The switch that determines if the operation
+ * is to "dilate" or "erode".
+ * @param doDilation do "dilation" when true and "erosion" when false
+ */
+ void setDoDilation(boolean doDilation);
+
+ /**
+ * Returns whether the operation is "dilation" or not("erosion")
+ */
+ boolean getDoDilation();
+
+ /**
+ * Returns the radius along the x-axis, in user space.
+ */
+ double getRadiusX();
+
+ /**
+ * Returns the radius along the y-axis, in user space.
+ */
+ double getRadiusY();
+}
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/MorphologyRable.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/MorphologyRable8Bit.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/MorphologyRable8Bit.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/MorphologyRable8Bit.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/MorphologyRable8Bit.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,294 @@
+/*
+
+ 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.RenderingHints;
+import java.awt.Shape;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.ColorModel;
+import java.awt.image.Raster;
+import java.awt.image.RenderedImage;
+import java.awt.image.WritableRaster;
+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.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.MorphologyOp;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.PadRed;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.RenderedImageCachableRed;
+
+/**
+ * Implements a Morphology operation, where the kernel size is
+ * defined by radius along the x and y axis.
+ *
+ * @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
+ * @version $Id: MorphologyRable8Bit.java 475477 2006-11-15 22:44:28Z cam $
+ */
+public class MorphologyRable8Bit
+ extends AbstractRable
+ implements MorphologyRable {
+ /**
+ * Morphology radius
+ */
+ private double radiusX, radiusY;
+
+ /**
+ * Controls whether this filter does dilation
+ * (as opposed to erosion)
+ */
+ private boolean doDilation;
+
+ public MorphologyRable8Bit(Filter src,
+ double radiusX,
+ double radiusY,
+ boolean doDilation){
+ super(src, null);
+ setRadiusX(radiusX);
+ setRadiusY(radiusY);
+ setDoDilation(doDilation);
+ }
+
+ /**
+ * Returns the source to be offset.
+ */
+ public Filter getSource(){
+ return (Filter)getSources().get(0);
+ }
+
+ /**
+ * Sets the source to be offset.
+ * @param src image to offset.
+ */
+ public void setSource(Filter src){
+ init(src, null);
+ }
+
+ /**
+ * Pass-through: returns the source's bounds
+ */
+ public Rectangle2D getBounds2D(){
+ return getSource().getBounds2D();
+ }
+
+ /**
+ * The radius along the x axis, in user space.
+ * @param radiusX should be greater than zero.
+ */
+ public void setRadiusX(double radiusX){
+ if(radiusX <= 0){
+ throw new IllegalArgumentException();
+ }
+
+ touch();
+ this.radiusX = radiusX;
+ }
+
+ /**
+ * The radius along the y axis, in user space.
+ * @param radiusY should be greater than zero.
+ */
+ public void setRadiusY(double radiusY){
+ if(radiusY <= 0){
+ throw new IllegalArgumentException();
+ }
+
+ touch();
+ this.radiusY = radiusY;
+ }
+
+ /**
+ * The switch that determines if the operation
+ * is to "dilate" or "erode".
+ * @param doDilation do "dilation" when true and "erosion" when false
+ */
+ public void setDoDilation(boolean doDilation){
+ touch();
+ this.doDilation = doDilation;
+ }
+
+ /**
+ * Returns whether the operation is "dilation" or not("erosion")
+ */
+ public boolean getDoDilation(){
+ return doDilation;
+ }
+
+ /**
+ * Returns the radius along the x-axis, in user space.
+ */
+ public double getRadiusX(){
+ return radiusX;
+ }
+
+ /**
+ * Returns the radius along the y-axis, in user space.
+ */
+ public double getRadiusY(){
+ return radiusY;
+ }
+
+ 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.
+ double scaleX = Math.sqrt(sx*sx + shy*shy);
+ double scaleY = Math.sqrt(sy*sy + shx*shx);
+
+ AffineTransform srcAt;
+ srcAt = AffineTransform.getScaleInstance(scaleX, scaleY);
+
+ int radX = (int)Math.round(radiusX*scaleX);
+ int radY = (int)Math.round(radiusY*scaleY);
+
+ MorphologyOp op = null;
+ if(radX > 0 && radY > 0){
+ op = new MorphologyOp(radX, radY, doDilation);
+ }
+
+ // This is the affine transform between our intermediate
+ // coordinate space and the real device space.
+ AffineTransform resAt;
+ // The shear/rotation simply divides out the
+ // common scale factor in the matrix.
+ resAt = new AffineTransform(sx/scaleX, shy/scaleX,
+ shx/scaleY, sy/scaleY,
+ tx, ty);
+
+ Shape aoi = rc.getAreaOfInterest();
+ if(aoi == null) {
+ aoi = getBounds2D();
+ }
+
+ Rectangle2D r = aoi.getBounds2D();
+ r = new Rectangle2D.Double(r.getX()-radX/scaleX,
+ r.getY()-radY/scaleY,
+ r.getWidth() +2*radX/scaleX,
+ r.getHeight()+2*radY/scaleY);
+
+ RenderedImage ri;
+ ri = getSource().createRendering(new RenderContext(srcAt, r, rh));
+ if (ri == null)
+ return null;
+
+ CachableRed cr;
+ cr = new RenderedImageCachableRed(ri);
+
+ Shape devShape = srcAt.createTransformedShape(aoi.getBounds2D());
+ r = devShape.getBounds2D();
+ r = new Rectangle2D.Double(r.getX()-radX,
+ r.getY()-radY,
+ r.getWidth() +2*radX,
+ r.getHeight()+2*radY);
+ cr = new PadRed(cr, r.getBounds(), PadMode.ZERO_PAD, rh);
+
+ // System.out.println("Src: " + cr.getBounds(rc));
+
+ ColorModel cm = ri.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();
+ Point pt = new Point(0,0);
+ WritableRaster wr = Raster.createWritableRaster(rr.getSampleModel(),
+ rr.getDataBuffer(),
+ pt);
+
+ BufferedImage srcBI;
+ srcBI = new BufferedImage(cm, wr, cm.isAlphaPremultiplied(), null);
+
+ BufferedImage destBI;
+ if(op != null){
+ destBI = op.filter(srcBI, null);
+ }
+ else{
+ destBI = srcBI;
+ }
+
+ final int rrMinX = cr.getMinX();
+ final int rrMinY = cr.getMinY();
+
+ cr = new BufferedImageCachableRed(destBI, rrMinX, rrMinY);
+
+ if (!resAt.isIdentity())
+ cr = new AffineRed(cr, resAt, rh);
+
+ // System.out.println("Res: " + cr.getBounds(rc));
+
+ 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/MorphologyRable8Bit.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/OffsetRable.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/OffsetRable.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/OffsetRable.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/OffsetRable.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;
+
+/**
+ * Adjusts the input images coordinate system by dx, dy.
+ *
+ * @author <a href="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
+ * @version $Id: OffsetRable.java 478276 2006-11-22 18:33:37Z dvholten $
+ */
+public interface OffsetRable extends Filter {
+ /**
+ * Returns the source to be offset.
+ */
+ Filter getSource();
+
+ /**
+ * Sets the source to be offset.
+ * @param src image to offset.
+ */
+ void setSource(Filter src);
+
+ /**
+ * Set the x offset.
+ * @param dx the amount to offset in the x direction
+ */
+ void setXoffset(double dx);
+
+ /**
+ * Get the x offset.
+ * @return the amount to offset in the x direction
+ */
+ double getXoffset();
+
+ /**
+ * Set the y offset.
+ * @param dy the amount to offset in the y direction
+ */
+ void setYoffset(double dy);
+
+ /**
+ * Get the y offset.
+ * @return the amount to offset in the y direction
+ */
+ double getYoffset();
+}
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/OffsetRable.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/PadRable.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/PadRable.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/PadRable.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/PadRable.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,67 @@
+/*
+
+ 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.PadMode;
+
+/**
+ * Pads image to the given Rectangle (the rect may be smaller than the
+ * image in which case this is actually a crop). The rectangle is
+ * specified in the user coordinate system of this Renderable.
+ *
+ * @author <a href="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
+ * @version $Id: PadRable.java 478276 2006-11-22 18:33:37Z dvholten $ */
+public interface PadRable extends Filter {
+ /**
+ * Returns the source to be padded
+ */
+ Filter getSource();
+
+ /**
+ * Sets the source to be padded
+ * @param src image to offset.
+ */
+ void setSource(Filter src);
+
+ /**
+ * Set the current rectangle for padding.
+ * @param rect the new rectangle to use for pad.
+ */
+ void setPadRect(Rectangle2D rect);
+
+ /**
+ * Get the current rectangle for padding
+ * @return Rectangle currently in use for pad.
+ */
+ Rectangle2D getPadRect();
+
+ /**
+ * Set the current extension mode for pad
+ * @param mode the new pad mode
+ */
+ void setPadMode(PadMode mode);
+
+ /**
+ * Get the current extension mode for pad
+ * @return Mode currently in use for pad
+ */
+ PadMode getPadMode();
+}
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/PadRable.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/PadRable8Bit.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/PadRable8Bit.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/PadRable8Bit.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/PadRable8Bit.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,229 @@
+/*
+
+ 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.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.SVGComposite;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.CachableRed;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.PadRed;
+
+/**
+ * Concrete implementation of the PadRable interface.
+ * This pads the image to a specified rectangle in user coord system.
+ *
+ * @author <a href="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
+ * @version $Id: PadRable8Bit.java 478276 2006-11-22 18:33:37Z dvholten $
+ */
+public class PadRable8Bit extends AbstractRable
+ implements PadRable, PaintRable {
+
+ PadMode padMode;
+ Rectangle2D padRect;
+
+ public PadRable8Bit(Filter src,
+ Rectangle2D padRect,
+ PadMode padMode) {
+ super.init(src, null);
+ this.padRect = padRect;
+ this.padMode = padMode;
+ }
+
+ /**
+ * 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) {
+ super.init(src, null);
+ }
+
+ public Rectangle2D getBounds2D() {
+ return (Rectangle2D)padRect.clone();
+ }
+
+ /**
+ * Set the current rectangle for padding.
+ * @param rect the new rectangle to use for pad.
+ */
+ public void setPadRect(Rectangle2D rect) {
+ touch();
+ this.padRect = rect;
+ }
+
+ /**
+ * Get the current rectangle for padding
+ * @return Rectangle currently in use for pad.
+ */
+ public Rectangle2D getPadRect() {
+ return (Rectangle2D)padRect.clone();
+ }
+
+ /**
+ * Set the current extension mode for pad
+ * @param padMode the new pad mode
+ */
+ public void setPadMode(PadMode padMode) {
+ touch();
+ this.padMode = padMode;
+ }
+
+ /**
+ * Get the current extension mode for pad
+ * @return Mode currently in use for pad
+ */
+ public PadMode getPadMode() {
+ return padMode;
+ }
+
+ /**
+ * 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;
+
+ if (getPadMode() != PadMode.ZERO_PAD)
+ return false;
+
+ Rectangle2D padBounds = getPadRect();
+
+ Shape clip = g2d.getClip();
+ g2d.clip(padBounds);
+ GraphicsUtil.drawImage(g2d, getSource());
+ g2d.setClip(clip);
+ return true;
+ }
+
+ public RenderedImage createRendering(RenderContext rc) {
+ RenderingHints rh = rc.getRenderingHints();
+ if (rh == null) rh = new RenderingHints(null);
+
+ Filter src = getSource();
+ Shape aoi = rc.getAreaOfInterest();
+
+ if(aoi == null){
+ aoi = getBounds2D();
+ }
+
+ AffineTransform usr2dev = rc.getTransform();
+
+ // We only depend on our source for stuff that is inside
+ // our bounds and his bounds (remember our bounds may be
+ // tighter than his in one or both directions).
+ Rectangle2D srect = src.getBounds2D();
+ Rectangle2D rect = getBounds2D();
+ Rectangle2D arect = aoi.getBounds2D();
+
+ // System.out.println("Rects Src:" + srect +
+ // "My: " + rect +
+ // "AOI: " + arect);
+ if ( ! arect.intersects(rect) )
+ return null;
+ Rectangle2D.intersect(arect, rect, arect);
+
+ RenderedImage ri = null;
+ if ( arect.intersects(srect) ) {
+ srect = (Rectangle2D)srect.clone();
+ Rectangle2D.intersect(srect, arect, srect);
+
+ RenderContext srcRC = new RenderContext(usr2dev, srect, rh);
+ ri = src.createRendering(srcRC);
+
+ // System.out.println("Pad filt: " + src + " R: " +
+ // src.getBounds2D());
+ }
+
+ // No source image so create a 1,1 transparent one...
+ if (ri == null)
+ ri = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
+
+ // org.apache.flex.forks.batik.test.gvt.ImageDisplay.showImage("Paded: ", ri);
+ // System.out.println("RI: " + ri + " R: " + srect);
+
+ CachableRed cr = GraphicsUtil.wrap(ri);
+
+ arect = usr2dev.createTransformedShape(arect).getBounds2D();
+
+ // System.out.println("Pad rect : " + arect);
+ // Use arect (my bounds intersect area of interest)
+ cr = new PadRed(cr, arect.getBounds(), padMode, rh);
+ return cr;
+ }
+
+ public Shape getDependencyRegion(int srcIndex, Rectangle2D outputRgn) {
+ if (srcIndex != 0)
+ throw new IndexOutOfBoundsException("Affine only has one input");
+
+ // We only depend on our source for stuff that is inside
+ // our bounds and his bounds (remember our bounds may be
+ // tighter than his in one or both directions).
+ Rectangle2D srect = getSource().getBounds2D();
+ if ( ! srect.intersects(outputRgn) )
+ return new Rectangle2D.Float();
+ Rectangle2D.intersect(srect, outputRgn, srect);
+
+ Rectangle2D bounds = getBounds2D();
+ if ( ! srect.intersects(bounds) )
+ return new Rectangle2D.Float();
+ Rectangle2D.intersect(srect, bounds, srect);
+ return srect;
+ }
+
+ public Shape getDirtyRegion(int srcIndex, Rectangle2D inputRgn) {
+ if (srcIndex != 0)
+ throw new IndexOutOfBoundsException("Affine only has one input");
+
+ inputRgn = (Rectangle2D)inputRgn.clone();
+ Rectangle2D bounds = getBounds2D();
+ // Changes in the input region don't propogate outside our
+ // bounds.
+ if ( ! inputRgn.intersects(bounds) )
+ return new Rectangle2D.Float();
+ Rectangle2D.intersect(inputRgn, bounds, inputRgn);
+ return inputRgn;
+ }
+
+}
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/PadRable8Bit.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/PaintRable.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/PaintRable.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/PaintRable.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/PaintRable.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,42 @@
+/*
+
+ 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;
+
+/**
+ * Interface for Rable's that can more efficently represent there
+ * action as a paint method instead of a RenderedImage when going to a
+ * Graphics2D anyways.
+ *
+ * @version $Id: PaintRable.java 478363 2006-11-22 23:01:13Z dvholten $
+ */
+public interface PaintRable {
+
+ /**
+ * 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).
+ */
+ boolean paintRable(Graphics2D g2d);
+}
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/PaintRable.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ProfileRable.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/ProfileRable.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ProfileRable.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ProfileRable.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,90 @@
+/*
+
+ 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.color.ICCColorSpaceExt;
+import org.apache.flex.forks.batik.ext.awt.image.GraphicsUtil;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.CachableRed;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.ProfileRed;
+
+/**
+ * Implements the interface expected from a color matrix
+ * operation
+ *
+ * @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
+ * @version $Id: ProfileRable.java 475477 2006-11-15 22:44:28Z cam $
+ */
+public class ProfileRable extends AbstractRable{
+
+ private ICCColorSpaceExt colorSpace;
+
+ /**
+ * Instances should be built through the static
+ * factory methods
+ */
+ public ProfileRable(Filter src, ICCColorSpaceExt colorSpace){
+ super(src);
+ this.colorSpace = colorSpace;
+ }
+
+ /**
+ * 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);
+ }
+
+ /**
+ * Sets the ColorSpace of the Profile operation
+ */
+ public void setColorSpace(ICCColorSpaceExt colorSpace){
+ touch();
+ this.colorSpace = colorSpace;
+ }
+
+ /**
+ * Returns the ColorSpace of the Profile operation
+ */
+ public ICCColorSpaceExt getColorSpace(){
+ return colorSpace;
+ }
+
+ public RenderedImage createRendering(RenderContext rc) {
+ //
+ // Get source's rendered image
+ //
+ RenderedImage srcRI = getSource().createRendering(rc);
+
+ if(srcRI == null)
+ return null;
+
+ CachableRed srcCR = GraphicsUtil.wrap(srcRI);
+ return new ProfileRed(srcCR, colorSpace);
+ }
+}
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/ProfileRable.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/RedRable.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/RedRable.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/RedRable.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/RedRable.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,116 @@
+/*
+
+ 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.rendered.AffineRed;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.CachableRed;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.TranslateRed;
+
+/**
+ * RasterRable This is used to wrap a Rendered Image back into the
+ * RenderableImage world.
+ *
+ * @author <a href="mailto:Thomas.DeWeese@Kodak.com">Thomas DeWeese</a>
+ * @version $Id: RedRable.java 478276 2006-11-22 18:33:37Z dvholten $
+ */
+public class RedRable
+ extends AbstractRable {
+ CachableRed src;
+
+ public RedRable(CachableRed src) {
+ super((Filter)null);
+ this.src = src;
+ }
+
+ public CachableRed getSource() {
+ return src;
+ }
+
+ public Object getProperty(String name) {
+ return src.getProperty(name);
+ }
+
+ public String [] getPropertyNames() {
+ return src.getPropertyNames();
+ }
+
+ public Rectangle2D getBounds2D() {
+ return getSource().getBounds();
+ }
+
+ public RenderedImage createDefaultRendering() {
+ return getSource();
+ }
+
+
+ public RenderedImage createRendering(RenderContext rc) {
+ // System.out.println("RedRable Create Rendering: " + this);
+
+ // Just copy over the rendering hints.
+ RenderingHints rh = rc.getRenderingHints();
+ if (rh == null) rh = new RenderingHints(null);
+
+ Shape aoi = rc.getAreaOfInterest();
+ Rectangle aoiR;
+ if (aoi != null)
+ aoiR = aoi.getBounds();
+ else
+ aoiR = getBounds2D().getBounds();
+
+ // get the current affine transform
+ AffineTransform at = rc.getTransform();
+
+ // For high quality output we should really apply a Gaussian
+ // Blur when we are scaling the image down significantly this
+ // helps to prevent aliasing in the result image.
+ CachableRed cr = getSource();
+
+ if ( ! aoiR.intersects(cr.getBounds()) )
+ return null;
+
+ if (at.isIdentity()) {
+ // System.out.println("Using as is");
+ return cr;
+ }
+
+ if ((at.getScaleX() == 1.0) && (at.getScaleY() == 1.0) &&
+ (at.getShearX() == 0.0) && (at.getShearY() == 0.0)) {
+ int xloc = (int)(cr.getMinX()+at.getTranslateX());
+ int yloc = (int)(cr.getMinY()+at.getTranslateY());
+ double dx = xloc - (cr.getMinX()+at.getTranslateX());
+ double dy = yloc - (cr.getMinY()+at.getTranslateY());
+ if (((dx > -0.0001) && (dx < 0.0001)) &&
+ ((dy > -0.0001) && (dy < 0.0001))) {
+ // System.out.println("Using TranslateRed");
+ return new TranslateRed(cr, xloc, yloc);
+ }
+ }
+
+ // System.out.println("Using Full affine: " + at);
+ return new AffineRed(cr, at, rh);
+ }
+}
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/RedRable.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/SpecularLightingRable.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/SpecularLightingRable.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/SpecularLightingRable.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/SpecularLightingRable.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,105 @@
+/*
+
+ 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 follows the specification of the feSpecularLighting filter in
+ * the SVG 1.0 specification.
+ *
+ * @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
+ * @version $Id: SpecularLightingRable.java 478276 2006-11-22 18:33:37Z dvholten $
+ */
+public interface SpecularLightingRable 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 specular constant, or ks.
+ */
+ double getKs();
+
+ /**
+ * Sets the specular constant, or ks
+ */
+ void setKs(double ks);
+
+ /**
+ * @return specular exponent, or kd
+ */
+ double getSpecularExponent();
+
+ /**
+ * Sets the specular exponent
+ */
+ void setSpecularExponent(double specularExponent);
+
+ /**
+ * @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/SpecularLightingRable.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/SpecularLightingRable8Bit.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/SpecularLightingRable8Bit.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/SpecularLightingRable8Bit.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/SpecularLightingRable8Bit.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,320 @@
+/*
+
+ 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.PadRed;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.SpecularLightingRed;
+
+/**
+ * Implementation of the SpecularLightRable interface.
+ *
+ * @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
+ * @version $Id: SpecularLightingRable8Bit.java 475477 2006-11-15 22:44:28Z cam $
+ */
+public class SpecularLightingRable8Bit
+ extends AbstractColorInterpolationRable
+ implements SpecularLightingRable {
+ /**
+ * Surface Scale
+ */
+ private double surfaceScale;
+
+ /**
+ * Specular constant
+ */
+ private double ks;
+
+ /**
+ * Specular exponent
+ */
+ private double specularExponent;
+
+ /**
+ * Light used for the specular 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 SpecularLightingRable8Bit(Filter src,
+ Rectangle2D litRegion,
+ Light light,
+ double ks,
+ double specularExponent,
+ double surfaceScale,
+ double [] kernelUnitLength) {
+ super(src, null);
+ setLight(light);
+ setKs(ks);
+ setSpecularExponent(specularExponent);
+ 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 specular 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 specular constant, or ks.
+ */
+ public double getKs(){
+ return ks;
+ }
+
+ /**
+ * Sets the specular constant, or ks
+ */
+ public void setKs(double ks){
+ touch();
+ this.ks = ks;
+ }
+
+ /**
+ * @return specular exponent
+ */
+ public double getSpecularExponent(){
+ return specularExponent;
+ }
+
+ /**
+ * Sets the specular exponent
+ */
+ public void setSpecularExponent(double specularExponent){
+ touch();
+ this.specularExponent = specularExponent;
+ }
+
+ /**
+ * 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;
+ }
+
+ //
+ // SpecularLightingRed 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
+ // SpecularLightingRed 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 (scaleX >= 1/kernelUnitLength[0])
+ scaleX = 1/kernelUnitLength[0];
+
+ if (scaleY >= 1/kernelUnitLength[1])
+ scaleY = 1/kernelUnitLength[1];
+ }
+
+ AffineTransform scale =
+ AffineTransform.getScaleInstance(scaleX, scaleY);
+
+ devRect = scale.createTransformedShape(aoiR).getBounds();
+
+ // Grow for surround needs.
+ 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 SpecularLightingRed(ks, specularExponent, 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/SpecularLightingRable8Bit.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/TileRable.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/TileRable.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/TileRable.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/TileRable.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;
+
+/**
+ * A renderable that can tile its source into the tile region.
+ *
+ * @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
+ * @version $Id: TileRable.java 478276 2006-11-22 18:33:37Z dvholten $
+ */
+public interface TileRable extends FilterColorInterpolation {
+ /**
+ * Returns the tile region
+ */
+ Rectangle2D getTileRegion();
+
+ /**
+ * Sets the tile region
+ */
+ void setTileRegion(Rectangle2D tileRegion);
+
+ /**
+ * Returns the tiled region
+ */
+ Rectangle2D getTiledRegion();
+
+ /**
+ * Sets the tile region
+ */
+ void setTiledRegion(Rectangle2D tiledRegion);
+
+ /**
+ * Returns whether or not the source can overflow
+ * the tile region or if the tile region should clip
+ * the source
+ */
+ boolean isOverflow();
+
+ /**
+ * Sets the overflow strategy
+ */
+ void setOverflow(boolean overflow);
+
+ /**
+ * Sets the filter source (the tile content used to fill the
+ * tile region.
+ */
+ void setSource(Filter source);
+
+ /**
+ * Return's the tile source (the tile content used to fill
+ * the tile region.
+ */
+ Filter getSource();
+}
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/TileRable.java
------------------------------------------------------------------------------
svn:eol-style = native