@@ -17,7 +17,7 @@ public abstract class DataSet<T extends Entry> extends BaseDataSet<T> {
17
17
/**
18
18
* the entries that this DataSet represents / holds together
19
19
*/
20
- protected List <T > mValues = null ;
20
+ protected List <T > mEntries ;
21
21
22
22
/**
23
23
* maximum y-value in the value array
@@ -45,15 +45,15 @@ public abstract class DataSet<T extends Entry> extends BaseDataSet<T> {
45
45
* label that describes the DataSet can be specified. The label can also be
46
46
* used to retrieve the DataSet from a ChartData object.
47
47
*
48
- * @param values
48
+ * @param entries
49
49
* @param label
50
50
*/
51
- public DataSet (List <T > values , String label ) {
51
+ public DataSet (List <T > entries , String label ) {
52
52
super (label );
53
- this .mValues = values ;
53
+ this .mEntries = entries ;
54
54
55
- if (mValues == null )
56
- mValues = new ArrayList <T >();
55
+ if (mEntries == null )
56
+ mEntries = new ArrayList <T >();
57
57
58
58
calcMinMax ();
59
59
}
@@ -66,10 +66,10 @@ public void calcMinMax() {
66
66
mXMax = -Float .MAX_VALUE ;
67
67
mXMin = Float .MAX_VALUE ;
68
68
69
- if (mValues == null || mValues .isEmpty ())
69
+ if (mEntries == null || mEntries .isEmpty ())
70
70
return ;
71
71
72
- for (T e : mValues ) {
72
+ for (T e : mEntries ) {
73
73
calcMinMax (e );
74
74
}
75
75
}
@@ -79,7 +79,7 @@ public void calcMinMaxY(float fromX, float toX) {
79
79
mYMax = -Float .MAX_VALUE ;
80
80
mYMin = Float .MAX_VALUE ;
81
81
82
- if (mValues == null || mValues .isEmpty ())
82
+ if (mEntries == null || mEntries .isEmpty ())
83
83
return ;
84
84
85
85
int indexFrom = getEntryIndex (fromX , Float .NaN , Rounding .DOWN );
@@ -90,7 +90,7 @@ public void calcMinMaxY(float fromX, float toX) {
90
90
for (int i = indexFrom ; i <= indexTo ; i ++) {
91
91
92
92
// only recalculate y
93
- calcMinMaxY (mValues .get (i ));
93
+ calcMinMaxY (mEntries .get (i ));
94
94
}
95
95
}
96
96
@@ -129,25 +129,47 @@ protected void calcMinMaxY(T e) {
129
129
130
130
@ Override
131
131
public int getEntryCount () {
132
- return mValues .size ();
132
+ return mEntries .size ();
133
133
}
134
134
135
135
/**
136
- * Returns the array of entries that this DataSet represents.
136
+ * This method is deprecated.
137
+ * Use getEntries() instead.
137
138
*
138
139
* @return
139
140
*/
141
+ @ Deprecated
140
142
public List <T > getValues () {
141
- return mValues ;
143
+ return mEntries ;
142
144
}
143
145
144
146
/**
145
- * Sets the array of entries that this DataSet represents, and calls notifyDataSetChanged()
147
+ * Returns the array of entries that this DataSet represents.
146
148
*
147
149
* @return
148
150
*/
151
+ public List <T > getEntries () {
152
+ return mEntries ;
153
+ }
154
+
155
+ /**
156
+ * This method is deprecated.
157
+ * Use setEntries(...) instead.
158
+ *
159
+ * @param values
160
+ */
161
+ @ Deprecated
149
162
public void setValues (List <T > values ) {
150
- mValues = values ;
163
+ setEntries (values );
164
+ }
165
+
166
+ /**
167
+ * Sets the array of entries that this DataSet represents, and calls notifyDataSetChanged()
168
+ *
169
+ * @return
170
+ */
171
+ public void setEntries (List <T > entries ) {
172
+ mEntries = entries ;
151
173
notifyDataSetChanged ();
152
174
}
153
175
@@ -162,8 +184,8 @@ public void setValues(List<T> values) {
162
184
public String toString () {
163
185
StringBuffer buffer = new StringBuffer ();
164
186
buffer .append (toSimpleString ());
165
- for (int i = 0 ; i < mValues .size (); i ++) {
166
- buffer .append (mValues .get (i ).toString () + " " );
187
+ for (int i = 0 ; i < mEntries .size (); i ++) {
188
+ buffer .append (mEntries .get (i ).toString () + " " );
167
189
}
168
190
return buffer .toString ();
169
191
}
@@ -176,7 +198,7 @@ public String toString() {
176
198
*/
177
199
public String toSimpleString () {
178
200
StringBuffer buffer = new StringBuffer ();
179
- buffer .append ("DataSet, label: " + (getLabel () == null ? "" : getLabel ()) + ", entries: " + mValues .size () +
201
+ buffer .append ("DataSet, label: " + (getLabel () == null ? "" : getLabel ()) + ", entries: " + mEntries .size () +
180
202
"\n " );
181
203
return buffer .toString ();
182
204
}
@@ -207,23 +229,23 @@ public void addEntryOrdered(T e) {
207
229
if (e == null )
208
230
return ;
209
231
210
- if (mValues == null ) {
211
- mValues = new ArrayList <T >();
232
+ if (mEntries == null ) {
233
+ mEntries = new ArrayList <T >();
212
234
}
213
235
214
236
calcMinMax (e );
215
237
216
- if (mValues .size () > 0 && mValues .get (mValues .size () - 1 ).getX () > e .getX ()) {
238
+ if (mEntries .size () > 0 && mEntries .get (mEntries .size () - 1 ).getX () > e .getX ()) {
217
239
int closestIndex = getEntryIndex (e .getX (), e .getY (), Rounding .UP );
218
- mValues .add (closestIndex , e );
240
+ mEntries .add (closestIndex , e );
219
241
} else {
220
- mValues .add (e );
242
+ mEntries .add (e );
221
243
}
222
244
}
223
245
224
246
@ Override
225
247
public void clear () {
226
- mValues .clear ();
248
+ mEntries .clear ();
227
249
notifyDataSetChanged ();
228
250
}
229
251
@@ -233,9 +255,9 @@ public boolean addEntry(T e) {
233
255
if (e == null )
234
256
return false ;
235
257
236
- List <T > values = getValues ();
258
+ List <T > values = getEntries ();
237
259
if (values == null ) {
238
- values = new ArrayList <T >();
260
+ values = new ArrayList <>();
239
261
}
240
262
241
263
calcMinMax (e );
@@ -250,11 +272,11 @@ public boolean removeEntry(T e) {
250
272
if (e == null )
251
273
return false ;
252
274
253
- if (mValues == null )
275
+ if (mEntries == null )
254
276
return false ;
255
277
256
278
// remove the entry
257
- boolean removed = mValues .remove (e );
279
+ boolean removed = mEntries .remove (e );
258
280
259
281
if (removed ) {
260
282
calcMinMax ();
@@ -265,15 +287,15 @@ public boolean removeEntry(T e) {
265
287
266
288
@ Override
267
289
public int getEntryIndex (Entry e ) {
268
- return mValues .indexOf (e );
290
+ return mEntries .indexOf (e );
269
291
}
270
292
271
293
@ Override
272
294
public T getEntryForXValue (float xValue , float closestToY , Rounding rounding ) {
273
295
274
296
int index = getEntryIndex (xValue , closestToY , rounding );
275
297
if (index > -1 )
276
- return mValues .get (index );
298
+ return mEntries .get (index );
277
299
return null ;
278
300
}
279
301
@@ -284,24 +306,24 @@ public T getEntryForXValue(float xValue, float closestToY) {
284
306
285
307
@ Override
286
308
public T getEntryForIndex (int index ) {
287
- return mValues .get (index );
309
+ return mEntries .get (index );
288
310
}
289
311
290
312
@ Override
291
313
public int getEntryIndex (float xValue , float closestToY , Rounding rounding ) {
292
314
293
- if (mValues == null || mValues .isEmpty ())
315
+ if (mEntries == null || mEntries .isEmpty ())
294
316
return -1 ;
295
317
296
318
int low = 0 ;
297
- int high = mValues .size () - 1 ;
319
+ int high = mEntries .size () - 1 ;
298
320
int closest = high ;
299
321
300
322
while (low < high ) {
301
323
int m = (low + high ) / 2 ;
302
324
303
- final float d1 = mValues .get (m ).getX () - xValue ,
304
- d2 = mValues .get (m + 1 ).getX () - xValue ,
325
+ final float d1 = mEntries .get (m ).getX () - xValue ,
326
+ d2 = mEntries .get (m + 1 ).getX () - xValue ,
305
327
ad1 = Math .abs (d1 ), ad2 = Math .abs (d2 );
306
328
307
329
if (ad2 < ad1 ) {
@@ -328,10 +350,10 @@ public int getEntryIndex(float xValue, float closestToY, Rounding rounding) {
328
350
}
329
351
330
352
if (closest != -1 ) {
331
- float closestXValue = mValues .get (closest ).getX ();
353
+ float closestXValue = mEntries .get (closest ).getX ();
332
354
if (rounding == Rounding .UP ) {
333
355
// If rounding up, and found x-value is lower than specified x, and we can go upper...
334
- if (closestXValue < xValue && closest < mValues .size () - 1 ) {
356
+ if (closestXValue < xValue && closest < mEntries .size () - 1 ) {
335
357
++closest ;
336
358
}
337
359
} else if (rounding == Rounding .DOWN ) {
@@ -343,18 +365,18 @@ public int getEntryIndex(float xValue, float closestToY, Rounding rounding) {
343
365
344
366
// Search by closest to y-value
345
367
if (!Float .isNaN (closestToY )) {
346
- while (closest > 0 && mValues .get (closest - 1 ).getX () == closestXValue )
368
+ while (closest > 0 && mEntries .get (closest - 1 ).getX () == closestXValue )
347
369
closest -= 1 ;
348
370
349
- float closestYValue = mValues .get (closest ).getY ();
371
+ float closestYValue = mEntries .get (closest ).getY ();
350
372
int closestYIndex = closest ;
351
373
352
374
while (true ) {
353
375
closest += 1 ;
354
- if (closest >= mValues .size ())
376
+ if (closest >= mEntries .size ())
355
377
break ;
356
378
357
- final Entry value = mValues .get (closest );
379
+ final Entry value = mEntries .get (closest );
358
380
359
381
if (value .getX () != closestXValue )
360
382
break ;
@@ -378,22 +400,22 @@ public List<T> getEntriesForXValue(float xValue) {
378
400
List <T > entries = new ArrayList <T >();
379
401
380
402
int low = 0 ;
381
- int high = mValues .size () - 1 ;
403
+ int high = mEntries .size () - 1 ;
382
404
383
405
while (low <= high ) {
384
406
int m = (high + low ) / 2 ;
385
- T entry = mValues .get (m );
407
+ T entry = mEntries .get (m );
386
408
387
409
// if we have a match
388
410
if (xValue == entry .getX ()) {
389
- while (m > 0 && mValues .get (m - 1 ).getX () == xValue )
411
+ while (m > 0 && mEntries .get (m - 1 ).getX () == xValue )
390
412
m --;
391
413
392
- high = mValues .size ();
414
+ high = mEntries .size ();
393
415
394
416
// loop over all "equal" entries
395
417
for (; m < high ; m ++) {
396
- entry = mValues .get (m );
418
+ entry = mEntries .get (m );
397
419
if (entry .getX () == xValue ) {
398
420
entries .add (entry );
399
421
} else {
0 commit comments