fdda.graphics.java2d
Class Container

java.lang.Object
  |
  +--fdda.graphics.java2d.Component
        |
        +--fdda.graphics.java2d.Container
All Implemented Interfaces:
Cloneable, Component, Container
Direct Known Subclasses:
ComponentSelection, Line

public class Container
extends Component
implements Container

Implementation of the container interface. Uses a linked list to store the elements; so the order of the elements is fixed to the insertion order. The Shape is the addition of all element shapes.

Author:
Jörg Rüdenauer

Field Summary
protected  LinkedList elements
          the elements in the container
 
Fields inherited from class fdda.graphics.java2d.Component
COLOR_NORMAL, COLOR_SELECTED, dirtyShape, selected, shape, x, y
 
Fields inherited from interface fdda.graphics.Component
SEL_ALL, SEL_EQUALS, SEL_MOVABLES, SEL_NOTHING
 
Constructor Summary
Container()
          Constructor.
 
Method Summary
 void addElement(Component element)
          Adds an element to the container.
protected  void calcShape()
          Recalculates the shape.
 void clear()
          Removes all elements from the container.
 Object clone()
          Clones the component
 void deselect()
          Deselects all elements in the container.
 void draw(Graphics2D graphContext)
          Draws all elements in the container.
 Component flatten()
          Returns a 'flattened' version of the container.
 ListIterator getIterator()
          Returns an iterator over the container.
 int getSize()
          Returns the current number of elements
 double getX()
          Returns the leftmost x coordinate of all the components in the container.
 double getY()
          Returns the topmost y coordinate of all the components in the container
 boolean hasElement(Component element)
          Checks whether the container contains a certain element.
 boolean isFlatteningAllowed()
          Returns true.
 boolean isMovable()
          Returns true iff all components in the container are movable.
 void move(double x, double y)
          Moves all elements in the container.
 void removeElement(Component element)
          Removes an element from the container.
 void select()
          Selects all elements in the container.
 int selectableWith()
          Returns the minimum of the SEL_XX values of all the components in the container.
 void setGraphicalSystem(GraphicalSystem graphicalSystem)
          Sets the graphical system for all elements.
 Object visit(ComponentVisitor visitor)
          Calls the visitContainer method according to the pattern
 
Methods inherited from class fdda.graphics.java2d.Component
getGraphicalSystem, getShape, isSelected, recalculateShape, setGraphicalSystem, setXY
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface fdda.graphics.Component
getGraphicalSystem, getShape, isSelected, recalculateShape, setGraphicalSystem, setXY
 

Field Detail

elements

protected LinkedList elements
the elements in the container

Constructor Detail

Container

public Container()
Constructor. Container is empty.

Method Detail

addElement

public void addElement(Component element)
Description copied from interface: Container
Adds an element to the container. No checks for doubles are performed.

Specified by:
addElement in interface Container
Parameters:
element - the element

removeElement

public void removeElement(Component element)
Description copied from interface: Container
Removes an element from the container. If the element doesn't exist, the container is unchanged.

Specified by:
removeElement in interface Container
Parameters:
element - the element

hasElement

public boolean hasElement(Component element)
Description copied from interface: Container
Checks whether the container contains a certain element.

Specified by:
hasElement in interface Container
Parameters:
element - the element
Returns:
true, iff the container includes this element

getIterator

public ListIterator getIterator()
Description copied from interface: Container
Returns an iterator over the container.

Specified by:
getIterator in interface Container
Returns:
a list iterator

clear

public void clear()
Description copied from interface: Container
Removes all elements from the container.

Specified by:
clear in interface Container

move

public void move(double x,
                 double y)
Moves all elements in the container.

Specified by:
move in interface Component
Parameters:
x - offset for move in x direction
y - offset for move in y direction
See Also:
Component.move(double, double)

select

public void select()
Selects all elements in the container.

Specified by:
select in interface Component
Overrides:
select in class Component
See Also:
Component.select()

deselect

public void deselect()
Deselects all elements in the container.

Specified by:
deselect in interface Component
Overrides:
deselect in class Component
See Also:
Component.deselect()

draw

public void draw(Graphics2D graphContext)
Draws all elements in the container. They are drawn in the order of their appearance in the container.

Specified by:
draw in class Component
Parameters:
graphContext - the graphics
See Also:
Component.draw(java.awt.Graphics2D)

calcShape

protected void calcShape()
Description copied from class: Component
Recalculates the shape. Is called by getShape if the flag dirtyShape is set. Must unset the flag after calculation.

Specified by:
calcShape in class Component

clone

public Object clone()
Description copied from interface: Component
Clones the component

Specified by:
clone in interface Component
Overrides:
clone in class Component
Returns:
the clone

getSize

public int getSize()
Description copied from interface: Container
Returns the current number of elements

Specified by:
getSize in interface Container
Returns:
the number of elements

getX

public double getX()
Returns the leftmost x coordinate of all the components in the container.

Specified by:
getX in interface Component
Overrides:
getX in class Component
Returns:
the x coordinate
See Also:
Component.getX()

getY

public double getY()
Returns the topmost y coordinate of all the components in the container

Specified by:
getY in interface Component
Overrides:
getY in class Component
Returns:
the y coordinate
See Also:
Component.getY()

isMovable

public boolean isMovable()
Returns true iff all components in the container are movable.

Specified by:
isMovable in interface Component
Returns:
true, iff the user can move the component
See Also:
Component.isMovable()

selectableWith

public int selectableWith()
Returns the minimum of the SEL_XX values of all the components in the container. It is: SEL_NOTHING < SEL_EQUALS < SEL_MOVABLES < SEL_ALL

Specified by:
selectableWith in interface Component
Returns:
constant indicating the selection class
See Also:
Component.selectableWith()

setGraphicalSystem

public void setGraphicalSystem(GraphicalSystem graphicalSystem)
Sets the graphical system for all elements.

See Also:
Component.setGraphicalSystem(fdda.graphics.GraphicalSystem)

flatten

public Component flatten()
Description copied from interface: Container
Returns a 'flattened' version of the container. This means two things: firstly, if an element of this container is a container itself and allows flattening, it will be removed from the container and replaced by its elements. Secondly, if the size of the container is 1, not the container, but its element is returned. If the container doesn't allow flattening, it is returned unchanged

Specified by:
flatten in interface Container
Returns:
the flattened version of the container

isFlatteningAllowed

public boolean isFlatteningAllowed()
Returns true.

Specified by:
isFlatteningAllowed in interface Container
Returns:
whether 'flattening' is allowed
See Also:
Container.isFlatteningAllowed()

visit

public Object visit(ComponentVisitor visitor)
Calls the visitContainer method according to the pattern

Specified by:
visit in interface Component
Parameters:
visitor - the visitor
Returns:
specific to subclass
See Also:
Component.visit(fdda.graphics.ComponentVisitor)


API documentation for FDDA version 0.9. Generated on 17/02/2004 14:12.