4
4
import android .graphics .Matrix ;
5
5
import android .graphics .PointF ;
6
6
import android .graphics .RectF ;
7
+ import android .util .Log ;
7
8
import android .view .View ;
8
9
9
10
/**
@@ -350,6 +351,11 @@ public void centerViewPort(final float[] transformedPts, final View view) {
350
351
refresh (save , view , true );
351
352
}
352
353
354
+ /**
355
+ * buffer for storing matrix values
356
+ */
357
+ protected final float [] matrixBuffer = new float [9 ];
358
+
353
359
/**
354
360
* call this method to refresh the graph with a given matrix
355
361
*
@@ -377,14 +383,13 @@ public Matrix refresh(Matrix newMatrix, View chart, boolean invalidate) {
377
383
*/
378
384
public void limitTransAndScale (Matrix matrix , RectF content ) {
379
385
380
- float [] vals = new float [9 ];
381
- matrix .getValues (vals );
386
+ matrix .getValues (matrixBuffer );
382
387
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 ];
385
390
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 ];
388
393
389
394
// min scale-x is 1f, max is the max float
390
395
mScaleX = Math .min (Math .max (mMinScaleX , curScaleX ), mMaxScaleX );
@@ -408,13 +413,13 @@ public void limitTransAndScale(Matrix matrix, RectF content) {
408
413
float newTransY = Math .max (Math .min (curTransY , maxTransY + mTransOffsetY ), -mTransOffsetY );
409
414
mTransY = newTransY ;
410
415
411
- vals [Matrix .MTRANS_X ] = mTransX ;
412
- vals [Matrix .MSCALE_X ] = mScaleX ;
416
+ matrixBuffer [Matrix .MTRANS_X ] = mTransX ;
417
+ matrixBuffer [Matrix .MSCALE_X ] = mScaleX ;
413
418
414
- vals [Matrix .MTRANS_Y ] = mTransY ;
415
- vals [Matrix .MSCALE_Y ] = mScaleY ;
419
+ matrixBuffer [Matrix .MTRANS_Y ] = mTransY ;
420
+ matrixBuffer [Matrix .MSCALE_Y ] = mScaleY ;
416
421
417
- matrix .setValues (vals );
422
+ matrix .setValues (matrixBuffer );
418
423
}
419
424
420
425
/**
0 commit comments