Home | History | Annotate | Download | only in xy
      1 /*
      2  * Copyright 2012 AndroidPlot.com
      3  *
      4  *    Licensed under the Apache License, Version 2.0 (the "License");
      5  *    you may not use this file except in compliance with the License.
      6  *    You may obtain a copy of the License at
      7  *
      8  *        http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  *    Unless required by applicable law or agreed to in writing, software
     11  *    distributed under the License is distributed on an "AS IS" BASIS,
     12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  *    See the License for the specific language governing permissions and
     14  *    limitations under the License.
     15  */
     16 
     17 package com.androidplot.xy;
     18 
     19 import android.graphics.Path;
     20 import android.graphics.PointF;
     21 
     22 /**
     23  * WARNING: This is an unfinished class.  Series drawn by this implementation may look nice
     24  * but they are not yet accurate representations of the control points from which they are derived.
     25  */
     26 public class BezierLineAndPointRenderer extends LineAndPointRenderer<BezierLineAndPointFormatter> {
     27     public BezierLineAndPointRenderer(XYPlot plot) {
     28         super(plot);
     29     }
     30 
     31     @Override
     32     protected void appendToPath(Path path, PointF thisPoint, PointF lastPoint) {
     33         //path.lineTo(thisPoint.x, thisPoint.y);
     34 
     35         // bezier curve version:
     36         PointF mid = new PointF();
     37         mid.set((lastPoint.x + thisPoint.x) / 2, (lastPoint.y + thisPoint.y) / 2);
     38         path.quadTo((lastPoint.x + mid.x) / 2, lastPoint.y, mid.x, mid.y);
     39         //path.quadTo((mid.x + thisPoint.x) / 2, thisPoint.y, thisPoint.x, thisPoint.y);
     40         path.quadTo((mid.x + thisPoint.x) / 2, lastPoint.y, thisPoint.x, thisPoint.y);
     41 
     42     }
     43 }
     44