-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFreehand.java
More file actions
53 lines (46 loc) · 1.36 KB
/
Copy pathFreehand.java
File metadata and controls
53 lines (46 loc) · 1.36 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
//henry bogardus
import java.awt.Graphics2D;
import java.util.LinkedList;
import java.util.ListIterator;
public class Freehand extends Shape
{
LinkedList<Point> pointList = new LinkedList<Point>();
public Freehand(ShapeManager shapeManager, Point point1)
{
super(shapeManager, point1);
}
public void drawShape(Graphics2D g2)
{
g2.setColor(mPenColor);
g2.setStroke(mLineThickness.getStrokeInformation());
if (pointList.size() >= 2)
{
ListIterator<Point> it1 = pointList.listIterator(0);
ListIterator<Point> it2 = pointList.listIterator(1);
while (it2.hasNext())
{
Point curPoint = it1.next();
Point nextPoint = it2.next();
int x1 = curPoint.getX();
int y1 = curPoint.getY();
int x2 = nextPoint.getX();
int y2 = nextPoint.getY();
g2.drawLine(x1, y1, x2, y2);
}
}
}
public void processMousePressed(Point point)
{
pointList.add(point);
}
public void processMouseReleased(Point point)
{
pointList.add(point);
mCompleted = true;
}
public void processMouseDragged(Point point)
{
pointList.add(point);
mCompleted = false;
}
}