Skip to content

Commit 94754ef

Browse files
author
Jim Miller
committed
Fix 6656710: center dot pattern in GlowPadView
This fixes a bug where the dots weren't aligned with the center of the view. The matrix should not contain the offset of the image itself since we really want to scale about the abstract points. The code now subtracts the image centering positions (cx,cy) from the point to be scaled. Change-Id: I1d46a5d51b1fd1d39944c64baf86c306c2d5e923
1 parent 2a2b021 commit 94754ef

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

core/java/com/android/internal/widget/multiwaveview/PointCloud.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,25 +202,25 @@ private float interp(float min, float max, float f) {
202202

203203
public void draw(Canvas canvas) {
204204
ArrayList<Point> points = mPointCloud;
205-
final float cx = mDrawable != null ? (-mDrawable.getIntrinsicWidth() / 2) : 0;
206-
final float cy = mDrawable != null ? (-mDrawable.getIntrinsicHeight() / 2) : 0;
207205
canvas.save(Canvas.MATRIX_SAVE_FLAG);
208206
canvas.scale(mScale, mScale, mCenterX, mCenterY);
209207
for (int i = 0; i < points.size(); i++) {
210208
Point point = points.get(i);
211209
final float pointSize = interp(MAX_POINT_SIZE, MIN_POINT_SIZE,
212210
point.radius / mOuterRadius);
213-
final float px = point.x + cx + mCenterX;
214-
final float py = point.y + cy + mCenterY;
211+
final float px = point.x + mCenterX;
212+
final float py = point.y + mCenterY;
215213
int alpha = getAlphaForPoint(point);
216214

217215
if (alpha == 0) continue;
218216

219217
if (mDrawable != null) {
220218
canvas.save(Canvas.MATRIX_SAVE_FLAG);
221-
float s = pointSize / MAX_POINT_SIZE;
219+
final float cx = mDrawable.getIntrinsicWidth() * 0.5f;
220+
final float cy = mDrawable.getIntrinsicHeight() * 0.5f;
221+
final float s = pointSize / MAX_POINT_SIZE;
222222
canvas.scale(s, s, px, py);
223-
canvas.translate(px, py);
223+
canvas.translate(px - cx, py - cy);
224224
mDrawable.setAlpha(alpha);
225225
mDrawable.draw(canvas);
226226
canvas.restore();

0 commit comments

Comments
 (0)