Loading tools/layoutlib/bridge/src/android/graphics/BitmapShader.java +9 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.graphics; import java.awt.Paint; public class BitmapShader extends Shader { // we hold on just for the GC, since our native counterpart is using it Loading @@ -37,5 +39,10 @@ public class BitmapShader extends Shader { public Bitmap getBitmap() { return mBitmap; } @Override Paint getPaint() { return null; } } tools/layoutlib/bridge/src/android/graphics/Canvas.java +11 −8 Original line number Diff line number Diff line Loading @@ -125,15 +125,18 @@ public class Canvas extends _Original_Canvas { } Shader shader = paint.getShader(); if (shader instanceof LinearGradient) { g.setPaint(((LinearGradient)shader).getPaint()); if (shader != null) { java.awt.Paint shaderPaint = shader.getPaint(); if (shaderPaint != null) { g.setPaint(shaderPaint); } else { if (mLogger != null && shader != null) { if (mLogger != null) { mLogger.warning(String.format( "Shader '%1$s' is not supported in the Layout Editor.", shader.getClass().getCanonicalName())); } } } return g; } Loading Loading @@ -409,7 +412,7 @@ public class Canvas extends _Original_Canvas { g.setColor(new Color(color)); getGraphics2d().fillRect(0, 0, getWidth(), getHeight()); g.fillRect(0, 0, getWidth(), getHeight()); g.setComposite(composite); Loading tools/layoutlib/bridge/src/android/graphics/ComposeShader.java +7 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.graphics; import java.awt.Paint; /** A subclass of shader that returns the composition of two other shaders, combined by an {@link android.graphics.Xfermode} subclass. */ Loading @@ -42,5 +44,10 @@ public class ComposeShader extends Shader { public ComposeShader(Shader shaderA, Shader shaderB, PorterDuff.Mode mode) { // FIXME Implement shader } @Override Paint getPaint() { return null; } } tools/layoutlib/bridge/src/android/graphics/LinearGradient.java +40 −32 Original line number Diff line number Diff line Loading @@ -24,19 +24,21 @@ public class LinearGradient extends Shader { private GradientPaint mGradientPaint; /** Create a shader that draws a linear gradient along a line. @param x0 The x-coordinate for the start of the gradient line @param y0 The y-coordinate for the start of the gradient line @param x1 The x-coordinate for the end of the gradient line @param y1 The y-coordinate for the end of the gradient line @param colors The colors to be distributed along the gradient line @param positions May be null. The relative positions [0..1] of each corresponding color in the colors array. If this is null, the the colors are distributed evenly along the gradient line. @param tile The Shader tiling mode /** * Create a shader that draws a linear gradient along a line. * * @param x0 The x-coordinate for the start of the gradient line * @param y0 The y-coordinate for the start of the gradient line * @param x1 The x-coordinate for the end of the gradient line * @param y1 The y-coordinate for the end of the gradient line * @param colors The colors to be distributed along the gradient line * @param positions May be null. The relative positions [0..1] of each * corresponding color in the colors array. If this is null, the * the colors are distributed evenly along the gradient line. * @param tile The Shader tiling mode */ public LinearGradient(float x0, float y0, float x1, float y1, int colors[], float positions[], TileMode tile) { public LinearGradient(float x0, float y0, float x1, float y1, int colors[], float positions[], TileMode tile) { if (colors.length < 2) { throw new IllegalArgumentException("needs >= 2 number of colors"); } Loading @@ -45,27 +47,33 @@ public class LinearGradient extends Shader { } // FIXME implement multi color linear gradient if (colors.length == 2) { mGradientPaint = new GradientPaint(x0, y0, new Color(colors[0], true /* hasalpha */), x1, y1, new Color(colors[1], true /* hasalpha */), tile != TileMode.CLAMP); } } /** Create a shader that draws a linear gradient along a line. @param x0 The x-coordinate for the start of the gradient line @param y0 The y-coordinate for the start of the gradient line @param x1 The x-coordinate for the end of the gradient line @param y1 The y-coordinate for the end of the gradient line @param color0 The color at the start of the gradient line. @param color1 The color at the end of the gradient line. @param tile The Shader tiling mode /** * Create a shader that draws a linear gradient along a line. * * @param x0 The x-coordinate for the start of the gradient line * @param y0 The y-coordinate for the start of the gradient line * @param x1 The x-coordinate for the end of the gradient line * @param y1 The y-coordinate for the end of the gradient line * @param color0 The color at the start of the gradient line. * @param color1 The color at the end of the gradient line. * @param tile The Shader tiling mode */ public LinearGradient(float x0, float y0, float x1, float y1, int color0, int color1, TileMode tile) { mGradientPaint = new GradientPaint(x0, y0, new Color(color0, true /* hasalpha */), x1,y1, new Color(color1, true /* hasalpha */), tile != TileMode.CLAMP); public LinearGradient(float x0, float y0, float x1, float y1, int color0, int color1, TileMode tile) { mGradientPaint = new GradientPaint(x0, y0, new Color(color0, true /* hasalpha */), x1, y1, new Color(color1, true /* hasalpha */), tile != TileMode.CLAMP); } // ---------- Custom Methods @Override public Paint getPaint() { return mGradientPaint; } } tools/layoutlib/bridge/src/android/graphics/Paint.java +0 −9 Original line number Diff line number Diff line Loading @@ -59,23 +59,14 @@ public class Paint extends _Original_Paint { private final FontRenderContext mFontContext = new FontRenderContext( new AffineTransform(), true, true); @SuppressWarnings("hiding") public static final int ANTI_ALIAS_FLAG = _Original_Paint.ANTI_ALIAS_FLAG; @SuppressWarnings("hiding") public static final int FILTER_BITMAP_FLAG = _Original_Paint.FILTER_BITMAP_FLAG; @SuppressWarnings("hiding") public static final int DITHER_FLAG = _Original_Paint.DITHER_FLAG; @SuppressWarnings("hiding") public static final int UNDERLINE_TEXT_FLAG = _Original_Paint.UNDERLINE_TEXT_FLAG; @SuppressWarnings("hiding") public static final int STRIKE_THRU_TEXT_FLAG = _Original_Paint.STRIKE_THRU_TEXT_FLAG; @SuppressWarnings("hiding") public static final int FAKE_BOLD_TEXT_FLAG = _Original_Paint.FAKE_BOLD_TEXT_FLAG; @SuppressWarnings("hiding") public static final int LINEAR_TEXT_FLAG = _Original_Paint.LINEAR_TEXT_FLAG; @SuppressWarnings("hiding") public static final int SUBPIXEL_TEXT_FLAG = _Original_Paint.SUBPIXEL_TEXT_FLAG; @SuppressWarnings("hiding") public static final int DEV_KERN_TEXT_FLAG = _Original_Paint.DEV_KERN_TEXT_FLAG; public static class FontMetrics extends _Original_Paint.FontMetrics { Loading Loading
tools/layoutlib/bridge/src/android/graphics/BitmapShader.java +9 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.graphics; import java.awt.Paint; public class BitmapShader extends Shader { // we hold on just for the GC, since our native counterpart is using it Loading @@ -37,5 +39,10 @@ public class BitmapShader extends Shader { public Bitmap getBitmap() { return mBitmap; } @Override Paint getPaint() { return null; } }
tools/layoutlib/bridge/src/android/graphics/Canvas.java +11 −8 Original line number Diff line number Diff line Loading @@ -125,15 +125,18 @@ public class Canvas extends _Original_Canvas { } Shader shader = paint.getShader(); if (shader instanceof LinearGradient) { g.setPaint(((LinearGradient)shader).getPaint()); if (shader != null) { java.awt.Paint shaderPaint = shader.getPaint(); if (shaderPaint != null) { g.setPaint(shaderPaint); } else { if (mLogger != null && shader != null) { if (mLogger != null) { mLogger.warning(String.format( "Shader '%1$s' is not supported in the Layout Editor.", shader.getClass().getCanonicalName())); } } } return g; } Loading Loading @@ -409,7 +412,7 @@ public class Canvas extends _Original_Canvas { g.setColor(new Color(color)); getGraphics2d().fillRect(0, 0, getWidth(), getHeight()); g.fillRect(0, 0, getWidth(), getHeight()); g.setComposite(composite); Loading
tools/layoutlib/bridge/src/android/graphics/ComposeShader.java +7 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.graphics; import java.awt.Paint; /** A subclass of shader that returns the composition of two other shaders, combined by an {@link android.graphics.Xfermode} subclass. */ Loading @@ -42,5 +44,10 @@ public class ComposeShader extends Shader { public ComposeShader(Shader shaderA, Shader shaderB, PorterDuff.Mode mode) { // FIXME Implement shader } @Override Paint getPaint() { return null; } }
tools/layoutlib/bridge/src/android/graphics/LinearGradient.java +40 −32 Original line number Diff line number Diff line Loading @@ -24,19 +24,21 @@ public class LinearGradient extends Shader { private GradientPaint mGradientPaint; /** Create a shader that draws a linear gradient along a line. @param x0 The x-coordinate for the start of the gradient line @param y0 The y-coordinate for the start of the gradient line @param x1 The x-coordinate for the end of the gradient line @param y1 The y-coordinate for the end of the gradient line @param colors The colors to be distributed along the gradient line @param positions May be null. The relative positions [0..1] of each corresponding color in the colors array. If this is null, the the colors are distributed evenly along the gradient line. @param tile The Shader tiling mode /** * Create a shader that draws a linear gradient along a line. * * @param x0 The x-coordinate for the start of the gradient line * @param y0 The y-coordinate for the start of the gradient line * @param x1 The x-coordinate for the end of the gradient line * @param y1 The y-coordinate for the end of the gradient line * @param colors The colors to be distributed along the gradient line * @param positions May be null. The relative positions [0..1] of each * corresponding color in the colors array. If this is null, the * the colors are distributed evenly along the gradient line. * @param tile The Shader tiling mode */ public LinearGradient(float x0, float y0, float x1, float y1, int colors[], float positions[], TileMode tile) { public LinearGradient(float x0, float y0, float x1, float y1, int colors[], float positions[], TileMode tile) { if (colors.length < 2) { throw new IllegalArgumentException("needs >= 2 number of colors"); } Loading @@ -45,27 +47,33 @@ public class LinearGradient extends Shader { } // FIXME implement multi color linear gradient if (colors.length == 2) { mGradientPaint = new GradientPaint(x0, y0, new Color(colors[0], true /* hasalpha */), x1, y1, new Color(colors[1], true /* hasalpha */), tile != TileMode.CLAMP); } } /** Create a shader that draws a linear gradient along a line. @param x0 The x-coordinate for the start of the gradient line @param y0 The y-coordinate for the start of the gradient line @param x1 The x-coordinate for the end of the gradient line @param y1 The y-coordinate for the end of the gradient line @param color0 The color at the start of the gradient line. @param color1 The color at the end of the gradient line. @param tile The Shader tiling mode /** * Create a shader that draws a linear gradient along a line. * * @param x0 The x-coordinate for the start of the gradient line * @param y0 The y-coordinate for the start of the gradient line * @param x1 The x-coordinate for the end of the gradient line * @param y1 The y-coordinate for the end of the gradient line * @param color0 The color at the start of the gradient line. * @param color1 The color at the end of the gradient line. * @param tile The Shader tiling mode */ public LinearGradient(float x0, float y0, float x1, float y1, int color0, int color1, TileMode tile) { mGradientPaint = new GradientPaint(x0, y0, new Color(color0, true /* hasalpha */), x1,y1, new Color(color1, true /* hasalpha */), tile != TileMode.CLAMP); public LinearGradient(float x0, float y0, float x1, float y1, int color0, int color1, TileMode tile) { mGradientPaint = new GradientPaint(x0, y0, new Color(color0, true /* hasalpha */), x1, y1, new Color(color1, true /* hasalpha */), tile != TileMode.CLAMP); } // ---------- Custom Methods @Override public Paint getPaint() { return mGradientPaint; } }
tools/layoutlib/bridge/src/android/graphics/Paint.java +0 −9 Original line number Diff line number Diff line Loading @@ -59,23 +59,14 @@ public class Paint extends _Original_Paint { private final FontRenderContext mFontContext = new FontRenderContext( new AffineTransform(), true, true); @SuppressWarnings("hiding") public static final int ANTI_ALIAS_FLAG = _Original_Paint.ANTI_ALIAS_FLAG; @SuppressWarnings("hiding") public static final int FILTER_BITMAP_FLAG = _Original_Paint.FILTER_BITMAP_FLAG; @SuppressWarnings("hiding") public static final int DITHER_FLAG = _Original_Paint.DITHER_FLAG; @SuppressWarnings("hiding") public static final int UNDERLINE_TEXT_FLAG = _Original_Paint.UNDERLINE_TEXT_FLAG; @SuppressWarnings("hiding") public static final int STRIKE_THRU_TEXT_FLAG = _Original_Paint.STRIKE_THRU_TEXT_FLAG; @SuppressWarnings("hiding") public static final int FAKE_BOLD_TEXT_FLAG = _Original_Paint.FAKE_BOLD_TEXT_FLAG; @SuppressWarnings("hiding") public static final int LINEAR_TEXT_FLAG = _Original_Paint.LINEAR_TEXT_FLAG; @SuppressWarnings("hiding") public static final int SUBPIXEL_TEXT_FLAG = _Original_Paint.SUBPIXEL_TEXT_FLAG; @SuppressWarnings("hiding") public static final int DEV_KERN_TEXT_FLAG = _Original_Paint.DEV_KERN_TEXT_FLAG; public static class FontMetrics extends _Original_Paint.FontMetrics { Loading