1 package org.catacomb.graph.gui;
2
3 import org.catacomb.be.Position;
4
5
6
7
8 public class Builder {
9
10 Painter painter;
11
12 PickStore pickStore;
13
14 int width;
15 int height;
16
17
18 public Builder(Painter p, PickStore ps) {
19 painter = p;
20 pickStore = ps;
21 }
22
23
24 public void setCanvasSize(int w, int h) {
25 width = w;
26 height = h;
27 }
28
29
30
31 public void clear() {
32 pickStore.clear();
33 }
34
35
36 public void add3DPickablePoint(double x, double y, double z, PickablePoint pp) {
37 double wx = painter.xProj(x, y, z);
38 double wy = painter.yProj(x, y, z);
39 pp.moveTo(wx, wy);
40
41 int ix = painter.powx(wx);
42 int iy = painter.powy(wy);
43
44 pickStore.addPoint(pp, ix, iy);
45
46 }
47
48
49 public void addPoint(PickablePoint pp) {
50 addPickablePoint(pp);
51 }
52
53
54
55
56 public void addPickablePoint(PickablePoint pp) {
57 addPickablePoint(pp, pp.getPosition());
58 }
59
60
61
62 public void addPickablePoint(PickablePoint pp, Position pos) {
63
64 int ix = painter.powx(pos.getX());
65 int iy = painter.powy(pos.getY());
66
67 pickStore.addPoint(pp, ix, iy);
68
69 painter.fillPixelRectangle(ix, iy, pp.getColor(), pp.getSize());
70
71 }
72
73
74
75 public void addPickableRegion(PickableRegion pka) {
76 pickStore.addPickableRegion(pka,
77 painter.powx(pka.getXReference()),
78 painter.powy(pka.getYReference()));
79
80 }
81
82
83
84 public void addPickableRegion(Pickable pbl, int x, int y, int w, int h) {
85 pickStore.addPoint(pbl, x, y, x + w, y + h);
86
87 }
88
89
90
91
92
93
94
95 public void add2DPickableRegionOn3DPoint(Pickable pbl, double x, double y, double z,
96 int dx, int dy, int w, int h) {
97 double wx = painter.xProj(x, y, z);
98 double wy = painter.yProj(x, y, z);
99
100 int ix = painter.powx(wx);
101 int iy = painter.powy(wy);
102 addPickableRegion(pbl, ix + dx, iy + dy, w, h);
103
104 }
105
106
107
108 }