@@ -184,76 +184,62 @@ public void drawHighlighted(Canvas c, Highlight[] indices) {
184184
185185 for (Highlight high : indices ) {
186186
187- final int minDataSetIndex = high .getDataSetIndex () == -1
188- ? 0
189- : high .getDataSetIndex ();
190- final int maxDataSetIndex = high .getDataSetIndex () == -1
191- ? bubbleData .getDataSetCount ()
192- : (high .getDataSetIndex () + 1 );
193- if (maxDataSetIndex - minDataSetIndex < 1 ) continue ;
187+ IBubbleDataSet set = bubbleData .getDataSetByIndex (high .getDataSetIndex ());
194188
195- for (int dataSetIndex = minDataSetIndex ; dataSetIndex < maxDataSetIndex ; dataSetIndex ++) {
196-
197- IBubbleDataSet dataSet = bubbleData .getDataSetByIndex (dataSetIndex );
198-
199- if (dataSet == null || !dataSet .isHighlightEnabled ())
200- continue ;
201-
202- final BubbleEntry entry = dataSet .getEntryForXPos (high .getX ());
189+ if (set == null || !set .isHighlightEnabled ())
190+ continue ;
203191
204- if (entry == null )
205- continue ;
192+ final BubbleEntry entry = set .getEntryForXPos (high .getX ());
206193
207- XBounds bounds = getXBounds (mChart , dataSet );
194+ if (!isInBoundsX (entry , set ))
195+ continue ;
208196
209- Transformer trans = mChart .getTransformer (dataSet .getAxisDependency ());
197+ Transformer trans = mChart .getTransformer (set .getAxisDependency ());
210198
211- sizeBuffer [0 ] = 0f ;
212- sizeBuffer [2 ] = 1f ;
199+ sizeBuffer [0 ] = 0f ;
200+ sizeBuffer [2 ] = 1f ;
213201
214- trans .pointValuesToPixel (sizeBuffer );
202+ trans .pointValuesToPixel (sizeBuffer );
215203
216- boolean normalizeSize = dataSet .isNormalizeSizeEnabled ();
204+ boolean normalizeSize = set .isNormalizeSizeEnabled ();
217205
218- // calcualte the full width of 1 step on the x-axis
219- final float maxBubbleWidth = Math .abs (sizeBuffer [2 ] - sizeBuffer [0 ]);
220- final float maxBubbleHeight = Math .abs (
221- mViewPortHandler .contentBottom () - mViewPortHandler .contentTop ());
222- final float referenceSize = Math .min (maxBubbleHeight , maxBubbleWidth );
206+ // calcualte the full width of 1 step on the x-axis
207+ final float maxBubbleWidth = Math .abs (sizeBuffer [2 ] - sizeBuffer [0 ]);
208+ final float maxBubbleHeight = Math .abs (
209+ mViewPortHandler .contentBottom () - mViewPortHandler .contentTop ());
210+ final float referenceSize = Math .min (maxBubbleHeight , maxBubbleWidth );
223211
224- pointBuffer [0 ] = entry .getX ();
225- pointBuffer [1 ] = (entry .getY ()) * phaseY ;
226- trans .pointValuesToPixel (pointBuffer );
212+ pointBuffer [0 ] = entry .getX ();
213+ pointBuffer [1 ] = (entry .getY ()) * phaseY ;
214+ trans .pointValuesToPixel (pointBuffer );
227215
228- float shapeHalf = getShapeSize (entry .getSize (),
229- dataSet .getMaxSize (),
230- referenceSize ,
231- normalizeSize ) / 2f ;
216+ high .setDraw (pointBuffer [0 ], pointBuffer [1 ]);
232217
233- if (!mViewPortHandler .isInBoundsTop (pointBuffer [1 ] + shapeHalf )
234- || !mViewPortHandler .isInBoundsBottom (pointBuffer [1 ] - shapeHalf ))
235- continue ;
218+ float shapeHalf = getShapeSize (entry .getSize (),
219+ set .getMaxSize (),
220+ referenceSize ,
221+ normalizeSize ) / 2f ;
236222
237- if (!mViewPortHandler .isInBoundsLeft (pointBuffer [0 ] + shapeHalf ))
238- continue ;
223+ if (!mViewPortHandler .isInBoundsTop (pointBuffer [1 ] + shapeHalf )
224+ || !mViewPortHandler .isInBoundsBottom (pointBuffer [1 ] - shapeHalf ))
225+ continue ;
239226
240- if (!mViewPortHandler .isInBoundsRight (pointBuffer [0 ] - shapeHalf ))
241- break ;
227+ if (!mViewPortHandler .isInBoundsLeft (pointBuffer [0 ] + shapeHalf ))
228+ continue ;
242229
243- if (high . getX () < bounds . min || high . getX () > bounds . max )
244- continue ;
230+ if (! mViewPortHandler . isInBoundsRight ( pointBuffer [ 0 ] - shapeHalf ) )
231+ break ;
245232
246- final int originalColor = dataSet .getColor ((int ) entry .getX ());
233+ final int originalColor = set .getColor ((int ) entry .getX ());
247234
248- Color .RGBToHSV (Color .red (originalColor ), Color .green (originalColor ),
249- Color .blue (originalColor ), _hsvBuffer );
250- _hsvBuffer [2 ] *= 0.5f ;
251- final int color = Color .HSVToColor (Color .alpha (originalColor ), _hsvBuffer );
235+ Color .RGBToHSV (Color .red (originalColor ), Color .green (originalColor ),
236+ Color .blue (originalColor ), _hsvBuffer );
237+ _hsvBuffer [2 ] *= 0.5f ;
238+ final int color = Color .HSVToColor (Color .alpha (originalColor ), _hsvBuffer );
252239
253- mHighlightPaint .setColor (color );
254- mHighlightPaint .setStrokeWidth (dataSet .getHighlightCircleWidth ());
255- c .drawCircle (pointBuffer [0 ], pointBuffer [1 ], shapeHalf , mHighlightPaint );
256- }
240+ mHighlightPaint .setColor (color );
241+ mHighlightPaint .setStrokeWidth (set .getHighlightCircleWidth ());
242+ c .drawCircle (pointBuffer [0 ], pointBuffer [1 ], shapeHalf , mHighlightPaint );
257243 }
258244 }
259245}
0 commit comments