]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
W.I.P. subclassing AreaFrame and ContentRectangle from
authorPeter Bernard West <pbwest@apache.org>
Sun, 13 Jun 2004 17:03:31 +0000 (17:03 +0000)
committerPeter Bernard West <pbwest@apache.org>
Sun, 13 Jun 2004 17:03:31 +0000 (17:03 +0000)
Area.AreaGeometry

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP_0-20-0_Alt-Design@197706 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/area/Area.java
src/java/org/apache/fop/area/AreaFrame.java [new file with mode: 0644]
src/java/org/apache/fop/area/BorderRectangle.java
src/java/org/apache/fop/area/ContentRectangle.java [new file with mode: 0644]
src/java/org/apache/fop/area/PaddingRectangle.java
src/java/org/apache/fop/area/SpacesRectangle.java

index 1c21c7ad63fac92d50ef376b2aa5f3e2912feb57..c1f702aae73ed3234b2ad72b1fc3024ffb4fc25a 100644 (file)
@@ -21,7 +21,6 @@ package org.apache.fop.area;
 import java.awt.geom.AffineTransform;
 import java.awt.geom.Point2D;
 import java.awt.geom.Rectangle2D;
-import java.awt.geom.Rectangle2D.Double;
 import java.util.ArrayList;
 
 import org.apache.fop.datastructs.Node;
