-
Notifications
You must be signed in to change notification settings - Fork 0
/
ObjArrow.pde
68 lines (58 loc) · 1.9 KB
/
ObjArrow.pde
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
class ObjArrow extends ObjTemplate /*implements Comparable*/ {
int arrowSize;
boolean dragged=false;
private PVector _tp1, _tp2, _tp3;
ObjArrow(int tX1, int tY1, int aSize, ObjHW theParent, ControlP5 tController) {
println("constructeur ObjArrow");
super.aController = tController;
parent = theParent;
arrowSize = aSize;
}
public ObjArrow(ObjTemplate anObj) {
parent = anObj.parent;
super.aController = anObj.aController;
center.x = (int)anObj.center.x;
center.y = (int)anObj.center.y;
arrowSize = anObj.getObjSize();
}
private void processCoord(PVector aP1, PVector aP2, int tSize) {
PVector orthoVector, vSegment, aVector, arrowBase;
vSegment = new PVector(aP2.x-aP1.x,aP2.y-aP1.y,0);
orthoVector = _getOrthogonalVector(aP1, aP2);
orthoVector.mult(tSize/2);
aVector = vSegment;
aVector.normalize();
aVector.mult(tSize/2);
arrowBase = PVector.sub(aP2, aVector);
_tp1 = PVector.add(arrowBase, orthoVector);
_tp2 = PVector.sub(arrowBase, orthoVector);
aVector.normalize();
aVector.mult(tSize/2);
_tp3 = PVector.add(aP2, aVector );
}
public void drawIt(PGraphics aBuffer, int contourWeight, int typeBuffer){
if (typeBuffer == 1) {
aBuffer.fill(color(id));
}
ObjTemplate myMate = getMyMate();
if (myMate != null) {
processCoord(myMate.center, center, arrowSize+contourWeight);
aBuffer.beginDraw();
aBuffer.noStroke();
aBuffer.triangle(_tp1.x, _tp1.y,_tp2.x, _tp2.y,_tp3.x, _tp3.y);
aBuffer.endDraw();
}
}
public void toXml(StringBuilder aSB) {
aSB.append("<ObjArrow id='"+id+"'>");
aSB.append("<arrowSize>"+arrowSize+"</arrowSize>");
//aSB.append("<position x='"+x+"' y='"+y+"'/>");
aSB.append("</ObjArrow>");
}
public void setObjSize(int aSize) {
arrowSize = aSize;
}
public int getObjSize() {
return arrowSize;
}
}