forked from PhilJay/MPAndroidChart
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRenderer.java
More file actions
71 lines (57 loc) · 2.09 KB
/
Renderer.java
File metadata and controls
71 lines (57 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package com.github.mikephil.charting.renderer;
import com.github.mikephil.charting.interfaces.BarLineScatterCandleDataProvider;
import com.github.mikephil.charting.utils.ViewPortHandler;
/**
* Abstract baseclass of all Renderers.
*
* @author Philipp Jahoda
*/
public abstract class Renderer {
/**
* the component that handles the drawing area of the chart and it's offsets
*/
protected ViewPortHandler mViewPortHandler;
/** the minimum value on the x-axis that should be plotted */
protected int mMinX = 0;
/** the maximum value on the x-axis that should be plotted */
protected int mMaxX = 0;
public Renderer(ViewPortHandler viewPortHandler) {
this.mViewPortHandler = viewPortHandler;
}
/**
* Returns true if the specified value fits in between the provided min
* and max bounds, false if not.
*
* @param val
* @param min
* @param max
* @return
*/
protected boolean fitsBounds(float val, float min, float max) {
if (val < min || val > max)
return false;
else
return true;
}
/**
* Calculates the minimum and maximum x-value the chart can currently
* display (with the given zoom level).
*
* @param chart
* @param modulus
*/
public void calcXBounds(BarLineScatterCandleDataProvider chart, int xAxisModulus) {
int low = chart.getLowestVisibleXIndex();
int high = chart.getHighestVisibleXIndex();
int subLow = (low % xAxisModulus == 0) ? xAxisModulus : 0;
mMinX = Math.max((low / xAxisModulus) * (xAxisModulus) - subLow, 0);
mMaxX = Math.min((high / xAxisModulus) * (xAxisModulus) + xAxisModulus, (int) chart.getXChartMax());
// double minx = trans.getValuesByTouchPoint(mViewPortHandler.contentLeft(), 0).x;
// double maxx = trans.getValuesByTouchPoint(mViewPortHandler.contentRight(), 0).x;
//
// if (!Double.isInfinite(minx))
// mMinX = (int) minx;
// if (!Double.isInfinite(maxx))
// mMaxX = (int) Math.ceil(maxx);
}
}