AbstractDrawingPreview.java revision afca1ddd233c03d79433931a0b6ba97ed22663ed
1/*
2 * Copyright (C) 2012 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.inputmethod.keyboard.internal;
18
19import android.graphics.Canvas;
20import android.view.View;
21
22import com.android.inputmethod.keyboard.PointerTracker;
23
24/**
25 * Abstract base class for previews that are drawn on DrawingPreviewPlacerView, e.g.,
26 * GestureFloatingTextDrawingPreview, GestureTrailsDrawingPreview, and
27 * SlidingKeyInputDrawingPreview.
28 */
29public abstract class AbstractDrawingPreview {
30    private final View mDrawingView;
31    private boolean mPreviewEnabled;
32
33    protected AbstractDrawingPreview(final View drawingView) {
34        mDrawingView = drawingView;
35    }
36
37    public final View getDrawingView() {
38        return mDrawingView;
39    }
40
41    public final void setPreviewEnabled(final boolean enabled) {
42        mPreviewEnabled = enabled;
43    }
44
45    public boolean isPreviewEnabled() {
46        return mPreviewEnabled;
47    }
48
49    public void setKeyboardGeometry(final int[] originCoords, final int width, final int height) {
50        // Default implementation is empty.
51    }
52
53    public abstract void onDeallocateMemory();
54
55    /**
56     * Draws the preview
57     * @param canvas The canvas where the preview is drawn.
58     */
59    public abstract void drawPreview(final Canvas canvas);
60
61    /**
62     * Set the position of the preview.
63     * @param tracker The new location of the preview is based on the points in PointerTracker.
64     */
65    public abstract void setPreviewPosition(final PointerTracker tracker);
66}
67