@Override public void cancelAnimation() { isAnimationStarted = false; handler.removeCallbacks(runnable); chart.animationDataFinished(); animationListener.onAnimationFinished(); }
@Override public void onAnimationUpdate(ValueAnimator animation) { chart.animationDataUpdate(animation.getAnimatedFraction()); }
public void resetTouchHandler() { this.computator = chart.getChartComputator(); this.renderer = chart.getChartRenderer(); }
public Viewport advanceViewport(Chart chart, Chart previewChart, float hours) { viewport = new Viewport(previewChart.getMaximumViewport()); viewport.inset((float) ((86400000 / hours) / FUZZER), 0); double distance_to_move = ((new Date().getTime()) / FUZZER) - viewport.left - (((viewport.right - viewport.left) / 2)); viewport.offset((float) distance_to_move, 0); return viewport; }
@Override public void resetRenderer() { this.computator = chart.getChartComputator(); }
private void onChartDataOrSizeChanged() { initAxis(chart.getChartData().getAxisXTop(), TOP); initAxis(chart.getChartData().getAxisXBottom(), BOTTOM); initAxis(chart.getChartData().getAxisYLeft(), LEFT); initAxis(chart.getChartData().getAxisYRight(), RIGHT); }
@Override public void onAnimationEnd(Animator animation) { chart.setCurrentViewport(targetViewport); animationListener.onAnimationFinished(); }
selectionModeOldValue.clear(); if (wasTouched && !renderer.isTouched()) { chart.callTouchListener(); chart.callTouchListener(); chart.callTouchListener(); renderer.clearTouch();
public Viewport advanceViewport(Chart chart, Chart previewChart, float hours) { viewport = new Viewport(previewChart.getMaximumViewport()); viewport.inset((float) ((86400000 / hours) / FUZZER), 0); double distance_to_move = ((new Date().getTime()) / FUZZER) - viewport.left - (((viewport.right - viewport.left) / 2)); viewport.offset((float) distance_to_move, 0); return viewport; }
public void resetRenderer() { this.computator = chart.getChartComputator(); }
/** * Draw axes labels and names in the foreground. * * @param canvas */ public void drawInForeground(Canvas canvas) { Axis axis = chart.getChartData().getAxisYLeft(); if (null != axis) { drawAxisLabelsAndName(canvas, axis, LEFT); } axis = chart.getChartData().getAxisYRight(); if (null != axis) { drawAxisLabelsAndName(canvas, axis, RIGHT); } axis = chart.getChartData().getAxisXBottom(); if (null != axis) { drawAxisLabelsAndName(canvas, axis, BOTTOM); } axis = chart.getChartData().getAxisXTop(); if (null != axis) { drawAxisLabelsAndName(canvas, axis, TOP); } }
@Override public void cancelAnimation() { isAnimationStarted = false; handler.removeCallbacks(runnable); chart.setCurrentViewport(targetViewport); animationListener.onAnimationFinished(); }
public Viewport advanceViewport(Chart chart, Chart previewChart) { viewport = new Viewport(previewChart.getMaximumViewport()); viewport.inset((float) ((86400000 / 2.5) / FUZZER), 0); double distance_to_move = ((new Date().getTime())/ FUZZER) - viewport.left - (((viewport.right - viewport.left) /2)); viewport.offset((float) distance_to_move, 0); return viewport; }
public ChartTouchHandler(Context context, Chart chart) { this.chart = chart; this.computator = chart.getChartComputator(); this.renderer = chart.getChartRenderer(); gestureDetector = new GestureDetector(context, new ChartGestureListener()); scaleGestureDetector = new ScaleGestureDetector(context, new ChartScaleGestureListener()); chartScroller = new ChartScroller(context); chartZoomer = new ChartZoomer(context, ZoomType.HORIZONTAL_AND_VERTICAL); }
private void insetContentRectWithAxesMargins(int axisMargin, int position) { if (LEFT == position) { chart.getChartComputator().insetContentRect(axisMargin, 0, 0, 0); } else if (RIGHT == position) { chart.getChartComputator().insetContentRect(0, 0, axisMargin, 0); } else if (TOP == position) { chart.getChartComputator().insetContentRect(0, axisMargin, 0, 0); } else if (BOTTOM == position) { chart.getChartComputator().insetContentRect(0, 0, 0, axisMargin); } }
@Override public void onChartDataChanged() { final ChartData data = chart.getChartData(); Typeface typeface = chart.getChartData().getValueLabelTypeface(); if (null != typeface) { labelPaint.setTypeface(typeface); } labelPaint.setColor(data.getValueLabelTextColor()); labelPaint.setTextSize(ChartUtils.sp2px(scaledDensity, data.getValueLabelTextSize())); labelPaint.getFontMetricsInt(fontMetrics); this.isValueLabelBackgroundEnabled = data.isValueLabelBackgroundEnabled(); this.isValueLabelBackgroundAuto = data.isValueLabelBackgroundAuto(); this.labelBackgroundPaint.setColor(data.getValueLabelBackgroundColor()); // Important - clear selection when data changed. selectedValue.clear(); }
@Override public void onAnimationUpdate(ValueAnimator animation) { float scale = animation.getAnimatedFraction(); float diffLeft = (targetViewport.left - startViewport.left) * scale; float diffTop = (targetViewport.top - startViewport.top) * scale; float diffRight = (targetViewport.right - startViewport.right) * scale; float diffBottom = (targetViewport.bottom - startViewport.bottom) * scale; newViewport.set(startViewport.left + diffLeft, startViewport.top + diffTop, startViewport.right + diffRight, startViewport.bottom + diffBottom); chart.setCurrentViewport(newViewport); }
@Override public void onAnimationEnd(Animator animation) { chart.animationDataFinished(); animationListener.onAnimationFinished(); }
@Override public void onChartSizeChanged() { final ChartComputator computator = chart.getChartComputator(); Rect contentRect = computator.getContentRectMinusAllMargins(); if (contentRect.width() < contentRect.height()) { isBubbleScaledByX = true; } else { isBubbleScaledByX = false; } }
/** * Prepare axes coordinates and draw axes lines(if enabled) in the background. * * @param canvas */ public void drawInBackground(Canvas canvas) { Axis axis = chart.getChartData().getAxisYLeft(); if (null != axis) { prepareAxisToDraw(axis, LEFT); drawAxisLines(canvas, axis, LEFT); } axis = chart.getChartData().getAxisYRight(); if (null != axis) { prepareAxisToDraw(axis, RIGHT); drawAxisLines(canvas, axis, RIGHT); } axis = chart.getChartData().getAxisXBottom(); if (null != axis) { prepareAxisToDraw(axis, BOTTOM); drawAxisLines(canvas, axis, BOTTOM); } axis = chart.getChartData().getAxisXTop(); if (null != axis) { prepareAxisToDraw(axis, TOP); drawAxisLines(canvas, axis, TOP); } }