@@ -74,7 +74,7 @@ public abstract class Chart<T extends ChartData<? extends DataSet<? extends Entr
7474 protected ValueFormatter mDefaultFormatter ;
7575
7676 /** the canvas that is used for drawing on the bitmap */
77- // protected Canvas mDrawCanvas;
77+ // protected Canvas mDrawCanvas;
7878
7979 /**
8080 * paint object used for drawing the description text in the bottom right
@@ -167,7 +167,7 @@ public Chart(Context context, AttributeSet attrs, int defStyle) {
167167 protected void init () {
168168
169169 setWillNotDraw (false );
170- // setLayerType(View.LAYER_TYPE_HARDWARE, null);
170+ // setLayerType(View.LAYER_TYPE_HARDWARE, null);
171171
172172 if (android .os .Build .VERSION .SDK_INT < 11 )
173173 mAnimator = new ChartAnimator ();
@@ -251,22 +251,12 @@ public void onAnimationUpdate(ValueAnimator animation) {
251251 */
252252 public void setData (T data ) {
253253
254- // if (data == null || !data.isValid()) {
255- // Log.e(LOG_TAG,
256- // "Cannot set data for chart. Provided chart values are null or contain less than 1 entry.");
257- // mDataNotSet = true;
258- // return;
259- // }
260-
261254 if (data == null ) {
262255 Log .e (LOG_TAG ,
263256 "Cannot set data for chart. Provided data object is null." );
264257 return ;
265258 }
266259
267- // Log.i(LOG_TAG, "xvalcount: " + data.getXValCount());
268- // Log.i(LOG_TAG, "entrycount: " + data.getYValCount());
269-
270260 // LET THE CHART KNOW THERE IS DATA
271261 mDataNotSet = false ;
272262 mOffsetsCalculated = false ;
@@ -389,12 +379,12 @@ protected void onDraw(Canvas canvas) {
389379 mOffsetsCalculated = true ;
390380 }
391381
392- // if (mDrawCanvas == null) {
393- // mDrawCanvas = new Canvas(mDrawBitmap);
394- // }
382+ // if (mDrawCanvas == null) {
383+ // mDrawCanvas = new Canvas(mDrawBitmap);
384+ // }
395385
396386 // clear everything
397- // mDrawBitmap.eraseColor(Color.TRANSPARENT);
387+ // mDrawBitmap.eraseColor(Color.TRANSPARENT);
398388 }
399389
400390 /**
@@ -403,8 +393,8 @@ protected void onDraw(Canvas canvas) {
403393 protected void drawDescription (Canvas c ) {
404394
405395 c .drawText (mDescription , getWidth () - mViewPortHandler .offsetRight () - 10 ,
406- getHeight () - mViewPortHandler .offsetBottom ()
407- - 10 , mDescPaint );
396+ getHeight () - mViewPortHandler .offsetBottom ()
397+ - 10 , mDescPaint );
408398 }
409399
410400 /**
@@ -418,6 +408,16 @@ protected void drawDescription(Canvas c) {
418408 */
419409 protected Highlight [] mIndicesToHightlight = new Highlight [0 ];
420410
411+ /**
412+ * Returns the array of currently highlighted values. This might be null or
413+ * empty if nothing is highlighted.
414+ *
415+ * @return
416+ */
417+ public Highlight [] getHighlighted () {
418+ return mIndicesToHightlight ;
419+ }
420+
421421 /**
422422 * Returns true if there are values to highlight, false if there are no
423423 * values to highlight. Checks if the highlight array is null, has a length
@@ -670,14 +670,14 @@ public void animateY(int durationMillis) {
670670 */
671671 /** BELOW THIS ONLY GETTERS AND SETTERS */
672672
673- // /**
674- // * Returns the canvas object the chart uses for drawing.
675- // *
676- // * @return
677- // */
678- // public Canvas getCanvas() {
679- // return mDrawCanvas;
680- // }
673+ // /**
674+ // * Returns the canvas object the chart uses for drawing.
675+ // *
676+ // * @return
677+ // */
678+ // public Canvas getCanvas() {
679+ // return mDrawCanvas;
680+ // }
681681
682682 /**
683683 * Returns the default ValueFormatter that has been determined by the chart
@@ -1344,7 +1344,7 @@ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
13441344 if (w > 0 && h > 0 && w < 10000 && h < 10000 ) {
13451345 // create a new bitmap with the new dimensions
13461346 mDrawBitmap = Bitmap .createBitmap (w , h , Bitmap .Config .ARGB_4444 );
1347- // mDrawCanvas = new Canvas(mDrawBitmap);
1347+ // mDrawCanvas = new Canvas(mDrawBitmap);
13481348 mViewPortHandler .setChartDimens (w , h );
13491349
13501350 if (mLogEnabled )
@@ -1365,4 +1365,17 @@ public View getChartView() {
13651365 public PointF getCenterOfView () {
13661366 return getCenter ();
13671367 }
1368+
1369+ /**
1370+ * Setting this to true will set the layer-type HARDWARE for the view, false
1371+ * will set layer-type SOFTWARE.
1372+ *
1373+ * @param enabled
1374+ */
1375+ public void setHardwareAccelerationEnabled (boolean enabled ) {
1376+ if (enabled )
1377+ setLayerType (View .LAYER_TYPE_HARDWARE , null );
1378+ else
1379+ setLayerType (View .LAYER_TYPE_SOFTWARE , null );
1380+ }
13681381}
0 commit comments