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/09/10 20:59:45 UTC
cvs commit: xml-batik/sources/org/apache/batik/ext/awt LinearGradientPaintContext.java
deweese 01/09/10 11:59:45
Modified: sources/org/apache/batik/gvt/filter BackgroundRable8Bit.java
sources/org/apache/batik/ext/awt
LinearGradientPaintContext.java
Log:
1) BackgroundRable now returns an empty rectangle when no
enable-background is found. This should lead to the same result as
returning a fully transparent black background, with much less
overhead.
2) Fixed an Off-by-one error in Linear gradient.
Revision Changes Path
1.7 +16 -7 xml-batik/sources/org/apache/batik/gvt/filter/BackgroundRable8Bit.java
Index: BackgroundRable8Bit.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/filter/BackgroundRable8Bit.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- BackgroundRable8Bit.java 2001/03/26 21:27:36 1.6
+++ BackgroundRable8Bit.java 2001/09/10 18:59:44 1.7
@@ -43,7 +43,7 @@
* createRendering methods.
*
* @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
- * @version $Id: BackgroundRable8Bit.java,v 1.6 2001/03/26 21:27:36 deweese Exp $
+ * @version $Id: BackgroundRable8Bit.java,v 1.7 2001/09/10 18:59:44 deweese Exp $
*/
public class BackgroundRable8Bit
extends AbstractRable {
@@ -192,8 +192,10 @@
GraphicsNode child) {
Rectangle2D r2d = null;
- if (gn == null)
+ if (gn == null) {
+ // System.out.println("Null GN Parent: " + child );
return null;
+ }
if (gn instanceof CompositeGraphicsNode) {
CompositeGraphicsNode cgn = (CompositeGraphicsNode)gn;
@@ -208,9 +210,11 @@
// No background enable so check our parent's value.
r2d = getBoundsRecursive(gn.getParent(), gn);
- // No background for any ancester (error) return null
- if (r2d == null)
- return null;
+ // No background for any ancester (error) return empty Rect...
+ if (r2d == null) {
+ // System.out.println("Null GetBoundsRec:" + gn + "\n\t" + child);
+ return new Rectangle2D.Float(0, 0, 0, 0);
+ }
// Our parent has background but no bounds (and we must
// have been the first child so build the new bounds...
@@ -240,8 +244,13 @@
// System.out.println("GetBounds2D called");
Rectangle2D r2d = getBoundsRecursive(node, null);
- if (r2d == CompositeGraphicsNode.VIEWPORT)
- r2d = getViewportBounds(node, null, getGraphicsNodeRenderContext());
+ // System.out.println("BoundsRec: " + r2d);
+
+ if (r2d == CompositeGraphicsNode.VIEWPORT) {
+ r2d = getViewportBounds(node, null,
+ getGraphicsNodeRenderContext());
+ // System.out.println("BoundsViewport: " + r2d);
+ }
return r2d;
}
1.6 +18 -12 xml-batik/sources/org/apache/batik/ext/awt/LinearGradientPaintContext.java
Index: LinearGradientPaintContext.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/ext/awt/LinearGradientPaintContext.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- LinearGradientPaintContext.java 2001/07/12 15:07:43 1.5
+++ LinearGradientPaintContext.java 2001/09/10 18:59:45 1.6
@@ -18,7 +18,7 @@
*
* @author Nicholas Talian, Vincent Hardy, Jim Graham, Jerry Evans
* @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
- * @version $Id: LinearGradientPaintContext.java,v 1.5 2001/07/12 15:07:43 deweese Exp $
+ * @version $Id: LinearGradientPaintContext.java,v 1.6 2001/09/10 18:59:45 deweese Exp $
* @see java.awt.PaintContext
* @see java.awt.Paint
* @see java.awt.GradientPaint
@@ -125,15 +125,21 @@
final int rowLimit = off+w; // end of row iteration
if (dgdX == 0) {
- if (g < 0) g = 0;
- if (g > 1) g = 1;
-
- // Could be a binary search...
- int gradIdx = 0;
- while (gradIdx < gradientsLength) {
- if (g < fractions[gradIdx+1])
- break;
- gradIdx++;
+ int gradIdx;
+ if (g <= 0) {
+ g = 0;
+ gradIdx = 0;
+ } else if (g >= 1) {
+ g = 1;
+ gradIdx = gradientsLength-1;
+ } else {
+ // Could be a binary search...
+ gradIdx = 0;
+ while (gradIdx < gradientsLength-1) {
+ if (g < fractions[gradIdx+1])
+ break;
+ gradIdx++;
+ }
}
float delta = (g-fractions[gradIdx]);
@@ -179,7 +185,7 @@
if (dgdX > 0) {
// Could be a binary search...
int gradIdx = 0;
- while (gradIdx < gradientsLength) {
+ while (gradIdx < gradientsLength-1) {
if (g < fractions[gradIdx+1])
break;
gradIdx++;
@@ -211,7 +217,7 @@
} else {
// Could be a binary search...
int gradIdx = gradientsLength-1;
- while (gradIdx >= 0) {
+ while (gradIdx > 0) {
if (g > fractions[gradIdx])
break;
gradIdx--;
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org