From 1fff419b0a8729cc0afcaaed8c970caea172d407 Mon Sep 17 00:00:00 2001 From: Peter Bernard West Date: Tue, 29 Jun 2004 07:34:22 +0000 Subject: [PATCH] Documentation changes and code re-arragement. Removed redundant getWritingMode method. Added double getBefore, getAfter, getStart & getEnd methods. WIP on incorporating reference-orientation. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP_0-20-0_Alt-Design@197747 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/area/AreaFrame.java | 127 ++++++++++++++++---- 1 file changed, 105 insertions(+), 22 deletions(-) diff --git a/src/java/org/apache/fop/area/AreaFrame.java b/src/java/org/apache/fop/area/AreaFrame.java index 156b5951d..708f3076f 100644 --- a/src/java/org/apache/fop/area/AreaFrame.java +++ b/src/java/org/apache/fop/area/AreaFrame.java @@ -42,7 +42,10 @@ public class AreaFrame extends AreaGeometry { protected Point2D contentOffset = null; /** - * @param writingMode + * Instantiates an AreaFrame with zero dimensions and offset, + * whose contents and contentOffset are null + * @param area the Area on which this AreaFrame + * is being defined */ public AreaFrame(Area area) { area.super(area.frameWritingMode); @@ -58,7 +61,8 @@ public class AreaFrame extends AreaGeometry { } /** - * Instantiates a frame with 0-width edges. + * Instantiates a frame with 0-width edges around the given + * AreaGeometry contents * @param contents the contained rectangle */ public AreaFrame(Area area, AreaGeometry contents) { @@ -110,10 +114,6 @@ public class AreaFrame extends AreaGeometry { this.contentOffset = contentOffset; } - public int getWritingMode() { - return writingMode; - } - /** * Sets the contents rectangle. The dimensions of this are * adjusted to the difference between the current framed contents and @@ -145,6 +145,11 @@ public class AreaFrame extends AreaGeometry { contentOffset = offset; } + /** + * Gets the offset of the contents rectangle's Java2D origin point + * from the Java2D origin point of the AreaFrame. + * @return the offset as a Point2D. + */ public Point2D getContentOffset() { return contentOffset; } @@ -168,6 +173,20 @@ public class AreaFrame extends AreaGeometry { } } + /** + * Gets the width of the before edge of the AreaFrame + * @return the width in user co-ordinate units (points) + */ + public double getBefore() { + try { + return getAbsoluteEdgeWidth( + WritingMode.getCorrespondingAbsoluteEdge( + writingMode, WritingMode.BEFORE)); + } catch (PropertyException e) { + throw new RuntimeException(e); + } + } + /** * Sets the start edge width of the frame. The contents size * is unaffected, but the size of the frame (this) will @@ -187,6 +206,20 @@ public class AreaFrame extends AreaGeometry { } } + /** + * Gets the width of the start edge of the AreaFrame + * @return the width in user co-ordinate units (points) + */ + public double getStart() { + try { + return getAbsoluteEdgeWidth( + WritingMode.getCorrespondingAbsoluteEdge( + writingMode, WritingMode.START)); + } catch (PropertyException e) { + throw new RuntimeException(e); + } + } + /** * Sets the after edge width of the frame. The contents size * and the contentOffset are unaffected, but the size of the @@ -205,6 +238,20 @@ public class AreaFrame extends AreaGeometry { } } + /** + * Gets the width of the after edge of the AreaFrame + * @return the width in user co-ordinate units (points) + */ + public double getAfter() { + try { + return getAbsoluteEdgeWidth( + WritingMode.getCorrespondingAbsoluteEdge( + writingMode, WritingMode.AFTER)); + } catch (PropertyException e) { + throw new RuntimeException(e); + } + } + /** * Sets the end edge width of the frame. The contents size * and the contentOffset are unaffected, but the size of the @@ -223,6 +270,26 @@ public class AreaFrame extends AreaGeometry { } } + /** + * Gets the width of the end edge of the AreaFrame + * @return the width in user co-ordinate units (points) + */ + public double getEnd() { + try { + return getAbsoluteEdgeWidth( + WritingMode.getCorrespondingAbsoluteEdge( + writingMode, WritingMode.END)); + } catch (PropertyException e) { + throw new RuntimeException(e); + } + } + + /** + * Sets an absolute edge width between the AreaFrame and the + * contents rectangle. + * @param edge absolute edge as defined in WritingMode. + * @param width to set in user co-ordinate units (points). + */ public void setAbsoluteEdgeWidth(int edge, double width) { switch (edge) { case WritingMode.TOP: @@ -259,6 +326,14 @@ public class AreaFrame extends AreaGeometry { contentOffset.setLocation(contentOffset.getX(), top); } + /** + * Gets the width of the top edge of the AreaFrame + * @return the width in user co-ordinate units (points) + */ + public double getTop() { + return contentOffset.getY(); + } + /** * Sets the left edge width of the frame. The contents size * is unaffected, but the size of the frame (this) will @@ -275,6 +350,14 @@ public class AreaFrame extends AreaGeometry { contentOffset.setLocation(left, contentOffset.getX()); } + /** + * Gets the width of the left edge of the AreaFrame + * @return the width in user co-ordinate units (points) + */ + public double getLeft() { + return contentOffset.getX(); + } + /** * Sets the bottom edge width of the frame. The contents size * and the contentOffset are unaffected, but the size of the @@ -288,6 +371,14 @@ public class AreaFrame extends AreaGeometry { setRect(getX(), getY(), getWidth(), getHeight() + diff); } + /** + * Gets the width of the bottom edge of the AreaFrame + * @return the width in user co-ordinate units (points) + */ + public double getBottom() { + return getHeight() - contentOffset.getY() - contents.getHeight(); + } + /** * Sets the right edge width of the frame. The contents size * and the contentOffset are unaffected, but the size of the @@ -301,6 +392,14 @@ public class AreaFrame extends AreaGeometry { setRect(getX(), getY(), getWidth() + diff, getHeight()); } + /** + * Gets the width of the right edge of the AreaFrame + * @return the width in user co-ordinate units (points) + */ + public double getRight() { + return getWidth() - contentOffset.getX() - contents.getWidth(); + } + public double getAbsoluteEdgeWidth(int edge) { switch (edge) { case WritingMode.TOP: @@ -317,20 +416,4 @@ public class AreaFrame extends AreaGeometry { } } - public double getTop() { - return contentOffset.getY(); - } - - public double getLeft() { - return contentOffset.getX(); - } - - public double getBottom() { - return getHeight() - contentOffset.getY() - contents.getHeight(); - } - - public double getRight() { - return getWidth() - contentOffset.getX() - contents.getWidth(); - } - } -- 2.39.5