-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGPPoint.java
More file actions
48 lines (40 loc) · 1.45 KB
/
GPPoint.java
File metadata and controls
48 lines (40 loc) · 1.45 KB
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 java.awt.geom.*;
import java.awt.*;
import java.io.*;
public class GPPoint implements Serializable {
static final long serialVersionUID = 1L;
public Type type;
public Point endPoint;
public Point ctrlPoint1;
public Point ctrlPoint2;
public GPPoint() {
this(null,null,null,Type.LINE);
}
public GPPoint(Point endPoint, Point ctrlPoint1, Point ctrlPoint2, GPPoint.Type type) {
this.endPoint = endPoint;
this.ctrlPoint1 = ctrlPoint1;
this.ctrlPoint2 = ctrlPoint2;
this.type = type;
}
public enum Type {
LINE,QUAD,CUBIC
}
public void copy(GPPoint gpPoint) {
type = gpPoint.type;
endPoint = (gpPoint.endPoint == null) ? null : new Point(gpPoint.endPoint.x, gpPoint.endPoint.y);
ctrlPoint1 = (gpPoint.ctrlPoint1 == null) ? null : new Point(gpPoint.ctrlPoint1.x, gpPoint.ctrlPoint1.y);
ctrlPoint2 = (gpPoint.ctrlPoint2 == null) ? null : new Point(gpPoint.ctrlPoint2.x, gpPoint.ctrlPoint2.y);
}
public GPPoint clone() {
GPPoint newGPPoint = new GPPoint();
newGPPoint.copy(this);
return newGPPoint;
}
public String toString() {
String pointString = "Point: (" + endPoint.x + "," + endPoint.y + ")";
String typeString = " type: " + type;
String ctrlPoint1String = (ctrlPoint1 == null) ? "" : " Ctrl: (" + ctrlPoint1.x + "," + ctrlPoint1.y + ")";
String ctrlPoint2String = (ctrlPoint1 == null) ? "" : " (" + ctrlPoint2.x + "," + ctrlPoint2.y + ")";
return pointString + typeString + ctrlPoint1String + ctrlPoint2String;
}
}