1 package org.catacomb.graph.drawing;
2
3 import org.catacomb.graph.gui.Painter;
4
5
6
7 public class StraightLine extends FixedDrawingComponent {
8
9
10 public double x0;
11 public double y0;
12 public double x1;
13 public double y1;
14
15
16
17
18
19
20 public StraightLine() {
21 super();
22 }
23
24 public StraightLine(double xa, double ya, double xb, double yb) {
25 x0 = xa;
26 y0 = ya;
27 x1 = xb;
28 y1 = yb;
29 }
30
31 public void instruct(Painter p, double offx, double offy, double scale) {
32 p.drawLine(offx + scale * x0, offy + scale * y0,
33 offx + scale * x1, offy + scale * y1,
34 getColor(), getWidth(), widthIsPixels());
35
36 }
37
38
39 public void applyToShape(Shape shp) {
40 shp.setClosure(Shape.OPEN);
41 shp.setCurviness(0.0);
42 shp.setSymmetry(ShapeSymmetry.NONE);
43 double[] xp = {x0, x1};
44 shp.setXpts(xp);
45 double[] yp = {y0, y1};
46 shp.setYpts(yp);
47 }
48
49 public void scaleBy(double d) {
50 x0 *= d;
51 x1 *= d;
52 y0 *= d;
53 y1 *= d;
54 }
55
56
57
58
59 }