| import android.graphics.Color; | import android.graphics.Color; | ||||
| import ch.spherIC.recurvebowsight.R; | import ch.spherIC.recurvebowsight.R; | ||||
| import ch.spherIC.recurvebowsight.logic.TrajectoryCalculator; | |||||
| import org.achartengine.ChartFactory; | import org.achartengine.ChartFactory; | ||||
| import org.achartengine.GraphicalView; | import org.achartengine.GraphicalView; | ||||
| this.mRenderer.setYTitle(context.getResources().getString(R.string.fcChart_TitleYAxis)); | this.mRenderer.setYTitle(context.getResources().getString(R.string.fcChart_TitleYAxis)); | ||||
| this.mRenderer.setYLabelsPadding(20); | this.mRenderer.setYLabelsPadding(20); | ||||
| this.mRenderer.setYLabelsVerticalPadding(-5); | |||||
| this.mRenderer.setYLabelsColor(0, Color.DKGRAY); | this.mRenderer.setYLabelsColor(0, Color.DKGRAY); | ||||
| // Zoom ausschalten | // Zoom ausschalten | ||||
| public void updateRendererAfterCalculation(final Double shootingDistance, final Double[][] flightCurve) { | public void updateRendererAfterCalculation(final Double shootingDistance, final Double[][] flightCurve) { | ||||
| Double deltaH; | |||||
| Double dy; | |||||
| Double rangeY; | |||||
| int xLbls = 1; | int xLbls = 1; | ||||
| int yLbls = 1; | |||||
| Double minH = 0.0; | |||||
| Double maxH = 0.0; | |||||
| // X-Achse | |||||
| if (shootingDistance <= 18d) { | if (shootingDistance <= 18d) { | ||||
| xLbls = (int) Math.round(shootingDistance); | xLbls = (int) Math.round(shootingDistance); | ||||
| } else if (shootingDistance <= 30d) { | } else if (shootingDistance <= 30d) { | ||||
| } else { | } else { | ||||
| xLbls = (int) Math.round(shootingDistance) / 10; | xLbls = (int) Math.round(shootingDistance) / 10; | ||||
| } | } | ||||
| this.mRenderer.setXLabels(xLbls); | 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); | |||||
| } | } | ||||
| } | } |