From dbdfa99fea35370366b176e1460343d47106f5fb Mon Sep 17 00:00:00 2001 From: Victor Date: Sun, 2 Mar 2014 19:46:12 +0200 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=20rect?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/com/annimon/graphics/GraphicsExt.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/com/annimon/graphics/GraphicsExt.java b/src/com/annimon/graphics/GraphicsExt.java index 1ee2ef8..f4a0c19 100644 --- a/src/com/annimon/graphics/GraphicsExt.java +++ b/src/com/annimon/graphics/GraphicsExt.java @@ -91,11 +91,27 @@ public class GraphicsExt { if (clip != null) { double[] coords = clip.clip(p1[0], p1[1], p2[0], p2[1]); g.drawLine(convertX(coords[0]), convertY(coords[1]), convertX(coords[2]), convertY(coords[3])); - } else { + } else { g.drawLine(convertX(p1[0]), convertY(p1[1]), convertX(p2[0]), convertY(p2[1])); } } + public void rect(double x, double y, double width, double height) { + rect(new Rect(x, y, width, height)); + } + + public void rect(Rect rect) { + final double x1 = rect.getX(); + final double y1 = rect.getY(); + final double x2 = x1 + rect.getWidth(); + final double y2 = y1 + rect.getHeight(); + move(x1, y1); + draw(x2, y1); + draw(x2, y2); + draw(x1, y2); + draw(x1, y1); + } + private int convertX(double x) { return (int) (x * (width / X_MAX) + 0.5d); }