de.erichseifert.gral.graphics
Class DrawableContainer
- java.lang.Object
-
- de.erichseifert.gral.graphics.AbstractDrawable
-
- de.erichseifert.gral.graphics.DrawableContainer
-
- Direct Known Subclasses:
- AbstractLegend, AbstractLegend.Item, AbstractPlot
public class DrawableContainer extends AbstractDrawable implements Container
Implementation ofContainerthat is aDrawableitself and stores instances ofDrawableas components. It takes care of laying out, managing insets for and painting the components.- See Also:
Drawable,Container, Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description DrawableContainer()Creates a new container forDrawables without layout manager.DrawableContainer(Layout layout)Creates a new container forDrawables with the specified layout manager.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidadd(Drawable drawable)Adds a new component to this container.voidadd(Drawable drawable, java.lang.Object constraints)Adds a new component to this container.booleancontains(Drawable drawable)Returns whether the specifiedDrawableis stored.voiddraw(DrawingContext context)Draws theDrawablewith the specified drawing context.java.lang.ObjectgetConstraints(Drawable drawable)Return additional information on componentjava.util.List<Drawable>getDrawables()Returns a list of stored components.java.util.List<Drawable>getDrawablesAt(java.awt.geom.Point2D point)Returns the components at the specified point.Insets2DgetInsets()Returns the space that this container must preserve at each of its edges.LayoutgetLayout()Returns the layout associated with this container.java.awt.geom.Dimension2DgetPreferredSize()Returns the preferred size of theDrawable.java.util.Iterator<Drawable>iterator()Returns an iterator over the container's elements.voidlayout()Recalculates this container's layout.voidremove(Drawable drawable)Removes a component from this container.voidsetBounds(double x, double y, double width, double height)Sets the bounds to the specified coordinates, width and height.voidsetBounds(java.awt.geom.Rectangle2D bounds)Sets the bounds to the specified bounding rectangle.voidsetInsets(Insets2D insets)Sets the space that this container must preserve at each of its edges.voidsetLayout(Layout layout)Sets the layout associated with this container.intsize()Returns the number of components that are stored in this container.-
Methods inherited from class de.erichseifert.gral.graphics.AbstractDrawable
getBounds, getHeight, getWidth, getX, getY, setPosition
-
-
-
-
Constructor Detail
-
DrawableContainer
public DrawableContainer()
Creates a new container forDrawables without layout manager.
-
DrawableContainer
public DrawableContainer(Layout layout)
Creates a new container forDrawables with the specified layout manager.- Parameters:
layout- Layout manager to be set.
-
-
Method Detail
-
draw
public void draw(DrawingContext context)
Draws theDrawablewith the specified drawing context.
-
add
public void add(Drawable drawable)
Adds a new component to this container.
-
add
public void add(Drawable drawable, java.lang.Object constraints)
Adds a new component to this container.
-
contains
public boolean contains(Drawable drawable)
Description copied from interface:ContainerReturns whether the specifiedDrawableis stored.
-
getDrawablesAt
public java.util.List<Drawable> getDrawablesAt(java.awt.geom.Point2D point)
Description copied from interface:ContainerReturns the components at the specified point. The first component in the resultListis the most specific component, i.e. the component with the deepest nesting level. If no component could be found an emptyListwill be returned.- Specified by:
getDrawablesAtin interfaceContainer- Parameters:
point- Two-dimensional point.- Returns:
- Components at the specified point, with the deepest nested component first.
-
getDrawables
public java.util.List<Drawable> getDrawables()
Description copied from interface:ContainerReturns a list of stored components.- Specified by:
getDrawablesin interfaceContainer- Returns:
- Contained drawables.
-
getConstraints
public java.lang.Object getConstraints(Drawable drawable)
Return additional information on component- Specified by:
getConstraintsin interfaceContainer- Parameters:
drawable- Component- Returns:
- Information object or
null
-
remove
public void remove(Drawable drawable)
Removes a component from this container.
-
getInsets
public Insets2D getInsets()
Returns the space that this container must preserve at each of its edges.
-
setInsets
public void setInsets(Insets2D insets)
Sets the space that this container must preserve at each of its edges.
-
getLayout
public Layout getLayout()
Returns the layout associated with this container.
-
setLayout
public void setLayout(Layout layout)
Sets the layout associated with this container.
-
layout
public void layout()
Recalculates this container's layout.
-
iterator
public java.util.Iterator<Drawable> iterator()
Returns an iterator over the container's elements.- Specified by:
iteratorin interfacejava.lang.Iterable<Drawable>- Returns:
- an Iterator.
-
size
public int size()
Returns the number of components that are stored in this container.
-
setBounds
public void setBounds(java.awt.geom.Rectangle2D bounds)
Description copied from class:AbstractDrawableSets the bounds to the specified bounding rectangle.
-
setBounds
public void setBounds(double x, double y, double width, double height)Description copied from class:AbstractDrawableSets the bounds to the specified coordinates, width and height. This method should be used when overriding functionality.- Specified by:
setBoundsin interfaceDrawable- Overrides:
setBoundsin classAbstractDrawable- Parameters:
x- horizontal position of the upper-left cornery- vertical position of the upper-left cornerwidth- horizontal extentheight- vertical extent
-
getPreferredSize
public java.awt.geom.Dimension2D getPreferredSize()
Description copied from class:AbstractDrawableReturns the preferred size of theDrawable.- Specified by:
getPreferredSizein interfaceDrawable- Overrides:
getPreferredSizein classAbstractDrawable- Returns:
- horizontal and vertical extent that wants to be reached
-
-
DataMelt 3.0 © DataMelt by jWork.ORG