pbwest      2004/07/24 10:01:50

  Modified:    src/java/org/apache/fop/area Tag: FOP_0-20-0_Alt-Design
                        SpacesRectangle.java
  Log:
  Added registerAreaListener() and notifyListeners to allow AllocationRectangle 
objects to register interest in size modifications to spaces
  Override setContents() to call notifyListeners() to update any dependent 
AllocationRectangles
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.1.2.6   +40 -2     xml-fop/src/java/org/apache/fop/area/Attic/SpacesRectangle.java
  
  Index: SpacesRectangle.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/area/Attic/SpacesRectangle.java,v
  retrieving revision 1.1.2.5
  retrieving revision 1.1.2.6
  diff -u -r1.1.2.5 -r1.1.2.6
  --- SpacesRectangle.java      14 Jun 2004 08:53:46 -0000      1.1.2.5
  +++ SpacesRectangle.java      24 Jul 2004 17:01:50 -0000      1.1.2.6
  @@ -21,6 +21,9 @@
   
   import java.awt.geom.Point2D;
   import java.awt.geom.Rectangle2D;
  +import java.util.ArrayList;
  +
  +import org.apache.fop.area.Area.AreaGeometry;
   
   /**
    * @author pbw
  @@ -51,5 +54,40 @@
               BorderRectangle contents, Point2D contentOffset) {
                super(area, rect, contents, contentOffset);
        }
  +
  +    public void setContents(AreaGeometry contents) {
  +        super.setContents(contents);
  +        notifyListeners(this);
  +    }
  +
  +    /** Initial size of the <code>listeners</code> array */
  +    private static final int INITIAL_SPACES_LISTENER_SIZE = 1;
  +    /** Array of registered <code>AreaListener</code>s */
  +    private ArrayList listeners = null;
  +    /**
  +     * Registers a listener to be notified on any change of dimension in the
  +     * <code>spaces</code> <code>AreaFrame</code>. 
  +     * @param listener to be notified
  +     */
  +    public void registerAreaListener(AreaListener listener) {
  +        synchronized (this) {
  +            if (listeners == null) {
  +                listeners = new ArrayList(INITIAL_SPACES_LISTENER_SIZE);
  +            }
  +            listeners.add(listener);
  +        }
  +    }
  +
  +    /**
  +     * Notifies any registered listener of a change of dimensions in the
  +     * <code>Rectangle2D</code> content
  +     */
  +    protected void notifyListeners(Area.AreaGeometry geometry) {
  +        for (int i = 0; i < listeners.size(); i++) {
  +            synchronized (this) {
  +                ((AreaListener)(listeners.get(i))).setDimensions(geometry);
  +            }
  +        }
  +    }
   
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to