@@ -138,10 +137,6 @@ public class Area extends AreaNode implements Cloneable  {
 
 
     private void setup() {
-        content = new ContentRectangle();
-        padding = content.getPadding();
-        borders = padding.getBorders();
-        spaces = borders.getSpaces();
         try {
             contentWritingMode = generatedBy.getWritingMode();
             contentIsHorizontal = WritingMode.isHorizontal(contentWritingMode);
@@ -153,6 +148,10 @@ public class Area extends AreaNode implements Cloneable  {
         } catch (PropertyException e) {
             throw new RuntimeException(e.getMessage());
         }
+        content = new ContentRectangle(this, contentWritingMode);
+        //padding = new PaddingRectangle(frameWritingMode, content, 0.0, 0.0);
+        borders = padding.getBorders();
+        spaces = borders.getSpaces();
     }
 
     /**
@@ -186,147 +185,6 @@ public class Area extends AreaNode implements Cloneable  {
         setup();
     }
 
-    /**
-     * Gets the <code>block-progression-dimension</code> of the contents of
-     * this area in millipoints.  This value is taken from the appropriate
-     * dimension of the <code>Rectangle2D</code> representing this area.  If no
-     * <code>Rectangle2D</code> exists, a zero-dimensioned default is first
-     * created, then the zero value is returned.
-     * @return the <code>block-progression-dimension</code> in millipoints
-     */
-    public int getBPDim() {
-        return (int)(getBPDimPts()*1000);
-    }
-
-    /**
-     * Gets the <code>block-progression-dimension</code> of the contents of
-     * this area in points.  This value is taken from the appropriate dimension
-     * of the <code>Rectangle2D</code> representing this area.  If no
-     * <code>Rectangle2D</code> exists, a zero-dimensioned default is first
-     * created, then the zero value is returned.
-     * N.B. The method is synchronized only on this object.
-     * @return the <code>block-progression-dimension</code> in points
-     */
-    public double getBPDimPts() {
-        synchronized (this) {
-            // TODO - check this.  Should the rectangle just be rotated as
-            // required?  This is incompatible with transform in space
-            // requests at block reference-areas.  OK if the transform is
-            // only for area rotations.  This depnds on how Java handles the
-            // layout of text in horizontal locales.
-            if (contentIsHorizontal) {
-                return content.getHeight();
-            } else {
-                return content.getWidth();
-            }
-        }
-    }
-
-    /**
-     * Sets the <code>block-progression-dimension</code> of the contents of
-     * this area to the specified value in millipoints.
-     * This value is applied to the appropriate dimension of the
-     * <code>Rectangle2D</code> representing this area.  If no
-     * <code>Rectangle2D</code> exists, a zero-dimensioned default is first
-     * created, then the value is applied.
-     * @param millipts <code>block-progression-dimension</code> to set, in
-     * millipoints
-     */
-    public void setBPDim(int millipts) {
-        setBPDimPts(millipts/1000.0f);
-    }
-
-    /**
-     * Sets the <code>block-progression-dimension</code> of the contents of
-     * this area to the specified value in points.
-     * This value is applied to the appropriate dimension of the
-     * <code>Rectangle2D</code> representing this area.  If no
-     * <code>Rectangle2D</code> exists, a zero-dimensioned default is first
-     * created, then the value is applied.
-     * N.B. The method is synchronized only on this object.
-     * @param pts <code>block-progression-dimension</code> to set, in points
-     */
-    public void setBPDimPts(double pts) {
-        synchronized (this) {
-            // TODO - check this
-            if (contentIsHorizontal) {
-                content.setRect(
-                        content.getX(),content.getY(), content.getWidth(), pts);
-            } else {
-                content.setRect(
-                        content.getX(),content.getY(), pts, content.getHeight());
-            }
-        }
-    }
-
-    /**
-     * Gets the <code>inline-progression-dimension</code> of the contents of
-     * this area in millipoints.  This value is taken from the appropriate
-     * dimension of the <code>Rectangle2D</code> representing this area.  If no
-     * <code>Rectangle2D</code> exists, a zero-dimensioned default is first
-     * created, then the zero value is returned.
-     * N.B. The method is synchronized only on this object.
-     * @return the <code>inline-progression-dimension</code> in millipoints
-     */
-    public int getIPDim() {
-        return (int)(getIPDimPts()*1000);
-    }
-
-    /**
-     * Gets the <code>inline-progression-dimension</code> of the contents of
-     * this area in points.  This value is taken from the appropriate dimension
-     * of the <code>Rectangle2D</code> representing this area.  If no
-     * <code>Rectangle2D</code> exists, a zero-dimensioned default is first
-     * created, then the zero value is returned.
-     * N.B. The method is synchronized only on this object.
-     * @return the <code>inline-progression-dimension</code> in points
-     */
-    public double getIPDimPts() {
-        synchronized (this) {
-            // TODO - check this
-            if (contentIsHorizontal){
-                return content.getWidth();
-            } else {
-                return content.getHeight();
-            }
-        }
-    }
-
-    /**
-     * Sets the <code>inline-progression-dimension</code> of the contents of
-     * this area, in points.  This value is applied to the appropriate
-     * dimension of the <code>Rectangle2D</code> representing this area.  If no
-     * <code>Rectangle2D</code> exists, a zero-dimensioned default is first
-     * created, then the value is applied.
-     * @param millipts <code>inline-progression-dimension</code> to set, in
-     * millipoints
-     */
-    public void setIPDim(int millipts) {
-        setIPDimPts(millipts/1000.0f);
-    }
-
-    /**
-     * Sets the <code>inline-progression-dimension</code> of the contents of
-     * this area, in points.  This value is applied to the appropriate
-     * dimension of the <code>Rectangle2D</code> representing this area.  If no
-     * <code>Rectangle2D</code> exists, a zero-dimensioned default is first
-     * created, then the value is applied.
-     * N.B. The method is synchronized only on this object.
-     * @param pts <code>inline-progression-dimension</code> to set, in points
-     */
-    public void setIPDimPts(double pts) {
-        synchronized (this) {
-            // Check this
-            if (contentIsHorizontal){
-                content.setRect(
-                        content.getX(), content.getY(), pts, content.getHeight());
-            } else {
-                content.setRect(
-                        content.getX(), content.getY(), content.getWidth(), pts);
-            }
-        }
-    }
-
     /** An initially null range of minima and maxima for
      * <code>inline-progression-dimension</code> and
      * <code>block-progression-dimension</code>.
@@ -375,13 +233,184 @@ public class Area extends AreaNode implements Cloneable  {
         }
     }
 
+    public class AreaGeometry extends Rectangle2D.Double {
+        protected int writingMode;
+        protected boolean isLeftToRight;
+        protected boolean isHorizontal;
+
+        public AreaGeometry(int writingMode) {
+            super();
+            this.writingMode = writingMode;
+            try {
+                isHorizontal = WritingMode.isHorizontal(writingMode);
+                isLeftToRight = WritingMode.isLeftToRight(writingMode);
+            } catch (PropertyException e) {
+                throw new RuntimeException(e.getMessage());
+            }
+        }
+
+        public AreaGeometry(int writingMode,
+                double ipOrigin, double bpOrigin, double ipDim, double bpDim) {
+            this(writingMode);
+            setRect(ipOrigin, bpOrigin, ipDim, bpDim);
+        }
+        
+        public void setRect(
+                double ipOrigin, double bpOrigin, double ipDim, double bpDim) {
+            // Now work out what belongs where
+            Point2D origin = null;
+            Point2D wideHigh = null;
+            try {
+                origin = WritingMode.dimsRelToAbs(
+                        ipOrigin, bpOrigin, writingMode);
+                wideHigh = WritingMode.dimsRelToAbs(
+                        ipDim, bpDim, writingMode);
+            } catch (PropertyException e) {
+                throw new RuntimeException(e.getMessage());
+            }
+            setRect(origin.getX(), origin.getY(),
+                    wideHigh.getX(), wideHigh.getY());
+        }
+
+        public int getWritingMode() {
+            return writingMode;
+        }
+
+        /**
+         * Gets the <code>block-progression-dimension</code> of the area
+         * geometry in millipoints.  This value is taken from the appropriate
+         * dimension of the <code>Rectangle2D</code> representing this area.
+         * @return the <code>block-progression-dimension</code> in millipoints
+         */
+        public int getBPDim() {
+            return (int)(getBPDimPts()*1000);
+        }
+
+        /**
+         * Gets the <code>block-progression-dimension</code> of the area
+         * geometry in points.  This value is taken from the appropriate dimension
+         * of the <code>Rectangle2D</code> representing this area.
+         * N.B. The method is synchronized only on this object.
+         * @return the <code>block-progression-dimension</code> in points
+         */
+        public double getBPDimPts() {
+            synchronized (this) {
+                // TODO - check this.  Should the rectangle just be rotated as
+                // required?  This is incompatible with transform in space
+                // requests at block reference-areas.  OK if the transform is
+                // only for area rotations.  This depnds on how Java handles the
+                // layout of text in horizontal locales.
+                if (isHorizontal) {
+                    return getHeight();
+                } else {
+                    return getWidth();
+                }
+            }
+        }
+
+        /**
+         * Sets the <code>block-progression-dimension</code> of the contents of
+         * this area to the specified value in millipoints.
+         * This value is applied to the appropriate dimension of the
+         * <code>Rectangle2D</code> representing this area.  If no
+         * <code>Rectangle2D</code> exists, a zero-dimensioned default is first
+         * created, then the value is applied.
+         * @param millipts <code>block-progression-dimension</code> to set, in
+         * millipoints
+         */
+        public void setBPDim(int millipts) {
+            setBPDimPts(millipts/1000.0f);
+        }
+
+        /**
+         * Sets the <code>block-progression-dimension</code> of the contents of
+         * this area to the specified value in points.
+         * This value is applied to the appropriate dimension of the
+         * <code>Rectangle2D</code> representing this area.  If no
+         * <code>Rectangle2D</code> exists, a zero-dimensioned default is first
+         * created, then the value is applied.
+         * N.B. The method is synchronized only on this object.
+         * @param pts <code>block-progression-dimension</code> to set, in points
+         */
+        public void setBPDimPts(double pts) {
+            synchronized (this) {
+                // TODO - check this
+                if (isHorizontal) {
+                    setRect(getX(), getY(), getWidth(), pts);
+                } else {
+                    setRect(getX(), getY(), pts, getHeight());
+                }
+            }
+        }
+
+        /**
+         * Gets the <code>inline-progression-dimension</code> of the contents of
+         * this area in millipoints.  This value is taken from the appropriate
+         * dimension of the <code>Rectangle2D</code> representing this area.
+         * N.B. The method is synchronized only on this object.
+         * @return the <code>inline-progression-dimension</code> in millipoints
+         */
+        public int getIPDim() {
+            return (int)(getIPDimPts()*1000);
+        }
+
+        /**
+         * Gets the <code>inline-progression-dimension</code> of the area
+         * geometry in points.  This value is taken from the appropriate dimension
+         * of the <code>Rectangle2D</code> representing this area.
+         * N.B. The method is synchronized only on this object.
+         * @return the <code>inline-progression-dimension</code> in points
+         */
+        public double getIPDimPts() {
+            synchronized (this) {
+                // TODO - check this
+                if (isHorizontal){
+                    return getWidth();
+                } else {
+                    return getHeight();
+                }
+            }
+        }
+
+        /**
+         * Sets the <code>inline-progression-dimension</code> of the contents of
+         * this area, in points.  This value is applied to the appropriate
+         * dimension of the <code>Rectangle2D</code> representing this area.  If no
+         * <code>Rectangle2D</code> exists, a zero-dimensioned default is first
+         * created, then the value is applied.
+         * @param millipts <code>inline-progression-dimension</code> to set, in
+         * millipoints
+         */
+        public void setIPDim(int millipts) {
+            setIPDimPts(millipts/1000.0f);
+        }
+
+        /**
+         * Sets the <code>inline-progression-dimension</code> of the area
+         * geometry, in points.  This value is applied to the appropriate
+         * dimension of the <code>Rectangle2D</code> representing this area.
+         * N.B. The method is synchronized only on this object.
+         * @param pts <code>inline-progression-dimension</code> to set, in points
+         */
+        public void setIPDimPts(double pts) {
+            synchronized (this) {
+                // Check this
+                if (isHorizontal){
+                    setRect(getX(), getY(), pts, getHeight());
+                } else {
+                    setRect(getX(), getY(), getWidth(), pts);
+                }
+            }
+        }
+    }
+
     /**
      * <code>AreaFrame</code> is the basic type for the geometry of a rectangle
      * enclosing another rectangle, e.g., a padding rectangle. 
      * @author pbw
      * @version $Revision: 1.1.2.2 $ $Name:  $
      */
-    public class AreaFrame extends Rectangle2D.Double {
+    public class AreaFrame extends AreaGeometry {
 
         /** The framed rectangle */
         protected Rectangle2D contents = null;
@@ -392,8 +421,8 @@ public class Area extends AreaNode implements Cloneable  {
         /**
          * 
          */
-        public AreaFrame() {
-            super();
+        public AreaFrame(int writingMode) {
+            super(writingMode);
             contents = new Rectangle2D.Double();
             contentOffset = new Point2D.Double();
         }
@@ -402,8 +431,8 @@ public class Area extends AreaNode implements Cloneable  {
          * Instantiates a frame with 0-width edges.
          * @param contents the contained rectangle
          */
-        public AreaFrame(Rectangle2D contents) {
-            super();
+        public AreaFrame(int writingMode, AreaGeometry contents) {
+            super(writingMode);
             setRect(contents);
             this.contents = contents;
             this.contentOffset = new Point2D.Double();
@@ -424,9 +453,10 @@ public class Area extends AreaNode implements Cloneable  {
          * @param contentOffset the offset to the origin point of the framed
          * rectangle from the origin point of <code>this</code> framing rectangle.
          */
-        public AreaFrame(double x, double y, double w, double h,
-                Rectangle2D contents, Point2D contentOffset) {
-            super(x, y, w, h);
+        public AreaFrame(int writingMode,
+                double ipOrigin, double bpOrigin, double ipDim, double bpDim,
+                AreaGeometry contents, Point2D contentOffset) {
+            super(writingMode, ipOrigin, bpOrigin, ipDim,  bpDim);
             this.contents = contents;
             this.contentOffset = contentOffset;
         }
@@ -442,9 +472,10 @@ public class Area extends AreaNode implements Cloneable  {
          * @param contentOffset offset from origin of the framing rectangle to the
          * origin of the framed rectangle
          */
-        public AreaFrame(Rectangle2D rect, Rectangle2D contents,
+        public AreaFrame(int writingMode,
+                Rectangle2D rect, AreaGeometry contents,
                 Point2D contentOffset) {
-            this(rect.getX(), rect.getY(),
+            this(writingMode, rect.getX(), rect.getY(),
                     rect.getWidth(), rect.getHeight(),
                     contents, contentOffset);
         }
@@ -543,48 +574,4 @@ public class Area extends AreaNode implements Cloneable  {
         }
     }
 
-    /**
-     * Defines the <i>content rectangle</i> of an area.  It is the central class
-     * in the management of the layout geometry of areas.  The other generated
-     * rectangular areas are accessed through and defined in terms of this area. 
-     * @author pbw
-     * @version $Revision: 1.1.2.2 $ $Name:  $
-     */
-    public class ContentRectangle extends Double {
-
-        /**
-         * Creates an empty contents object.
-         */
-        public ContentRectangle() {
-            super();
-            padding = new PaddingRectangle(Area.this);
-            padding.setContents(this);
-        }
-
-        /**
-         * Creates a contents object from the given origin (<code>x, y</code>)
-         * width (<code>w</code>) and height (<code>h</code>).
-         * @param x x-origin
-         * @param y y-origin
-         * @param w width
-         * @param h height
-         */
-        public ContentRectangle(double x, double y, double w, double h) {
-            super(x, y, w, h);
-            padding = new PaddingRectangle(Area.this);
-            padding.setContents(this);
-        }
-
-        private PaddingRectangle padding = null;
-
-        public PaddingRectangle getPadding() {
-            return padding;
-        }
-
-        public void setRect(double x, double y, double w, double h) {
-            super.setRect(x, y, w, h);
-            padding.setContents(this);
-        }
-    }
-
 }
diff --git a/src/java/org/apache/fop/area/AreaFrame.java b/src/java/org/apache/fop/area/AreaFrame.java
new file mode 100644 (file)
index 0000000..85d2008
--- /dev/null
@@ -0,0 +1,209 @@
+/*
+ *
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on 14/06/2004
+ * $Id$
+ */
+package org.apache.fop.area;
+
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+
+import org.apache.fop.area.Area.AreaGeometry;
+
+
+/**
+ * <code>AreaFrame</code> is the basic type for the geometry of a rectangle
+ * enclosing another rectangle, e.g., a padding rectangle. 
+ * @author pbw
+ * @version $Revision$ $Name$
+ */
+public class AreaFrame extends AreaGeometry {
+
+    /** The framed rectangle */
+    protected Rectangle2D contents = null;
+    /** The offset from <code>this</code> origin to the origin of the framed
+     * rectangle */
+    protected Point2D contentOffset = null;
+
+    /**
+     * @param writingMode
+     */
+    public AreaFrame(Area area, int writingMode) {
+        area.super(writingMode);
+    }
+
+    /**
+     * @param writingMode
+     * @param ipOrigin
+     * @param bpOrigin
+     * @param ipDim
+     * @param bpDim
+     */
+    public AreaFrame(Area area, int writingMode,
+            double ipOrigin, double bpOrigin, double ipDim, double bpDim) {
+        area.super(writingMode, ipOrigin, bpOrigin, ipDim, bpDim);
+    }
+
+    /**
+     * Instantiates a frame with 0-width edges.
+     * @param contents the contained rectangle
+     */
+    public AreaFrame(Area area, int writingMode, AreaGeometry contents) {
+        area.super(writingMode);
+        // TODO transform contents according to contents writing mode
+        int contentsWMode = contents.getWritingMode();
+        setRect(contents);
+        this.contents = contents;
+        this.contentOffset = new Point2D.Double();
+    }
+
+    /**
+     * Instantiates a new framing rectangle with the given origin point, the
+     * given width and height, the given content rectangle, and the given
+     * offset from the origin of the framing rectangle to the origin of the
+     * content rectangle.
+     * @param x x-value of the origin of the framing rectangle in user space
+     * units
+     * @param y y-value of the origin of the framing rectangle in user space
+     * units
+     * @param w width of the framing rectangle in user space units
+     * @param h height of the framing rectangle in user space units
+     * @param contents the framed rectangle
+     * @param contentOffset the offset to the origin point of the framed
+     * rectangle from the origin point of <code>this</code> framing rectangle.
+     */
+    public AreaFrame(Area area, int writingMode,
+            double ipOrigin, double bpOrigin, double ipDim, double bpDim,
+            AreaGeometry contents, Point2D contentOffset) {
+        area.super(writingMode, ipOrigin, bpOrigin, ipDim,  bpDim);
+        this.contents = contents;
+        this.contentOffset = contentOffset;
+    }
+
+    /**
+     * Instantiates a new framing rectangle from the given rectangle, given
+     * contents, and given offset from the origin of the framing rectangle to
+     * the origin of the framed rectangle.  The dimensions and location of the
+     * given rectangle are copied into the dimensions of the new framing
+     * rectangle.
+     * @param rect the framing rectangle
+     * @param contents the framed rectangle
+     * @param contentOffset offset from origin of the framing rectangle to the
+     * origin of the framed rectangle
+     */
+    public AreaFrame(Area area, int writingMode,
+            Rectangle2D rect, AreaGeometry contents,
+            Point2D contentOffset) {
+        this(area, writingMode, rect.getX(), rect.getY(),
+                rect.getWidth(), rect.getHeight(),
+                contents, contentOffset);
+    }
+
+    /**
+     * Sets the contents rectangle.  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(Rectangle2D contents) {
+        setRect(getX(), getY(),
+                getWidth() + (contents.getWidth() - this.contents.getWidth()),
+                getHeight() + (contents.getWidth() - this.contents.getWidth()));
+        contents = this.contents;
+    }
+
+    public Rectangle2D getContents() {
+        return contents;
+    }
+
+    /**
+     * Sets the offset from the origin of <code>this</code> to the origin of
+     * 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.
+     * @param offset the new offset to the framed rectangle
+     */
+    public void setContentOffset(Point2D offset) {
+        setStart(offset.getX());
+        setBefore(offset.getY());
+        contentOffset = offset;
+    }
+
+    public Point2D getContentOffset() {
+        return contentOffset;
+    }
+
+    /**
+     * Sets the before edge width of the frame.  The <code>contents</code> size
+     * is unaffected, but the size of the frame (<code>this</code>) will
+     * change.  The height will vary by the difference between the previous and
+     * new before edge.  The <code>contentOffset</code> will also change by the
+     * same amount.  Note that the origin of this frame (<code>getX(),
+     * getY()</code>) will not change.
+     * @param before
+     */
+    public void setBefore(double before) {
+        double diff = before - contentOffset.getY();
+        setRect(getX(), getY(),
+                getWidth(), getHeight() + diff);
+        contentOffset.setLocation(contentOffset.getX(), before);
+    }
+
+    /**
+     * Sets the start edge width of the frame.  The <code>contents</code> size
+     * is unaffected, but the size of the frame (<code>this</code>) will
+     * change.  The width will vary by the difference between the previous and
+     * new start edge.  The <code>contentOffset</code> will also change by the
+     * same amount.  Note that the origin of this frame (<code>getX(),
+     * getY()</code>) will not change.
+     * @param start
+     */
+    public void setStart(double start) {
+        double diff = start - contentOffset.getY();
+        setRect(getX(), getY(),
+                getWidth() + diff, getHeight());
+        contentOffset.setLocation(start, contentOffset.getX());
+    }
+
+    /**
+     * Sets the after edge width of the frame.  The <code>contents</code> size
+     * and the <code>contentOffset</code> are unaffected, but the size of the
+     * frame (<code>this</code>) will change.  The height will vary by the
+     * difference between the previous and new after edge.  Note that the
+     * origin of this frame (<code>getX(), getY()</code>) will not change.
+     * @param after
+     */
+    public void setAfter(double after) {
+        double diff = after - (getY() - contentOffset.getY() - contents.getY());
+        setRect(getX(), getY(), getWidth(), getHeight() + diff);
+    }
+
+    /**
+     * Sets the end edge width of the frame.  The <code>contents</code> size
+     * and the <code>contentOffset</code> are unaffected, but the size of the
+     * frame (<code>this</code>) will change.  The width will vary by the
+     * difference between the previous and new end edge.  Note that the
+     * origin of this frame (<code>getX(), getY()</code>) will not change.
+     * @param end
+     */
+    public void setEnd(double end) {
+        double diff = end - (getX() - contentOffset.getX() - contents.getX());
+        setRect(getX(), getY(), getWidth() + diff, getHeight());
+    }
+
+}
index 7ee3e4cdc01ba64c6c3a2e37b41d62c2be323714..b3523d99c07fd93974de839db2b7a8500e14cb6a 100644 (file)
@@ -28,11 +28,11 @@ import java.awt.geom.Rectangle2D;
  */
 public class BorderRectangle extends Area.AreaFrame {
 
-    public BorderRectangle(Area area) {
-        area.super();
-        contents = new PaddingRectangle(area);
+    public BorderRectangle(Area area, int writingMode) {
+        area.super(writingMode);
+        contents = new PaddingRectangle(area, writingMode);
         contentOffset = new Point2D.Double();
-        spaces = new SpacesRectangle(area);
+        spaces = new SpacesRectangle(area, writingMode);
         spaces.setContents(this);
     }
 
@@ -44,10 +44,11 @@ public class BorderRectangle extends Area.AreaFrame {
         * @param contents
         * @param contentOffset
         */
-       public BorderRectangle(Area area, double x, double y, double w, double h,
+       public BorderRectangle(Area area, int writingMode,
+            double x, double y, double w, double h,
                        PaddingRectangle contents, Point2D contentOffset) {
-               area.super(x, y, w, h, contents, contentOffset);
-        spaces = new SpacesRectangle(area);
+               area.super(writingMode, x, y, w, h, contents, contentOffset);
+        spaces = new SpacesRectangle(area, writingMode);
         spaces.setContents(this);
        }
 
@@ -56,10 +57,10 @@ public class BorderRectangle extends Area.AreaFrame {
         * @param contents
         * @param contentOffset
         */
-       public BorderRectangle(Area area, Rectangle2D rect,
+       public BorderRectangle(Area area, int writingMode, Rectangle2D rect,
             PaddingRectangle contents, Point2D contentOffset) {
-               area.super(rect, contents, contentOffset);
-        spaces = new SpacesRectangle(area);
+               area.super(writingMode, rect, contents, contentOffset);
+        spaces = new SpacesRectangle(area, writingMode);
         spaces.setContents(this);
        }
 
diff --git a/src/java/org/apache/fop/area/ContentRectangle.java b/src/java/org/apache/fop/area/ContentRectangle.java
new file mode 100644 (file)
index 0000000..c249e6b
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ *
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on 14/06/2004
+ * $Id$
+ */
+package org.apache.fop.area;
+
+import org.apache.fop.area.Area.AreaGeometry;
+
+
+/**
+ * Defines the <i>content rectangle</i> of an area.  It is the central class
+ * in the management of the layout geometry of areas.  The other generated
+ * rectangular areas are defined in terms of this area. 
+ * @author pbw
+ * @version $Revision$ $Name$
+ */
+public class ContentRectangle extends AreaGeometry {
+
+    /**
+     * @param writingMode
+     */
+    public ContentRectangle(Area area, int writingMode) {
+        area.super(writingMode);
+    }
+
+    /**
+     * @param writingMode
+     * @param ipOrigin
+     * @param bpOrigin
+     * @param ipDim
+     * @param bpDim
+     */
+    public ContentRectangle(Area area, int writingMode,
+            double ipOrigin, double bpOrigin, double ipDim, double bpDim) {
+        area.super(writingMode, ipOrigin, bpOrigin, ipDim, bpDim);
+    }
+
+    private PaddingRectangle padding = null;
+
+    public PaddingRectangle getPadding() {
+        return padding;
+    }
+
+    public void setPadding(PaddingRectangle padding) {
+        this.padding = padding; 
+    }
+
+    public void setRect(
+            double ipOrigin, double bpOrigin, double ipDim, double bpDim) {
+        super.setRect(ipOrigin, bpOrigin, ipDim, bpDim);
+        padding.setContents(this);
+    }
+
+}
index db6afb01da2e9e08edfc0ac3c62a06d185500392..90dcdb1c8c0be7aabf430c5e2e3f8327638ca530 100644 (file)
@@ -28,11 +28,11 @@ import java.awt.geom.Rectangle2D;
  */
 public class PaddingRectangle extends Area.AreaFrame {
 
-    public PaddingRectangle(Area area) {
-        area.super();
-        contents = area.new ContentRectangle();
+    public PaddingRectangle(Area area, int writingMode) {
+        area.super(writingMode);
+        contents = new ContentRectangle(area, writingMode);
         contentOffset = new Point2D.Double();
-        borders = new BorderRectangle(area);
+        borders = new BorderRectangle(area, writingMode);
         borders.setContents(this);
     }
 
@@ -44,10 +44,11 @@ public class PaddingRectangle extends Area.AreaFrame {
         * @param contents
         * @param contentOffset
         */
-       public PaddingRectangle(Area area, double x, double y, double w, double h,
-                       Area.ContentRectangle contents, Point2D contentOffset) {
-               area.super(x, y, w, h, contents, contentOffset);
-        borders = new BorderRectangle(area);
+       public PaddingRectangle(Area area, int writingMode,
+            double x, double y, double w, double h,
+                       ContentRectangle contents, Point2D contentOffset) {
+               area.super(writingMode, x, y, w, h, contents, contentOffset);
+        borders = new BorderRectangle(area, writingMode);
         borders.setContents(this);
        }
 
@@ -56,10 +57,10 @@ public class PaddingRectangle extends Area.AreaFrame {
         * @param contents
         * @param contentOffset
         */
-       public PaddingRectangle(Area area, Rectangle2D rect,
-            Area.ContentRectangle contents, Point2D contentOffset) {
-               area.super(rect, contents, contentOffset);
-        borders = new BorderRectangle(area);
+       public PaddingRectangle(Area area, int writingMode, Rectangle2D rect,
+            ContentRectangle contents, Point2D contentOffset) {
+               area.super(writingMode, rect, contents, contentOffset);
+        borders = new BorderRectangle(area, writingMode);
         borders.setContents(this);
        }
 
index dcf87ec19702aecbf2b6afb24c82480c027be754..9fd981846fffaff9e52f33a686370b732c7390da 100644 (file)
@@ -28,9 +28,9 @@ import java.awt.geom.Rectangle2D;
  */
 public class SpacesRectangle extends Area.AreaFrame {
 
-    public SpacesRectangle(Area area) {
-        area.super();
-        contents = new BorderRectangle(area);
+    public SpacesRectangle(Area area, int writingMode) {
+        area.super(writingMode);
+        contents = new BorderRectangle(area, writingMode);
         contentOffset = new Point2D.Double();
 
     }
@@ -43,9 +43,10 @@ public class SpacesRectangle extends Area.AreaFrame {
         * @param contents
         * @param contentOffset
         */
-       public SpacesRectangle(Area area, double x, double y, double w, double h,
+       public SpacesRectangle(Area area, int writingMode,
+            double x, double y, double w, double h,
                        BorderRectangle contents, Point2D contentOffset) {
-               area.super(x, y, w, h, contents, contentOffset);
+               area.super(writingMode, x, y, w, h, contents, contentOffset);
        }
 
        /**
@@ -53,9 +54,9 @@ public class SpacesRectangle extends Area.AreaFrame {
         * @param contents
         * @param contentOffset
         */
-       public SpacesRectangle(Area area, Rectangle2D rect,
+       public SpacesRectangle(Area area, int writingMode, Rectangle2D rect,
             BorderRectangle contents, Point2D contentOffset) {
-               area.super(rect, contents, contentOffset);
+               area.super(writingMode, rect, contents, contentOffset);
        }
 
 }