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/20 22:59:10 UTC

cvs commit: xml-batik/sources/org/apache/batik/swing/gvt JGVTComponent.java TextSelectionManager.java

deweese     2005/02/20 13:59:10

  Modified:    lib      pdf-transcoder.jar
               sources/org/apache/batik/bridge UpdateManager.java
               sources/org/apache/batik/swing/gvt JGVTComponent.java
                        TextSelectionManager.java
  Log:
  1) Fixed a race condition in the UpdateManager.
  2) Fixed a stray System.out in pdf-transcoder.
  3) Started exposure of TextSelection interfaces on Canvas (not
     fully done).
  
  Revision  Changes    Path
  1.8       +173 -160  xml-batik/lib/pdf-transcoder.jar
  
  	<<Binary file>>
  
  
  1.37      +39 -17    xml-batik/sources/org/apache/batik/bridge/UpdateManager.java
  
  Index: UpdateManager.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/UpdateManager.java,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- UpdateManager.java	17 Feb 2005 11:47:05 -0000	1.36
  +++ UpdateManager.java	20 Feb 2005 21:59:10 -0000	1.37
  @@ -76,6 +76,11 @@
       protected RunnableQueue updateRunnableQueue;
   
       /**
  +     * The RunHandler for the RunnableQueue.
  +     */
  +    protected RunnableQueue.RunHandler runHandler;
  +
  +    /**
        * Whether the update manager is running.
        */
       protected boolean running;
  @@ -130,7 +135,7 @@
           document = doc;
   
           updateRunnableQueue = RunnableQueue.createRunnableQueue();
  -        RunnableQueue.RunHandler runHandler = createRunHandler();
  +        runHandler = createRunHandler();
           updateRunnableQueue.setRunHandler(runHandler);
   
           graphicsNode = gn;
  @@ -254,17 +259,27 @@
        * Suspends the update manager.
        */
       public synchronized void suspend() {
  -        if (running) {
  -            suspendCalled = true;
  +        // System.err.println("Suspend: " + suspendCalled + " : " + running);
  +        if (updateRunnableQueue.getQueueState() == RunnableQueue.RUNNING) {
               updateRunnableQueue.suspendExecution(false);
           }
  +        suspendCalled = true;
       }
   
       /**
        * Resumes the update manager.
        */
       public synchronized void resume() {
  -        if (!running) {
  +        // System.err.println("Resume: " + suspendCalled + " : " + running);
  +
  +        // if (suspendCalled) {
  +        //     UpdateManagerEvent ev = new UpdateManagerEvent
  +        //         (this, null, null);
  +        //     // FIXX: Must happen in a different thread!
  +        //     fireEvent(suspendedDispatcher, ev); 
  +        //     fireEvent(resumedDispatcher, ev);
  +        // }
  +        if (updateRunnableQueue.getQueueState() != RunnableQueue.RUNNING) {
               updateRunnableQueue.resumeExecution();
           }
       }
  @@ -576,11 +591,14 @@
            * Called when the execution of the queue has been suspended.
            */
           public void executionSuspended(RunnableQueue rq) {
  -            if (suspendCalled) {
  -                running = false;
  -                UpdateManagerEvent ev = new UpdateManagerEvent
  -                    (this, null, null);
  -                fireEvent(suspendedDispatcher, ev);
  +            synchronized (UpdateManager.this) {
  +                // System.err.println("Suspended: " + suspendCalled);
  +                if (suspendCalled) {
  +                    running = false;
  +                    UpdateManagerEvent ev = new UpdateManagerEvent
  +                        (this, null, null);
  +                    fireEvent(suspendedDispatcher, ev);
  +                }
               }
           }
           
  @@ -588,13 +606,17 @@
            * Called when the execution of the queue has been resumed.
            */
           public void executionResumed(RunnableQueue rq) {
  -            if (suspendCalled && !running) {
  -                running = true;
  -                suspendCalled = false;
  -
  -                UpdateManagerEvent ev = new UpdateManagerEvent
  -                    (this, null, null);
  -                fireEvent(resumedDispatcher, ev);
  +            synchronized (UpdateManager.this) {
  +                // System.err.println("Resumed: " + suspendCalled + 
  +                //                    " : " + running);
  +                if (suspendCalled && !running) {
  +                    running = true;
  +                    suspendCalled = false;
  +
  +                    UpdateManagerEvent ev = new UpdateManagerEvent
  +                        (this, null, null);
  +                    fireEvent(resumedDispatcher, ev);
  +                }
               }
           }
       }
  
  
  
  1.49      +18 -3     xml-batik/sources/org/apache/batik/swing/gvt/JGVTComponent.java
  
  Index: JGVTComponent.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/swing/gvt/JGVTComponent.java,v
  retrieving revision 1.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- JGVTComponent.java	12 Feb 2005 01:48:24 -0000	1.48
  +++ JGVTComponent.java	20 Feb 2005 21:59:10 -0000	1.49
  @@ -317,17 +317,32 @@
           if (eventsEnabled) {
               eventDispatcher = new AWTEventDispatcher();
               if (selectableText) {
  -                textSelectionManager =
  -                    new TextSelectionManager(this, eventDispatcher);
  +                textSelectionManager = createTextSelectionManager();
               }
           }
       }
   
  +    /**
  +     *  Creates the TextSelectionManager to be used by this
  +     * JGVTComponent.  Subclasses may override to provide a
  +     * custom subclass.
  +     */
  +    protected TextSelectionManager createTextSelectionManager() {
  +        return new TextSelectionManager(this, eventDispatcher);
  +    }
  +
       ////////////////////////////////////////////////////////////////////////
       // Selection methods
       ////////////////////////////////////////////////////////////////////////
   
       /**
  +     *  Returns the current Text selection manager for the Component.
  +     */
  +    public TextSelectionManager getTextSelectionManager() {
  +        return textSelectionManager;
  +    }
  +
  +    /**
        * Sets the color of the selection overlay to the specified color.
        *
        * @param color the new color of the selection overlay
  
  
  
  1.22      +17 -1     xml-batik/sources/org/apache/batik/swing/gvt/TextSelectionManager.java
  
  Index: TextSelectionManager.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/swing/gvt/TextSelectionManager.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- TextSelectionManager.java	30 Oct 2004 18:38:06 -0000	1.21
  +++ TextSelectionManager.java	20 Feb 2005 21:59:10 -0000	1.22
  @@ -116,6 +116,22 @@
       }
   
       /**
  +     * Add a selection listener to be notified when the 
  +     * text selection changes in the document.
  +     */
  +    public void addSelectionListener(SelectionListener sl) {
  +        textSelector.addSelectionListener(sl);
  +    }
  +
  +    /**
  +     * Remove a selection listener to be notified when the 
  +     * text selection changes in the document.
  +     */
  +    public void removeSelectionListener(SelectionListener sl) {
  +        textSelector.removeSelectionListener(sl);
  +    }
  +
  +    /**
        * Sets the color of the selection overlay to the specified color.
        *
        * @param color the new color of the selection overlay
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org