Back to project page zmap.
The source code is released under:
GNU Lesser General Public License
If you think the Android project zmap listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.zmap.geom; //from w w w. j ava2s . com import java.util.ArrayList; public class Polyline extends PointCollection implements IPolyline { public Polyline() { super(); bound = new Envelope(); lineLength = Double.NaN; } @Override public boolean isEmpty() { return points.size() <= 1; } @Override public IEnvelope envelope() { return bound; } @Override public double length() { return lineLength; } @Override protected void update() { super.update(); calculateLength(); calculateEnvelope(); } private void calculateLength() { double length = 0; if(!isEmpty()){ int size = pointCount(); IPoint prevPoint = points.get(0); for(int i = 1 ; i < size ; i++){ IPoint point = points.get(i); length += GeometryUtil.distance(prevPoint, point); prevPoint = point; } } lineLength = length; } private void calculateEnvelope() { if(!isEmpty()){ int size = pointCount(); IPoint prevPoint = points.get(0); IEnvelope env = prevPoint.envelope(); bound = new Envelope(env); for(int i = 1 ; i < size ; i++){ IPoint point = points.get(i); bound.unionWith(point); } } } private double lineLength; private IEnvelope bound; }