/** The offset from <code>this</code> origin to the origin of the framed
* rectangle */
protected Point2D contentOffset = new Point2D.Double();
-//
-// /**
-// * Instantiates an <code>AreaFrame</code> with zero dimensions and offset,
-// * with <code>contents</code> of zero dimensions and contentOffsets of
-// * zero. The <i>writing-mode</i> and <i>reference-orientation</i> are
-// * assumed to be the same as the containing frame.
-// * @param area the <code>Area</code> on which this <code>AreaFrame</code>
-// * is being defined
-// */
-// public AreaFrame(Area area) {
-// area.super(area.frameWritingMode);
-// contents = area.new AreaGeometry(area.frameWritingMode);
-// contentOffset = new Point2D.Double();
-// }
-
-// /**
-// * Instantiates an <code>AreaFrame</code> with the given relative
-// * origin and dimensions, with
-// * Contents and offset remain null
-// */
-// public AreaFrame(Area area,
-// double ipOrigin, double bpOrigin, double ipDim, double bpDim) {
-// area.super(area.frameWritingMode, ipOrigin, bpOrigin, ipDim, bpDim);
-// contents = area.new AreaGeometry(area.frameWritingMode);
-// contentOffset = new Point2D.Double();
-// }
/**
* Instantiates a frame with 0-width edges around the given
*/
public AreaFrame(Area area, AreaGeometry contents) {
area.super(area.frameWritingMode);
- // TODO - check that this can be eliminated
- //setRect(contents);
+ // At this point, the frame is a point at offset 0,0
setContents(contents);
- this.contentOffset = new Point2D.Double();
+ // The offset to the frame is the default 0,0
}
/**
* @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.
+ * rectangle from the origin point of <code>this</code> framing rectangle.
*/
public AreaFrame(Area area,
double ipOrigin, double bpOrigin, double ipDim, double bpDim,
area.super(area.frameWritingMode, ipOrigin, bpOrigin, ipDim, bpDim);
// TODO check this against the handling of the contents rectangle
// Should this initialize with the contents and then set the edges?
- setContents(contents);
+ this.contents = contents;
this.contentOffset = contentOffset;
}
Rectangle2D rect, AreaGeometry contents,
Point2D contentOffset) {
area.super(area.frameWritingMode, rect);
- setContents(contents);
+ this.contents = contents;
this.contentOffset = contentOffset;
}
setRect(getX(), getY(),
getWidth() + contents.getFrameRelativeWidth(),
getHeight() + contents.getFrameRelativeHeight());
+ } else {
+ setRect(getX(), getY(),
+ getWidth() + (
+ contents.getFrameRelativeWidth() -
+ this.contents.getFrameRelativeWidth()),
+ getHeight() + (
+ contents.getFrameRelativeHeight() -
+ this.contents.getFrameRelativeHeight()));
}
- setRect(getX(), getY(),
- getWidth() + (
- contents.getFrameRelativeWidth() -
- this.contents.getFrameRelativeWidth()),
- getHeight() + (
- contents.getFrameRelativeHeight() -
- this.contents.getFrameRelativeHeight()));
this.contents = contents;
}
* @param offset the new offset to the framed rectangle
*/
public void setContentOffset(Point2D offset) {
- setStart(offset.getX());
- setBefore(offset.getY());
+ setLeft(offset.getX());
+ setTop(offset.getY());
contentOffset = offset;
}
* @param top
*/
public void setTop(double top) {
- double diff = top - contentOffset.getY();
- setRect(getX(), getY(),
- getWidth(), getHeight() + diff);
+ setRect(getX(), getY(), getWidth(),
+ getHeight() + (top - getTop()));
contentOffset.setLocation(contentOffset.getX(), top);
}
* @param left
*/
public void setLeft(double left) {
- double diff = left - contentOffset.getY();
setRect(getX(), getY(),
- getWidth() + diff, getHeight());
- contentOffset.setLocation(left, contentOffset.getX());
+ getWidth() + (left - getLeft()),
+ getHeight());
+ contentOffset.setLocation(left, contentOffset.getY());
}
/**
* @param bottom
*/
public void setBottom(double bottom) {
- double diff = bottom - (getY() - contentOffset.getY() - contents.getY());
- setRect(getX(), getY(), getWidth(), getHeight() + diff);
+ setRect(getX(), getY(), getWidth(),
+ getHeight() + (bottom - getBottom()));
}
/**
* @return the width in user co-ordinate units (points)
*/
public double getBottom() {
- return getHeight() - contentOffset.getY() - contents.getHeight();
+ return (getHeight()
+ - contentOffset.getY()
+ - contents.getFrameRelativeHeight());
}
/**
* @param right
*/
public void setRight(double right) {
- double diff = right - (getX() - contentOffset.getX() - contents.getX());
- setRect(getX(), getY(), getWidth() + diff, getHeight());
+ setRect(getX(), getY(),
+ getWidth() + (right - getRight()),
+ getHeight());
}
/**
* @return the width in user co-ordinate units (points)
*/
public double getRight() {
- return getWidth() - contentOffset.getX() - contents.getWidth();
+ return (getWidth()
+ - contentOffset.getX()
+ - contents.getFrameRelativeWidth());
}
public double getAbsoluteEdgeWidth(int edge) {