PixelXorXfermode_Delegate.java revision 63fd87113cea6abec97a6cd966e090e9b590fc3b
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
21import java.awt.Composite;
22
23/**
24 * Delegate implementing the native methods of android.graphics.PixelXorXfermode
25 *
26 * Through the layoutlib_create tool, the original native methods of PixelXorXfermode have been
27 * replaced by calls to methods of the same name in this delegate class.
28 *
29 * This class behaves like the original native implementation, but in Java, keeping previously
30 * native data into its own objects and mapping them to int that are sent back and forth between
31 * it and the original PixelXorXfermode class.
32 *
33 * Because this extends {@link Xfermode_Delegate}, there's no need to use a
34 * {@link DelegateManager}, as all the PathEffect classes will be added to the manager owned by
35 * {@link Xfermode_Delegate}.
36 *
37 * @see Xfermode_Delegate
38 */
39public class PixelXorXfermode_Delegate extends Xfermode_Delegate {
40    // ---- delegate data ----
41
42    // ---- Public Helper methods ----
43
44    @Override
45    public Composite getComposite(int alpha) {
46        // FIXME
47        return null;
48    }
49
50    @Override
51    public boolean isSupported() {
52        return false;
53    }
54
55    @Override
56    public String getSupportMessage() {
57        return "Pixel XOR Xfermodes are not supported in Layout Preview mode.";
58    }
59
60    // ---- native methods ----
61
62    /*package*/ static int nativeCreate(int opColor) {
63        PixelXorXfermode_Delegate newDelegate = new PixelXorXfermode_Delegate();
64        return sManager.addDelegate(newDelegate);
65    }
66
67    // ---- Private delegate/helper methods ----
68}
69