44import android .graphics .Matrix ;
55import android .graphics .PointF ;
66import android .graphics .RectF ;
7+ import android .util .Log ;
78import android .view .View ;
89
910/**
@@ -350,6 +351,11 @@ public void centerViewPort(final float[] transformedPts, final View view) {
350351 refresh (save , view , true );
351352 }
352353
354+ /**
355+ * buffer for storing matrix values
356+ */
357+ protected final float [] matrixBuffer = new float [9 ];
358+
353359 /**
354360 * call this method to refresh the graph with a given matrix
355361 *
@@ -377,14 +383,13 @@ public Matrix refresh(Matrix newMatrix, View chart, boolean invalidate) {
377383 */
378384 public void limitTransAndScale (Matrix matrix , RectF content ) {
379385
380- float [] vals = new float [9 ];
381- matrix .getValues (vals );
386+ matrix .getValues (matrixBuffer );
382387
383- float curTransX = vals [Matrix .MTRANS_X ];
384- float curScaleX = vals [Matrix .MSCALE_X ];
388+ float curTransX = matrixBuffer [Matrix .MTRANS_X ];
389+ float curScaleX = matrixBuffer [Matrix .MSCALE_X ];
385390
386- float curTransY = vals [Matrix .MTRANS_Y ];
387- float curScaleY = vals [Matrix .MSCALE_Y ];
391+ float curTransY = matrixBuffer [Matrix .MTRANS_Y ];
392+ float curScaleY = matrixBuffer [Matrix .MSCALE_Y ];
388393
389394 // min scale-x is 1f, max is the max float
390395 mScaleX = Math .min (Math .max (mMinScaleX , curScaleX ), mMaxScaleX );
@@ -408,13 +413,13 @@ public void limitTransAndScale(Matrix matrix, RectF content) {
408413 float newTransY = Math .max (Math .min (curTransY , maxTransY + mTransOffsetY ), -mTransOffsetY );
409414 mTransY = newTransY ;
410415
411- vals [Matrix .MTRANS_X ] = mTransX ;
412- vals [Matrix .MSCALE_X ] = mScaleX ;
416+ matrixBuffer [Matrix .MTRANS_X ] = mTransX ;
417+ matrixBuffer [Matrix .MSCALE_X ] = mScaleX ;
413418
414- vals [Matrix .MTRANS_Y ] = mTransY ;
415- vals [Matrix .MSCALE_Y ] = mScaleY ;
419+ matrixBuffer [Matrix .MTRANS_Y ] = mTransY ;
420+ matrixBuffer [Matrix .MSCALE_Y ] = mScaleY ;
416421
417- matrix .setValues (vals );
422+ matrix .setValues (matrixBuffer );
418423 }
419424
420425 /**
0 commit comments