protected Point2D contentOffset = null;
/**
- * @param writingMode
+ * 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);
}
/**
- * Instantiates a frame with 0-width edges.
+ * Instantiates a frame with 0-width edges around the given
+ * <code>AreaGeometry</code> contents
* @param contents the contained rectangle
*/
public AreaFrame(Area area, AreaGeometry contents) {
this.contentOffset = contentOffset;
}
- public int getWritingMode() {
- return writingMode;
- }
-
/**
* Sets the contents rectangle. The dimensions of <code>this</code> are
* adjusted to the difference between the current framed contents and
contentOffset = offset;
}
+ /**
+ * Gets the offset of the <i>contents</i> rectangle's Java2D origin point
+ * from the Java2D origin point of the <code>AreaFrame</code>.
+ * @return the offset as a <code>Point2D</code>.
+ */
public Point2D getContentOffset() {
return contentOffset;
}
}
}
+ /**
+ * Gets the width of the before edge of the <code>AreaFrame</code>
+ * @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 <code>contents</code> size
* is unaffected, but the size of the frame (<code>this</code>) will
}
}
+ /**
+ * Gets the width of the start edge of the <code>AreaFrame</code>
+ * @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 <code>contents</code> size
* and the <code>contentOffset</code> are unaffected, but the size of the
}
}
+ /**
+ * Gets the width of the after edge of the <code>AreaFrame</code>
+ * @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 <code>contents</code> size
* and the <code>contentOffset</code> are unaffected, but the size of the
}
}
+ /**
+ * Gets the width of the end edge of the <code>AreaFrame</code>
+ * @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 <code>AreaFrame</code> and the
+ * <code>contents</code> rectangle.
+ * @param edge absolute edge as defined in <code>WritingMode</code>.
+ * @param width to set in user co-ordinate units (points).
+ */
public void setAbsoluteEdgeWidth(int edge, double width) {
switch (edge) {
case WritingMode.TOP:
contentOffset.setLocation(contentOffset.getX(), top);
}
+ /**
+ * Gets the width of the top edge of the <code>AreaFrame</code>
+ * @return the width in user co-ordinate units (points)
+ */
+ public double getTop() {
+ return contentOffset.getY();
+ }
+
/**
* Sets the left edge width of the frame. The <code>contents</code> size
* is unaffected, but the size of the frame (<code>this</code>) will
contentOffset.setLocation(left, contentOffset.getX());
}
+ /**
+ * Gets the width of the left edge of the <code>AreaFrame</code>
+ * @return the width in user co-ordinate units (points)
+ */
+ public double getLeft() {
+ return contentOffset.getX();
+ }
+
/**
* Sets the bottom edge width of the frame. The <code>contents</code> size
* and the <code>contentOffset</code> are unaffected, but the size of the
setRect(getX(), getY(), getWidth(), getHeight() + diff);
}
+ /**
+ * Gets the width of the bottom edge of the <code>AreaFrame</code>
+ * @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 <code>contents</code> size
* and the <code>contentOffset</code> are unaffected, but the size of the
setRect(getX(), getY(), getWidth() + diff, getHeight());
}
+ /**
+ * Gets the width of the right edge of the <code>AreaFrame</code>
+ * @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:
}
}
- 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();
- }
-
}