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 19 import com.android.layoutlib.bridge.impl.DelegateManager; 20 import com.android.tools.layoutlib.annotations.LayoutlibDelegate; 21 22 import java.awt.Composite; 23 24 /** 25 * Delegate implementing the native methods of android.graphics.AvoidXfermode 26 * 27 * Through the layoutlib_create tool, the original native methods of AvoidXfermode have been 28 * replaced 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 AvoidXfermode class. 33 * 34 * Because this extends {@link Xfermode_Delegate}, there's no need to use a 35 * {@link DelegateManager}, as all the PathEffect classes will be added to the manager owned by 36 * {@link Xfermode_Delegate}. 37 * 38 */ 39 public class AvoidXfermode_Delegate extends Xfermode_Delegate { 40 41 // ---- delegate data ---- 42 43 // ---- Public Helper methods ---- 44 45 @Override getComposite(int alpha)46 public Composite getComposite(int alpha) { 47 // FIXME 48 return null; 49 } 50 51 @Override isSupported()52 public boolean isSupported() { 53 return false; 54 } 55 56 @Override getSupportMessage()57 public String getSupportMessage() { 58 return "Avoid Xfermodes are not supported in Layout Preview mode."; 59 } 60 61 // ---- native methods ---- 62 63 @LayoutlibDelegate nativeCreate(int opColor, int tolerance, int nativeMode)64 /*package*/ static long nativeCreate(int opColor, int tolerance, int nativeMode) { 65 AvoidXfermode_Delegate newDelegate = new AvoidXfermode_Delegate(); 66 return sManager.addNewDelegate(newDelegate); 67 } 68 69 // ---- Private delegate/helper methods ---- 70 } 71