The Physiologist's Friend Simulation API

ch.unizh.ini.friend.graphics
Class ShapeList

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList
              extended by ch.unizh.ini.friend.graphics.ShapeList
All Implemented Interfaces:
Intersectable, Transformable, Serializable, Cloneable, Iterable, Collection, List, RandomAccess

public class ShapeList
extends ArrayList
implements Intersectable, Transformable, Cloneable

An ArrayList of shapes which are Transformable and Intersectable as a whole.

A GratingStimulus (for example) is constructed by adding a number of ConvexPolygons to a ShapeList in a ConcreteStimulus.

Since:
$Revision: 1.10 $
Author:
tobi
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
ShapeList()
          Creates a new instance of ShapeList with an empty shape list.
ShapeList(Transformable t)
          creates a new ShapeList initialized with the given shape.
 
Method Summary
 Transformable apply(AffineTransform at)
          Applies the given transformation to the geometric object.
 float area()
          Computes the total area of the shapes.
 Object clone()
          clones this list of shapes, including cloning of the members of the list
 Intersectable intersect(Intersectable other)
          Computes the area of intersection between this and the given other object.
 Transformable rotate(float phi)
          Rotates the geometric object by the given angle around the origin.
 Transformable rotate(float phi, float x, float y)
          Rotates the geometric object by the given angle around the given point.
 Transformable scale(float sx, float sy)
          Scales the geomtric object by the given values in x- and y-coordinates with the origin as center.
 Transformable scale(float sx, float sy, float x, float y)
          Scales the geomtric object by the given values in x- and y-coordinates with the given center (x, y).
 String ShapeList()
          string regpresentation of ShapeList
 Transformable translate(float dx, float dy)
          Translates the geometric object by the given coordinates.
 
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList
 

Constructor Detail

ShapeList

public ShapeList()
Creates a new instance of ShapeList with an empty shape list.


ShapeList

public ShapeList(Transformable t)
creates a new ShapeList initialized with the given shape.

Parameters:
t - the starting shape
Method Detail

apply

public Transformable apply(AffineTransform at)
Applies the given transformation to the geometric object.

Specified by:
apply in interface Transformable
Parameters:
at - The affine transformation to apply.
Returns:
this for easy concatenation or a transformed clone.

area

public float area()
Computes the total area of the shapes.

Specified by:
area in interface Intersectable
Returns:
The area.

intersect

public Intersectable intersect(Intersectable other)
Computes the area of intersection between this and the given other object.

Specified by:
intersect in interface Intersectable
Parameters:
other - The object to intersect with.
Returns:
The intersection object.

rotate

public Transformable rotate(float phi)
Rotates the geometric object by the given angle around the origin.

Specified by:
rotate in interface Transformable
Parameters:
phi - Rotation angle.
Returns:
this for easy concatenation or a transformed clone.

rotate

public Transformable rotate(float phi,
                            float x,
                            float y)
Rotates the geometric object by the given angle around the given point.

Specified by:
rotate in interface Transformable
Parameters:
phi - Rotation angle.
x - x-coordinate of the rotation center.
y - y-coordinate of the rotation center.
Returns:
this for easy concatenation or a transformed clone.

scale

public Transformable scale(float sx,
                           float sy)
Scales the geomtric object by the given values in x- and y-coordinates with the origin as center.

Specified by:
scale in interface Transformable
Parameters:
sx - Scalar for x-coordinates.
sy - Scalar for y-coordinates.
Returns:
this for easy concatenation or a transformed clone.

scale

public Transformable scale(float sx,
                           float sy,
                           float x,
                           float y)
Scales the geomtric object by the given values in x- and y-coordinates with the given center (x, y).

Specified by:
scale in interface Transformable
Parameters:
sx - Scalar for x-coordinates.
sy - Scalar for y-coordinates.
x - x-coordinate of the center.
y - y-coordinate of the center.
Returns:
this for easy concatenation or a transformed clone.

translate

public Transformable translate(float dx,
                               float dy)
Translates the geometric object by the given coordinates.

Specified by:
translate in interface Transformable
Parameters:
dx - Translation in x-coordinates.
dy - Translation in y-coordinates.
Returns:
this for easy concatenation or a transformed clone.

ShapeList

public String ShapeList()
string regpresentation of ShapeList


clone

public Object clone()
clones this list of shapes, including cloning of the members of the list

Specified by:
clone in interface Transformable
Overrides:
clone in class ArrayList
Returns:
The clone.

http://www.ini.unizh.ch/~tobi/friend