Skip to content

Commit 6383af2

Browse files
committed
BarChart apply code suggestions
1 parent 40f0c03 commit 6383af2

File tree

2 files changed

+24
-37
lines changed

2 files changed

+24
-37
lines changed

MPChartLib/src/main/java/com/github/mikephil/charting/charts/BarChart.java

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ protected void calcMinMax() {
9797
*
9898
* @param x
9999
* @param y
100-
* @return
101-
*/
100+
*/
102101
@Override
103102
public Highlight getHighlightByTouchPoint(float x, float y) {
104103

@@ -120,13 +119,12 @@ public Highlight getHighlightByTouchPoint(float x, float y) {
120119
* Returns the bounding box of the specified Entry in the specified DataSet. Returns null if the Entry could not be
121120
* found in the charts data. Performance-intensive code should use void getBarBounds(BarEntry, RectF) instead.
122121
*
123-
* @param e
124-
* @return
125-
*/
126-
public RectF getBarBounds(BarEntry e) {
122+
* @param barEntry
123+
*/
124+
public RectF getBarBounds(BarEntry barEntry) {
127125

128126
RectF bounds = new RectF();
129-
getBarBounds(e, bounds);
127+
getBarBounds(barEntry, bounds);
130128

131129
return bounds;
132130
}
@@ -135,22 +133,19 @@ public RectF getBarBounds(BarEntry e) {
135133
* The passed outputRect will be assigned the values of the bounding box of the specified Entry in the specified DataSet.
136134
* The rect will be assigned Float.MIN_VALUE in all locations if the Entry could not be found in the charts data.
137135
*
138-
* @param e
139-
* @return
140-
*/
141-
public void getBarBounds(BarEntry e, RectF outputRect) {
136+
* @param barEntry
137+
*/
138+
public void getBarBounds(BarEntry barEntry, RectF outputRect) {
142139

143-
RectF bounds = outputRect;
144-
145-
IBarDataSet set = mData.getDataSetForEntry(e);
140+
IBarDataSet set = mData.getDataSetForEntry(barEntry);
146141

147142
if (set == null) {
148-
bounds.set(Float.MIN_VALUE, Float.MIN_VALUE, Float.MIN_VALUE, Float.MIN_VALUE);
143+
outputRect.set(Float.MIN_VALUE, Float.MIN_VALUE, Float.MIN_VALUE, Float.MIN_VALUE);
149144
return;
150145
}
151146

152-
float y = e.getY();
153-
float x = e.getX();
147+
float y = barEntry.getY();
148+
float x = barEntry.getX();
154149

155150
float barWidth = mData.getBarWidth();
156151

@@ -159,25 +154,23 @@ public void getBarBounds(BarEntry e, RectF outputRect) {
159154
float top = y >= 0 ? y : 0;
160155
float bottom = y <= 0 ? y : 0;
161156

162-
bounds.set(left, top, right, bottom);
157+
outputRect.set(left, top, right, bottom);
163158

164159
getTransformer(set.getAxisDependency()).rectValueToPixel(outputRect);
165160
}
166161

167162
/**
168163
* If set to true, all values are drawn above their bars, instead of below their top.
169164
*
170-
* @param enabled
171-
*/
165+
*/
172166
public void setDrawValueAboveBar(boolean enabled) {
173167
mDrawValueAboveBar = enabled;
174168
}
175169

176170
/**
177171
* returns true if drawing values above bars is enabled, false if not
178172
*
179-
* @return
180-
*/
173+
*/
181174
public boolean isDrawValueAboveBarEnabled() {
182175
return mDrawValueAboveBar;
183176
}
@@ -186,17 +179,15 @@ public boolean isDrawValueAboveBarEnabled() {
186179
* If set to true, a grey area is drawn behind each bar that indicates the maximum value. Enabling his will reduce
187180
* performance by about 50%.
188181
*
189-
* @param enabled
190-
*/
182+
*/
191183
public void setDrawBarShadow(boolean enabled) {
192184
mDrawBarShadow = enabled;
193185
}
194186

195187
/**
196188
* returns true if drawing shadows (maxvalue) for each bar is enabled, false if not
197189
*
198-
* @return
199-
*/
190+
*/
200191
public boolean isDrawBarShadowEnabled() {
201192
return mDrawBarShadow;
202193
}
@@ -207,8 +198,7 @@ public boolean isDrawBarShadowEnabled() {
207198
* was tapped.
208199
* Default: false
209200
*
210-
* @param enabled
211-
*/
201+
*/
212202
public void setHighlightFullBarEnabled(boolean enabled) {
213203
mHighlightFullBarEnabled = enabled;
214204
}
@@ -243,8 +233,7 @@ public BarData getBarData() {
243233
* fully displayed.
244234
* Default: false
245235
*
246-
* @param enabled
247-
*/
236+
*/
248237
public void setFitBars(boolean enabled) {
249238
mFitBars = enabled;
250239
}
@@ -303,11 +292,9 @@ public String getAccessibilityDescription() {
303292

304293
// Format the values of min and max; to recite them back
305294

306-
String description = String.format(Locale.getDefault(), "The bar chart has %d %s. " +
295+
return String.format(Locale.getDefault(), "The bar chart has %d %s. " +
307296
"The minimum value is %s and maximum value is %s." +
308297
"Data ranges from %s to %s.",
309298
entryCount, entries, minVal, maxVal, minRange, maxRange);
310-
311-
return description;
312299
}
313300
}

MPChartLib/src/main/java/com/github/mikephil/charting/charts/HorizontalBarChart.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,18 +217,18 @@ protected float[] getMarkerPosition(Highlight high) {
217217
}
218218

219219
@Override
220-
public void getBarBounds(BarEntry e, RectF outputRect) {
220+
public void getBarBounds(BarEntry barEntry, RectF outputRect) {
221221

222222
RectF bounds = outputRect;
223-
IBarDataSet set = mData.getDataSetForEntry(e);
223+
IBarDataSet set = mData.getDataSetForEntry(barEntry);
224224

225225
if (set == null) {
226226
outputRect.set(Float.MIN_VALUE, Float.MIN_VALUE, Float.MIN_VALUE, Float.MIN_VALUE);
227227
return;
228228
}
229229

230-
float y = e.getY();
231-
float x = e.getX();
230+
float y = barEntry.getY();
231+
float x = barEntry.getX();
232232

233233
float barWidth = mData.getBarWidth();
234234

0 commit comments

Comments
 (0)