de.cau.cs.kieler.klay.layered.p5edges
Class SimpleSplineGenerator

java.lang.Object
  extended by de.cau.cs.kieler.core.alg.AbstractAlgorithm
      extended by de.cau.cs.kieler.klay.layered.p5edges.SimpleSplineGenerator
All Implemented Interfaces:
IAlgorithm, ISplineGenerator

public class SimpleSplineGenerator
extends AbstractAlgorithm
implements ISplineGenerator

Simple implementation for the spline calculator.

Rating red

Nested Class Summary
 
Nested classes/interfaces inherited from interface de.cau.cs.kieler.klay.layered.p5edges.ISplineGenerator
ISplineGenerator.curvature
 
Constructor Summary
SimpleSplineGenerator()
           
 
Method Summary
 BezierSpline generateShortSpline(KVector q, KVector s)
          Generates a spline representation for straight edges.
 BezierSpline generateSpline(LinkedList<KVector> pArray)
          generates a simple piecewise bezier curve for given points.
 BezierSpline generateSpline(LinkedList<KVector> pArray, KVector vectorQ, KVector vectorS)
          generates a simple piecewise bezier curve for given points.
 boolean refineSpline(LinkedList<KVector> pArray, BezierSpline ospline, ISplineGenerator.curvature mode)
          perturb the control points of the spline in an attempt to make the spline fit.
 boolean straightenSpline(BezierSpline spline)
          straighten_spline adjusts the control points of the spline to reduce the curvature.
 
Methods inherited from class de.cau.cs.kieler.core.alg.AbstractAlgorithm
getMonitor, reset, reset, setProgressMonitor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleSplineGenerator

public SimpleSplineGenerator()
Method Detail

generateSpline

public BezierSpline generateSpline(LinkedList<KVector> pArray,
                                   KVector vectorQ,
                                   KVector vectorS)
generates a simple piecewise bezier curve for given points.

Specified by:
generateSpline in interface ISplineGenerator
Parameters:
pArray - array with points which should be lay on the spline
vectorQ - outgoing tangent vector of the initial node
vectorS - incoming tangent vector of the final node
Returns:
created spline

generateSpline

public BezierSpline generateSpline(LinkedList<KVector> pArray)
generates a simple piecewise bezier curve for given points.

Specified by:
generateSpline in interface ISplineGenerator
Parameters:
pArray - array with points which should be lay on the spline
Returns:
created spline

generateShortSpline

public BezierSpline generateShortSpline(KVector q,
                                        KVector s)
Generates a spline representation for straight edges.

Specified by:
generateShortSpline in interface ISplineGenerator
Parameters:
q - start point
s - end point
Returns:
BezierSpline representation.

refineSpline

public boolean refineSpline(LinkedList<KVector> pArray,
                            BezierSpline ospline,
                            ISplineGenerator.curvature mode)
perturb the control points of the spline in an attempt to make the spline fit. The approach is similar to the straightening approach. We try to decrease the curvature of the spline. If this does not seem to improve the fit, we try to increase the curvature. Since this process may never terminate, max_iterations controls how many times to try.

Specified by:
refineSpline in interface ISplineGenerator
Parameters:
pArray - array with points which should be lay on the spline
ospline - spline to be refined
mode - either decrease or increase the curvature
Returns:
created spline

straightenSpline

public boolean straightenSpline(BezierSpline spline)
straighten_spline adjusts the control points of the spline to reduce the curvature. the method is only used if there's only one bezier segment in the spline

Specified by:
straightenSpline in interface ISplineGenerator
Parameters:
spline - spline to be straightened
Returns:
true if successful otherwise false