Xavier Ducrohet | 4b606da | 2010-11-03 17:40:17 -0700 | [diff] [blame] | 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 | |
| 17 | package android.graphics; |
| 18 | |
Xavier Ducrohet | c2e9651 | 2010-11-09 18:25:03 -0800 | [diff] [blame] | 19 | import com.android.layoutlib.bridge.impl.DelegateManager; |
Xavier Ducrohet | 9a4fe29 | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 20 | import com.android.tools.layoutlib.annotations.LayoutlibDelegate; |
Xavier Ducrohet | 4b606da | 2010-11-03 17:40:17 -0700 | [diff] [blame] | 21 | |
Xavier Ducrohet | d348b6e | 2010-12-20 08:22:47 -0800 | [diff] [blame] | 22 | import java.awt.Stroke; |
| 23 | |
Xavier Ducrohet | 4b606da | 2010-11-03 17:40:17 -0700 | [diff] [blame] | 24 | /** |
| 25 | * Delegate implementing the native methods of android.graphics.PathEffect |
| 26 | * |
| 27 | * Through the layoutlib_create tool, the original native methods of PathEffect have been replaced |
| 28 | * by calls to methods of the same name in this delegate class. |
| 29 | * |
| 30 | * This class behaves like the original native implementation, but in Java, keeping previously |
| 31 | * native data into its own objects and mapping them to int that are sent back and forth between |
| 32 | * it and the original PathEffect class. |
| 33 | * |
| 34 | * This also serve as a base class for all PathEffect delegate classes. |
| 35 | * |
| 36 | * @see DelegateManager |
| 37 | * |
| 38 | */ |
Xavier Ducrohet | d348b6e | 2010-12-20 08:22:47 -0800 | [diff] [blame] | 39 | public abstract class PathEffect_Delegate { |
Xavier Ducrohet | 4b606da | 2010-11-03 17:40:17 -0700 | [diff] [blame] | 40 | |
| 41 | // ---- delegate manager ---- |
| 42 | protected static final DelegateManager<PathEffect_Delegate> sManager = |
Xavier Ducrohet | f0a5343 | 2011-02-23 16:51:08 -0800 | [diff] [blame] | 43 | new DelegateManager<PathEffect_Delegate>(PathEffect_Delegate.class); |
Xavier Ducrohet | 4b606da | 2010-11-03 17:40:17 -0700 | [diff] [blame] | 44 | |
| 45 | // ---- delegate helper data ---- |
| 46 | |
| 47 | // ---- delegate data ---- |
| 48 | |
| 49 | // ---- Public Helper methods ---- |
| 50 | |
| 51 | public static PathEffect_Delegate getDelegate(int nativeShader) { |
| 52 | return sManager.getDelegate(nativeShader); |
| 53 | } |
| 54 | |
Xavier Ducrohet | d348b6e | 2010-12-20 08:22:47 -0800 | [diff] [blame] | 55 | public abstract Stroke getStroke(Paint_Delegate paint); |
| 56 | public abstract boolean isSupported(); |
| 57 | public abstract String getSupportMessage(); |
| 58 | |
| 59 | |
Xavier Ducrohet | 4b606da | 2010-11-03 17:40:17 -0700 | [diff] [blame] | 60 | // ---- native methods ---- |
| 61 | |
Xavier Ducrohet | 9a4fe29 | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 62 | @LayoutlibDelegate |
Xavier Ducrohet | 4b606da | 2010-11-03 17:40:17 -0700 | [diff] [blame] | 63 | /*package*/ static void nativeDestructor(int native_patheffect) { |
Xavier Ducrohet | cc4977d | 2011-02-22 11:54:37 -0800 | [diff] [blame] | 64 | sManager.removeJavaReferenceFor(native_patheffect); |
Xavier Ducrohet | 4b606da | 2010-11-03 17:40:17 -0700 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | // ---- Private delegate/helper methods ---- |
| 68 | |
| 69 | } |