Logo Search packages:      
Sourcecode: libjfreechart-java version File versions  Download package

static void org::jfree::experimental::chart::renderer::xy::XYSmoothLineAndShapeRenderer::getControlPoints ( Point2D.Double  point0,
Point2D.Double  point1,
Point2D.Double  point2,
Point2D.Double  point3,
Point2D.Double  control1,
Point2D.Double  control2,
double  smooth 
) [inline, static]

Updates the control points.

Parameters:
point0 
point1 
point2 
point3 
control1 
control2 
smooth 

Definition at line 180 of file XYSmoothLineAndShapeRenderer.java.

Referenced by getBezierCurve().

                                                    {
         
        // Reference: http://www.antigrain.com/research/bezier_interpolation/
        
        if (point0 == null) point0 = point1; //new Point2D.Double(0, 0);
        if (point3 == null) point3 = point2; //new Point2D.Double(0, 0);
        
        Point2D.Double c1 = new Point2D.Double(
               (point0.x + point1.x) / 2.0, (point0.y + point1.y) / 2.0);
        Point2D.Double c2 = new Point2D.Double(
               (point1.x + point2.x) / 2.0, (point1.y + point2.y) / 2.0);
        Point2D.Double c3 = new Point2D.Double(
               (point2.x + point3.x) / 2.0, (point2.y + point3.y) / 2.0);
        
        double len1 = point1.distance(point0);
        double len2 = point2.distance(point1);
        double len3 = point3.distance(point2);
        
        double k1 = len1 / (len1 + len2);
        double k2 = len2 / (len2 + len3);
        
        Point2D.Double m1 = new Point2D.Double(
               c1.x + (c2.x - c1.x) * k1, c1.y + (c2.y - c1.y) * k1);
        Point2D.Double m2 = new Point2D.Double(
               c2.x + (c3.x - c2.x) * k2, c2.y + (c3.y - c2.y) * k2);
        
        control1.setLocation(new Point2D.Double(
               m1.x + (c2.x - m1.x) * smooth + point1.x - m1.x,
               m1.y + (c2.y - m1.y) * smooth + point1.y - m1.y));
        control2.setLocation(new Point2D.Double(
               m2.x + (c2.x - m2.x) * smooth + point2.x - m2.x,
               m2.y + (c2.y - m2.y) * smooth + point2.y - m2.y));
    }


Generated by  Doxygen 1.6.0   Back to index