You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by pb...@apache.org on 2004/06/14 10:53:47 UTC
cvs commit: xml-fop/src/java/org/apache/fop/area PaddingRectangle.java ContentRectangle.java Area.java SpacesRectangle.java BorderRectangle.java AreaFrame.java
pbwest 2004/06/14 01:53:46
Modified: src/java/org/apache/fop/fo/properties Tag:
FOP_0-20-0_Alt-Design WritingMode.java
src/java/org/apache/fop/area Tag: FOP_0-20-0_Alt-Design
PaddingRectangle.java ContentRectangle.java
Area.java SpacesRectangle.java BorderRectangle.java
AreaFrame.java
Log:
More W.I.P. subclassing AreaFrame and ContentRectangle from
Area.AreaGeometry
Revision Changes Path
No revision
No revision
1.1.2.9 +60 -1 xml-fop/src/java/org/apache/fop/fo/properties/Attic/WritingMode.java
Index: WritingMode.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/properties/Attic/WritingMode.java,v
retrieving revision 1.1.2.8
retrieving revision 1.1.2.9
diff -u -r1.1.2.8 -r1.1.2.9
--- WritingMode.java 13 Jun 2004 17:04:51 -0000 1.1.2.8
+++ WritingMode.java 14 Jun 2004 08:53:46 -0000 1.1.2.9
@@ -21,6 +21,7 @@
package org.apache.fop.fo.properties;
import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
import java.util.HashMap;
import org.apache.fop.datastructs.ROIntArray;
@@ -363,6 +364,15 @@
return leftToRight[writingMode];
}
+ public static Rectangle2D.Double rectRelToAbs(
+ double ipOffset, double bpOffset, double ipDim, double bpDim,
+ int wMode) throws PropertyException {
+ if (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
* <code>inline-progression-dimension</code> and a
@@ -383,5 +393,54 @@
}
return new Point2D.Double(bpDim, ipDim);
}
+
+ /**
+ * Normalizes a pair of values representing an
+ * <code>inline-progression-dimension</code> and a
+ * <code>block-progression-dimension</code> by converting them to a
+ * <code>Point2D</code> representing the corresponding X and Y values in
+ * Java 2D user co-ordinates.
+ * @param ipDim the <code>inline-progression-dimension</code>
+ * @param bpDim the <code>block-progression-dimension</code>
+ * @param writingMode
+ * @return the corresponding x, y values
+ * @throws PropertyException
+ */
+ public static Point2D dimsRelToAbs (Point2D in, int writingMode)
+ throws PropertyException {
+ if (isHorizontal(writingMode)) {
+ return in;
+ }
+ double x, y;
+ x = in.getX();
+ y = in.getY();
+ in.setLocation(y, x);
+ return in;
+ }
+
+ /**
+ * Normalizes a pair of values representing an
+ * <code>inline-progression-dimension</code> and a
+ * <code>block-progression-dimension</code> by converting them to a
+ * <code>Point2D</code> representing the corresponding X and Y values in
+ * Java 2D user co-ordinates.
+ * @param ipDim the <code>inline-progression-dimension</code>
+ * @param bpDim the <code>block-progression-dimension</code>
+ * @param writingMode
+ * @return the corresponding x, y values
+ * @throws PropertyException
+ */
+ public static Rectangle2D dimsRelToAbs (
+ Point2D offset, Point2D wideHigh, int writingMode)
+ throws PropertyException {
+ if (isHorizontal(writingMode)) {
+ return new Rectangle2D.Double(
+ offset.getX(), offset.getY(),
+ wideHigh.getX(), wideHigh.getY());
+ }
+ return new Rectangle2D.Double(
+ offset.getY(), offset.getX(), wideHigh.getY(), wideHigh.getX());
+ }
+
}
No revision
No revision
1.1.2.5 +13 -22 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.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- PaddingRectangle.java 13 Jun 2004 17:03:31 -0000 1.1.2.4
+++ PaddingRectangle.java 14 Jun 2004 08:53:46 -0000 1.1.2.5
@@ -26,30 +26,22 @@
* @author pbw
* @version $Revision$ $Name$
*/
-public class PaddingRectangle extends Area.AreaFrame {
+public class PaddingRectangle extends AreaFrame {
- public PaddingRectangle(Area area, int writingMode) {
- area.super(writingMode);
- contents = new ContentRectangle(area, writingMode);
- contentOffset = new Point2D.Double();
- borders = new BorderRectangle(area, writingMode);
- borders.setContents(this);
+ public PaddingRectangle(Area area, Area.AreaGeometry content) {
+ super(area, content);
+ borders = new BorderRectangle(area, this);
}
/**
- * @param x
- * @param y
- * @param w
- * @param h
* @param contents
* @param contentOffset
*/
- public PaddingRectangle(Area area, int writingMode,
- double x, double y, double w, double h,
+ public PaddingRectangle(Area area,
+ double ipOffset, double bpOffset, double ipDim, double bpDim,
ContentRectangle contents, Point2D contentOffset) {
- area.super(writingMode, x, y, w, h, contents, contentOffset);
- borders = new BorderRectangle(area, writingMode);
- borders.setContents(this);
+ super(area, ipOffset, bpOffset, ipDim, bpDim, contents, contentOffset);
+ borders = new BorderRectangle(area, this);
}
/**
@@ -57,11 +49,10 @@
* @param contents
* @param contentOffset
*/
- public PaddingRectangle(Area area, int writingMode, Rectangle2D rect,
+ public PaddingRectangle(Area area, Rectangle2D rect,
ContentRectangle contents, Point2D contentOffset) {
- area.super(writingMode, rect, contents, contentOffset);
- borders = new BorderRectangle(area, writingMode);
- borders.setContents(this);
+ super(area, rect, contents, contentOffset);
+ borders = new BorderRectangle(area, this);
}
private BorderRectangle borders = null;
1.1.2.5 +10 -4 xml-fop/src/java/org/apache/fop/area/Attic/ContentRectangle.java
Index: ContentRectangle.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/area/Attic/ContentRectangle.java,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- ContentRectangle.java 13 Jun 2004 17:03:31 -0000 1.1.2.4
+++ ContentRectangle.java 14 Jun 2004 08:53:46 -0000 1.1.2.5
@@ -45,9 +45,15 @@
* @param ipDim
* @param bpDim
*/
- public ContentRectangle(Area area, int writingMode,
+ public ContentRectangle(Area area,
double ipOrigin, double bpOrigin, double ipDim, double bpDim) {
- area.super(writingMode, ipOrigin, bpOrigin, ipDim, bpDim);
+ area.super(area.contentWritingMode, ipOrigin, bpOrigin, ipDim, bpDim);
+ // Get the padding writing mode
+ padding = new PaddingRectangle(area, this);
+ }
+
+ public int getWritingMode() {
+ return getContentWritingMode();
}
private PaddingRectangle padding = null;
1.1.2.19 +31 -190 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.18
retrieving revision 1.1.2.19
diff -u -r1.1.2.18 -r1.1.2.19
--- Area.java 13 Jun 2004 17:03:31 -0000 1.1.2.18
+++ Area.java 14 Jun 2004 08:53:46 -0000 1.1.2.19
@@ -19,7 +19,6 @@
package org.apache.fop.area;
import java.awt.geom.AffineTransform;
-import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
@@ -93,13 +92,13 @@
return content;
}
- protected void setMargins(
- double before, double after, double start, double end) {
- spaces.setBefore(before);
- spaces.setAfter(after);
- spaces.setStart(start);
- spaces.setEnd(end);
- }
+// protected void setMargins(
+// double before, double after, double start, double end) {
+// spaces.setBefore(before);
+// spaces.setAfter(after);
+// spaces.setStart(start);
+// spaces.setEnd(end);
+// }
/** Translates this area into position in its parent area */
protected AffineTransform translation = null;
/**
@@ -252,30 +251,42 @@
public AreaGeometry(int writingMode,
double ipOrigin, double bpOrigin, double ipDim, double bpDim) {
this(writingMode);
- setRect(ipOrigin, bpOrigin, ipDim, bpDim);
+ try {
+ setRect(WritingMode.rectRelToAbs(
+ ipOrigin, bpOrigin, ipDim, bpDim, writingMode));
+ } catch (PropertyException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public AreaGeometry(int writingMode, Rectangle2D geometry) {
+ this(writingMode);
+ setRect(geometry);
}
-
+
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);
+ setRect(WritingMode.rectRelToAbs(
+ ipOrigin, bpOrigin, ipDim, bpDim, writingMode));
} catch (PropertyException e) {
- throw new RuntimeException(e.getMessage());
+ throw new RuntimeException(e);
}
- setRect(origin.getX(), origin.getY(),
- wideHigh.getX(), wideHigh.getY());
}
- public int getWritingMode() {
+ protected int getWritingMode() {
return writingMode;
}
+ protected int getContentWritingMode() {
+ return contentWritingMode;
+ }
+
+ protected int getFrameWritingMode() {
+ return frameWritingMode;
+ }
+
/**
* Gets the <code>block-progression-dimension</code> of the area
* geometry in millipoints. This value is taken from the appropriate
@@ -401,176 +412,6 @@
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$ $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;
-
- /**
- *
- */
- public AreaFrame(int writingMode) {
- super(writingMode);
- contents = new Rectangle2D.Double();
- contentOffset = new Point2D.Double();
- }
-
- /**
- * Instantiates a frame with 0-width edges.
- * @param contents the contained rectangle
- */
- public AreaFrame(int writingMode, AreaGeometry contents) {
- super(writingMode);
- 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(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;
- }
-
- /**
- * 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(int writingMode,
- Rectangle2D rect, AreaGeometry contents,
- Point2D contentOffset) {
- this(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());
}
}
1.1.2.5 +10 -17 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.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- SpacesRectangle.java 13 Jun 2004 17:03:31 -0000 1.1.2.4
+++ SpacesRectangle.java 14 Jun 2004 08:53:46 -0000 1.1.2.5
@@ -26,27 +26,20 @@
* @author pbw
* @version $Revision$ $Name$
*/
-public class SpacesRectangle extends Area.AreaFrame {
-
- public SpacesRectangle(Area area, int writingMode) {
- area.super(writingMode);
- contents = new BorderRectangle(area, writingMode);
- contentOffset = new Point2D.Double();
+public class SpacesRectangle extends AreaFrame {
+ public SpacesRectangle(Area area, BorderRectangle content) {
+ super(area, content);
}
/**
- * @param x
- * @param y
- * @param w
- * @param h
* @param contents
* @param contentOffset
*/
- public SpacesRectangle(Area area, int writingMode,
- double x, double y, double w, double h,
+ public SpacesRectangle(Area area,
+ double ipOffset, double bpOffset, double ipDim, double bpDim,
BorderRectangle contents, Point2D contentOffset) {
- area.super(writingMode, x, y, w, h, contents, contentOffset);
+ super(area, ipOffset, bpOffset, ipDim, bpDim, contents, contentOffset);
}
/**
@@ -54,9 +47,9 @@
* @param contents
* @param contentOffset
*/
- public SpacesRectangle(Area area, int writingMode, Rectangle2D rect,
+ public SpacesRectangle(Area area, Rectangle2D rect,
BorderRectangle contents, Point2D contentOffset) {
- area.super(writingMode, rect, contents, contentOffset);
+ super(area, rect, contents, contentOffset);
}
}
1.1.2.5 +13 -26 xml-fop/src/java/org/apache/fop/area/Attic/BorderRectangle.java
Index: BorderRectangle.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/area/Attic/BorderRectangle.java,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- BorderRectangle.java 13 Jun 2004 17:03:31 -0000 1.1.2.4
+++ BorderRectangle.java 14 Jun 2004 08:53:46 -0000 1.1.2.5
@@ -26,30 +26,18 @@
* @author pbw
* @version $Revision$ $Name$
*/
-public class BorderRectangle extends Area.AreaFrame {
+public class BorderRectangle extends AreaFrame {
- public BorderRectangle(Area area, int writingMode) {
- area.super(writingMode);
- contents = new PaddingRectangle(area, writingMode);
- contentOffset = new Point2D.Double();
- spaces = new SpacesRectangle(area, writingMode);
- spaces.setContents(this);
+ public BorderRectangle(Area area, PaddingRectangle content) {
+ super(area, content);
+ spaces = new SpacesRectangle(area, this);
}
- /**
- * @param x
- * @param y
- * @param w
- * @param h
- * @param contents
- * @param contentOffset
- */
- public BorderRectangle(Area area, int writingMode,
- double x, double y, double w, double h,
+ public BorderRectangle(Area area,
+ double ipOffset, double bpOffset, double ipDim, double bpDim,
PaddingRectangle contents, Point2D contentOffset) {
- area.super(writingMode, x, y, w, h, contents, contentOffset);
- spaces = new SpacesRectangle(area, writingMode);
- spaces.setContents(this);
+ super(area, ipOffset, bpOffset, ipDim, bpDim, contents, contentOffset);
+ spaces = new SpacesRectangle(area, this);
}
/**
@@ -57,11 +45,10 @@
* @param contents
* @param contentOffset
*/
- public BorderRectangle(Area area, int writingMode, Rectangle2D rect,
+ public BorderRectangle(Area area, Rectangle2D rect,
PaddingRectangle contents, Point2D contentOffset) {
- area.super(writingMode, rect, contents, contentOffset);
- spaces = new SpacesRectangle(area, writingMode);
- spaces.setContents(this);
+ super(area, rect, contents, contentOffset);
+ spaces = new SpacesRectangle(area, this);
}
private SpacesRectangle spaces = null;
1.1.2.5 +20 -21 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.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- AreaFrame.java 13 Jun 2004 17:03:31 -0000 1.1.2.4
+++ AreaFrame.java 14 Jun 2004 08:53:46 -0000 1.1.2.5
@@ -42,30 +42,25 @@
/**
* @param writingMode
*/
- public AreaFrame(Area area, int writingMode) {
- area.super(writingMode);
+ public AreaFrame(Area area) {
+ area.super(area.frameWritingMode);
+ // contents and contentOffset remain null
}
/**
- * @param writingMode
- * @param ipOrigin
- * @param bpOrigin
- * @param ipDim
- * @param bpDim
+ * Contents and offset remain null
*/
- public AreaFrame(Area area, int writingMode,
+ public AreaFrame(Area area,
double ipOrigin, double bpOrigin, double ipDim, double bpDim) {
- area.super(writingMode, ipOrigin, bpOrigin, ipDim, bpDim);
+ area.super(area.frameWritingMode, 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();
+ public AreaFrame(Area area, AreaGeometry contents) {
+ area.super(area.frameWritingMode);
setRect(contents);
this.contents = contents;
this.contentOffset = new Point2D.Double();
@@ -86,10 +81,10 @@
* @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,
+ public AreaFrame(Area area,
double ipOrigin, double bpOrigin, double ipDim, double bpDim,
AreaGeometry contents, Point2D contentOffset) {
- area.super(writingMode, ipOrigin, bpOrigin, ipDim, bpDim);
+ area.super(area.frameWritingMode, ipOrigin, bpOrigin, ipDim, bpDim);
this.contents = contents;
this.contentOffset = contentOffset;
}
@@ -105,12 +100,16 @@
* @param contentOffset offset from origin of the framing rectangle to the
* origin of the framed rectangle
*/
- public AreaFrame(Area area, int writingMode,
+ public AreaFrame(Area area,
Rectangle2D rect, AreaGeometry contents,
Point2D contentOffset) {
- this(area, writingMode, rect.getX(), rect.getY(),
- rect.getWidth(), rect.getHeight(),
- contents, contentOffset);
+ area.super(area.frameWritingMode, rect);
+ this.contents = contents;
+ this.contentOffset = contentOffset;
+ }
+
+ public int getWritingMode() {
+ return writingMode;
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-cvs-help@xml.apache.org