gizmoball.shape
Class UnionShape

java.lang.Object
  extended by gizmoball.shape.UnionShape
All Implemented Interfaces:
Shape
Direct Known Subclasses:
FlipperShape

public class UnionShape
extends java.lang.Object
implements Shape

This object, implementing the Shape interface, represents a shape constructed as a combination of other shapes.

Author:
Eitan Reich

Constructor Summary
UnionShape(java.util.List<Shape> shapes)
          Constructs a UnionShape out of a list of shapes, which must all be either Cirle09, Polygon or UnionShape.
UnionShape(Shape s1, Shape s2)
          Constructs a UnionShape out of a pair of shapes, which must be either Circle09, UnionShape or Polygon.
 
Method Summary
 boolean containsPoint(Vect pt)
          returns true iff shape contains specified point
 java.util.List<Circle> getCircles()
          returns list of circles constituting UnionShape
 java.util.List<LineSegment> getLineSegments()
          returns list of LineSegments constituting UnionShape
 java.util.List<Shape> getShapes()
           
 Vect maxXY()
          Returns the maximum coordinates of a bounding rectangle of the shape
 Vect minXY()
          Returns the minimum coordinates for a bounding rectangle of the shape
 UnionShape rotate(Angle theta, Vect centerOfRotation)
          returns a new UnionShape rotated by specified angle around center of rotation
 UnionShape translate(Vect v)
          returns a new UnionShape translated by specified vector.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UnionShape

public UnionShape(java.util.List<Shape> shapes)
Constructs a UnionShape out of a list of shapes, which must all be either Cirle09, Polygon or UnionShape.

Parameters:
shapes - list of shapes

UnionShape

public UnionShape(Shape s1,
                  Shape s2)
Constructs a UnionShape out of a pair of shapes, which must be either Circle09, UnionShape or Polygon.

Parameters:
s1 - shape
s2 - shape
Method Detail

minXY

public Vect minXY()
Returns the minimum coordinates for a bounding rectangle of the shape

Specified by:
minXY in interface Shape
Returns:
the minimum coordinates for a bounding rectangle of the shape

maxXY

public Vect maxXY()
Returns the maximum coordinates of a bounding rectangle of the shape

Specified by:
maxXY in interface Shape
Returns:
the maximum coordinates for a bounding rectangle of the shape

getShapes

public java.util.List<Shape> getShapes()
Returns:
list of shapes constituting the UnionShape

containsPoint

public boolean containsPoint(Vect pt)
returns true iff shape contains specified point

Specified by:
containsPoint in interface Shape

getCircles

public java.util.List<Circle> getCircles()
returns list of circles constituting UnionShape

Specified by:
getCircles in interface Shape
Returns:
List list of Circle objects

getLineSegments

public java.util.List<LineSegment> getLineSegments()
returns list of LineSegments constituting UnionShape

Specified by:
getLineSegments in interface Shape
Returns:
List list of LineSegment objects

rotate

public UnionShape rotate(Angle theta,
                         Vect centerOfRotation)
returns a new UnionShape rotated by specified angle around center of rotation

Specified by:
rotate in interface Shape
Parameters:
theta - angle to rotate
centerOfRotation - point to rotate around
Returns:
shape rotated around centerOfRotation by angle theta

translate

public UnionShape translate(Vect v)
returns a new UnionShape translated by specified vector.

Specified by:
translate in interface Shape
Parameters:
v - vector to translate shape by
Returns:
shape translated by v