com.caffeineowl.graphics.bezier.flatnessalgos
Class GenericQuadSubdivCriterion

java.lang.Object
  extended by com.caffeineowl.graphics.bezier.flatnessalgos.GenericQuadSubdivCriterion
All Implemented Interfaces:
QuadSubdivisionCriterion

public class GenericQuadSubdivCriterion
extends java.lang.Object
implements QuadSubdivisionCriterion

A QuadSubdivisionCriterion which does its job by using a provided QuadFlatnessAlgorithm and a tolerance: the criterion will ask for yet one subdivision whenever algorithm returns a flatness value that's greater than the required tolerance.

Author:
Adrian Colomitchi (acolomitchi(monkey_tail)gmail.com)

Field Summary
protected  QuadFlatnessAlgorithm flatnessAlgo
          The flatness algorithm.
protected  double sqTol
          Squared tolerance, for the QuadFlatnessAlgorithm that prefers working with squared distances.
protected  double tol
          The tolerance.
 
Constructor Summary
GenericQuadSubdivCriterion()
          Initialises a new instance with a ConvexHullFlatnessAlgo as the flatness algorithm and a tolerance of 1.0e-5.
GenericQuadSubdivCriterion(double tolerance)
          Initialises a new instance with a ConvexHullFlatnessAlgo as the flatness algorithm and the provided tolerance.
GenericQuadSubdivCriterion(QuadFlatnessAlgorithm algo)
          Initialises a new instance the provided flatness algo and a tolerance of 1.0e-5.
GenericQuadSubdivCriterion(QuadFlatnessAlgorithm algo, double tolerance)
          Initialises using the provided parameters.
 
Method Summary
 boolean shouldSplit(java.awt.geom.QuadCurve2D curve)
          Returns true whenever the flatnessAlgo returns a value greater than the required tolerance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

flatnessAlgo

protected QuadFlatnessAlgorithm flatnessAlgo
The flatness algorithm.


tol

protected double tol
The tolerance.


sqTol

protected double sqTol
Squared tolerance, for the QuadFlatnessAlgorithm that prefers working with squared distances.

Constructor Detail

GenericQuadSubdivCriterion

public GenericQuadSubdivCriterion()
Initialises a new instance with a ConvexHullFlatnessAlgo as the flatness algorithm and a tolerance of 1.0e-5.


GenericQuadSubdivCriterion

public GenericQuadSubdivCriterion(double tolerance)
Initialises a new instance with a ConvexHullFlatnessAlgo as the flatness algorithm and the provided tolerance.


GenericQuadSubdivCriterion

public GenericQuadSubdivCriterion(QuadFlatnessAlgorithm algo)
Initialises a new instance the provided flatness algo and a tolerance of 1.0e-5.


GenericQuadSubdivCriterion

public GenericQuadSubdivCriterion(QuadFlatnessAlgorithm algo,
                                  double tolerance)
Initialises using the provided parameters.

Method Detail

shouldSplit

public boolean shouldSplit(java.awt.geom.QuadCurve2D curve)
Returns true whenever the flatnessAlgo returns a value greater than the required tolerance. If the flatness algorithm prefers the computation of squared distances, the comparison is made against the squared tolerance.

Specified by:
shouldSplit in interface QuadSubdivisionCriterion