Loading tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java +51 −35 Original line number Original line Diff line number Diff line Loading @@ -970,6 +970,8 @@ public class Canvas_Delegate { Graphics2D g = getGraphics2d(); Graphics2D g = getGraphics2d(); g = (Graphics2D)g.create(); g = (Graphics2D)g.create(); // configure it if (paint.isAntiAliased()) { if (paint.isAntiAliased()) { g.setRenderingHint( g.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Loading @@ -977,60 +979,74 @@ public class Canvas_Delegate { RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); } } // configure it boolean useColorPaint = true; // get the shader first, as it'll replace the color if it can be used it. Shader_Delegate shaderDelegate = Shader_Delegate.getDelegate(paint.getShader()); if (shaderDelegate != null) { java.awt.Paint shaderPaint = shaderDelegate.getJavaPaint(); if (shaderPaint != null) { g.setPaint(shaderPaint); useColorPaint = false; } else { if (mLogger != null) { mLogger.warning(String.format( "Shader '%1$s' is not supported in the Layout Editor.", shaderDelegate.getClass().getCanonicalName())); } } } // need to get the alpha to set it in the composite. float falpha = 1.f; if (useColorPaint) { g.setColor(new Color(paint.getColor())); g.setColor(new Color(paint.getColor())); // the alpha is taken from the alpha channel of the color int alpha = paint.getAlpha(); int alpha = paint.getAlpha(); float falpha = alpha / 255.f; falpha = alpha / 255.f; } int style = paint.getStyle(); int style = paint.getStyle(); if (style == Paint.Style.STROKE.nativeInt || if (style == Paint.Style.STROKE.nativeInt || style == Paint.Style.FILL_AND_STROKE.nativeInt) { style == Paint.Style.FILL_AND_STROKE.nativeInt) { /* FIXME PathEffect e = paint.getPathEffect(); PathEffect_Delegate effectDelegate = PathEffect_Delegate.getDelegate( if (e instanceof DashPathEffect) { paint.getPathEffect()); DashPathEffect dpe = (DashPathEffect)e; if (effectDelegate instanceof DashPathEffect_Delegate) { DashPathEffect_Delegate dpe = (DashPathEffect_Delegate)effectDelegate; g.setStroke(new BasicStroke( g.setStroke(new BasicStroke( paint.getStrokeWidth(), paint.getStrokeWidth(), paint.getStrokeCap().getJavaCap(), paint.getJavaCap(), paint.getStrokeJoin().getJavaJoin(), paint.getJavaJoin(), paint.getStrokeMiter(), paint.getStrokeMiter(), dpe.getIntervals(), dpe.getIntervals(), dpe.getPhase())); dpe.getPhase())); } else {*/ } else { g.setStroke(new BasicStroke( g.setStroke(new BasicStroke( paint.getStrokeWidth(), paint.getStrokeWidth(), paint.getJavaCap(), paint.getJavaCap(), paint.getJavaJoin(), paint.getJavaJoin(), paint.getStrokeMiter())); paint.getStrokeMiter())); /* }*/ } } /* } Xfermode xfermode = paint.getXfermode(); if (xfermode instanceof PorterDuffXfermode) { Xfermode_Delegate xfermodeDelegate = Xfermode_Delegate.getDelegate(paint.getXfermode()); PorterDuff.Mode mode = ((PorterDuffXfermode)xfermode).getMode(); if (xfermodeDelegate instanceof PorterDuffXfermode_Delegate) { int mode = ((PorterDuffXfermode_Delegate)xfermodeDelegate).getMode(); setModeInGraphics(mode, g, falpha); setModeInGraphics(g, mode, falpha); } else { } else { if (mLogger != null && xfermode != null) { // default mode is src_over mLogger.warning(String.format( "Xfermode '%1$s' is not supported in the Layout Editor.", xfermode.getClass().getCanonicalName())); } g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, falpha)); g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, falpha)); } */ // if xfermode wasn't null, then it's something we don't support. log it. int nativeShader = paint.getShader(); if (mLogger != null && xfermodeDelegate != null) { Shader_Delegate shaderDelegate = Shader_Delegate.getDelegate(nativeShader); if (shaderDelegate != null) { java.awt.Paint shaderPaint = shaderDelegate.getJavaPaint(); if (shaderPaint != null) { g.setPaint(shaderPaint); } else { if (mLogger != null) { mLogger.warning(String.format( mLogger.warning(String.format( "Shader '%1$s' is not supported in the Layout Editor.", "Xfermode '%1$s' is not supported in the Layout Editor.", shaderDelegate.getClass().getCanonicalName())); xfermodeDelegate.getClass().getCanonicalName())); } } } } } Loading tools/layoutlib/bridge/src/android/graphics/DashPathEffect.java→tools/layoutlib/bridge/src/android/graphics/DashPathEffect_Delegate.java +68 −0 Original line number Original line Diff line number Diff line Loading @@ -16,32 +16,31 @@ package android.graphics; package android.graphics; public class DashPathEffect extends PathEffect { import com.android.layoutlib.bridge.DelegateManager; private final float[] mIntervals; private final float mPhase; /** /** * The intervals array must contain an even number of entries (>=2), with * Delegate implementing the native methods of android.graphics.DashPathEffect * the even indices specifying the "on" intervals, and the odd indices * * specifying the "off" intervals. phase is an offset into the intervals * Through the layoutlib_create tool, the original native methods of DashPathEffect have been * array (mod the sum of all of the intervals). The intervals array * replaced by calls to methods of the same name in this delegate class. * controls the length of the dashes. The paint's strokeWidth controls the * * thickness of the dashes. * This class behaves like the original native implementation, but in Java, keeping previously * Note: this patheffect only affects drawing with the paint's style is set * native data into its own objects and mapping them to int that are sent back and forth between * to STROKE or STROKE_AND_FILL. It is ignored if the drawing is done with * it and the original DashPathEffect class. * style == FILL. * * @param intervals array of ON and OFF distances * Because this extends {@link PathEffect_Delegate}, there's no need to use a * @param phase offset into the intervals array * {@link DelegateManager}, as all the PathEffect classes will be added to the manager owned by * {@link PathEffect_Delegate}. * */ */ public DashPathEffect(float intervals[], float phase) { public class DashPathEffect_Delegate extends PathEffect_Delegate { if (intervals.length < 2) { throw new ArrayIndexOutOfBoundsException(); } mIntervals = intervals; // ---- delegate data ---- mPhase = phase; } private final float[] mIntervals; private final float mPhase; // ---- Public Helper methods ---- public float[] getIntervals() { public float[] getIntervals() { return mIntervals; return mIntervals; Loading @@ -50,5 +49,20 @@ public class DashPathEffect extends PathEffect { public float getPhase() { public float getPhase() { return mPhase; return mPhase; } } // ---- native methods ---- /*package*/ static int nativeCreate(float intervals[], float phase) { DashPathEffect_Delegate newDelegate = new DashPathEffect_Delegate(intervals, phase); return sManager.addDelegate(newDelegate); } // ---- Private delegate/helper methods ---- private DashPathEffect_Delegate(float intervals[], float phase) { mIntervals = new float[intervals.length]; System.arraycopy(intervals, 0, mIntervals, 0, intervals.length); mPhase = phase; } } } tools/layoutlib/bridge/src/android/graphics/PathEffect_Delegate.java 0 → 100644 +60 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.graphics; import com.android.layoutlib.bridge.DelegateManager; /** * Delegate implementing the native methods of android.graphics.PathEffect * * Through the layoutlib_create tool, the original native methods of PathEffect have been replaced * by calls to methods of the same name in this delegate class. * * This class behaves like the original native implementation, but in Java, keeping previously * native data into its own objects and mapping them to int that are sent back and forth between * it and the original PathEffect class. * * This also serve as a base class for all PathEffect delegate classes. * * @see DelegateManager * */ public class PathEffect_Delegate { // ---- delegate manager ---- protected static final DelegateManager<PathEffect_Delegate> sManager = new DelegateManager<PathEffect_Delegate>(); // ---- delegate helper data ---- // ---- delegate data ---- // ---- Public Helper methods ---- public static PathEffect_Delegate getDelegate(int nativeShader) { return sManager.getDelegate(nativeShader); } // ---- native methods ---- /*package*/ static void nativeDestructor(int native_patheffect) { sManager.removeDelegate(native_patheffect); } // ---- Private delegate/helper methods ---- } tools/layoutlib/bridge/src/android/graphics/PorterDuffXfermode.java→tools/layoutlib/bridge/src/android/graphics/PorterDuffXfermode_Delegate.java +61 −0 Original line number Original line Diff line number Diff line /* /* * Copyright (C) 2008 The Android Open Source Project * Copyright (C) 2010 The Android Open Source Project * * * Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License. Loading @@ -16,25 +16,46 @@ package android.graphics; package android.graphics; import android.graphics.PorterDuff.Mode; import com.android.layoutlib.bridge.DelegateManager; public class PorterDuffXfermode extends Xfermode { private final Mode mMode; /** /** * Create an xfermode that uses the specified porter-duff mode. * Delegate implementing the native methods of android.graphics.PorterDuffXfermode * * Through the layoutlib_create tool, the original native methods of PorterDuffXfermode have been * replaced by calls to methods of the same name in this delegate class. * * This class behaves like the original native implementation, but in Java, keeping previously * native data into its own objects and mapping them to int that are sent back and forth between * it and the original PorterDuffXfermode class. * * Because this extends {@link Xfermode_Delegate}, there's no need to use a * {@link DelegateManager}, as all the PathEffect classes will be added to the manager owned by * {@link Xfermode_Delegate}. * * * @param mode The porter-duff mode that is applied */ */ public PorterDuffXfermode(PorterDuff.Mode mode) { public class PorterDuffXfermode_Delegate extends Xfermode_Delegate { mMode = mode; } // ---- delegate data ---- private final int mMode; //---------- Custom Methods // ---- Public Helper methods ---- public PorterDuff.Mode getMode() { public int getMode() { return mMode; return mMode; } } //---------- // ---- native methods ---- /*package*/ static int nativeCreateXfermode(int mode) { PorterDuffXfermode_Delegate newDelegate = new PorterDuffXfermode_Delegate(mode); return sManager.addDelegate(newDelegate); } // ---- Private delegate/helper methods ---- private PorterDuffXfermode_Delegate(int mode) { mMode = mode; } } } tools/layoutlib/bridge/src/android/graphics/Xfermode_Delegate.java 0 → 100644 +60 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.graphics; import com.android.layoutlib.bridge.DelegateManager; /** * Delegate implementing the native methods of android.graphics.Xfermode * * Through the layoutlib_create tool, the original native methods of Xfermode have been replaced * by calls to methods of the same name in this delegate class. * * This class behaves like the original native implementation, but in Java, keeping previously * native data into its own objects and mapping them to int that are sent back and forth between * it and the original Xfermode class. * * This also serve as a base class for all Xfermode delegate classes. * * @see DelegateManager * */ public class Xfermode_Delegate { // ---- delegate manager ---- protected static final DelegateManager<Xfermode_Delegate> sManager = new DelegateManager<Xfermode_Delegate>(); // ---- delegate helper data ---- // ---- delegate data ---- // ---- Public Helper methods ---- public static Xfermode_Delegate getDelegate(int native_instance) { return sManager.getDelegate(native_instance); } // ---- native methods ---- /*package*/ static void finalizer(int native_instance) { sManager.removeDelegate(native_instance); } // ---- Private delegate/helper methods ---- } Loading
tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java +51 −35 Original line number Original line Diff line number Diff line Loading @@ -970,6 +970,8 @@ public class Canvas_Delegate { Graphics2D g = getGraphics2d(); Graphics2D g = getGraphics2d(); g = (Graphics2D)g.create(); g = (Graphics2D)g.create(); // configure it if (paint.isAntiAliased()) { if (paint.isAntiAliased()) { g.setRenderingHint( g.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Loading @@ -977,60 +979,74 @@ public class Canvas_Delegate { RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); } } // configure it boolean useColorPaint = true; // get the shader first, as it'll replace the color if it can be used it. Shader_Delegate shaderDelegate = Shader_Delegate.getDelegate(paint.getShader()); if (shaderDelegate != null) { java.awt.Paint shaderPaint = shaderDelegate.getJavaPaint(); if (shaderPaint != null) { g.setPaint(shaderPaint); useColorPaint = false; } else { if (mLogger != null) { mLogger.warning(String.format( "Shader '%1$s' is not supported in the Layout Editor.", shaderDelegate.getClass().getCanonicalName())); } } } // need to get the alpha to set it in the composite. float falpha = 1.f; if (useColorPaint) { g.setColor(new Color(paint.getColor())); g.setColor(new Color(paint.getColor())); // the alpha is taken from the alpha channel of the color int alpha = paint.getAlpha(); int alpha = paint.getAlpha(); float falpha = alpha / 255.f; falpha = alpha / 255.f; } int style = paint.getStyle(); int style = paint.getStyle(); if (style == Paint.Style.STROKE.nativeInt || if (style == Paint.Style.STROKE.nativeInt || style == Paint.Style.FILL_AND_STROKE.nativeInt) { style == Paint.Style.FILL_AND_STROKE.nativeInt) { /* FIXME PathEffect e = paint.getPathEffect(); PathEffect_Delegate effectDelegate = PathEffect_Delegate.getDelegate( if (e instanceof DashPathEffect) { paint.getPathEffect()); DashPathEffect dpe = (DashPathEffect)e; if (effectDelegate instanceof DashPathEffect_Delegate) { DashPathEffect_Delegate dpe = (DashPathEffect_Delegate)effectDelegate; g.setStroke(new BasicStroke( g.setStroke(new BasicStroke( paint.getStrokeWidth(), paint.getStrokeWidth(), paint.getStrokeCap().getJavaCap(), paint.getJavaCap(), paint.getStrokeJoin().getJavaJoin(), paint.getJavaJoin(), paint.getStrokeMiter(), paint.getStrokeMiter(), dpe.getIntervals(), dpe.getIntervals(), dpe.getPhase())); dpe.getPhase())); } else {*/ } else { g.setStroke(new BasicStroke( g.setStroke(new BasicStroke( paint.getStrokeWidth(), paint.getStrokeWidth(), paint.getJavaCap(), paint.getJavaCap(), paint.getJavaJoin(), paint.getJavaJoin(), paint.getStrokeMiter())); paint.getStrokeMiter())); /* }*/ } } /* } Xfermode xfermode = paint.getXfermode(); if (xfermode instanceof PorterDuffXfermode) { Xfermode_Delegate xfermodeDelegate = Xfermode_Delegate.getDelegate(paint.getXfermode()); PorterDuff.Mode mode = ((PorterDuffXfermode)xfermode).getMode(); if (xfermodeDelegate instanceof PorterDuffXfermode_Delegate) { int mode = ((PorterDuffXfermode_Delegate)xfermodeDelegate).getMode(); setModeInGraphics(mode, g, falpha); setModeInGraphics(g, mode, falpha); } else { } else { if (mLogger != null && xfermode != null) { // default mode is src_over mLogger.warning(String.format( "Xfermode '%1$s' is not supported in the Layout Editor.", xfermode.getClass().getCanonicalName())); } g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, falpha)); g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, falpha)); } */ // if xfermode wasn't null, then it's something we don't support. log it. int nativeShader = paint.getShader(); if (mLogger != null && xfermodeDelegate != null) { Shader_Delegate shaderDelegate = Shader_Delegate.getDelegate(nativeShader); if (shaderDelegate != null) { java.awt.Paint shaderPaint = shaderDelegate.getJavaPaint(); if (shaderPaint != null) { g.setPaint(shaderPaint); } else { if (mLogger != null) { mLogger.warning(String.format( mLogger.warning(String.format( "Shader '%1$s' is not supported in the Layout Editor.", "Xfermode '%1$s' is not supported in the Layout Editor.", shaderDelegate.getClass().getCanonicalName())); xfermodeDelegate.getClass().getCanonicalName())); } } } } } Loading
tools/layoutlib/bridge/src/android/graphics/DashPathEffect.java→tools/layoutlib/bridge/src/android/graphics/DashPathEffect_Delegate.java +68 −0 Original line number Original line Diff line number Diff line Loading @@ -16,32 +16,31 @@ package android.graphics; package android.graphics; public class DashPathEffect extends PathEffect { import com.android.layoutlib.bridge.DelegateManager; private final float[] mIntervals; private final float mPhase; /** /** * The intervals array must contain an even number of entries (>=2), with * Delegate implementing the native methods of android.graphics.DashPathEffect * the even indices specifying the "on" intervals, and the odd indices * * specifying the "off" intervals. phase is an offset into the intervals * Through the layoutlib_create tool, the original native methods of DashPathEffect have been * array (mod the sum of all of the intervals). The intervals array * replaced by calls to methods of the same name in this delegate class. * controls the length of the dashes. The paint's strokeWidth controls the * * thickness of the dashes. * This class behaves like the original native implementation, but in Java, keeping previously * Note: this patheffect only affects drawing with the paint's style is set * native data into its own objects and mapping them to int that are sent back and forth between * to STROKE or STROKE_AND_FILL. It is ignored if the drawing is done with * it and the original DashPathEffect class. * style == FILL. * * @param intervals array of ON and OFF distances * Because this extends {@link PathEffect_Delegate}, there's no need to use a * @param phase offset into the intervals array * {@link DelegateManager}, as all the PathEffect classes will be added to the manager owned by * {@link PathEffect_Delegate}. * */ */ public DashPathEffect(float intervals[], float phase) { public class DashPathEffect_Delegate extends PathEffect_Delegate { if (intervals.length < 2) { throw new ArrayIndexOutOfBoundsException(); } mIntervals = intervals; // ---- delegate data ---- mPhase = phase; } private final float[] mIntervals; private final float mPhase; // ---- Public Helper methods ---- public float[] getIntervals() { public float[] getIntervals() { return mIntervals; return mIntervals; Loading @@ -50,5 +49,20 @@ public class DashPathEffect extends PathEffect { public float getPhase() { public float getPhase() { return mPhase; return mPhase; } } // ---- native methods ---- /*package*/ static int nativeCreate(float intervals[], float phase) { DashPathEffect_Delegate newDelegate = new DashPathEffect_Delegate(intervals, phase); return sManager.addDelegate(newDelegate); } // ---- Private delegate/helper methods ---- private DashPathEffect_Delegate(float intervals[], float phase) { mIntervals = new float[intervals.length]; System.arraycopy(intervals, 0, mIntervals, 0, intervals.length); mPhase = phase; } } }
tools/layoutlib/bridge/src/android/graphics/PathEffect_Delegate.java 0 → 100644 +60 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.graphics; import com.android.layoutlib.bridge.DelegateManager; /** * Delegate implementing the native methods of android.graphics.PathEffect * * Through the layoutlib_create tool, the original native methods of PathEffect have been replaced * by calls to methods of the same name in this delegate class. * * This class behaves like the original native implementation, but in Java, keeping previously * native data into its own objects and mapping them to int that are sent back and forth between * it and the original PathEffect class. * * This also serve as a base class for all PathEffect delegate classes. * * @see DelegateManager * */ public class PathEffect_Delegate { // ---- delegate manager ---- protected static final DelegateManager<PathEffect_Delegate> sManager = new DelegateManager<PathEffect_Delegate>(); // ---- delegate helper data ---- // ---- delegate data ---- // ---- Public Helper methods ---- public static PathEffect_Delegate getDelegate(int nativeShader) { return sManager.getDelegate(nativeShader); } // ---- native methods ---- /*package*/ static void nativeDestructor(int native_patheffect) { sManager.removeDelegate(native_patheffect); } // ---- Private delegate/helper methods ---- }
tools/layoutlib/bridge/src/android/graphics/PorterDuffXfermode.java→tools/layoutlib/bridge/src/android/graphics/PorterDuffXfermode_Delegate.java +61 −0 Original line number Original line Diff line number Diff line /* /* * Copyright (C) 2008 The Android Open Source Project * Copyright (C) 2010 The Android Open Source Project * * * Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License. Loading @@ -16,25 +16,46 @@ package android.graphics; package android.graphics; import android.graphics.PorterDuff.Mode; import com.android.layoutlib.bridge.DelegateManager; public class PorterDuffXfermode extends Xfermode { private final Mode mMode; /** /** * Create an xfermode that uses the specified porter-duff mode. * Delegate implementing the native methods of android.graphics.PorterDuffXfermode * * Through the layoutlib_create tool, the original native methods of PorterDuffXfermode have been * replaced by calls to methods of the same name in this delegate class. * * This class behaves like the original native implementation, but in Java, keeping previously * native data into its own objects and mapping them to int that are sent back and forth between * it and the original PorterDuffXfermode class. * * Because this extends {@link Xfermode_Delegate}, there's no need to use a * {@link DelegateManager}, as all the PathEffect classes will be added to the manager owned by * {@link Xfermode_Delegate}. * * * @param mode The porter-duff mode that is applied */ */ public PorterDuffXfermode(PorterDuff.Mode mode) { public class PorterDuffXfermode_Delegate extends Xfermode_Delegate { mMode = mode; } // ---- delegate data ---- private final int mMode; //---------- Custom Methods // ---- Public Helper methods ---- public PorterDuff.Mode getMode() { public int getMode() { return mMode; return mMode; } } //---------- // ---- native methods ---- /*package*/ static int nativeCreateXfermode(int mode) { PorterDuffXfermode_Delegate newDelegate = new PorterDuffXfermode_Delegate(mode); return sManager.addDelegate(newDelegate); } // ---- Private delegate/helper methods ---- private PorterDuffXfermode_Delegate(int mode) { mMode = mode; } } }
tools/layoutlib/bridge/src/android/graphics/Xfermode_Delegate.java 0 → 100644 +60 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.graphics; import com.android.layoutlib.bridge.DelegateManager; /** * Delegate implementing the native methods of android.graphics.Xfermode * * Through the layoutlib_create tool, the original native methods of Xfermode have been replaced * by calls to methods of the same name in this delegate class. * * This class behaves like the original native implementation, but in Java, keeping previously * native data into its own objects and mapping them to int that are sent back and forth between * it and the original Xfermode class. * * This also serve as a base class for all Xfermode delegate classes. * * @see DelegateManager * */ public class Xfermode_Delegate { // ---- delegate manager ---- protected static final DelegateManager<Xfermode_Delegate> sManager = new DelegateManager<Xfermode_Delegate>(); // ---- delegate helper data ---- // ---- delegate data ---- // ---- Public Helper methods ---- public static Xfermode_Delegate getDelegate(int native_instance) { return sManager.getDelegate(native_instance); } // ---- native methods ---- /*package*/ static void finalizer(int native_instance) { sManager.removeDelegate(native_instance); } // ---- Private delegate/helper methods ---- }