summaryrefslogtreecommitdiffstats
path: root/tools/layoutlib
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2010-01-21 14:30:48 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2010-01-21 14:30:48 -0800
commitbeb0993c6aa7ccaf4e1ec88355a28f4c3ea93c7a (patch)
tree493ce6dae1d107d3d604af65309298e4ef4ac555 /tools/layoutlib
parent900399f3e8bc3001d3dd017449aea15487c68c59 (diff)
parent38fa9eee9324b2355f28372e80dba12c1d7cc105 (diff)
downloadframeworks_base-beb0993c6aa7ccaf4e1ec88355a28f4c3ea93c7a.zip
frameworks_base-beb0993c6aa7ccaf4e1ec88355a28f4c3ea93c7a.tar.gz
frameworks_base-beb0993c6aa7ccaf4e1ec88355a28f4c3ea93c7a.tar.bz2
am 38fa9eee: am 89d538dc: ADT/Layoutlib: don\'t draw 0-sized rectangle, AWT doesn\'t like that.
Merge commit '38fa9eee9324b2355f28372e80dba12c1d7cc105' * commit '38fa9eee9324b2355f28372e80dba12c1d7cc105': ADT/Layoutlib: don't draw 0-sized rectangle, AWT doesn't like that.
Diffstat (limited to 'tools/layoutlib')
-rw-r--r--tools/layoutlib/bridge/src/android/graphics/Canvas.java60
1 files changed, 32 insertions, 28 deletions
diff --git a/tools/layoutlib/bridge/src/android/graphics/Canvas.java b/tools/layoutlib/bridge/src/android/graphics/Canvas.java
index 9f4dfd0..c49e11e 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Canvas.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Canvas.java
@@ -784,23 +784,25 @@ public class Canvas extends _Original_Canvas {
private final void doDrawRect(int left, int top, int width, int height, Paint paint) {
// get current graphisc
- Graphics2D g = getGraphics2d();
+ if (width != 0 && height != 0) {
+ Graphics2D g = getGraphics2d();
- g = getNewGraphics(paint, g);
+ g = getNewGraphics(paint, g);
- Style style = paint.getStyle();
+ Style style = paint.getStyle();
- // draw
- if (style == Style.FILL || style == Style.FILL_AND_STROKE) {
- g.fillRect(left, top, width, height);
- }
+ // draw
+ if (style == Style.FILL || style == Style.FILL_AND_STROKE) {
+ g.fillRect(left, top, width, height);
+ }
- if (style == Style.STROKE || style == Style.FILL_AND_STROKE) {
- g.drawRect(left, top, width, height);
- }
+ if (style == Style.STROKE || style == Style.FILL_AND_STROKE) {
+ g.drawRect(left, top, width, height);
+ }
- // dispose Graphics2D object
- g.dispose();
+ // dispose Graphics2D object
+ g.dispose();
+ }
}
/* (non-Javadoc)
@@ -809,29 +811,31 @@ public class Canvas extends _Original_Canvas {
@Override
public void drawRoundRect(RectF rect, float rx, float ry, Paint paint) {
// get current graphisc
- Graphics2D g = getGraphics2d();
+ if (rect.width() != 0 && rect.height() != 0) {
+ Graphics2D g = getGraphics2d();
- g = getNewGraphics(paint, g);
+ g = getNewGraphics(paint, g);
- Style style = paint.getStyle();
+ Style style = paint.getStyle();
- // draw
+ // draw
- int arcWidth = (int)(rx * 2);
- int arcHeight = (int)(ry * 2);
+ int arcWidth = (int)(rx * 2);
+ int arcHeight = (int)(ry * 2);
- if (style == Style.FILL || style == Style.FILL_AND_STROKE) {
- g.fillRoundRect((int)rect.left, (int)rect.top, (int)rect.width(), (int)rect.height(),
- arcWidth, arcHeight);
- }
+ if (style == Style.FILL || style == Style.FILL_AND_STROKE) {
+ g.fillRoundRect((int)rect.left, (int)rect.top, (int)rect.width(), (int)rect.height(),
+ arcWidth, arcHeight);
+ }
- if (style == Style.STROKE || style == Style.FILL_AND_STROKE) {
- g.drawRoundRect((int)rect.left, (int)rect.top, (int)rect.width(), (int)rect.height(),
- arcWidth, arcHeight);
- }
+ if (style == Style.STROKE || style == Style.FILL_AND_STROKE) {
+ g.drawRoundRect((int)rect.left, (int)rect.top, (int)rect.width(), (int)rect.height(),
+ arcWidth, arcHeight);
+ }
- // dispose Graphics2D object
- g.dispose();
+ // dispose Graphics2D object
+ g.dispose();
+ }
}