-
Notifications
You must be signed in to change notification settings - Fork 89
Expand file tree
/
Copy pathDisplayPointsHandle.java
More file actions
44 lines (35 loc) · 1.18 KB
/
DisplayPointsHandle.java
File metadata and controls
44 lines (35 loc) · 1.18 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
package nodebox.handle;
import nodebox.graphics.*;
import nodebox.node.Node;
public class DisplayPointsHandle extends AbstractHandle {
private boolean displayPointNumbers = false;
public DisplayPointsHandle(Node node) {
super(node);
}
public void draw(GraphicsContext ctx) {
if (!(node.getOutputValue() instanceof Path)) return;
Path dots = new Path();
dots.setFillColor(HANDLE_COLOR);
dots.setStrokeWidth(0f);
drawDots(ctx, (Path) node.getOutputValue(), dots);
ctx.draw(dots);
}
public boolean isDisplayPointNumbers() {
return displayPointNumbers;
}
public void setDisplayPointNumbers(boolean displayPointNumbers) {
this.displayPointNumbers = displayPointNumbers;
}
private void drawDots(GraphicsContext ctx, Path path, Path dots) {
boolean displayPointNumbers = this.displayPointNumbers;
int i = 0;
for (Point pt : path.getPoints()) {
drawDot(dots, pt.x, pt.y);
if (displayPointNumbers) {
Text t = ctx.text(String.valueOf(i), pt.x + 7, pt.y);
t.setFontSize(10);
}
i++;
}
}
}