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 2005/02/23 12:05:54 UTC
cvs commit: xml-batik/test-sources/org/apache/batik/util RunnableQueueTest.java
deweese 2005/02/23 03:05:54
Modified: sources/org/apache/batik/gvt CompositeGraphicsNode.java
sources/org/apache/batik/gvt/renderer DynamicRenderer.java
sources/org/apache/batik/swing JSVGScrollPane.java
sources/org/apache/batik/util RunnableQueue.java
test-sources/org/apache/batik/util RunnableQueueTest.java
Log:
1) Improved consistency of events from the RunnableQueue.
Calling suspend/resumeExecution should now always generate
a runHandler event (although the events may be "compressed"
so suspend/resume may only generate one resume event).
2) Fixed "no paint" bug with dynamic canvas as child of JSVGScrollPane
3) ScrollPane now should do a better job of fitting document w/o
scrollbars
Revision Changes Path
1.43 +12 -2 xml-batik/sources/org/apache/batik/gvt/CompositeGraphicsNode.java
Index: CompositeGraphicsNode.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/CompositeGraphicsNode.java,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- CompositeGraphicsNode.java 12 Feb 2005 01:48:23 -0000 1.42
+++ CompositeGraphicsNode.java 23 Feb 2005 11:05:53 -0000 1.43
@@ -196,7 +196,14 @@
Rectangle2D bounds = null;
while ((bounds == null) && i < count) {
bounds = children[i++].getTransformedBounds(IDENTITY);
+ if (((i & 0x0F) == 0) && HaltingThread.hasBeenHalted())
+ break; // check every 16 children if we have been interrupted.
}
+ if (HaltingThread.hasBeenHalted()) {
+ invalidateGeometryCache();
+ return null;
+ }
+
if (bounds == null) {
primitiveBounds = NULL_RECT;
return null;
@@ -215,6 +222,9 @@
primitiveBounds.add(ctb);
}
}
+
+ if (((i & 0x0F) == 0) && HaltingThread.hasBeenHalted())
+ break; // check every 16 children if we have been interrupted.
}
// Check If we should halt early.
@@ -300,7 +310,7 @@
*/
public Rectangle2D getGeometryBounds() {
if (geometryBounds == null) {
- // System.out.println("geometryBounds are null");
+ // System.err.println("geometryBounds are null");
int i=0;
while(geometryBounds == null && i < count){
geometryBounds =
1.22 +3 -4 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.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- DynamicRenderer.java 23 Oct 2004 17:11:03 -0000 1.21
+++ DynamicRenderer.java 23 Feb 2005 11:05:54 -0000 1.22
@@ -119,7 +119,6 @@
(rootCR.getColorModel(),
workingRaster,
rootCR.getColorModel().isAlphaPremultiplied(), null);
-
}
if (!isDoubleBuffered) {
@@ -160,8 +159,8 @@
updateWorkingBuffers();
if ((rootCR == null) ||
(workingBaseRaster == null)) {
- // System.out.println("RootCR: " + rootCR);
- // System.out.println("wrkBaseRaster: " + workingBaseRaster);
+ // System.err.println("RootCR: " + rootCR);
+ // System.err.println("wrkBaseRaster: " + workingBaseRaster);
return;
}
cr = rootCR;
1.8 +4 -1 xml-batik/sources/org/apache/batik/swing/JSVGScrollPane.java
Index: JSVGScrollPane.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/swing/JSVGScrollPane.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- JSVGScrollPane.java 20 Nov 2004 19:27:10 -0000 1.7
+++ JSVGScrollPane.java 23 Feb 2005 11:05:54 -0000 1.8
@@ -345,12 +345,15 @@
public void gvtBuildPrepare (GVTTreeBuilderEvent e) {
isReady = false;
+ // Start by assuming we won't need them.
+ vertical .setVisible(false);
+ horizontalPanel.setVisible(false);
+ cornerBox .setVisible(false);
}
public void gvtBuildCompleted(GVTTreeBuilderEvent e)
{
isReady = true;
viewBox = null; // new document forget old viewBox if any.
- resizeScrollBars();
}// gvtRenderingCompleted()
public void updateCompleted(UpdateManagerEvent e) {
1.21 +41 -12 xml-batik/sources/org/apache/batik/util/RunnableQueue.java
Index: RunnableQueue.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/util/RunnableQueue.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- RunnableQueue.java 2 Dec 2004 01:24:37 -0000 1.20
+++ RunnableQueue.java 23 Feb 2005 11:05:54 -0000 1.21
@@ -71,6 +71,11 @@
*/
protected Object stateLock = new Object();
+ /**
+ * Used to indicate if the queue was resumed while
+ * still running, so a 'resumed' event can be sent.
+ */
+ protected boolean wasResumed;
/**
* The Runnable objects list, also used as synchoronization point
@@ -78,6 +83,10 @@
*/
protected DoublyLinkedList list = new DoublyLinkedList();
+ /**
+ * Count of preempt entries in queue, so preempt entries
+ * can be kept properly ordered.
+ */
protected int preemptCount = 0;
/**
@@ -131,21 +140,30 @@
// Mutex for suspention work.
synchronized (stateLock) {
- if (state != RUNNING) {
- state = SUSPENDED;
-
- // notify suspendExecution in case it is
- // waiting til we shut down.
- stateLock.notifyAll();
-
- executionSuspended();
+ if (state == RUNNING) {
+ if (wasResumed) {
+ wasResumed = false;
+ executionResumed();
+ }
+ } else {
+
while (state != RUNNING) {
state = SUSPENDED;
+
+ // notify suspendExecution in case it is
+ // waiting til we shut down.
+ stateLock.notifyAll();
+
+ executionSuspended();
+
// Wait until resumeExecution called.
- stateLock.wait();
+ try {
+ stateLock.wait();
+ } catch(InterruptedException ie) { }
}
+ wasResumed = false;
executionResumed();
}
}
@@ -321,10 +339,16 @@
throw new IllegalStateException
("RunnableQueue not started or has exited");
}
+ // System.err.println("Suspend Called");
synchronized (stateLock) {
- if (state == SUSPENDED)
- // already suspended...
+ wasResumed = false;
+
+ if (state == SUSPENDED) {
+ // already suspended, notify stateLock so an event is
+ // generated.
+ stateLock.notifyAll();
return;
+ }
if (state == RUNNING) {
state = SUSPENDING;
@@ -351,12 +375,15 @@
* @throws IllegalStateException if getThread() is null.
*/
public void resumeExecution() {
+ // System.err.println("Resume Called");
if (runnableQueueThread == null) {
throw new IllegalStateException
("RunnableQueue not started or has exited");
}
synchronized (stateLock) {
+ wasResumed = true;
+
if (state != RUNNING) {
state = RUNNING;
stateLock.notifyAll(); // wake it up.
@@ -425,6 +452,7 @@
* Currently just notifies runHandler
*/
protected synchronized void executionSuspended() {
+ // System.err.println("Suspend Sent");
if (runHandler != null) {
runHandler.executionSuspended(this);
}
@@ -435,6 +463,7 @@
* Currently just notifies runHandler
*/
protected synchronized void executionResumed() {
+ // System.err.println("Resumed Sent");
if (runHandler != null) {
runHandler.executionResumed(this);
}
1.7 +5 -2 xml-batik/test-sources/org/apache/batik/util/RunnableQueueTest.java
Index: RunnableQueueTest.java
===================================================================
RCS file: /home/cvs/xml-batik/test-sources/org/apache/batik/util/RunnableQueueTest.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- RunnableQueueTest.java 18 Aug 2004 07:17:15 -0000 1.6
+++ RunnableQueueTest.java 23 Feb 2005 11:05:54 -0000 1.7
@@ -37,9 +37,12 @@
* @param sync Should requests be made synchronously (from
* different threads).
*/
- public RunnableQueueTest(int nThreads, boolean sync) {
+ public RunnableQueueTest(int nThreads) {
this.nThreads = nThreads;
}
+ public RunnableQueueTest(Integer nThreads) {
+ this((nThreads==null)?10:nThreads.intValue());
+ }
/**
* Returns this Test's name
@@ -203,7 +206,7 @@
}
public static void main(String []args) {
- RunnableQueueTest rqt = new RunnableQueueTest(20, false);
+ RunnableQueueTest rqt = new RunnableQueueTest(20);
try {
rqt.runImpl();
} catch (Exception e) {
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org