A convenience class for creating new classes that implement
the
interface.
| Method from org.jfree.chart.block.AbstractBlock Detail: |
public Size2D arrange(Graphics2D g2) {
return arrange(g2, RectangleConstraint.NONE);
}
Arranges the contents of the block, with no constraints, and returns
the block size. |
public Size2D arrange(Graphics2D g2,
RectangleConstraint constraint) {
Size2D base = new Size2D(getWidth(), getHeight());
return constraint.calculateConstrainedSize(base);
}
Arranges the contents of the block, within the given constraints, and
returns the block size. |
protected double calculateTotalHeight(double contentHeight) {
double result = contentHeight;
result = this.padding.extendHeight(result);
result = this.frame.getInsets().extendHeight(result);
result = this.margin.extendHeight(result);
return result;
}
Adds the margin, border and padding to the specified content height. |
protected double calculateTotalWidth(double contentWidth) {
double result = contentWidth;
result = this.padding.extendWidth(result);
result = this.frame.getInsets().extendWidth(result);
result = this.margin.extendWidth(result);
return result;
}
Adds the margin, border and padding to the specified content width. |
public Object clone() throws CloneNotSupportedException {
AbstractBlock clone = (AbstractBlock) super.clone();
clone.bounds = (Rectangle2D) ShapeUtilities.clone(this.bounds);
if (this.frame instanceof PublicCloneable) {
PublicCloneable pc = (PublicCloneable) this.frame;
clone.frame = (BlockFrame) pc.clone();
}
return clone;
}
Returns a clone of this block. |
protected void drawBorder(Graphics2D g2,
Rectangle2D area) {
this.frame.draw(g2, area);
}
Draws the border around the perimeter of the specified area. |
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof AbstractBlock)) {
return false;
}
AbstractBlock that = (AbstractBlock) obj;
if (!ObjectUtilities.equal(this.id, that.id)) {
return false;
}
if (!this.frame.equals(that.frame)) {
return false;
}
if (!this.bounds.equals(that.bounds)) {
return false;
}
if (!this.margin.equals(that.margin)) {
return false;
}
if (!this.padding.equals(that.padding)) {
return false;
}
if (this.height != that.height) {
return false;
}
if (this.width != that.width) {
return false;
}
return true;
}
Tests this block for equality with an arbitrary object. |
public BlockBorder getBorder() {
if (this.frame instanceof BlockBorder) {
return (BlockBorder) this.frame;
}
else {
return null;
}
} Deprecated! Use - #getFrame() instead.
|
public Rectangle2D getBounds() {
return this.bounds;
}
Returns the current bounds of the block. |
public double getContentXOffset() {
return this.margin.getLeft() + this.frame.getInsets().getLeft()
+ this.padding.getLeft();
}
Returns the x-offset for the content within the block. |
public double getContentYOffset() {
return this.margin.getTop() + this.frame.getInsets().getTop()
+ this.padding.getTop();
}
Returns the y-offset for the content within the block. |
public BlockFrame getFrame() {
return this.frame;
}
Returns the current frame (border). |
public double getHeight() {
return this.height;
}
Returns the natural height of the block, if this is known in advance.
The actual height of the block may be overridden if layout constraints
make this necessary. |
public String getID() {
return this.id;
}
|
public RectangleInsets getMargin() {
return this.margin;
}
|
public RectangleInsets getPadding() {
return this.padding;
}
|
public double getWidth() {
return this.width;
}
Returns the natural width of the block, if this is known in advance.
The actual width of the block may be overridden if layout constraints
make this necessary. |
public void setBorder(BlockBorder border) {
setFrame(border);
} Deprecated! Use - #setFrame(BlockFrame) instead.
|
public void setBorder(double top,
double left,
double bottom,
double right) {
setFrame(new BlockBorder(top, left, bottom, right));
}
Sets a black border with the specified line widths. |
public void setBounds(Rectangle2D bounds) {
if (bounds == null) {
throw new IllegalArgumentException("Null 'bounds' argument.");
}
this.bounds = bounds;
}
Sets the bounds of the block. |
public void setFrame(BlockFrame frame) {
if (frame == null) {
throw new IllegalArgumentException("Null 'frame' argument.");
}
this.frame = frame;
}
Sets the frame (or border). |
public void setHeight(double height) {
this.height = height;
}
Sets the natural width of the block, if this is known in advance. |
public void setID(String id) {
this.id = id;
}
Sets the id for the block. |
public void setMargin(RectangleInsets margin) {
if (margin == null) {
throw new IllegalArgumentException("Null 'margin' argument.");
}
this.margin = margin;
}
|
public void setMargin(double top,
double left,
double bottom,
double right) {
setMargin(new RectangleInsets(top, left, bottom, right));
}
|
public void setPadding(RectangleInsets padding) {
if (padding == null) {
throw new IllegalArgumentException("Null 'padding' argument.");
}
this.padding = padding;
}
|
public void setPadding(double top,
double left,
double bottom,
double right) {
setPadding(new RectangleInsets(top, left, bottom, right));
}
|
public void setWidth(double width) {
this.width = width;
}
Sets the natural width of the block, if this is known in advance. |
protected RectangleConstraint toContentConstraint(RectangleConstraint c) {
if (c == null) {
throw new IllegalArgumentException("Null 'c' argument.");
}
if (c.equals(RectangleConstraint.NONE)) {
return c;
}
double w = c.getWidth();
Range wr = c.getWidthRange();
double h = c.getHeight();
Range hr = c.getHeightRange();
double ww = trimToContentWidth(w);
double hh = trimToContentHeight(h);
Range wwr = trimToContentWidth(wr);
Range hhr = trimToContentHeight(hr);
return new RectangleConstraint(
ww, wwr, c.getWidthConstraintType(),
hh, hhr, c.getHeightConstraintType()
);
}
Returns a constraint for the content of this block that will result in
the bounds of the block matching the specified constraint. |
protected Rectangle2D trimBorder(Rectangle2D area) {
// defer argument checking...
this.frame.getInsets().trim(area);
return area;
}
Reduces the specified area by the amount of space consumed
by the border. |
protected Rectangle2D trimMargin(Rectangle2D area) {
// defer argument checking...
this.margin.trim(area);
return area;
}
Reduces the specified area by the amount of space consumed
by the margin. |
protected Rectangle2D trimPadding(Rectangle2D area) {
// defer argument checking...
this.padding.trim(area);
return area;
}
Reduces the specified area by the amount of space consumed
by the padding. |
protected double trimToContentHeight(double fixedHeight) {
double result = this.margin.trimHeight(fixedHeight);
result = this.frame.getInsets().trimHeight(result);
result = this.padding.trimHeight(result);
return Math.max(result, 0.0);
}
Calculate the height available for content after subtracting
the margin, border and padding space from the specified fixed
height. |
protected double trimToContentWidth(double fixedWidth) {
double result = this.margin.trimWidth(fixedWidth);
result = this.frame.getInsets().trimWidth(result);
result = this.padding.trimWidth(result);
return Math.max(result, 0.0);
}
Calculate the width available for content after subtracting
the margin, border and padding space from the specified fixed
width. |