wyvern.lib.properties
Class PointList

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.AbstractList
          extended byjava.util.ArrayList
              extended bywyvern.lib.properties.PointList
All Implemented Interfaces:
java.lang.Cloneable, java.util.Collection, java.util.List, MutableProperty, java.util.RandomAccess, SelfExternalizable, java.io.Serializable

public class PointList
extends java.util.ArrayList
implements SelfExternalizable, MutableProperty

This property knows how to read & write itself as a list of points.

Version:
1.0, Apr 18, 1998
Author:
Steve Yegge
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
PointList()
          Constructs a new, empty PointList.
PointList(int size)
          Constructs a new PointList with the specified size.
PointList(java.util.List locs)
          Constructs a new PointList with the specified points.
 
Method Summary
 void add(Point p)
          Adds a point to the list.
 java.lang.Object createClone()
          Produces a clone of the property for the caller.
 boolean equals(java.lang.Object o)
          Returns true if the passed PointList matches this one well enough for them to pass as "equal".
 java.util.List getList()
          Gets the list of locations.
 void readData(org.w3c.dom.Node bean)
          Initializes the object from the passed lines-list.
 void remove(Point p)
          Removes the specified point from the list.
 void setList(java.util.List locs)
          Sets the location list.
 boolean shouldWrite()
          Returns true if we should write the object at all.
 java.lang.String toString()
          Returns a String representation of the list.
 PointList translate(int xtrans, int ytrans)
          Returns a new list whose points are the original lists's, after translating each point by (x,y).
 PointList translateToOrigin()
          Returns a new list whose points are the original list's, translated so that the first point in the list is at (0,0).
 java.util.List writeData()
          Writes the object's externalized representation to the specified output stream.
 
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, remove, removeAll, retainAll
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, hashCode, iterator, listIterator, listIterator, remove, removeAll, retainAll, subList
 

Constructor Detail

PointList

public PointList(int size)
Constructs a new PointList with the specified size.


PointList

public PointList()
Constructs a new, empty PointList.


PointList

public PointList(java.util.List locs)
Constructs a new PointList with the specified points.

Parameters:
locs - the new list of points to use
Method Detail

getList

public java.util.List getList()
Gets the list of locations.

Returns:
the list of points in this PointList

setList

public void setList(java.util.List locs)
Sets the location list.

Parameters:
locs - the new list of points to use

add

public void add(Point p)
Adds a point to the list.


remove

public void remove(Point p)
Removes the specified point from the list.


readData

public void readData(org.w3c.dom.Node bean)
              throws java.lang.Exception
Initializes the object from the passed lines-list.

Specified by:
readData in interface SelfExternalizable
Parameters:
bean - the node representing the SelfExternalizable bean object, which should have at least one child data node.
Throws:
java.lang.Exception

writeData

public java.util.List writeData()
                         throws java.lang.Exception
Writes the object's externalized representation to the specified output stream.

Specified by:
writeData in interface SelfExternalizable
Returns:
a String containing the serialized version of the object.
Throws:
java.lang.Exception

shouldWrite

public boolean shouldWrite()
Returns true if we should write the object at all.

Specified by:
shouldWrite in interface SelfExternalizable
Returns:
true

createClone

public java.lang.Object createClone()
Produces a clone of the property for the caller.

Specified by:
createClone in interface MutableProperty

toString

public java.lang.String toString()
Returns a String representation of the list.


equals

public boolean equals(java.lang.Object o)
Returns true if the passed PointList matches this one well enough for them to pass as "equal".

Specified by:
equals in interface java.util.List
Parameters:
o - another PointList object

translate

public PointList translate(int xtrans,
                           int ytrans)
Returns a new list whose points are the original lists's, after translating each point by (x,y).

Parameters:
xtrans - x translation
ytrans - y translation

translateToOrigin

public PointList translateToOrigin()
Returns a new list whose points are the original list's, translated so that the first point in the list is at (0,0). That is, the list is translated by (-x, -y) where (x,y) are the coordinates of the first point in the list. Used by the map editor.