Skip to content

Commit 8322de6

Browse files
committed
Renamed values -> entries for consistency
ChartsOrg/Charts#3847
1 parent 4e62248 commit 8322de6

File tree

8 files changed

+82
-60
lines changed

8 files changed

+82
-60
lines changed

MPChartLib/src/main/java/com/github/mikephil/charting/data/BarDataSet.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ public BarDataSet(List<BarEntry> yVals, String label) {
5252
@Override
5353
public DataSet<BarEntry> copy() {
5454
List<BarEntry> entries = new ArrayList<BarEntry>();
55-
for (int i = 0; i < mValues.size(); i++) {
56-
entries.add(mValues.get(i).copy());
55+
for (int i = 0; i < mEntries.size(); i++) {
56+
entries.add(mEntries.get(i).copy());
5757
}
5858
BarDataSet copied = new BarDataSet(entries, getLabel());
5959
copy(copied);

MPChartLib/src/main/java/com/github/mikephil/charting/data/BubbleDataSet.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ protected void calcMinMax(BubbleEntry e) {
4242
@Override
4343
public DataSet<BubbleEntry> copy() {
4444
List<BubbleEntry> entries = new ArrayList<BubbleEntry>();
45-
for (int i = 0; i < mValues.size(); i++) {
46-
entries.add(mValues.get(i).copy());
45+
for (int i = 0; i < mEntries.size(); i++) {
46+
entries.add(mEntries.get(i).copy());
4747
}
4848
BubbleDataSet copied = new BubbleDataSet(entries, getLabel());
4949
copy(copied);

MPChartLib/src/main/java/com/github/mikephil/charting/data/CandleDataSet.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ public CandleDataSet(List<CandleEntry> yVals, String label) {
8080
@Override
8181
public DataSet<CandleEntry> copy() {
8282
List<CandleEntry> entries = new ArrayList<CandleEntry>();
83-
for (int i = 0; i < mValues.size(); i++) {
84-
entries.add(mValues.get(i).copy());
83+
for (int i = 0; i < mEntries.size(); i++) {
84+
entries.add(mEntries.get(i).copy());
8585
}
8686
CandleDataSet copied = new CandleDataSet(entries, getLabel());
8787
copy(copied);

MPChartLib/src/main/java/com/github/mikephil/charting/data/DataSet.java

Lines changed: 68 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public abstract class DataSet<T extends Entry> extends BaseDataSet<T> {
1717
/**
1818
* the entries that this DataSet represents / holds together
1919
*/
20-
protected List<T> mValues = null;
20+
protected List<T> mEntries;
2121

2222
/**
2323
* maximum y-value in the value array
@@ -45,15 +45,15 @@ public abstract class DataSet<T extends Entry> extends BaseDataSet<T> {
4545
* label that describes the DataSet can be specified. The label can also be
4646
* used to retrieve the DataSet from a ChartData object.
4747
*
48-
* @param values
48+
* @param entries
4949
* @param label
5050
*/
51-
public DataSet(List<T> values, String label) {
51+
public DataSet(List<T> entries, String label) {
5252
super(label);
53-
this.mValues = values;
53+
this.mEntries = entries;
5454

55-
if (mValues == null)
56-
mValues = new ArrayList<T>();
55+
if (mEntries == null)
56+
mEntries = new ArrayList<T>();
5757

5858
calcMinMax();
5959
}
@@ -66,10 +66,10 @@ public void calcMinMax() {
6666
mXMax = -Float.MAX_VALUE;
6767
mXMin = Float.MAX_VALUE;
6868

69-
if (mValues == null || mValues.isEmpty())
69+
if (mEntries == null || mEntries.isEmpty())
7070
return;
7171

72-
for (T e : mValues) {
72+
for (T e : mEntries) {
7373
calcMinMax(e);
7474
}
7575
}
@@ -79,7 +79,7 @@ public void calcMinMaxY(float fromX, float toX) {
7979
mYMax = -Float.MAX_VALUE;
8080
mYMin = Float.MAX_VALUE;
8181

82-
if (mValues == null || mValues.isEmpty())
82+
if (mEntries == null || mEntries.isEmpty())
8383
return;
8484

8585
int indexFrom = getEntryIndex(fromX, Float.NaN, Rounding.DOWN);
@@ -90,7 +90,7 @@ public void calcMinMaxY(float fromX, float toX) {
9090
for (int i = indexFrom; i <= indexTo; i++) {
9191

9292
// only recalculate y
93-
calcMinMaxY(mValues.get(i));
93+
calcMinMaxY(mEntries.get(i));
9494
}
9595
}
9696

@@ -129,25 +129,47 @@ protected void calcMinMaxY(T e) {
129129

130130
@Override
131131
public int getEntryCount() {
132-
return mValues.size();
132+
return mEntries.size();
133133
}
134134

135135
/**
136-
* Returns the array of entries that this DataSet represents.
136+
* This method is deprecated.
137+
* Use getEntries() instead.
137138
*
138139
* @return
139140
*/
141+
@Deprecated
140142
public List<T> getValues() {
141-
return mValues;
143+
return mEntries;
142144
}
143145

144146
/**
145-
* Sets the array of entries that this DataSet represents, and calls notifyDataSetChanged()
147+
* Returns the array of entries that this DataSet represents.
146148
*
147149
* @return
148150
*/
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
149162
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;
151173
notifyDataSetChanged();
152174
}
153175

@@ -170,8 +192,8 @@ protected void copy(DataSet dataSet) {
170192
public String toString() {
171193
StringBuffer buffer = new StringBuffer();
172194
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() + " ");
175197
}
176198
return buffer.toString();
177199
}
@@ -184,7 +206,7 @@ public String toString() {
184206
*/
185207
public String toSimpleString() {
186208
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() +
188210
"\n");
189211
return buffer.toString();
190212
}
@@ -215,23 +237,23 @@ public void addEntryOrdered(T e) {
215237
if (e == null)
216238
return;
217239

218-
if (mValues == null) {
219-
mValues = new ArrayList<T>();
240+
if (mEntries == null) {
241+
mEntries = new ArrayList<T>();
220242
}
221243

222244
calcMinMax(e);
223245

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()) {
225247
int closestIndex = getEntryIndex(e.getX(), e.getY(), Rounding.UP);
226-
mValues.add(closestIndex, e);
248+
mEntries.add(closestIndex, e);
227249
} else {
228-
mValues.add(e);
250+
mEntries.add(e);
229251
}
230252
}
231253

232254
@Override
233255
public void clear() {
234-
mValues.clear();
256+
mEntries.clear();
235257
notifyDataSetChanged();
236258
}
237259

@@ -241,9 +263,9 @@ public boolean addEntry(T e) {
241263
if (e == null)
242264
return false;
243265

244-
List<T> values = getValues();
266+
List<T> values = getEntries();
245267
if (values == null) {
246-
values = new ArrayList<T>();
268+
values = new ArrayList<>();
247269
}
248270

249271
calcMinMax(e);
@@ -258,11 +280,11 @@ public boolean removeEntry(T e) {
258280
if (e == null)
259281
return false;
260282

261-
if (mValues == null)
283+
if (mEntries == null)
262284
return false;
263285

264286
// remove the entry
265-
boolean removed = mValues.remove(e);
287+
boolean removed = mEntries.remove(e);
266288

267289
if (removed) {
268290
calcMinMax();
@@ -273,15 +295,15 @@ public boolean removeEntry(T e) {
273295

274296
@Override
275297
public int getEntryIndex(Entry e) {
276-
return mValues.indexOf(e);
298+
return mEntries.indexOf(e);
277299
}
278300

279301
@Override
280302
public T getEntryForXValue(float xValue, float closestToY, Rounding rounding) {
281303

282304
int index = getEntryIndex(xValue, closestToY, rounding);
283305
if (index > -1)
284-
return mValues.get(index);
306+
return mEntries.get(index);
285307
return null;
286308
}
287309

@@ -292,24 +314,24 @@ public T getEntryForXValue(float xValue, float closestToY) {
292314

293315
@Override
294316
public T getEntryForIndex(int index) {
295-
return mValues.get(index);
317+
return mEntries.get(index);
296318
}
297319

298320
@Override
299321
public int getEntryIndex(float xValue, float closestToY, Rounding rounding) {
300322

301-
if (mValues == null || mValues.isEmpty())
323+
if (mEntries == null || mEntries.isEmpty())
302324
return -1;
303325

304326
int low = 0;
305-
int high = mValues.size() - 1;
327+
int high = mEntries.size() - 1;
306328
int closest = high;
307329

308330
while (low < high) {
309331
int m = (low + high) / 2;
310332

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,
313335
ad1 = Math.abs(d1), ad2 = Math.abs(d2);
314336

315337
if (ad2 < ad1) {
@@ -336,10 +358,10 @@ public int getEntryIndex(float xValue, float closestToY, Rounding rounding) {
336358
}
337359

338360
if (closest != -1) {
339-
float closestXValue = mValues.get(closest).getX();
361+
float closestXValue = mEntries.get(closest).getX();
340362
if (rounding == Rounding.UP) {
341363
// 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) {
343365
++closest;
344366
}
345367
} else if (rounding == Rounding.DOWN) {
@@ -351,18 +373,18 @@ public int getEntryIndex(float xValue, float closestToY, Rounding rounding) {
351373

352374
// Search by closest to y-value
353375
if (!Float.isNaN(closestToY)) {
354-
while (closest > 0 && mValues.get(closest - 1).getX() == closestXValue)
376+
while (closest > 0 && mEntries.get(closest - 1).getX() == closestXValue)
355377
closest -= 1;
356378

357-
float closestYValue = mValues.get(closest).getY();
379+
float closestYValue = mEntries.get(closest).getY();
358380
int closestYIndex = closest;
359381

360382
while (true) {
361383
closest += 1;
362-
if (closest >= mValues.size())
384+
if (closest >= mEntries.size())
363385
break;
364386

365-
final Entry value = mValues.get(closest);
387+
final Entry value = mEntries.get(closest);
366388

367389
if (value.getX() != closestXValue)
368390
break;
@@ -386,22 +408,22 @@ public List<T> getEntriesForXValue(float xValue) {
386408
List<T> entries = new ArrayList<T>();
387409

388410
int low = 0;
389-
int high = mValues.size() - 1;
411+
int high = mEntries.size() - 1;
390412

391413
while (low <= high) {
392414
int m = (high + low) / 2;
393-
T entry = mValues.get(m);
415+
T entry = mEntries.get(m);
394416

395417
// if we have a match
396418
if (xValue == entry.getX()) {
397-
while (m > 0 && mValues.get(m - 1).getX() == xValue)
419+
while (m > 0 && mEntries.get(m - 1).getX() == xValue)
398420
m--;
399421

400-
high = mValues.size();
422+
high = mEntries.size();
401423

402424
// loop over all "equal" entries
403425
for (; m < high; m++) {
404-
entry = mValues.get(m);
426+
entry = mEntries.get(m);
405427
if (entry.getX() == xValue) {
406428
entries.add(entry);
407429
} else {

MPChartLib/src/main/java/com/github/mikephil/charting/data/LineDataSet.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ public LineDataSet(List<Entry> yVals, String label) {
8585
@Override
8686
public DataSet<Entry> copy() {
8787
List<Entry> entries = new ArrayList<Entry>();
88-
for (int i = 0; i < mValues.size(); i++) {
89-
entries.add(mValues.get(i).copy());
88+
for (int i = 0; i < mEntries.size(); i++) {
89+
entries.add(mEntries.get(i).copy());
9090
}
9191
LineDataSet copied = new LineDataSet(entries, getLabel());
9292
copy(copied);

MPChartLib/src/main/java/com/github/mikephil/charting/data/PieDataSet.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ public PieDataSet(List<PieEntry> yVals, String label) {
4040
@Override
4141
public DataSet<PieEntry> copy() {
4242
List<PieEntry> entries = new ArrayList<>();
43-
for (int i = 0; i < mValues.size(); i++) {
44-
entries.add(mValues.get(i).copy());
43+
for (int i = 0; i < mEntries.size(); i++) {
44+
entries.add(mEntries.get(i).copy());
4545
}
4646
PieDataSet copied = new PieDataSet(entries, getLabel());
4747
copy(copied);

MPChartLib/src/main/java/com/github/mikephil/charting/data/RadarDataSet.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ public void setHighlightCircleStrokeWidth(float strokeWidth) {
102102
@Override
103103
public DataSet<RadarEntry> copy() {
104104
List<RadarEntry> entries = new ArrayList<RadarEntry>();
105-
for (int i = 0; i < mValues.size(); i++) {
106-
entries.add(mValues.get(i).copy());
105+
for (int i = 0; i < mEntries.size(); i++) {
106+
entries.add(mEntries.get(i).copy());
107107
}
108108
RadarDataSet copied = new RadarDataSet(entries, getLabel());
109109
copy(copied);

MPChartLib/src/main/java/com/github/mikephil/charting/data/ScatterDataSet.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ public ScatterDataSet(List<Entry> yVals, String label) {
4848
@Override
4949
public DataSet<Entry> copy() {
5050
List<Entry> entries = new ArrayList<Entry>();
51-
for (int i = 0; i < mValues.size(); i++) {
52-
entries.add(mValues.get(i).copy());
51+
for (int i = 0; i < mEntries.size(); i++) {
52+
entries.add(mEntries.get(i).copy());
5353
}
5454
ScatterDataSet copied = new ScatterDataSet(entries, getLabel());
5555
copy(copied);

0 commit comments

Comments
 (0)