xmlgraphics-batik-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vha...@apache.org
Subject cvs commit: xml-batik/test-sources/org/apache/batik/svggen JPainterComponent.java
Date Wed, 06 Mar 2002 09:06:39 GMT
vhardy      02/03/06 01:06:39

  Modified:    sources/org/apache/batik/bridge RepaintManager.java
                        RepaintRateManager.java UpdateManager.java
               sources/org/apache/batik/gvt AbstractGraphicsNode.java
                        CompositeGraphicsNode.java GraphicsNode.java
                        UpdateTracker.java
               sources/org/apache/batik/gvt/event AWTEventDispatcher.java
                        EventDispatcher.java
               sources/org/apache/batik/swing/svg JSVGComponent.java
               test-sources/org/apache/batik/svggen JPainterComponent.java
  Log:
  - Removed RepaintRateManager usage as it is not needed until we have SMIL support
  - Made event-handling consistent in AWTEventDispatcher
  - Removed event-dispatching from GraphicsNodes as it was not used
  - Removed unused 'times' in UpdateManager
  - Simplified relationship between UpdateManager and RepaintManager. Now, 
    RepaintManager is responsible for *all* interactions with the ImageRenderer
    and the UpdateManager does not interact with the ImageRenderer directly
  - UpdateTracker fix
  - Added comment in JSVGComponent
  - Now, JPainterComponent uses an offscreen with a transparent background.
  
  Revision  Changes    Path
  1.12      +35 -61    xml-batik/sources/org/apache/batik/bridge/RepaintManager.java
  
  Index: RepaintManager.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/RepaintManager.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- RepaintManager.java	25 Feb 2002 15:55:20 -0000	1.11
  +++ RepaintManager.java	6 Mar 2002 09:06:39 -0000	1.12
  @@ -14,6 +14,8 @@
   import java.awt.geom.AffineTransform;
   import java.awt.geom.Rectangle2D;
   
  +import java.awt.image.BufferedImage;
  +
   import java.util.ArrayList;
   import java.util.Iterator;
   import java.util.List;
  @@ -26,86 +28,29 @@
    * This class manages the rendering of a GVT tree.
    *
    * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
  - * @version $Id: RepaintManager.java,v 1.11 2002/02/25 15:55:20 hillion Exp $
  + * @author <a href="mailto:vincent.hardy@sun.com">Vincent Hardy</a>
  + * @version $Id: RepaintManager.java,v 1.12 2002/03/06 09:06:39 vhardy Exp $
    */
   public class RepaintManager {
  -    
  -    /**
  -     * The associated UpdateManager.
  -     */
  -    protected UpdateManager updateManager;
  -
       /**
        * The renderer used to repaint the buffer.
        */
       protected ImageRenderer renderer;
   
       /**
  -     * Whether or not the manager is active.
  -     */
  -    protected boolean enabled;
  -
  -    /**
        * Creates a new repaint manager.
        */
  -    public RepaintManager(UpdateManager um, ImageRenderer r) {
  -        updateManager = um;
  +    public RepaintManager(ImageRenderer r) {
           renderer = r;
       }
       
       /**
  -     * Repaints the dirty areas, if needed.
  -     */
  -    public void repaint() {
  -        UpdateTracker ut = updateManager.getUpdateTracker();
  -        if (ut.hasChanged()) {
  -            List dirtyAreas = ut.getDirtyAreas();
  -            if (dirtyAreas != null) {
  -                // Calls the UpdateManager methods
  -                // to allow events to be fired.
  -                updateManager.modifiedAreas(dirtyAreas);
  -                updateManager.updateRendering(dirtyAreas);
  -            }
  -            ut.clear();
  -        }
  -    }
  -
  -    /**
  -     * Call this to let the Repaint Manager know that certain areas
  -     * in the image have been modified and need to be rerendered..
  -     */
  -    public void modifiedAreas(List areas) {
  -        renderer.flush(areas);
  -    }
  -
  -    /**
  -     * Updates the rendering buffer.
  -     * @param u2d The user to device transform.
  -     * @param dbr Whether the double buffering should be used.
  -     * @param aoi The area of interest in the renderer space units.
  -     * @param width&nbsp;height The offscreen buffer size.
  -     * @return the list of the rectangles to repaint.
  -     */
  -    public List updateRendering(AffineTransform u2d,
  -                                boolean dbr,
  -                                Shape aoi,
  -                                int width,
  -                                int height) throws InterruptedException {
  -        renderer.setTransform(u2d);
  -        renderer.setDoubleBuffered(dbr);
  -        renderer.updateOffScreen(width, height);
  -        renderer.clearOffScreen();
  -        List l = new ArrayList(1);
  -        l.add(aoi);
  -        return updateRendering(l);
  -    }
  -
  -    /**
        * Updates the rendering buffer.
        * @param aoi The area of interest in the renderer space units.
        * @return the list of the rectangles to repaint.
        */
       public List updateRendering(List areas) throws InterruptedException {
  +        renderer.flush(areas);
           List rects = new ArrayList(areas.size());
           AffineTransform at = renderer.getTransform();
   
  @@ -128,4 +73,33 @@
           renderer.repaint(areas);
           return rects;
       }
  +
  +    /**
  +     * Sets up the renderer so that it is ready to render for the new
  +     * 'context' defined by the user to device transform, double buffering
  +     * state, area of interest and width/height.
  +     * @param u2d The user to device transform.
  +     * @param dbr Whether the double buffering should be used.
  +     * @param aoi The area of interest in the renderer space units.
  +     * @param width&nbsp;height The offscreen buffer size.
  +     */
  +    public void setupRenderer(AffineTransform u2d,
  +                              boolean dbr,
  +                              Shape aoi,
  +                              int width,
  +                              int height) {
  +        renderer.setTransform(u2d);
  +        renderer.setDoubleBuffered(dbr);
  +        renderer.updateOffScreen(width, height);
  +        renderer.clearOffScreen();
  +    }
  +
  +    /**
  +     * Returns the renderer's offscreen, i.e., the current state as rendered
  +     * by the associated renderer.
  +     */
  +    public BufferedImage getOffScreen(){
  +        return renderer.getOffScreen();
  +    }
  +
   }
  
  
  
  1.3       +7 -3      xml-batik/sources/org/apache/batik/bridge/RepaintRateManager.java
  
  Index: RepaintRateManager.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/RepaintRateManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RepaintRateManager.java	25 Feb 2002 15:05:31 -0000	1.2
  +++ RepaintRateManager.java	6 Mar 2002 09:06:39 -0000	1.3
  @@ -15,7 +15,7 @@
    *
    * @author <a href="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
    * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
  - * @version $Id: RepaintRateManager.java,v 1.2 2002/02/25 15:05:31 hillion Exp $
  + * @version $Id: RepaintRateManager.java,v 1.3 2002/03/06 09:06:39 vhardy Exp $
    */
   public class RepaintRateManager extends Thread {
       
  @@ -46,15 +46,19 @@
        * current frame-rate easily)
        */
       public void run() {
  +        // <!> IMPORTANT
  +        // The 'time' should be controlled by a TimeLine abstraction
  +        // and not necessarily rely on the System 'real world' time.
  +        // <!> END IMPORTANT
  +
           long lastFrameTime;
           long currentTime;
           long tm;
           long sleepTime;
   
  -        final RepaintManager rm = updateManager.getRepaintManager();
           Runnable repaintRunnable = new NoRepaintRunnable() {
                   public void run() {
  -                    rm.repaint();
  +                    updateManager.repaint();
                   }
               };
           RunnableQueue rq = updateManager.getUpdateRunnableQueue();
  
  
  
  1.13      +24 -77    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.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- UpdateManager.java	25 Feb 2002 15:05:31 -0000	1.12
  +++ UpdateManager.java	6 Mar 2002 09:06:39 -0000	1.13
  @@ -44,7 +44,7 @@
    * This class provides features to manage the update of an SVG document.
    *
    * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
  - * @version $Id: UpdateManager.java,v 1.12 2002/02/25 15:05:31 hillion Exp $
  + * @version $Id: UpdateManager.java,v 1.13 2002/03/06 09:06:39 vhardy Exp $
    */
   public class UpdateManager implements RunnableQueue.RunHandler {
   
  @@ -66,31 +66,11 @@
       protected Document document;
   
       /**
  -     * The renderer used to paint.
  -     */
  -    protected ImageRenderer renderer;
  -
  -    /**
        * The update RunnableQueue.
        */
       protected RunnableQueue updateRunnableQueue;
   
       /**
  -     * The initial time.
  -     */
  -    protected long initialTime;
  -
  -    /**
  -     * The time elapsed in suspended state.
  -     */
  -    protected long suspendedTime;
  -
  -    /**
  -     * The starting time of the current pause.
  -     */
  -    protected long suspendStartTime;
  -
  -    /**
        * Whether the update manager is running.
        */
       protected boolean running;
  @@ -106,11 +86,6 @@
       protected List listeners = Collections.synchronizedList(new LinkedList());
   
       /**
  -     * The starting time.
  -     */
  -    protected long startingTime;
  -
  -    /**
        * The scripting environment.
        */
       protected ScriptingEnvironment scriptingEnvironment;
  @@ -121,11 +96,6 @@
       protected RepaintManager repaintManager;
   
       /**
  -     * The repaint-rate manager.
  -     */
  -    protected RepaintRateManager repaintRateManager;
  -
  -    /**
        * The update tracker.
        */
       protected UpdateTracker updateTracker;
  @@ -179,10 +149,7 @@
           updateRunnableQueue.preemptLater(new Runnable() {
                   public void run() {
                       synchronized (UpdateManager.this) {
  -                        startingTime = System.currentTimeMillis();
  -
                           running = true;
  -                        renderer = r;
           
                           updateTracker = new UpdateTracker();
                           RootGraphicsNode root = graphicsNode.getRoot();
  @@ -192,10 +159,7 @@
                           }
   
                           repaintManager =
  -                            new RepaintManager(UpdateManager.this, renderer);
  -                        repaintRateManager =
  -                            new RepaintRateManager(UpdateManager.this);
  -                        repaintRateManager.start();
  +                            new RepaintManager(r);
   
                           fireManagerStartedEvent();
                           started = true;
  @@ -256,17 +220,6 @@
       }
   
       /**
  -     * Returns the presentation time, in milliseconds.
  -     */
  -    public long getPresentationTime() {
  -        if (running) {
  -            return System.currentTimeMillis() - initialTime - suspendedTime;
  -        } else {
  -            return suspendStartTime - initialTime - suspendedTime;
  -        }
  -    }
  -
  -    /**
        * Suspends the update manager.
        */
       public synchronized void suspend() {
  @@ -298,9 +251,6 @@
                           public void run() {
                               synchronized (UpdateManager.this) {
                                   running = false;
  -                                if (repaintManager != null) {
  -                                    repaintRateManager.interrupt();
  -                                }
                                   scriptingEnvironment.interrupt();
                                   updateRunnableQueue.getThread().interrupt();
                               }
  @@ -321,7 +271,7 @@
               throw new IllegalStateException("UpdateManager not started.");
           }
   
  -        // Invoke first to cancel the pending tasks
  +        // Invoke first to cancel the pending tasksaalder@bsf.ca
           updateRunnableQueue.preemptLater(new Runnable() {
                   public void run() {
                       synchronized (UpdateManager.this) {
  @@ -332,7 +282,6 @@
                               dispatchEvent(evt);
                           running = false;
                       
  -                        repaintRateManager.interrupt();
                           scriptingEnvironment.interrupt();
                           updateRunnableQueue.getThread().interrupt();
                           fireManagerStoppedEvent();
  @@ -343,14 +292,6 @@
       }
   
       /**
  -     * Call this to let the Update Manager know that certain areas
  -     * in the image have been modified and need to be rerendered..
  -     */
  -    public void modifiedAreas(List areas) {
  -        repaintManager.modifiedAreas(areas);
  -    }
  -
  -    /**
        * Updates the rendering buffer.
        * @param u2d The user to device transform.
        * @param dbr Whether the double buffering should be used.
  @@ -362,16 +303,10 @@
                                   Shape aoi,
                                   int width,
                                   int height) {
  -        try {
  -            fireStartedEvent(renderer.getOffScreen());
  -            
  -            List l = repaintManager.updateRendering(u2d, dbr, aoi,
  -                                                    width, height);
  -            
  -            fireCompletedEvent(renderer.getOffScreen(), l);
  -        } catch (Exception e) {
  -            fireFailedEvent();
  -        }
  +        repaintManager.setupRenderer(u2d,dbr,aoi,width,height);
  +        List l = new ArrayList(1);
  +        l.add(aoi);
  +        updateRendering(l);
       }
   
       /**
  @@ -380,17 +315,31 @@
        */
       public void updateRendering(List areas) {
           try {
  -            fireStartedEvent(renderer.getOffScreen());
  +            fireStartedEvent(repaintManager.getOffScreen());
   
               List l = repaintManager.updateRendering(areas);
   
  -            fireCompletedEvent(renderer.getOffScreen(), l);
  +            fireCompletedEvent(repaintManager.getOffScreen(), l);
           } catch (Exception e) {
               fireFailedEvent();
           }
       }
   
       /**
  +     * Repaints the dirty areas, if needed.
  +     */
  +    public void repaint() {
  +        if (updateTracker.hasChanged()) {
  +            List dirtyAreas = updateTracker.getDirtyAreas();
  +            if (dirtyAreas != null) {
  +                updateRendering(dirtyAreas);
  +            }
  +            updateTracker.clear();
  +        }
  +    }
  +
  +
  +    /**
        * Adds a UpdateManagerListener to this UpdateManager.
        */
       public void addUpdateManagerListener(UpdateManagerListener l) {
  @@ -510,7 +459,7 @@
        */
       public void runnableInvoked(RunnableQueue rq, Runnable r) {
           if (running && !(r instanceof NoRepaintRunnable)) {
  -            repaintManager.repaint();
  +            repaint();
           }
       }
   
  @@ -520,7 +469,6 @@
       public void executionSuspended(RunnableQueue rq) {
           if (suspendCalled) {
               running = false;
  -            suspendStartTime = System.currentTimeMillis();
               fireManagerSuspendedEvent();
           }
       }
  @@ -533,7 +481,6 @@
               running = true;
   
               suspendCalled = false;
  -            suspendedTime = System.currentTimeMillis() - suspendStartTime;
               fireManagerResumedEvent();
           }
       }
  
  
  
  1.37      +1 -184    xml-batik/sources/org/apache/batik/gvt/AbstractGraphicsNode.java
  
  Index: AbstractGraphicsNode.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/AbstractGraphicsNode.java,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- AbstractGraphicsNode.java	22 Feb 2002 16:52:09 -0000	1.36
  +++ AbstractGraphicsNode.java	6 Mar 2002 09:06:39 -0000	1.37
  @@ -54,7 +54,7 @@
    * @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
    * @author <a href="mailto:etissandier@ilog.fr">Emmanuel Tissandier</a>
    * @author <a href="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
  - * @version $Id: AbstractGraphicsNode.java,v 1.36 2002/02/22 16:52:09 tkormann Exp $
  + * @version $Id: AbstractGraphicsNode.java,v 1.37 2002/03/06 09:06:39 vhardy Exp $
    */
   public abstract class AbstractGraphicsNode implements GraphicsNode {
   
  @@ -646,189 +646,6 @@
           }
       }
   
  -
  -    /**
  -     * Dispatches the specified event to the interested registered listeners.
  -     *
  -     * @param evt the event to dispatch
  -     */
  -    public void dispatchEvent(GraphicsNodeEvent evt) {
  -        switch(evt.getID()) {
  -        case GraphicsNodeMouseEvent.MOUSE_PRESSED:
  -        case GraphicsNodeMouseEvent.MOUSE_RELEASED:
  -        case GraphicsNodeMouseEvent.MOUSE_MOVED:
  -        case GraphicsNodeMouseEvent.MOUSE_ENTERED:
  -        case GraphicsNodeMouseEvent.MOUSE_EXITED:
  -        case GraphicsNodeMouseEvent.MOUSE_DRAGGED:
  -            processMouseEvent((GraphicsNodeMouseEvent)evt);
  -            break;
  -        case GraphicsNodeKeyEvent.KEY_TYPED:
  -        case GraphicsNodeKeyEvent.KEY_PRESSED:
  -        case GraphicsNodeKeyEvent.KEY_RELEASED:
  -            processKeyEvent((GraphicsNodeKeyEvent)evt);
  -            break;
  -        default:
  -            break;
  -        }
  -    }
  -
  -    /**
  -     * Adds the specified graphics node mouse listener to receive graphics node
  -     * mouse events from this node.
  -     *
  -     * @param l the graphics node mouse listener to add
  -     */
  -    public void addGraphicsNodeMouseListener(GraphicsNodeMouseListener l) {
  -        if (listeners == null) {
  -            listeners = new EventListenerList();
  -        }
  -        listeners.add(GraphicsNodeMouseListener.class, l);
  -    }
  -
  -    /**
  -     * Removes the specified graphics node mouse listener so that it no longer
  -     * receives graphics node mouse events from this node.
  -     *
  -     * @param l the graphics node mouse listener to remove
  -     */
  -    public void removeGraphicsNodeMouseListener(GraphicsNodeMouseListener l) {
  -        if (listeners != null) {
  -            listeners.remove(GraphicsNodeMouseListener.class, l);
  -        }
  -    }
  -
  -    /**
  -     * Adds the specified graphics node key listener to receive graphics node
  -     * key events from this node.
  -     *
  -     * @param l the graphics node key listener to add
  -     */
  -    public void addGraphicsNodeKeyListener(GraphicsNodeKeyListener l) {
  -        if (listeners == null) {
  -            listeners = new EventListenerList();
  -        }
  -        listeners.add(GraphicsNodeKeyListener.class, l);
  -    }
  -
  -    /**
  -     * Removes the specified graphics node key listener so that it no longer
  -     * receives graphics node key events from this node.
  -     *
  -     * @param l the graphics node key listener to remove
  -     */
  -    public void removeGraphicsNodeKeyListener(GraphicsNodeKeyListener l) {
  -        if (listeners != null) {
  -            listeners.remove(GraphicsNodeKeyListener.class, l);
  -        }
  -    }
  -
  -    /**
  -     * Dispatches a graphics node mouse event to this node or one of its child.
  -     *
  -     * @param evt the evt to dispatch
  -     */
  -    public void processMouseEvent(GraphicsNodeMouseEvent evt) {
  -        if ((listeners != null) && acceptEvent(evt)) {
  -            GraphicsNodeMouseListener[] listeners =
  -                (GraphicsNodeMouseListener[])
  -                getListeners(GraphicsNodeMouseListener.class);
  -
  -            switch (evt.getID()) {
  -            case GraphicsNodeMouseEvent.MOUSE_MOVED:
  -                for (int i=0; i<listeners.length; ++i) {
  -                    listeners[i].mouseMoved(evt);
  -                }
  -                break;
  -            case GraphicsNodeMouseEvent.MOUSE_DRAGGED:
  -                for (int i=0; i<listeners.length; ++i) {
  -                    listeners[i].mouseDragged(evt);
  -                }
  -                break;
  -            case GraphicsNodeMouseEvent.MOUSE_ENTERED:
  -                for (int i=0; i<listeners.length; ++i) {
  -                    listeners[i].mouseEntered(evt);
  -                }
  -                break;
  -            case GraphicsNodeMouseEvent.MOUSE_EXITED:
  -                for (int i=0; i<listeners.length; ++i) {
  -                    listeners[i].mouseExited(evt);
  -                }
  -                    break;
  -            case GraphicsNodeMouseEvent.MOUSE_CLICKED:
  -                for (int i=0; i<listeners.length; ++i) {
  -                    listeners[i].mouseClicked(evt);
  -                }
  -                break;
  -            case GraphicsNodeMouseEvent.MOUSE_PRESSED:
  -                for (int i=0; i<listeners.length; ++i) {
  -                    listeners[i].mousePressed(evt);
  -                }
  -                break;
  -            case GraphicsNodeMouseEvent.MOUSE_RELEASED:
  -                for (int i=0; i<listeners.length; ++i) {
  -                    listeners[i].mouseReleased(evt);
  -                }
  -                break;
  -            default:
  -                throw new Error("Unknown Mouse Event type: "+evt.getID());
  -            }
  -        }
  -        evt.consume();
  -    }
  -
  -    /**
  -     * Dispatches a graphics node key event to this node or one of its child.
  -     *
  -     * @param evt the evt to dispatch
  -     */
  -    public void processKeyEvent(GraphicsNodeKeyEvent evt) {
  -        if ((listeners != null) && acceptEvent(evt)) {
  -            GraphicsNodeKeyListener[] listeners =
  -                (GraphicsNodeKeyListener[])
  -                getListeners(GraphicsNodeKeyListener.class);
  -
  -            switch (evt.getID()) {
  -            case GraphicsNodeKeyEvent.KEY_PRESSED:
  -                for (int i=0; i<listeners.length; ++i) {
  -                    listeners[i].keyPressed(evt);
  -                }
  -                break;
  -            case GraphicsNodeKeyEvent.KEY_RELEASED:
  -                for (int i=0; i<listeners.length; ++i) {
  -                    listeners[i].keyReleased(evt);
  -                }
  -                break;
  -            case GraphicsNodeKeyEvent.KEY_TYPED:
  -                for (int i=0; i<listeners.length; ++i) {
  -                    listeners[i].keyTyped(evt);
  -                }
  -                break;
  -            default:
  -                throw new Error("Unknown Key Event type: "+evt.getID());
  -            }
  -        }
  -        evt.consume();
  -    }
  -
  -    /**
  -     * Returns an array of listeners that were added to this node and of the
  -     * specified type.
  -     *
  -     * @param listenerType the type of the listeners to return
  -     */
  -    public EventListener [] getListeners(Class listenerType) {
  -        return listeners.getListeners(listenerType);
  -    }
  -
  -    /**
  -     * Returns true is this node accepts the specified event, false otherwise.
  -     *
  -     * @param evt the event to check
  -     * @return always true at this time
  -     */
  -    protected boolean acceptEvent(GraphicsNodeEvent evt) {
  -        return true;
  -    }
   
       //
       // Structural methods
  
  
  
  1.28      +11 -87    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.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- CompositeGraphicsNode.java	31 Jan 2002 21:57:35 -0000	1.27
  +++ CompositeGraphicsNode.java	6 Mar 2002 09:06:39 -0000	1.28
  @@ -25,15 +25,13 @@
   import java.util.NoSuchElementException;
   import java.util.Vector;
   import javax.swing.event.EventListenerList;
  -import org.apache.batik.gvt.event.CompositeGraphicsNodeEvent;
  -import org.apache.batik.gvt.event.CompositeGraphicsNodeListener;
   import org.apache.batik.gvt.event.GraphicsNodeEvent;
   
   /**
    * A CompositeGraphicsNode is a graphics node that can contain graphics nodes.
    *
    * @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
  - * @version $Id: CompositeGraphicsNode.java,v 1.27 2002/01/31 21:57:35 deweese Exp $
  + * @version $Id: CompositeGraphicsNode.java,v 1.28 2002/03/06 09:06:39 vhardy Exp $
    */
   public class CompositeGraphicsNode extends AbstractGraphicsNode 
       implements List {
  @@ -137,80 +135,6 @@
       // Event support methods
       //
   
  -    /**
  -     * Dispatches the specified event to the interested registered listeners.
  -     *
  -     * @param evt the event to dispatch
  -     */
  -    public void dispatchEvent(GraphicsNodeEvent evt) {
  -        super.dispatchEvent(evt);
  -        switch(evt.getID()) {
  -        case CompositeGraphicsNodeEvent.GRAPHICS_NODE_ADDED:
  -        case CompositeGraphicsNodeEvent.GRAPHICS_NODE_REMOVED:
  -            processCompositeEvent((CompositeGraphicsNodeEvent)evt);
  -            break;
  -        default:
  -            break;
  -        }
  -    }
  -
  -    /**
  -     * Adds the specified composite graphics node listener to receive composite
  -     * graphics node events from this node.
  -     *
  -     * @param l the composite graphics node listener to add 
  -     */
  -    public void addCompositeGraphicsNodeListener
  -	(CompositeGraphicsNodeListener l) {
  -
  -        if (listeners == null) {
  -            listeners = new EventListenerList();
  -        }
  -        listeners.add(CompositeGraphicsNodeListener.class, l);
  -    }
  -
  -    /**
  -     * Removes the specified composite graphics node listener so that it no
  -     * longer receives composite graphics node events from this node.
  -     *
  -     * @param l the composite graphics node listener to remove 
  -     */
  -    public void removeCompositeGraphicsNodeListener
  -	(CompositeGraphicsNodeListener l) {
  -
  -        if (listeners != null) {
  -            listeners.remove(CompositeGraphicsNodeListener.class, l);
  -        }
  -    }
  -
  -    /**
  -     * Processes a composite event occuring on this graphics node.
  -     *
  -     * @param evt the event to process
  -     */
  -   public void processCompositeEvent(CompositeGraphicsNodeEvent evt) {
  -        if ((listeners != null) && acceptEvent(evt)) {
  -            CompositeGraphicsNodeListener [] listeners =
  -                (CompositeGraphicsNodeListener[])
  -                getListeners(CompositeGraphicsNodeListener.class);
  -
  -            switch (evt.getID()) {
  -            case CompositeGraphicsNodeEvent.GRAPHICS_NODE_ADDED:
  -                for (int i=0; i<listeners.length; ++i) {
  -                    listeners[i].graphicsNodeAdded(evt);
  -                }
  -                break;
  -            case CompositeGraphicsNodeEvent.GRAPHICS_NODE_REMOVED:
  -                for (int i=0; i<listeners.length; ++i) {
  -                    listeners[i].graphicsNodeRemoved(evt);
  -                }
  -                break;
  -            default:
  -                throw new Error("Unknown Composite Event type: "+evt.getID());
  -            }
  -        }
  -        evt.consume();
  -    }
   
       //
       // Geometric methods
  @@ -567,10 +491,10 @@
           // Invalidates cached values
           invalidateGeometryCache();
           // Create and dispatch events
  -        int id = CompositeGraphicsNodeEvent.GRAPHICS_NODE_REMOVED;
  -        dispatchEvent(new CompositeGraphicsNodeEvent(this, id, oldNode));
  -        id = CompositeGraphicsNodeEvent.GRAPHICS_NODE_ADDED;
  -        dispatchEvent(new CompositeGraphicsNodeEvent(this, id, node));
  +        // int id = CompositeGraphicsNodeEvent.GRAPHICS_NODE_REMOVED;
  +        // dispatchEvent(new CompositeGraphicsNodeEvent(this, id, oldNode));
  +        // id = CompositeGraphicsNodeEvent.GRAPHICS_NODE_ADDED;
  +        // dispatchEvent(new CompositeGraphicsNodeEvent(this, id, node));
           fireGraphicsNodeChangeCompleted();
           return oldNode;
        }
  @@ -604,8 +528,8 @@
           // Invalidates cached values
           invalidateGeometryCache();
           // Create and dispatch event
  -        int id = CompositeGraphicsNodeEvent.GRAPHICS_NODE_ADDED;
  -        dispatchEvent(new CompositeGraphicsNodeEvent(this, id, node));
  +        // int id = CompositeGraphicsNodeEvent.GRAPHICS_NODE_ADDED;
  +        // dispatchEvent(new CompositeGraphicsNodeEvent(this, id, node));
           fireGraphicsNodeChangeCompleted();
           return true;
       }
  @@ -650,8 +574,8 @@
           // Invalidates cached values
           invalidateGeometryCache();
           // Create and dispatch event
  -        int id = CompositeGraphicsNodeEvent.GRAPHICS_NODE_ADDED;
  -        dispatchEvent(new CompositeGraphicsNodeEvent(this, id, node));
  +        // int id = CompositeGraphicsNodeEvent.GRAPHICS_NODE_ADDED;
  +        // dispatchEvent(new CompositeGraphicsNodeEvent(this, id, node));
           fireGraphicsNodeChangeCompleted();
       }
   
  @@ -726,8 +650,8 @@
           // Invalidates cached values
           invalidateGeometryCache();
           // Create and dispatch event
  -        int id = CompositeGraphicsNodeEvent.GRAPHICS_NODE_REMOVED;
  -        dispatchEvent(new CompositeGraphicsNodeEvent(this, id, oldNode));
  +        // int id = CompositeGraphicsNodeEvent.GRAPHICS_NODE_REMOVED;
  +        // dispatchEvent(new CompositeGraphicsNodeEvent(this, id, oldNode));
           fireGraphicsNodeChangeCompleted();
           return oldNode;
       }
  
  
  
  1.34      +9 -9      xml-batik/sources/org/apache/batik/gvt/GraphicsNode.java
  
  Index: GraphicsNode.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/GraphicsNode.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- GraphicsNode.java	23 Jan 2002 14:14:08 -0000	1.33
  +++ GraphicsNode.java	6 Mar 2002 09:06:39 -0000	1.34
  @@ -35,7 +35,7 @@
    *
    * @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
    * @author <a href="mailto:etissandier@ilog.fr">Emmanuel Tissandier</a>
  - * @version $Id: GraphicsNode.java,v 1.33 2002/01/23 14:14:08 deweese Exp $
  + * @version $Id: GraphicsNode.java,v 1.34 2002/03/06 09:06:39 vhardy Exp $
    */
   public interface GraphicsNode {
   
  @@ -276,7 +276,7 @@
        * Dispatches the specified event to the interested registered listeners.
        * @param evt the event to dispatch
        */
  -    void dispatchEvent(GraphicsNodeEvent evt);
  +    // void dispatchEvent(GraphicsNodeEvent evt);
   
       /**
        * Adds the specified graphics node mouse listener to receive graphics node
  @@ -284,7 +284,7 @@
        *
        * @param l the graphics node mouse listener to add
        */
  -    void addGraphicsNodeMouseListener(GraphicsNodeMouseListener l);
  +    // void addGraphicsNodeMouseListener(GraphicsNodeMouseListener l);
   
       /**
        * Removes the specified graphics node mouse listener so that it no longer
  @@ -292,7 +292,7 @@
        *
        * @param l the graphics node mouse listener to remove
        */
  -    void removeGraphicsNodeMouseListener(GraphicsNodeMouseListener l);
  +    // void removeGraphicsNodeMouseListener(GraphicsNodeMouseListener l);
   
       /**
        * Adds the specified graphics node key listener to receive graphics node
  @@ -300,7 +300,7 @@
        *
        * @param l the graphics node key listener to add
        */
  -    void addGraphicsNodeKeyListener(GraphicsNodeKeyListener l);
  +    // void addGraphicsNodeKeyListener(GraphicsNodeKeyListener l);
   
       /**
        * Removes the specified graphics node key listener so that it no longer
  @@ -308,21 +308,21 @@
        *
        * @param l the graphics node key listener to remove
        */
  -    void removeGraphicsNodeKeyListener(GraphicsNodeKeyListener l);
  +    // void removeGraphicsNodeKeyListener(GraphicsNodeKeyListener l);
   
       /**
        * Dispatches a graphics node mouse event to this node or one of its child.
        *
        * @param evt the evt to dispatch
        */
  -    void processMouseEvent(GraphicsNodeMouseEvent evt);
  +    // void processMouseEvent(GraphicsNodeMouseEvent evt);
   
       /**
        * Dispatches a graphics node key event to this node or one of its child.
        *
        * @param evt the evt to dispatch
        */
  -    void processKeyEvent(GraphicsNodeKeyEvent evt);
  +    // void processKeyEvent(GraphicsNodeKeyEvent evt);
   
       /**
        * Returns an array of listeners that were added to this node and of the
  @@ -330,7 +330,7 @@
        *
        * @param listenerType the type of the listeners to return
        */
  -    EventListener [] getListeners(Class listenerType);
  +    // EventListener [] getListeners(Class listenerType);
   
       //
       // Structural methods
  
  
  
  1.10      +30 -12    xml-batik/sources/org/apache/batik/gvt/UpdateTracker.java
  
  Index: UpdateTracker.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/UpdateTracker.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- UpdateTracker.java	19 Feb 2002 18:01:29 -0000	1.9
  +++ UpdateTracker.java	6 Mar 2002 09:06:39 -0000	1.10
  @@ -29,7 +29,7 @@
    * This class tracks the changes on a GVT tree
    *
    * @author <a href="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
  - * @version $Id: UpdateTracker.java,v 1.9 2002/02/19 18:01:29 deweese Exp $
  + * @version $Id: UpdateTracker.java,v 1.10 2002/03/06 09:06:39 vhardy Exp $
    */
   public class UpdateTracker extends GraphicsNodeChangeAdapter {
   
  @@ -50,8 +50,6 @@
        * Returns the list of dirty areas on GVT.
        */
       public List getDirtyAreas() {
  -        // System.out.println("Getting dirty areas");
  -
           if (dirtyNodes == null) 
               return null;
   
  @@ -75,6 +73,11 @@
   
               Rectangle2D srcNRgn = gn.getBounds();
               AffineTransform nat = gn.getTransform();
  +
  +            if (nat != null){
  +                nat = (nat == null) ? null : new AffineTransform(nat);
  +            }
  +
               nodeBounds.put(gnWRef, srcNRgn); // remember the new bounds...
               // System.out.println("Rgns: " + srcORgn + " - " + srcNRgn);
               // System.out.println("ATs: " + oat + " - " + nat);
  @@ -82,37 +85,43 @@
               Shape nRgn = srcNRgn;
   
               do {
  -                Filter f;
  -                f = gn.getGraphicsNodeRable(false);
  +                // Filter f;
  +                // f = gn.getGraphicsNodeRable(false);
                   // f.invalidateCache(oRng);
                   // f.invalidateCache(nRng);
   
  -                f = gn.getEnableBackgroundGraphicsNodeRable(false);
  +                // f = gn.getEnableBackgroundGraphicsNodeRable(false);
                   // (need to push rgn through filter chain if any...)
                   // f.invalidateCache(oRng);
                   // f.invalidateCache(nRng);
   
                   gn = gn.getParent();
  -                if (gn == null) break;
  -                if (dirtyNodes.get(gn.getWeakReference()) != null) break;
  +                if (gn == null)
  +                    break; // We reached the top of the tree
  +
  +                if (dirtyNodes.get(gn.getWeakReference()) != null) 
  +                    break; // We already have the parent in the list of
  +                           // dirty nodes. The following if (gn == null)
  +                           // makes sure we do not add this child's 
  +                           // dirty areas.
   
                   AffineTransform at = gn.getTransform();
   
                   if (oat != null){
  -                    oRgn = oat.createTransformedShape(srcORgn);
  +                    // oRgn = oat.createTransformedShape(srcORgn);
                       if (at != null){
                           oat.preConcatenate(at);
                       }
                   } else {
  -                    oat = at;
  +                    oat = (at == null) ? null : new AffineTransform(at);
                   }
                   if (nat != null){
  -                    nRgn = nat.createTransformedShape(srcNRgn);
  +                    //  nRgn = nat.createTransformedShape(srcNRgn);
                       if (at != null){
                           nat.preConcatenate(at);
                       }
                   } else {
  -                    nat = at;
  +                    nat = (at == null) ? null : new AffineTransform(at);
                   }
   
               } while (true);
  @@ -123,7 +132,16 @@
                   //     ("Adding: " + oat + " - " + nat + "\n" +
                   //      org.ImageDisplay.stringShape(oRgn) + "\n" +
                   //      org.ImageDisplay.stringShape(nRgn) + "\n");
  +                // <!>
  +                if (oat != null){
  +                    oRgn = oat.createTransformedShape(srcORgn);
  +                }
  +                if (nat != null){
  +                    nRgn = nat.createTransformedShape(srcNRgn);
  +                }
  +
                   ret.add(oRgn);
  +
                   if (nRgn != null) {
                       ret.add(nRgn);
                   }
  
  
  
  1.6       +42 -29    xml-batik/sources/org/apache/batik/gvt/event/AWTEventDispatcher.java
  
  Index: AWTEventDispatcher.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/event/AWTEventDispatcher.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- AWTEventDispatcher.java	17 Sep 2001 16:28:26 -0000	1.5
  +++ AWTEventDispatcher.java	6 Mar 2002 09:06:39 -0000	1.6
  @@ -39,7 +39,7 @@
    * @author <a href="bill.haneman@ireland.sun.com>Bill Haneman</a>
    * @author <a href="cjolif@ilog.fr>Christophe Jolif</a>
    * @author <a href="tkormann@ilog.fr>Thierry Kormann</a>
  - * @version $Id: AWTEventDispatcher.java,v 1.5 2001/09/17 16:28:26 tkormann Exp $
  + * @version $Id: AWTEventDispatcher.java,v 1.6 2002/03/06 09:06:39 vhardy Exp $
    */
   public class AWTEventDispatcher implements EventDispatcher,
                                              MouseListener,
  @@ -270,29 +270,6 @@
       }
   
       /**
  -     * Adds the specified 'global' GraphicsNodeFocusListener which is
  -     * notified of all FocusEvents dispatched.
  -     * @param l the listener to add
  -     */
  -    public void addGraphicsNodeFocusListener(GraphicsNodeFocusListener l) {
  -        if (glisteners == null) {
  -            glisteners = new EventListenerList();
  -        }
  -        glisteners.add(GraphicsNodeFocusListener.class, l);
  -    }
  -
  -    /**
  -     * Removes the specified 'global' GraphicsNodeFocusListener which is
  -     * notified of all FocusEvents dispatched.
  -     * @param l the listener to remove
  -     */
  -    public void removeGraphicsNodeFocusListener(GraphicsNodeFocusListener l) {
  -        if (glisteners != null) {
  -            glisteners.remove(GraphicsNodeFocusListener.class, l);
  -        }
  -    }
  -
  -    /**
        * Returns an array of listeners that were added to this event
        * dispatcher and of the specified type.
        * @param listenerType the type of the listeners to return
  @@ -342,7 +319,7 @@
        */
       protected void dispatchKeyEvent(KeyEvent evt) {
           if (currentKeyEventTarget != null) {
  -            currentKeyEventTarget.processKeyEvent
  +            processKeyEvent
                   (new GraphicsNodeKeyEvent(currentKeyEventTarget,
                                             evt.getID(),
                                             evt.getWhen(),
  @@ -351,7 +328,7 @@
                                             evt.getKeyChar()));
           }
       }
  -
  +    
       /**
        * Dispatches the specified AWT mouse event.
        * @param evt the mouse event to dispatch
  @@ -389,7 +366,7 @@
                                                       evt.getClickCount(),
                                                       node);
                   processMouseEvent(gvtevt);
  -                lastHit.processMouseEvent(gvtevt);
  +                // lastHit.processMouseEvent(gvtevt);
               }
               // post an MOUSE_ENTERED
               if (node != null) {
  @@ -405,7 +382,7 @@
                                                       getClickCount(),
                                                       lastHit);
                   processMouseEvent(gvtevt);
  -                node.processMouseEvent(gvtevt);
  +                // node.processMouseEvent(gvtevt);
               }
           }
           // In all cases, dispatch the original event
  @@ -419,7 +396,7 @@
                                                   evt.getClickCount(),
                                                   relatedNode);
   
  -            node.processMouseEvent(gvtevt);
  +            // node.processMouseEvent(gvtevt);
               processMouseEvent(gvtevt);
   
           } else if (node == null && evt.getID() == evt.MOUSE_CLICKED
  @@ -510,6 +487,42 @@
               }
           }
       }
  +
  +    /**
  +     * Dispatches a graphics node key event to by firing the 'global'
  +     * listeners attached to this event dispatcher.
  +     *
  +     * @param evt the evt to dispatch
  +     */
  +    public void processKeyEvent(GraphicsNodeKeyEvent evt) {
  +        if ((glisteners != null)) {
  +            GraphicsNodeKeyListener[] listeners =
  +                (GraphicsNodeKeyListener[])
  +                getListeners(GraphicsNodeKeyListener.class);
  +
  +            switch (evt.getID()) {
  +            case GraphicsNodeKeyEvent.KEY_PRESSED:
  +                for (int i=0; i<listeners.length; ++i) {
  +                    listeners[i].keyPressed(evt);
  +                }
  +                break;
  +            case GraphicsNodeKeyEvent.KEY_RELEASED:
  +                for (int i=0; i<listeners.length; ++i) {
  +                    listeners[i].keyReleased(evt);
  +                }
  +                break;
  +            case GraphicsNodeKeyEvent.KEY_TYPED:
  +                for (int i=0; i<listeners.length; ++i) {
  +                    listeners[i].keyTyped(evt);
  +                }
  +                break;
  +            default:
  +                throw new Error("Unknown Key Event type: "+evt.getID());
  +            }
  +        }
  +        evt.consume();
  +    }
  +
   
       private void incrementKeyTarget() {
           // <!> FIXME TODO: Not implemented.
  
  
  
  1.3       +1 -15     xml-batik/sources/org/apache/batik/gvt/event/EventDispatcher.java
  
  Index: EventDispatcher.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/event/EventDispatcher.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- EventDispatcher.java	29 Jan 2001 10:28:14 -0000	1.2
  +++ EventDispatcher.java	6 Mar 2002 09:06:39 -0000	1.3
  @@ -24,7 +24,7 @@
    *
    * @author <a href="bill.haneman@ireland.sun.com>Bill Haneman</a>
    * @author <a href="tkormann@ilog.fr>Thierry Kormann</a>
  - * @version $Id: EventDispatcher.java,v 1.2 2001/01/29 10:28:14 tkormann Exp $ */
  + * @version $Id: EventDispatcher.java,v 1.3 2002/03/06 09:06:39 vhardy Exp $ */
   public interface EventDispatcher {
   
       /**
  @@ -97,20 +97,6 @@
        * @param l the listener to remove
        */
       void removeGraphicsNodeKeyListener(GraphicsNodeKeyListener l);
  -
  -    /**
  -     * Adds the specified 'global' GraphicsNodeFocusListener which is
  -     * notified of all FocusEvents dispatched.
  -     * @param l the listener to add
  -     */
  -    void addGraphicsNodeFocusListener(GraphicsNodeFocusListener l);
  -
  -    /**
  -     * Removes the specified 'global' GraphicsNodeFocusListener which is
  -     * notified of all FocusEvents dispatched.
  -     * @param l the listener to remove
  -     */
  -    void removeGraphicsNodeFocusListener(GraphicsNodeFocusListener l);
   
       /**
        * Returns an array of listeners that were added to this event
  
  
  
  1.45      +12 -1     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.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- JSVGComponent.java	25 Feb 2002 15:05:33 -0000	1.44
  +++ JSVGComponent.java	6 Mar 2002 09:06:39 -0000	1.45
  @@ -180,7 +180,7 @@
    * building/rendering a document (invalid XML file, missing attributes...).</p>
    *
    * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
  - * @version $Id: JSVGComponent.java,v 1.44 2002/02/25 15:05:33 hillion Exp $
  + * @version $Id: JSVGComponent.java,v 1.45 2002/03/06 09:06:39 vhardy Exp $
    */
   public class JSVGComponent extends JGVTComponent {
   
  @@ -1170,6 +1170,17 @@
            */
           public void updateCompleted(final UpdateManagerEvent e) {
               try {
  +                //
  +                // IMPORTANT:
  +                // ==========
  +                //
  +                // The following call is 'invokeAndWait' and not 'invokeLater'
  +                // because it is essential that the UpdateManager thread (which
  +                // invokes this 'updateCompleted' method, blocks until the 
  +                // repaint has completed. Otherwise, there is a possibility that
  +                // internal buffers would get updated in the middle of a swing
  +                // repaint.
  +                //
                   EventQueue.invokeAndWait(new Runnable() {
                           public void run() {
                               image = e.getImage();
  
  
  
  1.2       +5 -2      xml-batik/test-sources/org/apache/batik/svggen/JPainterComponent.java
  
  Index: JPainterComponent.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/test-sources/org/apache/batik/svggen/JPainterComponent.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JPainterComponent.java	18 Sep 2001 10:55:55 -0000	1.1
  +++ JPainterComponent.java	6 Mar 2002 09:06:39 -0000	1.2
  @@ -10,6 +10,7 @@
   
   import java.awt.*;
   import java.awt.geom.*;
  +import java.awt.image.*;
   import javax.swing.JComponent;
   import javax.swing.JFrame;
   
  @@ -18,7 +19,7 @@
    * a <tt>Painter</tt>.
    *
    * @author <a href="mailto:vincent.hardy@sun.com">Vincent Hardy</a>
  - * @version $Id: JPainterComponent.java,v 1.1 2001/09/18 10:55:55 vhardy Exp $
  + * @version $Id: JPainterComponent.java,v 1.2 2002/03/06 09:06:39 vhardy Exp $
    */
   public class JPainterComponent extends JComponent {
       /**
  @@ -31,7 +32,9 @@
        */
       public void paint(Graphics _g){
           Graphics2D g = (Graphics2D)_g;
  -        painter.paint(g);
  +        BufferedImage buf = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB);
  +        painter.paint(buf.createGraphics());
  +        g.drawImage(buf, 0, 0, null);
       }
   
       /**
  
  
  

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


Mime
View raw message