-
Notifications
You must be signed in to change notification settings - Fork 0
/
ObjCir.pde
76 lines (66 loc) · 1.72 KB
/
ObjCir.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
68
69
70
71
72
73
74
75
76
class ObjCir extends ObjTemplate {
int radius;
boolean dragged=false;
/*
* Constructeur
*/
public ObjCir(int tX, int tY, int tRad, ObjHW theParent, ControlP5 tController) {
println("constructeur ObjCir");
parent = theParent;
super.aController = tController;
center.x = tX;
center.y = tY;
radius = tRad;
}
public ObjCir(ObjTemplate anObj) {
parent = anObj.parent;
super.aController = anObj.aController;
center.x = (int)anObj.center.x;
center.y = (int)anObj.center.y;
radius = anObj.getObjSize();
}
public void setSelected(boolean tSelected) {
if ((selected == true) && (selected != tSelected)) {
println("set selected radius:"+radius);
aController.controller("headRadius").setValue(radius);
}
selected = tSelected;
}
/*
* Private
*/
private void _drawSelection(PGraphics aBuffer) {
aBuffer.pushStyle();
aBuffer.noFill();
aBuffer.stroke(255,0,0);
aBuffer.ellipse(center.x,center.y,radius,radius);
aBuffer.popStyle();
}
/*
* PUBLIC
*/
/*
* dessine l'élement
*/
public void drawIt(PGraphics aBuffer, int contour, int typeBuffer){
if (typeBuffer == 1) {
aBuffer.fill(color(id));
}
aBuffer.beginDraw();
aBuffer.noStroke();
aBuffer.ellipse(center.x,center.y,radius+contour,radius+contour);
aBuffer.endDraw();
}
public void toXml(StringBuilder aSB) {
aSB.append("<ObjCir id='"+id+"'>");
aSB.append("<radius>"+radius+"</radius>");
aSB.append("<position x='"+center.x+"' y='"+center.y+"'/>");
aSB.append("</ObjCir>");
}
public void setObjSize(int aSize) {
radius = aSize;
}
public int getObjSize() {
return (int)radius;
}
}