Добавлен метод rect

This commit is contained in:
Victor 2014-03-02 19:46:12 +02:00
parent 1f75426cd8
commit dbdfa99fea

View File

@ -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);
}