1/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.test.hwui;
18
19import android.app.Activity;
20import android.content.Context;
21import android.graphics.Canvas;
22import android.graphics.Color;
23import android.graphics.Paint;
24import android.graphics.Path;
25import android.os.Bundle;
26import android.view.MotionEvent;
27import android.view.View;
28
29@SuppressWarnings({"UnusedDeclaration"})
30public class PathOffsetActivity extends Activity {
31    @Override
32    protected void onCreate(Bundle savedInstanceState) {
33        super.onCreate(savedInstanceState);
34        final PathsView view = new PathsView(this);
35        setContentView(view);
36    }
37
38    public class PathsView extends View {
39        private Path mPath;
40        private Paint mPaint;
41
42        public PathsView(Context context) {
43            super(context);
44
45            mPaint = new Paint();
46            mPaint.setStyle(Paint.Style.STROKE);
47            mPaint.setStrokeWidth(3);
48
49            mPath = new Path();
50            mPath.lineTo(100, 100);
51            mPath.lineTo(200, 300);
52        }
53
54        @Override
55        protected void onDraw(Canvas canvas) {
56            mPath.offset(1, 1);
57            mPaint.setColor(Color.RED);
58            canvas.drawPath(mPath, mPaint);
59        }
60
61        @Override
62        public boolean onTouchEvent(MotionEvent event) {
63            invalidate();
64            return super.onTouchEvent(event);
65        }
66    }
67}
68