public class AbstractBlock
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable
Block interface.| Modifier and Type | Field and Description |
|---|---|
private java.awt.geom.Rectangle2D |
bounds
The current bounds for the block (position of the block in Java2D space).
|
private BlockFrame |
frame
The frame (or border) for the block.
|
private double |
height
The natural height of the block (may be overridden if there are
constraints in sizing).
|
private java.lang.String |
id
The id for the block.
|
private org.jfree.ui.RectangleInsets |
margin
The margin around the outside of the block.
|
private org.jfree.ui.RectangleInsets |
padding
The padding between the block content and the border.
|
private static long |
serialVersionUID
For serialization.
|
private double |
width
The natural width of the block (may be overridden if there are
constraints in sizing).
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractBlock()
Creates a new block.
|
| Modifier and Type | Method and Description |
|---|---|
org.jfree.ui.Size2D |
arrange(java.awt.Graphics2D g2)
Arranges the contents of the block, with no constraints, and returns
the block size.
|
org.jfree.ui.Size2D |
arrange(java.awt.Graphics2D g2,
RectangleConstraint constraint)
Arranges the contents of the block, within the given constraints, and
returns the block size.
|
protected double |
calculateTotalHeight(double contentHeight)
Adds the margin, border and padding to the specified content height.
|
protected double |
calculateTotalWidth(double contentWidth)
Adds the margin, border and padding to the specified content width.
|
java.lang.Object |
clone()
Returns a clone of this block.
|
protected void |
drawBorder(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D area)
Draws the border around the perimeter of the specified area.
|
boolean |
equals(java.lang.Object obj)
Tests this block for equality with an arbitrary object.
|
BlockBorder |
getBorder()
Deprecated.
Use
getFrame() instead. |
java.awt.geom.Rectangle2D |
getBounds()
Returns the current bounds of the block.
|
double |
getContentXOffset()
Returns the x-offset for the content within the block.
|
double |
getContentYOffset()
Returns the y-offset for the content within the block.
|
BlockFrame |
getFrame()
Returns the current frame (border).
|
double |
getHeight()
Returns the natural height of the block, if this is known in advance.
|
java.lang.String |
getID()
Returns the id.
|
org.jfree.ui.RectangleInsets |
getMargin()
Returns the margin.
|
org.jfree.ui.RectangleInsets |
getPadding()
Returns the padding.
|
double |
getWidth()
Returns the natural width of the block, if this is known in advance.
|
private void |
readObject(java.io.ObjectInputStream stream)
Provides serialization support.
|
void |
setBorder(BlockBorder border)
Deprecated.
Use
setFrame(BlockFrame) instead. |
void |
setBorder(double top,
double left,
double bottom,
double right)
Sets a black border with the specified line widths.
|
void |
setBounds(java.awt.geom.Rectangle2D bounds)
Sets the bounds of the block.
|
void |
setFrame(BlockFrame frame)
Sets the frame (or border).
|
void |
setHeight(double height)
Sets the natural width of the block, if this is known in advance.
|
void |
setID(java.lang.String id)
Sets the id for the block.
|
void |
setMargin(double top,
double left,
double bottom,
double right)
Sets the margin.
|
void |
setMargin(org.jfree.ui.RectangleInsets margin)
Sets the margin (use
RectangleInsets.ZERO_INSETS for no
padding). |
void |
setPadding(double top,
double left,
double bottom,
double right)
Sets the padding.
|
void |
setPadding(org.jfree.ui.RectangleInsets padding)
Sets the padding (use
RectangleInsets.ZERO_INSETS for no
padding). |
void |
setWidth(double width)
Sets the natural width of the block, if this is known in advance.
|
protected RectangleConstraint |
toContentConstraint(RectangleConstraint c)
Returns a constraint for the content of this block that will result in
the bounds of the block matching the specified constraint.
|
protected java.awt.geom.Rectangle2D |
trimBorder(java.awt.geom.Rectangle2D area)
Reduces the specified area by the amount of space consumed
by the border.
|
protected java.awt.geom.Rectangle2D |
trimMargin(java.awt.geom.Rectangle2D area)
Reduces the specified area by the amount of space consumed
by the margin.
|
protected java.awt.geom.Rectangle2D |
trimPadding(java.awt.geom.Rectangle2D area)
Reduces the specified area by the amount of space consumed
by the padding.
|
protected double |
trimToContentHeight(double fixedHeight)
Calculate the height available for content after subtracting
the margin, border and padding space from the specified fixed
height.
|
private Range |
trimToContentHeight(Range r) |
protected double |
trimToContentWidth(double fixedWidth)
Calculate the width available for content after subtracting
the margin, border and padding space from the specified fixed
width.
|
private Range |
trimToContentWidth(Range r) |
private void |
writeObject(java.io.ObjectOutputStream stream)
Provides serialization support.
|
private static final long serialVersionUID
private java.lang.String id
private org.jfree.ui.RectangleInsets margin
private BlockFrame frame
private org.jfree.ui.RectangleInsets padding
private double width
private double height
private transient java.awt.geom.Rectangle2D bounds
public java.lang.String getID()
null).setID(String)public void setID(java.lang.String id)
id - the id (null permitted).getID()public double getWidth()
setWidth(double)public void setWidth(double width)
width - the width (in Java2D units)getWidth()public double getHeight()
setHeight(double)public void setHeight(double height)
height - the width (in Java2D units)getHeight()public org.jfree.ui.RectangleInsets getMargin()
null).getMargin()public void setMargin(org.jfree.ui.RectangleInsets margin)
RectangleInsets.ZERO_INSETS for no
padding).margin - the margin (null not permitted).getMargin()public void setMargin(double top,
double left,
double bottom,
double right)
top - the top margin.left - the left margin.bottom - the bottom margin.right - the right margin.getMargin()public BlockBorder getBorder()
getFrame() instead.null).public void setBorder(BlockBorder border)
setFrame(BlockFrame) instead.BlockBorder.NONE for
no border).border - the border (null not permitted).getBorder()public void setBorder(double top,
double left,
double bottom,
double right)
top - the top border line width.left - the left border line width.bottom - the bottom border line width.right - the right border line width.public BlockFrame getFrame()
setFrame(BlockFrame)public void setFrame(BlockFrame frame)
frame - the frame (null not permitted).getFrame()public org.jfree.ui.RectangleInsets getPadding()
null).setPadding(RectangleInsets)public void setPadding(org.jfree.ui.RectangleInsets padding)
RectangleInsets.ZERO_INSETS for no
padding).padding - the padding (null not permitted).getPadding()public void setPadding(double top,
double left,
double bottom,
double right)
top - the top padding.left - the left padding.bottom - the bottom padding.right - the right padding.public double getContentXOffset()
getContentYOffset()public double getContentYOffset()
getContentXOffset()public org.jfree.ui.Size2D arrange(java.awt.Graphics2D g2)
g2 - the graphics device.null).public org.jfree.ui.Size2D arrange(java.awt.Graphics2D g2,
RectangleConstraint constraint)
g2 - the graphics device.constraint - the constraint (null not permitted).null).public java.awt.geom.Rectangle2D getBounds()
setBounds(Rectangle2D)public void setBounds(java.awt.geom.Rectangle2D bounds)
bounds - the bounds (null not permitted).getBounds()protected double trimToContentWidth(double fixedWidth)
fixedWidth - the fixed width.trimToContentHeight(double)protected double trimToContentHeight(double fixedHeight)
fixedHeight - the fixed height.trimToContentWidth(double)protected RectangleConstraint toContentConstraint(RectangleConstraint c)
c - the outer constraint (null not permitted).protected double calculateTotalWidth(double contentWidth)
contentWidth - the content width.protected double calculateTotalHeight(double contentHeight)
contentHeight - the content height.protected java.awt.geom.Rectangle2D trimMargin(java.awt.geom.Rectangle2D area)
area - the area (null not permitted).protected java.awt.geom.Rectangle2D trimBorder(java.awt.geom.Rectangle2D area)
area - the area (null not permitted).protected java.awt.geom.Rectangle2D trimPadding(java.awt.geom.Rectangle2D area)
area - the area (null not permitted).protected void drawBorder(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D area)
g2 - the graphics device.area - the area.public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - the object (null permitted).public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
clone in class java.lang.Objectjava.lang.CloneNotSupportedException - if there is a problem creating the
clone.private void writeObject(java.io.ObjectOutputStream stream)
throws java.io.IOException
stream - the output stream.java.io.IOException - if there is an I/O error.private void readObject(java.io.ObjectInputStream stream)
throws java.io.IOException,
java.lang.ClassNotFoundException
stream - the input stream.java.io.IOException - if there is an I/O error.java.lang.ClassNotFoundException - if there is a classpath problem.