public class DrawableContainer extends AbstractDrawable implements Container
Container
that is a Drawable
itself and stores instances of Drawable
as components.
It takes care of laying out, managing insets for and painting the
components.Drawable
,
Container
,
Serialized FormConstructor and Description |
---|
DrawableContainer()
Creates a new container for
Drawable s without layout
manager. |
DrawableContainer(Layout layout)
Creates a new container for
Drawable s with the specified
layout manager. |
Modifier and Type | Method and Description |
---|---|
void |
add(Drawable drawable)
Adds a new component to this container.
|
void |
add(Drawable drawable,
Object constraints)
Adds a new component to this container.
|
void |
draw(DrawingContext context)
Draws the
Drawable with the specified drawing context. |
protected void |
drawComponents(DrawingContext context)
Invokes the draw method of each
Drawable . |
Object |
getConstraints(Drawable drawable)
Return additional information on component
|
Drawable |
getDrawableAt(Point2D point)
Returns the top-most component at the specified point.
|
Insets2D |
getInsets()
Returns the space that this container must preserve at each of its
edges.
|
Layout |
getLayout()
Returns the layout associated with this container.
|
Dimension2D |
getPreferredSize()
Returns the preferred size of the
Drawable . |
Iterator<Drawable> |
iterator()
Returns an iterator over the container's elements.
|
void |
layout()
Recalculates this container's layout.
|
void |
remove(Drawable drawable)
Removes a component from this container.
|
void |
setBounds(double x,
double y,
double width,
double height)
Sets the bounds to the specified coordinates, width and height.
|
void |
setBounds(Rectangle2D bounds)
Sets the bounds to the specified bounding rectangle.
|
void |
setInsets(Insets2D insets)
Sets the space that this container must preserve at each of its
edges.
|
void |
setLayout(Layout layout)
Sets the layout associated with this container.
|
int |
size()
Returns the number of components that are stored in this container.
|
getBounds, getHeight, getWidth, getX, getY
public DrawableContainer()
Drawable
s without layout
manager.public DrawableContainer(Layout layout)
Drawable
s with the specified
layout manager.layout
- Layout manager to be set.public void draw(DrawingContext context)
Drawable
with the specified drawing context.protected void drawComponents(DrawingContext context)
Drawable
.context
- Environment used for drawing.public void add(Drawable drawable)
public Drawable getDrawableAt(Point2D point)
null
will be returned.getDrawableAt
in interface Container
point
- Two-dimensional point.null
if no
component could be found.public Object getConstraints(Drawable drawable)
getConstraints
in interface Container
drawable
- Componentnull
public void remove(Drawable drawable)
public Insets2D getInsets()
public void setInsets(Insets2D insets)
public Layout getLayout()
public void setLayout(Layout layout)
public void layout()
public int size()
public void setBounds(Rectangle2D bounds)
AbstractDrawable
public void setBounds(double x, double y, double width, double height)
AbstractDrawable
setBounds
in interface Drawable
setBounds
in class AbstractDrawable
x
- horizontal position of the upper-left cornery
- vertical position of the upper-left cornerwidth
- horizontal extentheight
- vertical extentpublic Dimension2D getPreferredSize()
AbstractDrawable
Drawable
.getPreferredSize
in interface Drawable
getPreferredSize
in class AbstractDrawable
Copyright © 2009-2013. All Rights Reserved.