deweese 2003/03/07 04:36:30
Modified: sources/org/apache/batik/gvt/renderer DynamicRenderer.java
sources/org/apache/batik/swing/svg JSVGComponent.java
Added: samples/tests/spec/scripting rootSizeChange.svg
Log:
Fixed a bug in the update engine when the size/location of the
root graphics node changed (reported on batik mail lists)
Revision Changes Path
1.14 +52 -1
xml-batik/sources/org/apache/batik/gvt/renderer/DynamicRenderer.java
Index: DynamicRenderer.java
===================================================================
RCS file:
/home/cvs/xml-batik/sources/org/apache/batik/gvt/renderer/DynamicRenderer.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- DynamicRenderer.java 6 Jun 2002 16:08:20 -0000 1.13
+++ DynamicRenderer.java 7 Mar 2003 12:36:29 -0000 1.14
@@ -10,12 +10,14 @@
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
+import java.awt.Point;
import java.awt.RenderingHints;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.image.BufferedImage;
import java.awt.image.Raster;
import java.awt.image.WritableRaster;
+import java.awt.image.SampleModel;
import java.util.List;
import java.util.Iterator;
@@ -67,6 +69,55 @@
public void flush(List areas) {
// Since we don't cache we don't need to flush
return;
+ }
+
+ protected void updateWorkingBuffers() {
+ if (rootFilter == null) {
+ rootFilter = rootGN.getGraphicsNodeRable(true);
+ rootCR = null;
+ }
+
+ rootCR = renderGNR();
+ if (rootCR == null) {
+ // No image to display so clear everything out...
+ workingRaster = null;
+ workingOffScreen = null;
+ workingBaseRaster = null;
+
+ currentOffScreen = null;
+ currentBaseRaster = null;
+ currentRaster = null;
+ return;
+ }
+
+ SampleModel sm = rootCR.getSampleModel();
+ int w = offScreenWidth;
+ int h = offScreenHeight;
+
+ if ((workingBaseRaster == null) ||
+ (workingBaseRaster.getWidth() < w) ||
+ (workingBaseRaster.getHeight() < h)) {
+
+ sm = sm.createCompatibleSampleModel(w, h);
+
+ workingBaseRaster
+ = Raster.createWritableRaster(sm, new Point(0,0));
+
+ workingRaster = workingBaseRaster.createWritableChild
+ (0, 0, w, h, 0, 0, null);
+
+ workingOffScreen = new BufferedImage
+ (rootCR.getColorModel(),
+ workingRaster,
+ rootCR.getColorModel().isAlphaPremultiplied(), null);
+
+ }
+
+ if (!isDoubleBuffered) {
+ currentOffScreen = workingOffScreen;
+ currentBaseRaster = workingBaseRaster;
+ currentRaster = workingRaster;
+ }
}
/**
1.65 +1 -2 xml-batik/sources/org/apache/batik/swing/svg/JSVGComponent.java
Index: JSVGComponent.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/swing/svg/JSVGComponent.java,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -r1.64 -r1.65
--- JSVGComponent.java 26 Feb 2003 11:13:46 -0000 1.64
+++ JSVGComponent.java 7 Mar 2003 12:36:30 -0000 1.65
@@ -1432,7 +1432,6 @@
if (ml.size() < l.size()) {
l = ml;
}
-
Iterator i = l.iterator();
while (i.hasNext()) {
Rectangle r = (Rectangle)i.next();
1.1 xml-batik/samples/tests/spec/scripting/rootSizeChange.svg
Index: rootSizeChange.svg
===================================================================
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000802//EN"
"http://www.w3.org/TR/2000/CR-SVG-20000802/DTD/svg-20000802.dtd">
<!-- ====================================================================== -->
<!-- Copyright (C) The Apache Software Foundation. All rights reserved. -->
<!-- -->
<!-- This software is published under the terms of the Apache Software -->
<!-- License version 1.1, a copy of which has been included with this -->
<!-- distribution in the LICENSE file. -->
<!-- ====================================================================== -->
<!-- ====================================================================== -->
<!-- Modification of a circle attributes -->
<!-- -->
<!-- @author [EMAIL PROTECTED] -->
<!-- @version $Id: rootSizeChange.svg,v 1.1 2003/03/07 12:36:30 deweese Exp $ -->
<!-- ====================================================================== -->
<?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?>
<svg id="body" width="450" height="500" viewBox="0 0 450 500"
onload="updateGroup1(); updateGroup2()">
<title>Testing Update engine when root changes size/location.</title>
<desc>To ensure proper test results you may need to turn off
double buffering and pause the animation and force a repaint, if
you see lots of junk then the repaint engine is not working
properly.</desc>
<script type="text/ecmascript">
var time1 = 90;
function updateGroup1() {
var elt = document.getElementById("g1");
var x = Math.cos(time1*3.1415926/180)*150 + 225;
var y = Math.sin(.5*(time1+90)*3.1415926/180)*150 + 250;
elt.setAttributeNS(null, "transform",
"translate("+x+","+y+")");
time1 += 5;
setTimeout('updateGroup1()', 100);
}
var time2 = 90;
function updateGroup2() {
var elt = document.getElementById("g2");
var x = Math.cos(time2*3.1415926/180)*150 + 225;
var y = Math.sin(.5*(time2+90)*3.1415926/180)*150 + 250;
elt.setAttributeNS(null, "transform",
"translate("+x+","+y+")");
time2 -= 5;
setTimeout('updateGroup2()', 100);
}
</script>
<g id="test-content">
<g id="g1">
<rect x="-15" y="-25" width="30" height="50"
fill="none" stroke="black"/>
<circle cx="0" cy="0" r="10" fill="red"/>
</g>
<g id="g2">
<rect x="-15" y="-25" width="30" height="50"
fill="none" stroke="black"/>
<circle cx="0" cy="0" r="10" fill="blue"/>
</g>
</g>
</svg>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]