| @@ -8,6 +8,7 @@ import android.content.Context; | |||
| import android.graphics.Color; | |||
| import ch.spherIC.recurvebowsight.R; | |||
| import ch.spherIC.recurvebowsight.logic.TrajectoryCalculator; | |||
| import org.achartengine.ChartFactory; | |||
| import org.achartengine.GraphicalView; | |||
| @@ -63,6 +64,7 @@ public class FlightCurveChart { | |||
| this.mRenderer.setYTitle(context.getResources().getString(R.string.fcChart_TitleYAxis)); | |||
| this.mRenderer.setYLabelsPadding(20); | |||
| this.mRenderer.setYLabelsVerticalPadding(-5); | |||
| this.mRenderer.setYLabelsColor(0, Color.DKGRAY); | |||
| // Zoom ausschalten | |||
| @@ -106,8 +108,16 @@ public class FlightCurveChart { | |||
| public void updateRendererAfterCalculation(final Double shootingDistance, final Double[][] flightCurve) { | |||
| Double deltaH; | |||
| Double dy; | |||
| Double rangeY; | |||
| int xLbls = 1; | |||
| int yLbls = 1; | |||
| Double minH = 0.0; | |||
| Double maxH = 0.0; | |||
| // X-Achse | |||
| if (shootingDistance <= 18d) { | |||
| xLbls = (int) Math.round(shootingDistance); | |||
| } else if (shootingDistance <= 30d) { | |||
| @@ -117,11 +127,45 @@ public class FlightCurveChart { | |||
| } else { | |||
| xLbls = (int) Math.round(shootingDistance) / 10; | |||
| } | |||
| this.mRenderer.setXLabels(xLbls); | |||
| this.mRenderer.setYLabels(10); | |||
| this.mRenderer.setYAxisMin(-0.9); | |||
| this.mRenderer.setYAxisMax(0.9); | |||
| // Y-Achse | |||
| for (int i = 0; i < flightCurve.length; i++) { | |||
| if (flightCurve[i][TrajectoryCalculator.IDX_Y] > maxH) { | |||
| maxH = flightCurve[i][TrajectoryCalculator.IDX_Y]; | |||
| } | |||
| } | |||
| minH = maxH; | |||
| for (int i = 0; i < flightCurve.length; i++) { | |||
| if (flightCurve[i][TrajectoryCalculator.IDX_Y] < minH) { | |||
| minH = flightCurve[i][TrajectoryCalculator.IDX_Y]; | |||
| } | |||
| } | |||
| deltaH = maxH - minH; | |||
| if (deltaH <= shootingDistance / 10) { | |||
| dy = (shootingDistance / 10 - deltaH) / 2; | |||
| rangeY = shootingDistance / 10; | |||
| } else if (deltaH <= shootingDistance / 5) { | |||
| dy = (shootingDistance / 5 - deltaH) / 2; | |||
| rangeY = shootingDistance / 5; | |||
| } else { | |||
| dy = (deltaH + shootingDistance * 0.1) / 2; | |||
| rangeY = deltaH + shootingDistance * 0.1; | |||
| } | |||
| if (rangeY <= 3d) { | |||
| yLbls = 10; | |||
| } else if (rangeY <= 6d) { | |||
| yLbls = 12; | |||
| } else if (rangeY <= 9d) { | |||
| yLbls = 18; | |||
| } else { | |||
| yLbls = 20; | |||
| } | |||
| this.mRenderer.setYAxisMin(minH - dy); | |||
| this.mRenderer.setYAxisMax(maxH + dy); | |||
| this.mRenderer.setYLabels(yLbls); | |||
| } | |||
| } | |||