Posted by pepe
on February 26, 2008 at 10:43 PM PST
Splines project got published. Sources, a webstart demo using the integrated splines editor prototype (which only acts as a viewer at the moment) and a two liner example are online.
Splines project is my latest contribution to oss.
It is aimed at helping people use, display and edit splines without too much hassle.
The main entity of the project is Curve, which is a list of CurseSection objects. Three types of sections can be added at the moment, but the system can accept new implementations anytime (you can already add yours).
Actually implemented CurveSection types are:
linear: a direct interpolation between previous section and current
cubic: a cubic spline interpolation between previous section and current
quadratic: a quadratic spline interpolation between previous section and current
Taken from the webstart Demo , here is how i created the Curve:
Curve = new Curve( new LinearSection( 0, 0 ) ) );
curve.addSection( new LinearSection( 1.0, 5.0 ) );
curve.addSection( new QuadraticSection( 3.0, 4.0, 2, 4 ) );
curve.addSection( new CubicSection( 6., 2., 4, 5, 5, 0 ) );
Cannot be easier.
and here is how i displayed the curve:
this.curveViewControl.setCurve( curve )
Once again, cannot be easier.
Curve and its sections can be listened for modification, curve can be serialized (listeners will not) and the whole is easy to use and fits in a very small single jar.
Sections can be replaced by others, and section objects can be modified externally. Library is totally threadsafe and a curve or its sections can be used and modified from multiple threads without collisions.
Plans for the future are to enhance the swing component to enable pluggable editors for curves, pluggable renderers, and before all more complete refreshing after edit.