de.erichseifert.gral
Class DrawableContainer

java.lang.Object
  extended by de.erichseifert.gral.AbstractDrawable
      extended by de.erichseifert.gral.DrawableContainer
All Implemented Interfaces:
Container, Drawable, Iterable<Drawable>
Direct Known Subclasses:
Legend, Plot

public class DrawableContainer
extends AbstractDrawable
implements Container

Implementation of Container that is a Drawable itself. It takes care of the layout and the insets and stores Drawables.


Constructor Summary
DrawableContainer()
          Creates a new container for Drawables without layout manager.
DrawableContainer(Layout layout)
          Creates a new container for Drawables with the specified layout manager.
 
Method Summary
 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 Graphics2D object.
 Object getConstraints(Drawable drawable)
          Return additional information on component
 Insets2D getInsets()
          Return the space that this DrawableContainer must leave 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()
           
 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 DrawableContainer must leave 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.
 
Methods inherited from class de.erichseifert.gral.AbstractDrawable
getBounds, getHeight, getWidth, getX, getY
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.erichseifert.gral.Container
getBounds
 

Constructor Detail

DrawableContainer

public DrawableContainer()
Creates a new container for Drawables without layout manager.


DrawableContainer

public DrawableContainer(Layout layout)
Creates a new container for Drawables with the specified layout manager.

Parameters:
layout - Layout manager to be set.
Method Detail

draw

public void draw(DrawingContext context)
Description copied from interface: Drawable
Draws the Drawable with the specified Graphics2D object.

Specified by:
draw in interface Drawable
Parameters:
context - Environment used for drawing

add

public void add(Drawable drawable)
Description copied from interface: Container
Adds a new component to this container.

Specified by:
add in interface Container
Parameters:
drawable - Component

add

public void add(Drawable drawable,
                Object constraints)
Description copied from interface: Container
Adds a new component to this container.

Specified by:
add in interface Container
Parameters:
drawable - Component
constraints - Additional information (e.g. for layout)

remove

public void remove(Drawable drawable)
Description copied from interface: Container
Removes a component from this container.

Specified by:
remove in interface Container
Parameters:
drawable - Component

getConstraints

public Object getConstraints(Drawable drawable)
Description copied from interface: Container
Return additional information on component

Specified by:
getConstraints in interface Container
Parameters:
drawable - Component
Returns:
Information object or null

getInsets

public Insets2D getInsets()
Description copied from interface: Container
Return the space that this DrawableContainer must leave at each of its edges.

Specified by:
getInsets in interface Container
Returns:
The insets of this DrawableContainer

setInsets

public void setInsets(Insets2D insets)
Description copied from interface: Container
Sets the space that this DrawableContainer must leave at each of its edges.

Specified by:
setInsets in interface Container
Parameters:
insets - Insets to be set.

getLayout

public Layout getLayout()
Description copied from interface: Container
Returns the layout associated with this container.

Specified by:
getLayout in interface Container
Returns:
Layout manager

setLayout

public void setLayout(Layout layout)
Description copied from interface: Container
Sets the layout associated with this container.

Specified by:
setLayout in interface Container
Parameters:
layout - Layout to be set.

iterator

public Iterator<Drawable> iterator()
Specified by:
iterator in interface Iterable<Drawable>

size

public int size()
Description copied from interface: Container
Returns the number of components that are stored in this container.

Specified by:
size in interface Container
Returns:
total number of components

setBounds

public void setBounds(Rectangle2D bounds)
Description copied from interface: Drawable
Sets the bounds to the specified bounding rectangle.

Specified by:
setBounds in interface Container
Specified by:
setBounds in interface Drawable
Overrides:
setBounds in class AbstractDrawable
Parameters:
bounds - rectangle containing the component.

setBounds

public void setBounds(double x,
                      double y,
                      double width,
                      double height)
Description copied from interface: Drawable
Sets the bounds to the specified coordinates, width and height.

Specified by:
setBounds in interface Drawable
Overrides:
setBounds in class AbstractDrawable
Parameters:
x - horizontal position of the upper-left corner
y - vertical position of the upper-left corner
width - horizontal extent
height - vertical extent

getPreferredSize

public Dimension2D getPreferredSize()
Description copied from interface: Drawable
Returns the preferred size of the Drawable.

Specified by:
getPreferredSize in interface Drawable
Overrides:
getPreferredSize in class AbstractDrawable
Returns:
horizontal and vertical extent that wants to be reached


Copyright © 2009-2010. All Rights Reserved.