-
Notifications
You must be signed in to change notification settings - Fork 0
/
LineExt.java
48 lines (39 loc) · 1.06 KB
/
LineExt.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import javax.swing.*;
import java.awt.geom.*;
class LineExt extends Line2D.Double {
private String name;
private double m;
public LineExt(PointExt a, PointExt b){
super(a.getX(), a.getY(), b.getX(), b.getY());
this.m = ((b.getY()-a.getY())/(b.getX()-a.getX()));
}
public LineExt(){
}
public LineExt(Point2D a, PointExt b){
super(a.getX(), a.getY(), b.getX(), b.getY());
this.m = ((b.getY()-a.getY())/(b.getX()-a.getX()));
}
public LineExt(PointExt a, Point2D b){
super(a.getX(), a.getY(), b.getX(), b.getY());
this.m = ((b.getY()-a.getY())/(b.getX()-a.getX()));
}
public static void main(String[] args) {
}
public double getM(){
return this.m;
}
public void setLine(PointExt a, PointExt b){
super.setLine(a.getX(), a.getY(), b.getX(), b.getY());
this.m = ((b.getY()-a.getY())/(b.getX()-a.getX()));
}
public void setLine(double x1, double y1, double x2, double y2){
super.setLine(x1, y1, x2, y2);
this.m = (y2-y1)/(x2-x1);
}
public void setName(String name){
this.name = name;
}
public String getName(){
return this.name;
}
}