From: Peter Bernard West Date: Tue, 6 Jul 2004 14:16:25 +0000 (+0000) Subject: No initializer for writing modes and rotations. X-Git-Tag: Defoe_export~61 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d026ebb3115348dd7c025cee2247deae7a07ca8a;p=xmlgraphics-fop.git No initializer for writing modes and rotations. Set up rotateToFrame and rotateToContent in initializer. Added getContentRotation(), getRotationToFrame(), getFrameRotation(), getRotationToContent(), getFrameRelativeDimensions(), getFrameRelativeWidth() and getFrameRelativeHeight(). More Javadoc comments. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP_0-20-0_Alt-Design@197756 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/area/Area.java b/src/java/org/apache/fop/area/Area.java index 650f42007..017353580 100644 --- a/src/java/org/apache/fop/area/Area.java +++ b/src/java/org/apache/fop/area/Area.java @@ -86,6 +86,7 @@ public class Area extends AreaNode implements Cloneable { /** Geometrical area embraced by the content rectangle of this area */ protected ContentRectangle content = null; /** + * Gets the content-rectangle of this * @return the content */ protected ContentRectangle getContent() { @@ -114,7 +115,7 @@ public class Area extends AreaNode implements Cloneable { this.translation = translation; } /** The writing-mode of the generating FO */ - protected int contentWritingMode = 0; + protected int contentWritingMode; /** True if the writing-mode of the content area is * horizontal */ protected boolean contentIsHorizontal = true; @@ -122,11 +123,11 @@ public class Area extends AreaNode implements Cloneable { * left-to-right */ protected boolean contentLeftToRight = true; /** The rotation trait for the content rectangle of this area */ - protected int contentRotation = 0; + protected int contentRotation; /** The writing-mode of the parent of the generating FO. This may * differ from the writing mode of the generating FO if this is a * reference-area. */ - protected int frameWritingMode = 0; + protected int frameWritingMode; /** True if the writing-mode of the frames of this area is * horizontal. May differ from contentIsHorizontal if this is a * reference-area. */ @@ -136,8 +137,11 @@ public class Area extends AreaNode implements Cloneable { * reference-area. */ protected boolean frameLeftToRight = true; /** The rotation trait for the framing rectangles of this area */ - protected int frameRotation = 0; - + protected int frameRotation; + /** Rotation from content to frame. One of 0, 90, 180, 270. */ + protected int rotateToFrame; + /** Rotation from frame to content. One of 0, 90, 180, 270. */ + protected int rotateToContent; protected void setup() { try { @@ -154,6 +158,17 @@ public class Area extends AreaNode implements Cloneable { } catch (PropertyException e) { throw new RuntimeException(e.getMessage()); } + rotateToFrame = frameRotation - contentRotation; + if (rotateToFrame == 0) { + rotateToContent = 0; + } else { + if (rotateToFrame < 0) { + rotateToContent = -rotateToFrame; + rotateToFrame +=360; + } else { + rotateToContent = 360 - rotateToFrame; + } + } content = new ContentRectangle(this); padding = content.getPadding(); borders = padding.getBorders(); @@ -239,11 +254,24 @@ public class Area extends AreaNode implements Cloneable { } } + /** + * 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 + * allocation-rectangle. + * @author pbw + * @version $Revision$ $Name$ + */ public class AreaGeometry extends Rectangle2D.Double { protected int writingMode; protected boolean isLeftToRight; protected boolean isHorizontal; + /** + * Creates an empty rectangle, with height and width of 0.0 at an + * offset of 0.0,0.0, with the given writing-mode + * @param writingMode + */ public AreaGeometry(int writingMode) { super(); this.writingMode = writingMode; @@ -255,10 +283,31 @@ public class Area extends AreaNode implements Cloneable { } } + /** + * Creates a rectangle with an origin determined by the parameters + * ipOrigin and bpOrigin, and with width and + * height determined by the parameters ipDim and + * bpDim. The translation of the relative offsets and + * dimensions into absolute directions is determined by the parameter + * writingMode. + * @param writingMode the writing-mode of the instantiated + * rectangular area, expressed as an enumerated constant from the + * set given in WritingMode. + * @param ipOrigin the origin point along the + * inline-progression-direction axis + * @param bpOrigin the origin point along the + * block-progression-direction axis + * @param ipDim the size of the rectangular area along the + * inline-progression-direction axis + * @param bpDim the size of the rectangular area along the + * i>block-progression-direction axis + */ public AreaGeometry(int writingMode, double ipOrigin, double bpOrigin, double ipDim, double bpDim) { this(writingMode); try { + // TODO move rectRelToAbs from WritingMode to a more suitable + // place setRect(WritingMode.rectRelToAbs( ipOrigin, bpOrigin, ipDim, bpDim, writingMode)); } catch (PropertyException e) { @@ -266,11 +315,36 @@ public class Area extends AreaNode implements Cloneable { } } + /** + * Creates a rectangle whose dimensions and offset are expressed in the + * parameter geometry. The rectangular area has the + * given writing-mode + * @param writingMode the writing-mode of the instantiated + * rectangular area, expressed as an enumerated constant from the + * set given in WritingMode. + * @param geometry the dimensions and offset of the geometrical area + * represented by this. + */ public AreaGeometry(int writingMode, Rectangle2D geometry) { this(writingMode); setRect(geometry); } + /** + * Overrides Rectangle2D method to set the dimensions + * and offset of the rectangular area. The dimensions and offset are + * expressed in relative terms, which must be translated into absolute + * terms according to the writing-mode of this. + * @param ipOrigin the origin point along the + * inline-progression-direction axis + * @param bpOrigin the origin point along the + * block-progression-direction axis + * @param ipDim the size of the rectangular area along the + * inline-progression-direction axis + * @param bpDim the size of the rectangular area along the + * i>block-progression-direction axis + * @see java.awt.geom.Rectangle2D#setRect(double, double, double, double) + */ public void setRect( double ipOrigin, double bpOrigin, double ipDim, double bpDim) { // Now work out what belongs where @@ -282,18 +356,88 @@ public class Area extends AreaNode implements Cloneable { } } + /** + * Gets the writing-mode of this rectangular area, expressed as an + * enumerated constant from WritingMode + * @return the emnumerated writing-mode + */ public int getWritingMode() { return writingMode; } + /** + * Gets the writing-mode of the content-rectangle of + * this Area + * @return the writing-mode of the content-rectangle + */ public int getContentWritingMode() { return contentWritingMode; } + /** + * Gets the writing-mode of the framing rectangles of the content of + * this Area + * @return the writing-mode of the framing rectangles + */ public int getFrameWritingMode() { return frameWritingMode; } + /** + * Gets the reference-orientation applying to the contents of this + * area, expressed as a normalized angle; one of 0, 90, 180 or 270. + * @return the reference-orientation + */ + public int getContentRotation() { + return contentRotation; + } + + public int getRotationToFrame() { + return rotateToFrame; + } + + /** + * Gets the reference-oroientation applying to the parent + * FONode of the generating FONode. This + * rotation applied to frames surrounding the content-rectangle. + * @return the parent's reference-orientation + */ + public int getFrameRotation() { + return frameRotation; + } + + public int getRotationToContent() { + return rotateToContent; + } + + /** + * Gets the dimensions of this AreaGeometry as seen + * from any surrounding frame within this Area. For all + * AreaGeometrys except ContentRectangles, + * the relative dimensions are the same for frame and contents; i.e. + * height is height and width is width. + * @return the adjusted dimensions + */ + protected DimensionDbl getFrameRelativeDimensions() { + return new DimensionDbl(getWidth(), getHeight()); + } + + /** + * Gets the width of this AreaGeometry as seen from any + * enclosing frame + * @return the frame-view width + */ + protected double getFrameRelativeWidth() { + return getFrameRelativeDimensions().getWidth(); + } + /** + * Gets the height of this AreaGeometry as seen from any + * enclosing frame + * @return the frame-view height + */ + protected double getFrameRelativeHeight() { + return getFrameRelativeDimensions().getHeight(); + } /** * Gets the block-progression-dimension of the area * geometry in millipoints. This value is taken from the appropriate @@ -316,8 +460,8 @@ public class Area extends AreaNode implements Cloneable { // 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. + // only for area rotations. This depends on how Java handles + // the layout of text in horizontal locales. if (isHorizontal) { return getHeight(); } else {