am 89d538dc: ADT/Layoutlib: don\'t draw 0-sized rectangle, AWT doesn\'t like that.

Merge commit '89d538dcca9a4cb95682c56b0c4b85e8a77442be' into eclair-plus-aosp

* commit '89d538dcca9a4cb95682c56b0c4b85e8a77442be':
  ADT/Layoutlib: don't draw 0-sized rectangle, AWT doesn't like that.
This commit is contained in:
Xavier Ducrohet
2010-01-14 19:15:22 -08:00
committed by Android Git Automerger

View File

@@ -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);
}
// dispose Graphics2D object
g.dispose();
}
if (style == Style.STROKE || style == Style.FILL_AND_STROKE) {
g.drawRect(left, top, width, height);
}
// 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);
}
// dispose Graphics2D object
g.dispose();
}
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();
}