pbwest      2004/07/07 15:18:29

  Modified:    src/java/org/apache/fop/area Tag: FOP_0-20-0_Alt-Design
                        PaddingRectangle.java Area.java DimensionDbl.java
                        AbstractReferenceArea.java AreaFrame.java
  Log:
  W.I.P.
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.1.2.6   +6 -2      xml-fop/src/java/org/apache/fop/area/Attic/PaddingRectangle.java
  
  Index: PaddingRectangle.java
  ===================================================================
  RCS file: 
/home/cvs/xml-fop/src/java/org/apache/fop/area/Attic/PaddingRectangle.java,v
  retrieving revision 1.1.2.5
  retrieving revision 1.1.2.6
  diff -u -r1.1.2.5 -r1.1.2.6
  --- PaddingRectangle.java     14 Jun 2004 08:53:46 -0000      1.1.2.5
  +++ PaddingRectangle.java     7 Jul 2004 22:18:29 -0000       1.1.2.6
  @@ -28,6 +28,10 @@
    */
   public class PaddingRectangle extends AreaFrame {
   
  +    private static final String tag = "$Name$";
  +    private static final String revision = "$Revision$";
  +
  +
       public PaddingRectangle(Area area, Area.AreaGeometry content) {
           super(area, content);
           borders = new BorderRectangle(area, this);
  
  
  
  1.1.2.24  +94 -2     xml-fop/src/java/org/apache/fop/area/Area.java
  
  Index: Area.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/area/Area.java,v
  retrieving revision 1.1.2.23
  retrieving revision 1.1.2.24
  diff -u -r1.1.2.23 -r1.1.2.24
  --- Area.java 6 Jul 2004 14:16:25 -0000       1.1.2.23
  +++ Area.java 7 Jul 2004 22:18:29 -0000       1.1.2.24
  @@ -19,6 +19,7 @@
   package org.apache.fop.area;
   
   import java.awt.geom.AffineTransform;
  +import java.awt.geom.Point2D;
   import java.awt.geom.Rectangle2D;
   import java.util.ArrayList;
   
  @@ -255,6 +256,97 @@
       }
   
       /**
  +     * Returns a <code>Rectangle2D</code> constructed from the normailized
  +     * values of offset and dimensions expressed in terms of 
  +     * <i>inline-progression-direction</i> and
  +     * <i>block-progression-direction</i>
  +     * @param ipOffset
  +     * @param bpOffset
  +     * @param ipDim the <i>inline-progression-dimension</i>
  +     * @param bpDim the <i>block-progression-dimension</i>
  +     * @param wMode
  +     * @return
  +     * @throws PropertyException
  +     */
  +    public static Rectangle2D.Double rectRelToAbs(
  +            double ipOffset, double bpOffset, double ipDim, double bpDim,
  +            int wMode) throws PropertyException {
  +        if (WritingMode.isHorizontal(wMode)) {
  +            return new Rectangle2D.Double(ipOffset, bpOffset, ipDim, bpDim);
  +        }
  +        return new Rectangle2D.Double(bpOffset, ipOffset, bpDim, ipDim);
  +    }
  +
  +    /**
  +     * Normalizes a pair of values representing an
  +     * <i>inline-progression-dimension</i> and a
  +     * <i>block-progression-dimension</i> by converting them to a
  +     * <i>Point2D</i> representing the corresponding X and Y values in
  +     * Java 2D user co-ordinates.
  +     * @param ipDim the <i>inline-progression-dimension</i>
  +     * @param bpDim the <i>block-progression-dimension</i>
  +     * @param writingMode
  +     * @return the corresponding x, y values
  +     * @throws PropertyException
  +     */
  +    public static DimensionDbl dimsRelToAbs (
  +            double ipDim, double bpDim, int writingMode)
  +    throws PropertyException {
  +        if (WritingMode.isHorizontal(writingMode)) {
  +            return new DimensionDbl(ipDim, bpDim);
  +        }
  +        return new DimensionDbl(bpDim, ipDim);
  +    }
  +
  +    /**
  +     * Normalizes a <code>DimensonDbl</code> representing an
  +     * <i>inline-progression-dimension</i> (<i>width</i>) and a
  +     * <i>block-progression-dimension</i> (<i>height</i>) by converting them to
  +     * a <code>DimensonDbl</code> representing the corresponding width and
  +     * height values in Java 2D user co-ordinates.
  +     * @param in the dimensions expressed as <i>inline-progression-dimension</i>
  +     * and <i>block-progression-dimension</i>
  +     * @param writingMode
  +     * @return the corresponding Java2D width, height values
  +     * @throws PropertyException
  +     */
  +    public static DimensionDbl dimsRelToAbs (DimensionDbl in, int writingMode)
  +    throws PropertyException {
  +        if (WritingMode.isHorizontal(writingMode)) {
  +            return in;
  +        }
  +        double width, height;
  +        width = in.getHeight();
  +        height = in.getWidth();
  +        in.setSize(width, height);
  +        return in;
  +    }
  +
  +    /**
  +     * Returns a <code>Rectangle2D</code> constructed from the normailized
  +     * values of offset and dimensions expressed in terms of 
  +     * <i>inline-progression-direction</i> and
  +     * <i>block-progression-direction</i>
  +     * @param offset
  +     * @param wideHigh
  +     * @param writingMode
  +     * @return
  +     * @throws PropertyException
  +     */
  +    public static Rectangle2D dimsRelToAbs (
  +            Point2D offset, DimensionDbl wideHigh, int writingMode)
  +    throws PropertyException {
  +        if (WritingMode.isHorizontal(writingMode)) {
  +            return new Rectangle2D.Double(
  +                    offset.getX(), offset.getY(),
  +                    wideHigh.getWidth(), wideHigh.getHeight());
  +        }
  +        return new Rectangle2D.Double(
  +                offset.getY(), offset.getX(),
  +                wideHigh.getHeight(), wideHigh.getWidth());
  +    }
  +
  +    /**
        * A nested class of Area, representing the geometry of one of the frames
        * associated with this area.  These include the content-rectangle,
        * border-rectangle, padding-rectangle, spaces-rectangle and
  @@ -308,7 +400,7 @@
               try {
                   // TODO move rectRelToAbs from WritingMode to a more suitable
                   // place
  -                setRect(WritingMode.rectRelToAbs(
  +                setRect(rectRelToAbs(
                           ipOrigin, bpOrigin, ipDim, bpDim, writingMode));
               } catch (PropertyException e) {
                   throw new RuntimeException(e);
  @@ -349,7 +441,7 @@
                   double ipOrigin, double bpOrigin, double ipDim, double bpDim) {
               // Now work out what belongs where
               try {
  -                setRect(WritingMode.rectRelToAbs(
  +                setRect(rectRelToAbs(
                           ipOrigin, bpOrigin, ipDim, bpDim, writingMode));
               } catch (PropertyException e) {
                   throw new RuntimeException(e);
  
  
  
  1.1.2.2   +5 -2      xml-fop/src/java/org/apache/fop/area/Attic/DimensionDbl.java
  
  Index: DimensionDbl.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/area/Attic/DimensionDbl.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- DimensionDbl.java 6 Jul 2004 14:26:45 -0000       1.1.2.1
  +++ DimensionDbl.java 7 Jul 2004 22:18:29 -0000       1.1.2.2
  @@ -28,6 +28,9 @@
    */
   public class DimensionDbl extends Dimension2D {
   
  +    private static final String tag = "$Name$";
  +    private static final String revision = "$Revision$";
  +
       private double width = 0.0;
       private double height = 0.0;
   
  
  
  
  1.1.2.7   +5 -2      
xml-fop/src/java/org/apache/fop/area/Attic/AbstractReferenceArea.java
  
  Index: AbstractReferenceArea.java
  ===================================================================
  RCS file: 
/home/cvs/xml-fop/src/java/org/apache/fop/area/Attic/AbstractReferenceArea.java,v
  retrieving revision 1.1.2.6
  retrieving revision 1.1.2.7
  diff -u -r1.1.2.6 -r1.1.2.7
  --- AbstractReferenceArea.java        17 Jun 2004 11:33:06 -0000      1.1.2.6
  +++ AbstractReferenceArea.java        7 Jul 2004 22:18:29 -0000       1.1.2.7
  @@ -34,6 +34,9 @@
       extends Area
       implements ReferenceArea {
   
  +    private static final String tag = "$Name$";
  +    private static final String revision = "$Revision$";
  +
       // Set up as identity matrix
       protected AffineTransform transformer = new AffineTransform();
   
  
  
  
  1.1.2.10  +57 -32    xml-fop/src/java/org/apache/fop/area/Attic/AreaFrame.java
  
  Index: AreaFrame.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/area/Attic/AreaFrame.java,v
  retrieving revision 1.1.2.9
  retrieving revision 1.1.2.10
  diff -u -r1.1.2.9 -r1.1.2.10
  --- AreaFrame.java    6 Jul 2004 14:19:26 -0000       1.1.2.9
  +++ AreaFrame.java    7 Jul 2004 22:18:29 -0000       1.1.2.10
  @@ -35,30 +35,41 @@
    */
   public class AreaFrame extends AreaGeometry {
   
  +    private static final String tag = "$Name$";
  +    private static final String revision = "$Revision$";
  +
  +
       /** The framed rectangle */
  -    protected AreaGeometry contents = null;
  +    protected AreaGeometry contents;
       /** The offset from <code>this</code> origin to the origin of the framed
        * rectangle */
  -    protected Point2D contentOffset = null;
  -
  -    /**
  -     * Instantiates an <code>AreaFrame</code> with zero dimensions and offset,
  -     * whose contents and contentOffset are null
  -     * @param area the <code>Area</code> on which this <code>AreaFrame</code>
  -     * is being defined
  -     */
  -    public AreaFrame(Area area) {
  -        area.super(area.frameWritingMode);
  -        // contents and contentOffset remain null
  -    }
  -
  -    /**
  -     * Contents and offset remain null
  -     */
  -    public AreaFrame(Area area,
  -            double ipOrigin, double bpOrigin, double ipDim, double bpDim) {
  -        area.super(area.frameWritingMode, ipOrigin, bpOrigin, ipDim, bpDim);
  -    }
  +    protected Point2D contentOffset = new Point2D.Double();
  +//
  +//    /**
  +//     * Instantiates an <code>AreaFrame</code> with zero dimensions and offset,
  +//     * with <code>contents</code> of zero dimensions and contentOffsets of
  +//     * zero.  The <i>writing-mode</i> and <i>reference-orientation</i> are
  +//     * assumed to be the same as the containing frame.
  +//     * @param area the <code>Area</code> on which this <code>AreaFrame</code>
  +//     * is being defined
  +//     */
  +//    public AreaFrame(Area area) {
  +//        area.super(area.frameWritingMode);
  +//        contents = area.new AreaGeometry(area.frameWritingMode);
  +//        contentOffset = new Point2D.Double();
  +//    }
  +
  +//    /**
  +//     * Instantiates an <code>AreaFrame</code> with the given relative
  +//     * origin and dimensions, with 
  +//     * Contents and offset remain null
  +//     */
  +//    public AreaFrame(Area area,
  +//            double ipOrigin, double bpOrigin, double ipDim, double bpDim) {
  +//        area.super(area.frameWritingMode, ipOrigin, bpOrigin, ipDim, bpDim);
  +//        contents = area.new AreaGeometry(area.frameWritingMode);
  +//        contentOffset = new Point2D.Double();
  +//    }
   
       /**
        * Instantiates a frame with 0-width edges around the given
  @@ -67,8 +78,9 @@
        */
       public AreaFrame(Area area, AreaGeometry contents) {
           area.super(area.frameWritingMode);
  -        setRect(contents);
  -        this.contents = contents;
  +        // TODO - check that this can be eliminated
  +        //setRect(contents);
  +        setContents(contents);
           this.contentOffset = new Point2D.Double();
       }
   
  @@ -91,7 +103,9 @@
               double ipOrigin, double bpOrigin, double ipDim, double bpDim,
               AreaGeometry contents, Point2D contentOffset) {
           area.super(area.frameWritingMode, ipOrigin, bpOrigin, ipDim,  bpDim);
  -        this.contents = contents;
  +        // TODO check this against the handling of the contents rectangle
  +        // Should this initialize with the contents and then set the edges? 
  +        setContents(contents);
           this.contentOffset = contentOffset;
       }
   
  @@ -110,21 +124,31 @@
               Rectangle2D rect, AreaGeometry contents,
               Point2D contentOffset) {
           area.super(area.frameWritingMode, rect);
  -        this.contents = contents;
  +        setContents(contents);
           this.contentOffset = contentOffset;
       }
   
       /**
  -     * Sets the contents rectangle.  The dimensions of <code>this</code> are
  +     * Sets the contents rectangle to the given <code>AreaFrame</code>.
  +     * The dimensions of <code>this</code> are
        * adjusted to the difference between the current framed contents and
        * the new framed contents.  The offset is not affected.
        * @param contents the new framed contents
        */
       public void setContents(AreaGeometry contents) {
  +        if (this.contents == null) {
  +            setRect(getX(), getY(),
  +                    getWidth() + contents.getFrameRelativeWidth(),
  +                    getHeight() + contents.getFrameRelativeHeight());
  +        }
           setRect(getX(), getY(),
  -                getWidth() + (contents.getWidth() - this.contents.getWidth()),
  -                getHeight() + (contents.getWidth() - this.contents.getWidth()));
  -        contents = this.contents;
  +                getWidth() + (
  +                        contents.getFrameRelativeWidth() -
  +                        this.contents.getFrameRelativeWidth()),
  +                getHeight() + (
  +                        contents.getFrameRelativeHeight() -
  +                        this.contents.getFrameRelativeHeight()));
  +        this.contents = contents;
       }
   
       public Rectangle2D getContents() {
  @@ -136,7 +160,8 @@
        * the framed contents rectangle.  The dimensions of the framed contents
        * are not affected, but the dimensions of <code>this</code> are changed
        * by the difference between the current offset and the new offset in the
  -     * X and Y axes.
  +     * X and Y axes.  Note that this is a frame-centric view.  The offset is
  +     * expressed in the frame's frame-of-reference. 
        * @param offset the new offset to the framed rectangle
        */
       public void setContentOffset(Point2D offset) {
  
  
  

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

Reply via email to