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
,org.jfree.ui.Drawable
,org.jfree.util.PublicCloneable
- Direct Known Subclasses:
LegendItemBlockContainer
public class BlockContainer extends AbstractBlock implements Block, java.lang.Cloneable, org.jfree.util.PublicCloneable, java.io.Serializable
A container for a collection ofBlock
objects. The container uses anArrangement
object to handle the position of each block.- See Also:
- Serialized Form
-
-
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 void
add(Block block)
Adds a block to the container.void
add(Block block, java.lang.Object key)
Adds a block to the container.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.void
clear()
Clears all the blocks from the container.java.lang.Object
clone()
Returns a clone of the container.void
draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area)
Draws the container and all the blocks within it.java.lang.Object
draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area, java.lang.Object params)
Draws the block within the specified area.boolean
equals(java.lang.Object obj)
Tests this container for equality with an arbitrary object.Arrangement
getArrangement()
Returns the arrangement (layout) manager for the container.java.util.List
getBlocks()
Returns an unmodifiable list of theBlock
objects managed by this arrangement.boolean
isEmpty()
Returnstrue
if there are no blocks in the container, andfalse
otherwise.void
setArrangement(Arrangement arrangement)
Sets the arrangement (layout) manager.-
Methods inherited from class org.jfree.chart.block.AbstractBlock
arrange, calculateTotalHeight, calculateTotalWidth, drawBorder, getBorder, getBounds, getContentXOffset, getContentYOffset, getFrame, getHeight, getID, getMargin, getPadding, getWidth, setBorder, setBorder, setBounds, setFrame, setHeight, setID, setMargin, setMargin, setPadding, setPadding, setWidth, toContentConstraint, trimBorder, trimMargin, trimPadding, trimToContentHeight, trimToContentWidth
-
-
-
-
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 (null
not 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 (null
not permitted).
-
isEmpty
public boolean isEmpty()
Returnstrue
if there are no blocks in the container, andfalse
otherwise.- Returns:
- A boolean.
-
getBlocks
public java.util.List getBlocks()
Returns an unmodifiable list of theBlock
objects 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 (null
permitted).
-
add
public void add(Block block, java.lang.Object key)
Adds a block to the container.- Parameters:
block
- the block (null
permitted).key
- the key (null
permitted).
-
clear
public void clear()
Clears all the blocks from the container.
-
arrange
public 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.- Specified by:
arrange
in interfaceBlock
- Overrides:
arrange
in classAbstractBlock
- Parameters:
g2
- the graphics device.constraint
- the constraint (null
not 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.- Specified by:
draw
in interfaceorg.jfree.ui.Drawable
- Parameters:
g2
- the graphics device.area
- the area.
-
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:
draw
in interfaceBlock
- Parameters:
g2
- the graphics device.area
- the area.params
- passed on to blocks within the container (null
permitted).- Returns:
- An instance of
EntityBlockResult
, ornull
.
-
equals
public boolean equals(java.lang.Object obj)
Tests this container for equality with an arbitrary object.- Overrides:
equals
in classAbstractBlock
- Parameters:
obj
- the object (null
permitted).- Returns:
- A boolean.
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
Returns a clone of the container.- Specified by:
clone
in interfaceorg.jfree.util.PublicCloneable
- Overrides:
clone
in classAbstractBlock
- Returns:
- A clone.
- Throws:
java.lang.CloneNotSupportedException
- if there is a problem cloning.
-
-