1e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka/* 2e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka * Copyright (C) 2013 The Android Open Source Project 3e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka * 4e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka * Licensed under the Apache License, Version 2.0 (the "License"); 5e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka * you may not use this file except in compliance with the License. 6e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka * You may obtain a copy of the License at 7e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka * 8e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka * http://www.apache.org/licenses/LICENSE-2.0 9e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka * 10e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka * Unless required by applicable law or agreed to in writing, software 11e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka * distributed under the License is distributed on an "AS IS" BASIS, 12e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka * See the License for the specific language governing permissions and 14e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka * limitations under the License. 15e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka */ 16e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka 17e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaokapackage com.android.inputmethod.keyboard.internal; 18e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka 19e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaokaimport android.content.res.TypedArray; 20e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka 21e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaokaimport com.android.inputmethod.latin.R; 22e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka 23e2a6253cb581f9ab70cfb723d32b14f9ac7d2ab7Tadashi G. Takaoka/** 24e2a6253cb581f9ab70cfb723d32b14f9ac7d2ab7Tadashi G. Takaoka * This class holds parameters to control how a gesture stroke is sampled and drawn on the screen. 25e2a6253cb581f9ab70cfb723d32b14f9ac7d2ab7Tadashi G. Takaoka * 26e2a6253cb581f9ab70cfb723d32b14f9ac7d2ab7Tadashi G. Takaoka * @attr ref R.styleable#MainKeyboardView_gestureTrailMinSamplingDistance 27e2a6253cb581f9ab70cfb723d32b14f9ac7d2ab7Tadashi G. Takaoka * @attr ref R.styleable#MainKeyboardView_gestureTrailMaxInterpolationAngularThreshold 28e2a6253cb581f9ab70cfb723d32b14f9ac7d2ab7Tadashi G. Takaoka * @attr ref R.styleable#MainKeyboardView_gestureTrailMaxInterpolationDistanceThreshold 29e2a6253cb581f9ab70cfb723d32b14f9ac7d2ab7Tadashi G. Takaoka * @attr ref R.styleable#MainKeyboardView_gestureTrailMaxInterpolationSegments 30e2a6253cb581f9ab70cfb723d32b14f9ac7d2ab7Tadashi G. Takaoka */ 31e2a6253cb581f9ab70cfb723d32b14f9ac7d2ab7Tadashi G. Takaokapublic final class GestureStrokeDrawingParams { 32e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka public final double mMinSamplingDistance; // in pixel 33e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka public final double mMaxInterpolationAngularThreshold; // in radian 34e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka public final double mMaxInterpolationDistanceThreshold; // in pixel 35e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka public final int mMaxInterpolationSegments; 36e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka 37e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka private static final float DEFAULT_MIN_SAMPLING_DISTANCE = 0.0f; // dp 38e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka private static final int DEFAULT_MAX_INTERPOLATION_ANGULAR_THRESHOLD = 15; // in degree 39e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka private static final float DEFAULT_MAX_INTERPOLATION_DISTANCE_THRESHOLD = 0.0f; // dp 40e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka private static final int DEFAULT_MAX_INTERPOLATION_SEGMENTS = 4; 41e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka 42e2a6253cb581f9ab70cfb723d32b14f9ac7d2ab7Tadashi G. Takaoka public GestureStrokeDrawingParams(final TypedArray mainKeyboardViewAttr) { 43e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka mMinSamplingDistance = mainKeyboardViewAttr.getDimension( 44e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka R.styleable.MainKeyboardView_gestureTrailMinSamplingDistance, 45e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka DEFAULT_MIN_SAMPLING_DISTANCE); 46e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka final int interpolationAngularDegree = mainKeyboardViewAttr.getInteger(R.styleable 47e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka .MainKeyboardView_gestureTrailMaxInterpolationAngularThreshold, 0); 48e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka mMaxInterpolationAngularThreshold = (interpolationAngularDegree <= 0) 49e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka ? Math.toRadians(DEFAULT_MAX_INTERPOLATION_ANGULAR_THRESHOLD) 50e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka : Math.toRadians(interpolationAngularDegree); 51e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka mMaxInterpolationDistanceThreshold = mainKeyboardViewAttr.getDimension(R.styleable 52e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka .MainKeyboardView_gestureTrailMaxInterpolationDistanceThreshold, 53e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka DEFAULT_MAX_INTERPOLATION_DISTANCE_THRESHOLD); 54e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka mMaxInterpolationSegments = mainKeyboardViewAttr.getInteger( 55e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka R.styleable.MainKeyboardView_gestureTrailMaxInterpolationSegments, 56e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka DEFAULT_MAX_INTERPOLATION_SEGMENTS); 57e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka } 58e82200787c662488c908c7973b9857ee6ce037b3Tadashi G. Takaoka} 59