@@ -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
@@ -170,8 +192,8 @@ protected void copy(DataSet dataSet) {
170
192
public String toString () {
171
193
StringBuffer buffer = new StringBuffer ();
172
194
buffer .append (toSimpleString ());
173
- for (int i = 0 ; i < mValues .size (); i ++) {
174
- buffer .append (mValues .get (i ).toString () + " " );
195
+ for (int i = 0 ; i < mEntries .size (); i ++) {
196
+ buffer .append (mEntries .get (i ).toString () + " " );
175
197
}
176
198
return buffer .toString ();
177
199
}
@@ -184,7 +206,7 @@ public String toString() {
184
206
*/
185
207
public String toSimpleString () {
186
208
StringBuffer buffer = new StringBuffer ();
187
- buffer .append ("DataSet, label: " + (getLabel () == null ? "" : getLabel ()) + ", entries: " + mValues .size () +
209
+ buffer .append ("DataSet, label: " + (getLabel () == null ? "" : getLabel ()) + ", entries: " + mEntries .size () +
188
210
"\n " );
189
211
return buffer .toString ();
190
212
}
@@ -215,23 +237,23 @@ public void addEntryOrdered(T e) {
215
237
if (e == null )
216
238
return ;
217
239
218
- if (mValues == null ) {
219
- mValues = new ArrayList <T >();
240
+ if (mEntries == null ) {
241
+ mEntries = new ArrayList <T >();
220
242
}
221
243
222
244
calcMinMax (e );
223
245
224
- if (mValues .size () > 0 && mValues .get (mValues .size () - 1 ).getX () > e .getX ()) {
246
+ if (mEntries .size () > 0 && mEntries .get (mEntries .size () - 1 ).getX () > e .getX ()) {
225
247
int closestIndex = getEntryIndex (e .getX (), e .getY (), Rounding .UP );
226
- mValues .add (closestIndex , e );
248
+ mEntries .add (closestIndex , e );
227
249
} else {
228
- mValues .add (e );
250
+ mEntries .add (e );
229
251
}
230
252
}
231
253
232
254
@ Override
233
255
public void clear () {
234
- mValues .clear ();
256
+ mEntries .clear ();
235
257
notifyDataSetChanged ();
236
258
}
237
259
@@ -241,9 +263,9 @@ public boolean addEntry(T e) {
241
263
if (e == null )
242
264
return false ;
243
265
244
- List <T > values = getValues ();
266
+ List <T > values = getEntries ();
245
267
if (values == null ) {
246
- values = new ArrayList <T >();
268
+ values = new ArrayList <>();
247
269
}
248
270
249
271
calcMinMax (e );
@@ -258,11 +280,11 @@ public boolean removeEntry(T e) {
258
280
if (e == null )
259
281
return false ;
260
282
261
- if (mValues == null )
283
+ if (mEntries == null )
262
284
return false ;
263
285
264
286
// remove the entry
265
- boolean removed = mValues .remove (e );
287
+ boolean removed = mEntries .remove (e );
266
288
267
289
if (removed ) {
268
290
calcMinMax ();
@@ -273,15 +295,15 @@ public boolean removeEntry(T e) {
273
295
274
296
@ Override
275
297
public int getEntryIndex (Entry e ) {
276
- return mValues .indexOf (e );
298
+ return mEntries .indexOf (e );
277
299
}
278
300
279
301
@ Override
280
302
public T getEntryForXValue (float xValue , float closestToY , Rounding rounding ) {
281
303
282
304
int index = getEntryIndex (xValue , closestToY , rounding );
283
305
if (index > -1 )
284
- return mValues .get (index );
306
+ return mEntries .get (index );
285
307
return null ;
286
308
}
287
309
@@ -292,24 +314,24 @@ public T getEntryForXValue(float xValue, float closestToY) {
292
314
293
315
@ Override
294
316
public T getEntryForIndex (int index ) {
295
- return mValues .get (index );
317
+ return mEntries .get (index );
296
318
}
297
319
298
320
@ Override
299
321
public int getEntryIndex (float xValue , float closestToY , Rounding rounding ) {
300
322
301
- if (mValues == null || mValues .isEmpty ())
323
+ if (mEntries == null || mEntries .isEmpty ())
302
324
return -1 ;
303
325
304
326
int low = 0 ;
305
- int high = mValues .size () - 1 ;
327
+ int high = mEntries .size () - 1 ;
306
328
int closest = high ;
307
329
308
330
while (low < high ) {
309
331
int m = (low + high ) / 2 ;
310
332
311
- final float d1 = mValues .get (m ).getX () - xValue ,
312
- d2 = mValues .get (m + 1 ).getX () - xValue ,
333
+ final float d1 = mEntries .get (m ).getX () - xValue ,
334
+ d2 = mEntries .get (m + 1 ).getX () - xValue ,
313
335
ad1 = Math .abs (d1 ), ad2 = Math .abs (d2 );
314
336
315
337
if (ad2 < ad1 ) {
@@ -336,10 +358,10 @@ public int getEntryIndex(float xValue, float closestToY, Rounding rounding) {
336
358
}
337
359
338
360
if (closest != -1 ) {
339
- float closestXValue = mValues .get (closest ).getX ();
361
+ float closestXValue = mEntries .get (closest ).getX ();
340
362
if (rounding == Rounding .UP ) {
341
363
// If rounding up, and found x-value is lower than specified x, and we can go upper...
342
- if (closestXValue < xValue && closest < mValues .size () - 1 ) {
364
+ if (closestXValue < xValue && closest < mEntries .size () - 1 ) {
343
365
++closest ;
344
366
}
345
367
} else if (rounding == Rounding .DOWN ) {
@@ -351,18 +373,18 @@ public int getEntryIndex(float xValue, float closestToY, Rounding rounding) {
351
373
352
374
// Search by closest to y-value
353
375
if (!Float .isNaN (closestToY )) {
354
- while (closest > 0 && mValues .get (closest - 1 ).getX () == closestXValue )
376
+ while (closest > 0 && mEntries .get (closest - 1 ).getX () == closestXValue )
355
377
closest -= 1 ;
356
378
357
- float closestYValue = mValues .get (closest ).getY ();
379
+ float closestYValue = mEntries .get (closest ).getY ();
358
380
int closestYIndex = closest ;
359
381
360
382
while (true ) {
361
383
closest += 1 ;
362
- if (closest >= mValues .size ())
384
+ if (closest >= mEntries .size ())
363
385
break ;
364
386
365
- final Entry value = mValues .get (closest );
387
+ final Entry value = mEntries .get (closest );
366
388
367
389
if (value .getX () != closestXValue )
368
390
break ;
@@ -386,22 +408,22 @@ public List<T> getEntriesForXValue(float xValue) {
386
408
List <T > entries = new ArrayList <T >();
387
409
388
410
int low = 0 ;
389
- int high = mValues .size () - 1 ;
411
+ int high = mEntries .size () - 1 ;
390
412
391
413
while (low <= high ) {
392
414
int m = (high + low ) / 2 ;
393
- T entry = mValues .get (m );
415
+ T entry = mEntries .get (m );
394
416
395
417
// if we have a match
396
418
if (xValue == entry .getX ()) {
397
- while (m > 0 && mValues .get (m - 1 ).getX () == xValue )
419
+ while (m > 0 && mEntries .get (m - 1 ).getX () == xValue )
398
420
m --;
399
421
400
- high = mValues .size ();
422
+ high = mEntries .size ();
401
423
402
424
// loop over all "equal" entries
403
425
for (; m < high ; m ++) {
404
- entry = mValues .get (m );
426
+ entry = mEntries .get (m );
405
427
if (entry .getX () == xValue ) {
406
428
entries .add (entry );
407
429
} else {
0 commit comments