edu.umd.cfar.lamp.viper.geometry
Class Squiggle

java.lang.Object
  extended byedu.umd.cfar.lamp.viper.geometry.Squiggle
All Implemented Interfaces:
java.lang.Cloneable, Moveable

public class Squiggle
extends java.lang.Object
implements java.lang.Cloneable, Moveable

Represents a squiggly line as a list of connected line segments.


Field Summary
 
Fields inherited from interface edu.umd.cfar.lamp.viper.geometry.Moveable
EAST, NORTH, NORTHEAST, NORTHWEST, SOUTH, SOUTHEAST, SOUTHWEST, WEST
 
Constructor Summary
Squiggle()
          Constructs the empty squiggle.
Squiggle(java.lang.String S)
          Constructs a new squiggle from the given list of parenthesized points.
 
Method Summary
 void addPoint(Pnt p)
          Adds a new point at the end of the squiggle.
 java.lang.Object clone()
          Copies the squiggle.
 boolean diagonalie(Pnt a, Pnt b)
          Determines if the segment ab is a diagonal that doesn't intersect the edge.
 BoundingBox getBoundingBox()
          Gets the closest bounding box around the squiggle.
 java.util.Iterator getPoints()
          Gets an iterator through all the (@link Pnt} objects making up the squiggle.
 boolean isClockwise()
          Determine the direction of the points in the squiggle, assuming a closed squiggle.
 Moveable move(int direction, int distance)
          Creates a new copy of this movable item, shifted in the given direction by the given number of pixels.
 Squiggle reverse()
          Returns this squiggle, with the points in the opposite order.
 Moveable shift(int x, int y)
          Shifts the moveable by the given amount.
 java.lang.String toString()
          Gets a string representation.
 java.util.List triangulate()
          Returns a list of triangle polygonsthat, together, tile the interior of this squiggle.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Squiggle

public Squiggle()
Constructs the empty squiggle.


Squiggle

public Squiggle(java.lang.String S)
         throws BadDataException
Constructs a new squiggle from the given list of parenthesized points.

Parameters:
S - a string in the form (x y) ...
Throws:
BadDataException
Method Detail

clone

public java.lang.Object clone()
Copies the squiggle.

Returns:
a new copy of the squiggle.

toString

public java.lang.String toString()
Gets a string representation.

Returns:
a string representation as a list of vertices

getBoundingBox

public BoundingBox getBoundingBox()
Gets the closest bounding box around the squiggle.

Returns:
the closest bounding box around the squiggle

getPoints

public java.util.Iterator getPoints()
Gets an iterator through all the (@link Pnt} objects making up the squiggle.

Returns:
an Iterator of Pnts.

addPoint

public void addPoint(Pnt p)
Adds a new point at the end of the squiggle.

Parameters:
p - the point to add.

move

public Moveable move(int direction,
                     int distance)
Description copied from interface: Moveable
Creates a new copy of this movable item, shifted in the given direction by the given number of pixels.

Specified by:
move in interface Moveable
Parameters:
direction - the direction to move the item
distance - the distance to move it
Returns:
the new item, the same as the old one, but shifted

shift

public Moveable shift(int x,
                      int y)
Description copied from interface: Moveable
Shifts the moveable by the given amount.

Specified by:
shift in interface Moveable
Parameters:
x -
y -
Returns:

reverse

public Squiggle reverse()
Returns this squiggle, with the points in the opposite order.

Returns:
the reversed-point-list squiggle

isClockwise

public boolean isClockwise()
Determine the direction of the points in the squiggle, assuming a closed squiggle.

Returns:
if the polygon's points are listed in a clockwise direction

triangulate

public java.util.List triangulate()
Returns a list of triangle polygonsthat, together, tile the interior of this squiggle.

Returns:

diagonalie

public boolean diagonalie(Pnt a,
                          Pnt b)
Determines if the segment ab is a diagonal that doesn't intersect the edge. It may be internal or external

Parameters:
a -
b -
Returns: