All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.graphbuilder.curve.Polyline Maven / Gradle / Ivy

Go to download

Implementation of various mathematical curves that define themselves over a set of control points. The API is written in Java. The curves supported are: Bezier, B-Spline, Cardinal Spline, Catmull-Rom Spline, Lagrange, Natural Cubic Spline, and NURBS.

There is a newer version: 1.08
Show newest version
package com.graphbuilder.curve;

/**
A polyline is a sequence of connected line segments based on the control-path points specified
by the group-iterator.
*/

public class Polyline extends Curve {

	public Polyline(ControlPath cp, GroupIterator gi) {
		super(cp, gi);
	}

	public void appendTo(MultiPath mp) {
		if (!gi.isInRange(0, cp.numPoints()))
			throw new IllegalArgumentException("Group iterator not in range");

		gi.set(0, 0);

		if (connect)
			mp.lineTo(cp.getPoint(gi.next()).getLocation());
		else
			mp.moveTo(cp.getPoint(gi.next()).getLocation());

		while (gi.hasNext())
			mp.lineTo(cp.getPoint(gi.next()).getLocation());
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy