1 package fi.jyu.mit.graphics;
2
3 import java.awt.*;
4
5
10 public class Line extends BasicShape {
11
12 private RPoint p1, p2;
13
14 public Line() {
15 super();
16 this.p1 = new RPoint();
17 this.p2 = new RPoint();
18 }
19
20
27 public Line(double x1, double y1, double x2, double y2) {
28 super();
29 this.p1 = new RPoint(x1, y1);
30 this.p2 = new RPoint(x2, y2);
31 }
32
33
42 public Line(double x1, double y1, double z1, double x2, double y2, double z2) {
43 super();
44 this.p1 = new RPoint(x1, y1, z1);
45 this.p2 = new RPoint(x2, y2, z2);
46 }
47
48
53 public Line(RPoint p1, RPoint p2) {
54 super();
55 this.p1 = p1;
56 this.p2 = p2;
57 }
58
59 public void setPoints(double x1, double y1, double z1, double x2, double y2, double z2) {
60 this.p1.set(x1, y1, z1);
61 this.p2.set(x2, y2, z2);
62 this.redraw();
63 }
64
65 @Override
66 protected void drawShape(Graphics g, Matrix a) {
67 SPoint point1 = a.transform(p1);
68 SPoint point2 = a.transform(p2);
69 g.drawLine(point1.getX(), point1.getY(), point2.getX(), point2.getY());
70 }
71 }
72