You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by de...@apache.org on 2001/03/28 21:18:02 UTC
cvs commit: xml-batik/sources/org/apache/batik/ext/awt/image/renderable DiffuseLightingRable.java DiffuseLightingRable8Bit.java SpecularLightingRable.java SpecularLightingRable8Bit.java
deweese 01/03/28 11:18:01
Modified: sources/org/apache/batik/ext/awt/image/renderable
DiffuseLightingRable.java
DiffuseLightingRable8Bit.java
SpecularLightingRable.java
SpecularLightingRable8Bit.java
Log:
Added kernelUnitLength support to the interface.
It currently defaults to using device space (backwards compatible)
Revision Changes Path
1.3 +13 -1 xml-batik/sources/org/apache/batik/ext/awt/image/renderable/DiffuseLightingRable.java
Index: DiffuseLightingRable.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/ext/awt/image/renderable/DiffuseLightingRable.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DiffuseLightingRable.java 2001/03/26 21:27:31 1.2
+++ DiffuseLightingRable.java 2001/03/28 19:18:00 1.3
@@ -23,7 +23,7 @@
* the SVG 1.0 specification.
*
* @author <a href="mailto:vincent.hardy@eng.sun.com>Vincent Hardy</a>
- * @version $Id: DiffuseLightingRable.java,v 1.2 2001/03/26 21:27:31 deweese Exp $
+ * @version $Id: DiffuseLightingRable.java,v 1.3 2001/03/28 19:18:00 deweese Exp $
*/
public interface DiffuseLightingRable extends Filter {
/**
@@ -75,5 +75,17 @@
* Sets the litRegion for this filter
*/
public void setLitRegion(Rectangle2D litRegion);
+
+ /**
+ * Returns the min [dx,dy] distance in user space for evalutation of
+ * the sobel gradient.
+ */
+ public 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.
+ */
+ public void setKernelUnitLength(double [] kernelUnitLength);
}
1.7 +48 -5 xml-batik/sources/org/apache/batik/ext/awt/image/renderable/DiffuseLightingRable8Bit.java
Index: DiffuseLightingRable8Bit.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/ext/awt/image/renderable/DiffuseLightingRable8Bit.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- DiffuseLightingRable8Bit.java 2001/03/26 21:27:32 1.6
+++ DiffuseLightingRable8Bit.java 2001/03/28 19:18:00 1.7
@@ -29,7 +29,7 @@
* Implementation of the DiffuseLightRable interface.
*
* @author <a href="mailto:vincent.hardy@eng.sun.com>Vincent Hardy</a>
- * @version $Id: DiffuseLightingRable8Bit.java,v 1.6 2001/03/26 21:27:32 deweese Exp $
+ * @version $Id: DiffuseLightingRable8Bit.java,v 1.7 2001/03/28 19:18:00 deweese Exp $
*/
public class DiffuseLightingRable8Bit
extends AbstractRable
@@ -54,6 +54,11 @@
*/
private Rectangle2D litRegion;
+ /**
+ * The dx/dy to use in user space for the sobel gradient.
+ */
+ float [] kernelUnitLength = null;
+
public DiffuseLightingRable8Bit(Filter src,
Rectangle2D litRegion,
Light light,
@@ -142,8 +147,38 @@
public void setKd(double kd){
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;
+ }
- static final boolean SCALE_RESULT=true;
+ 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();
@@ -187,10 +222,18 @@
return null;
}
- if (SCALE_RESULT) {
- scaleX = 1;
- scaleY = 1;
+ // 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);
1.3 +13 -1 xml-batik/sources/org/apache/batik/ext/awt/image/renderable/SpecularLightingRable.java
Index: SpecularLightingRable.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/ext/awt/image/renderable/SpecularLightingRable.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SpecularLightingRable.java 2001/03/26 21:27:33 1.2
+++ SpecularLightingRable.java 2001/03/28 19:18:00 1.3
@@ -17,7 +17,7 @@
* the SVG 1.0 specification.
*
* @author <a href="mailto:vincent.hardy@eng.sun.com>Vincent Hardy</a>
- * @version $Id: SpecularLightingRable.java,v 1.2 2001/03/26 21:27:33 deweese Exp $
+ * @version $Id: SpecularLightingRable.java,v 1.3 2001/03/28 19:18:00 deweese Exp $
*/
public interface SpecularLightingRable extends Filter {
/**
@@ -79,5 +79,17 @@
* Sets the litRegion for this filter
*/
public void setLitRegion(Rectangle2D litRegion);
+
+ /**
+ * Returns the min [dx,dy] distance in user space for evalutation of
+ * the sobel gradient.
+ */
+ public 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.
+ */
+ public void setKernelUnitLength(double [] kernelUnitLength);
}
1.7 +46 -5 xml-batik/sources/org/apache/batik/ext/awt/image/renderable/SpecularLightingRable8Bit.java
Index: SpecularLightingRable8Bit.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/ext/awt/image/renderable/SpecularLightingRable8Bit.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- SpecularLightingRable8Bit.java 2001/03/26 21:27:33 1.6
+++ SpecularLightingRable8Bit.java 2001/03/28 19:18:01 1.7
@@ -29,7 +29,7 @@
* Implementation of the SpecularLightRable interface.
*
* @author <a href="mailto:vincent.hardy@eng.sun.com>Vincent Hardy</a>
- * @version $Id: SpecularLightingRable8Bit.java,v 1.6 2001/03/26 21:27:33 deweese Exp $
+ * @version $Id: SpecularLightingRable8Bit.java,v 1.7 2001/03/28 19:18:01 deweese Exp $
*/
public class SpecularLightingRable8Bit
extends AbstractRable
@@ -59,6 +59,11 @@
*/
private Rectangle2D litRegion;
+ /**
+ * The dx/dy to use in user space for the sobel gradient.
+ */
+ float [] kernelUnitLength = null;
+
public SpecularLightingRable8Bit(Filter src,
Rectangle2D litRegion,
Light light,
@@ -163,8 +168,38 @@
public void setSpecularExponent(double specularExponent){
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;
+ }
- static final boolean SCALE_RESULT=true;
+ 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();
@@ -208,10 +243,16 @@
return null;
}
- if (SCALE_RESULT) {
- scaleX = 1;
- scaleY = 1;
+ // 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);
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org