forked from PhilJay/MPAndroidChart
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEntry.java
More file actions
145 lines (124 loc) · 3.35 KB
/
Entry.java
File metadata and controls
145 lines (124 loc) · 3.35 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
package com.github.mikephil.charting.data;
/**
* Class representing one entry in the chart. Might contain multiple values.
* Might only contain a single value depending on the used constructor.
*
* @author Philipp Jahoda
*/
public class Entry {
/** the actual value */
private float mVal = 0f;
/** the index on the x-axis */
private int mXIndex = 0;
/** optional spot for additional data this Entry represents */
private Object mData = null;
/**
* A Entry represents one single entry in the chart.
*
* @param val the y value (the actual value of the entry)
* @param xIndex the corresponding index in the x value array (index on the
* x-axis of the chart, must NOT be higher than the length of the
* x-values String array)
*/
public Entry(float val, int xIndex) {
mVal = val;
mXIndex = xIndex;
}
/**
* A Entry represents one single entry in the chart.
*
* @param val the y value (the actual value of the entry)
* @param xIndex the corresponding index in the x value array (index on the
* x-axis of the chart, must NOT be higher than the length of the
* x-values String array)
* @param data Spot for additional data this Entry represents.
*/
public Entry(float val, int xIndex, Object data) {
this(val, xIndex);
this.mData = data;
}
/**
* returns the x-index the value of this object is mapped to
*
* @return
*/
public int getXIndex() {
return mXIndex;
}
/**
* sets the x-index for the entry
*
* @param x
*/
public void setXIndex(int x) {
this.mXIndex = x;
}
/**
* Returns the total value the entry represents.
*
* @return
*/
public float getVal() {
return mVal;
}
/**
* Sets the value for the entry.
*
* @param val
*/
public void setVal(float val) {
this.mVal = val;
}
/**
* Returns the data, additional information that this Entry represents, or
* null, if no data has been specified.
*
* @return
*/
public Object getData() {
return mData;
}
/**
* Sets additional data this Entry should represent.
*
* @param data
*/
public void setData(Object data) {
this.mData = data;
}
/**
* returns an exact copy of the entry
*
* @return
*/
public Entry copy() {
Entry e = new Entry(mVal, mXIndex, mData);
return e;
}
/**
* Compares value, xIndex and data of the entries. Returns true if entries
* are equal in those points, false if not. Does not check by hash-code like
* it's done by the "equals" method.
*
* @param e
* @return
*/
public boolean equalTo(Entry e) {
if (e == null)
return false;
if (e.mData != this.mData)
return false;
if (e.mXIndex != this.mXIndex)
return false;
if (Math.abs(e.mVal - this.mVal) > 0.00001f)
return false;
return true;
}
/**
* returns a string representation of the entry containing x-index and value
*/
@Override
public String toString() {
return "Entry, xIndex: " + mXIndex + " val (sum): " + getVal();
}
}