-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuadCurveData.java
More file actions
68 lines (54 loc) · 1.58 KB
/
QuadCurveData.java
File metadata and controls
68 lines (54 loc) · 1.58 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import java.awt.geom.*;
import java.io.*;
import java.awt.*;
public class QuadCurveData extends ShapeData implements Serializable {
static final long serialVersionUID = 1L;
private Point start;
private Point end;
private Point ctrlPoint;
public QuadCurveData() {
super();
}
@Override
public void update(Point start, Point end, Point ctrlPoint) {
this.start = start;
this.end = end;
this.ctrlPoint = ctrlPoint;
}
@Override
public Shape getShape() {
return new QuadCurve2D.Double(start.x,start.y, ctrlPoint.x,ctrlPoint.y, end.x,end.y);
}
@Override
public void draw(Graphics2D g2d) {
if (isEmpty()) return;
super.draw(g2d);
g2d.draw(getShape());
}
@Override
public boolean isEmpty() {
return start == null || end == null || ctrlPoint == null;
}
public void copy(QuadCurveData quadCurveData) {
super.copy(quadCurveData);
Point s = quadCurveData.start;
Point e = quadCurveData.end;
Point cP = quadCurveData.ctrlPoint;
this.start = (s == null) ? null : new Point((int)s.getX(), (int)s.getY());
this.end = (e == null) ? null : new Point((int)e.getX(), (int)e.getY());
this.ctrlPoint = (e == null) ? null : new Point((int)cP.getX(), (int)cP.getY());
}
public QuadCurveData clone() {
QuadCurveData newQuadCurveData = new QuadCurveData();
newQuadCurveData.copy(this);
return newQuadCurveData;
}
@Override
public String shapeName() {
return "QUAD_CURVE";
}
@Override
public String toString() {
return "Quad curve: (" + start.x + "," + start.y + "), (" + ctrlPoint.x + "," + ctrlPoint.y + "), (" + end.x + "," + end.y + ")";
}
}