Package org.jfree.chart.block
Class BlockContainer
- java.lang.Object
-
- org.jfree.chart.block.AbstractBlock
-
- org.jfree.chart.block.BlockContainer
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,Block,Drawable,PublicCloneable
- Direct Known Subclasses:
LegendItemBlockContainer
public class BlockContainer extends AbstractBlock implements Block, java.lang.Cloneable, PublicCloneable, java.io.Serializable
A container for a collection ofBlockobjects. The container uses anArrangementobject to handle the position of each block.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private ArrangementarrangementThe object responsible for laying out the blocks.private java.util.ListblocksThe blocks within the container.private static longserialVersionUIDFor serialization.
-
Constructor Summary
Constructors Constructor Description BlockContainer()Creates a new instance with default settings.BlockContainer(Arrangement arrangement)Creates a new instance with the specified arrangement.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(Block block)Adds a block to the container.voidadd(Block block, java.lang.Object key)Adds a block to the container.Size2Darrange(java.awt.Graphics2D g2, RectangleConstraint constraint)Arranges the contents of the block, within the given constraints, and returns the block size.booleancanEqual(java.lang.Object other)Ensures symmetry between super/subclass implementations of equals.voidclear()Clears all the blocks from the container.java.lang.Objectclone()Returns a clone of the container.voiddraw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area)Draws the container and all the blocks within it.java.lang.Objectdraw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area, java.lang.Object params)Draws the block within the specified area.booleanequals(java.lang.Object obj)Tests this container for equality with an arbitrary object.ArrangementgetArrangement()Returns the arrangement (layout) manager for the container.java.util.ListgetBlocks()Returns an unmodifiable list of theBlockobjects managed by this arrangement.inthashCode()booleanisEmpty()Returnstrueif there are no blocks in the container, andfalseotherwise.voidsetArrangement(Arrangement arrangement)Sets the arrangement (layout) manager.-
Methods inherited from class org.jfree.chart.block.AbstractBlock
arrange, calculateTotalHeight, calculateTotalWidth, drawBorder, getBounds, getContentXOffset, getContentYOffset, getFrame, getHeight, getID, getMargin, getPadding, getWidth, setBorder, setBounds, setFrame, setHeight, setID, setMargin, setMargin, setPadding, setPadding, setWidth, toContentConstraint, trimBorder, trimMargin, trimPadding, trimToContentHeight, trimToContentWidth
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
For serialization.- See Also:
- Constant Field Values
-
blocks
private final java.util.List blocks
The blocks within the container.
-
arrangement
private Arrangement arrangement
The object responsible for laying out the blocks.
-
-
Constructor Detail
-
BlockContainer
public BlockContainer()
Creates a new instance with default settings.
-
BlockContainer
public BlockContainer(Arrangement arrangement)
Creates a new instance with the specified arrangement.- Parameters:
arrangement- the arrangement manager (nullnot permitted).
-
-
Method Detail
-
getArrangement
public Arrangement getArrangement()
Returns the arrangement (layout) manager for the container.- Returns:
- The arrangement manager (never
null).
-
setArrangement
public void setArrangement(Arrangement arrangement)
Sets the arrangement (layout) manager.- Parameters:
arrangement- the arrangement (nullnot permitted).
-
isEmpty
public boolean isEmpty()
Returnstrueif there are no blocks in the container, andfalseotherwise.- Returns:
- A boolean.
-
getBlocks
public java.util.List getBlocks()
Returns an unmodifiable list of theBlockobjects managed by this arrangement.- Returns:
- A list of blocks.
-
add
public void add(Block block)
Adds a block to the container.- Parameters:
block- the block (nullpermitted).
-
add
public void add(Block block, java.lang.Object key)
Adds a block to the container.- Parameters:
block- the block (nullpermitted).key- the key (nullpermitted).
-
clear
public void clear()
Clears all the blocks from the container.
-
arrange
public Size2D arrange(java.awt.Graphics2D g2, RectangleConstraint constraint)
Arranges the contents of the block, within the given constraints, and returns the block size.- Specified by:
arrangein interfaceBlock- Overrides:
arrangein classAbstractBlock- Parameters:
g2- the graphics device.constraint- the constraint (nullnot permitted).- Returns:
- The block size (in Java2D units, never
null).
-
draw
public void draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area)Draws the container and all the blocks within it.
-
draw
public java.lang.Object draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area, java.lang.Object params)Draws the block within the specified area.- Specified by:
drawin interfaceBlock- Parameters:
g2- the graphics device.area- the area.params- passed on to blocks within the container (nullpermitted).- Returns:
- An instance of
EntityBlockResult, ornull.
-
equals
public boolean equals(java.lang.Object obj)
Tests this container for equality with an arbitrary object.- Overrides:
equalsin classAbstractBlock- Parameters:
obj- the object (nullpermitted).- Returns:
- A boolean.
-
canEqual
public boolean canEqual(java.lang.Object other)
Ensures symmetry between super/subclass implementations of equals. For more detail, see http://jqno.nl/equalsverifier/manual/inheritance.- Overrides:
canEqualin classAbstractBlock- Parameters:
other- Object- Returns:
- true ONLY if the parameter is THIS class type
-
hashCode
public int hashCode()
- Overrides:
hashCodein classAbstractBlock
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedExceptionReturns a clone of the container.- Specified by:
clonein interfacePublicCloneable- Overrides:
clonein classAbstractBlock- Returns:
- A clone.
- Throws:
java.lang.CloneNotSupportedException- if there is a problem cloning.
-
-