com.partnersoft.geometry.xy
Class XyPolylineBuilder

java.lang.Object
  extended by com.partnersoft.geometry.xy.XyPolylineBuilder

public class XyPolylineBuilder
extends java.lang.Object

Builder class for XyPolylines.

This class gives you a straightforward method of accumulating vertices for a polyline. It has a few extra conveniences over a raw XyDynamicPointArray. For example, you can set a minimum segment length, and it will discard points given if they are not at least that far away from the previous point.

Copyright 2007 Partner Software, Inc.

Version:
$Id: XyPolylineBuilder.java 2474 2010-03-13 14:28:43Z paul $
Author:
Paul Reavis, Rich Stepanski

Constructor Summary
XyPolylineBuilder()
           
 
Method Summary
 void append(double... coords)
          Appends coordinates, which must be in the order x1, y1, x2, y2, etc.
 void append(double[] coords, int start, int size)
          Appends coordinates, which must be in the order x1, y1, x2, y2, etc.
 void append(XyPoint point)
          Adds a new point, if it is different from the current last point.
 void append(XyPolyline polyline)
          Appends all the points in the given polyline.
 void clear()
          Clears the current points, so that we start fresh.
 double getMinimumSegmentLength()
          Get the current minimum segment length setting.
 int getPointCount()
           
 XyPolyline getPolyline()
          Returns the constructed XyPolyline, or null if there were not enough points to build one.
 boolean isEmpty()
          Returns true if there are no points appended to this builder.
 void setMinimumSegmentLength(double newLength)
          Sets the current minimum segment length.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XyPolylineBuilder

public XyPolylineBuilder()
Method Detail

append

public void append(XyPoint point)
Adds a new point, if it is different from the current last point.


append

public void append(XyPolyline polyline)
Appends all the points in the given polyline. Does not duplicate the current last point and the start point of the given polyline if they are equal.


append

public void append(double... coords)
Appends coordinates, which must be in the order x1, y1, x2, y2, etc.


append

public void append(double[] coords,
                   int start,
                   int size)
Appends coordinates, which must be in the order x1, y1, x2, y2, etc.


getPolyline

public XyPolyline getPolyline()
Returns the constructed XyPolyline, or null if there were not enough points to build one. You can keep calling this as you build, if for some reason you want polylines at different stages while you're building. Returns null if you don't have enough points.


clear

public void clear()
Clears the current points, so that we start fresh.


isEmpty

public boolean isEmpty()
Returns true if there are no points appended to this builder.


getPointCount

public int getPointCount()

getMinimumSegmentLength

public double getMinimumSegmentLength()
Get the current minimum segment length setting. Zero means there is no minimum length.


setMinimumSegmentLength

public void setMinimumSegmentLength(double newLength)
Sets the current minimum segment length. Zero means there is no minimum length.