DashPathEffect_Delegate.java revision c2e9651bf386a1f7bf7fc706cf5424950570470c
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 android.graphics;
18
19import com.android.layoutlib.bridge.impl.DelegateManager;
20
21/**
22 * Delegate implementing the native methods of android.graphics.DashPathEffect
23 *
24 * Through the layoutlib_create tool, the original native methods of DashPathEffect have been
25 * replaced by calls to methods of the same name in this delegate class.
26 *
27 * This class behaves like the original native implementation, but in Java, keeping previously
28 * native data into its own objects and mapping them to int that are sent back and forth between
29 * it and the original DashPathEffect class.
30 *
31 * Because this extends {@link PathEffect_Delegate}, there's no need to use a
32 * {@link DelegateManager}, as all the PathEffect classes will be added to the manager owned by
33 * {@link PathEffect_Delegate}.
34 *
35 */
36public class DashPathEffect_Delegate extends PathEffect_Delegate {
37
38    // ---- delegate data ----
39
40    private final float[] mIntervals;
41    private final float mPhase;
42
43    // ---- Public Helper methods ----
44
45    public float[] getIntervals() {
46        return mIntervals;
47    }
48
49    public float getPhase() {
50        return mPhase;
51    }
52
53    // ---- native methods ----
54
55    /*package*/ static int nativeCreate(float intervals[], float phase) {
56        DashPathEffect_Delegate newDelegate = new DashPathEffect_Delegate(intervals, phase);
57        return sManager.addDelegate(newDelegate);
58    }
59
60    // ---- Private delegate/helper methods ----
61
62    private DashPathEffect_Delegate(float intervals[], float phase) {
63        mIntervals = new float[intervals.length];
64        System.arraycopy(intervals, 0, mIntervals, 0, intervals.length);
65        mPhase = phase;
66    }
67}
68
69