1- public class TemplateCanvas extends Panel
1+ public class TemplateCanvas extends ParentPanel
22{
3- PGraphics drawPG;
43 PGraphics fontPlacer;
54 PImage cardPic;
65 PFont drawFont;
76
87 ArrayList<Element > elements;
98 Table contents;
109
11- // int offsetX = 300;
12- // int offsetY = 100;
13- // float zoom = 0.5;
14- int pgWidth;
15- int pgHeight;
10+ int canvasWid;
11+ int canvasHei;
1612
1713 int contentExample = 0 ;
1814
@@ -28,30 +24,25 @@ public class TemplateCanvas extends Panel
2824 int lastMX;
2925 int lastMY;
3026
31- TemplateCanvas (ArrayList<Element > e, Table conts, int xx, int yy, int canW, int canH)
27+ TemplateCanvas (String nm, ArrayList<Element > e, Table conts, int xx, int yy, int canW, int canH)
3228 {
33- x = xx;
34- y = yy;
29+ name = nm; x = xx; y = yy; wid = int (canW * zoom); hei = int (canH * zoom);
3530 elements = e;
36- wid = canW;
37- hei = canH;
31+ canvasWid = canW;
32+ canvasHei = canH;
3833 contents = conts;
34+ drawPG = createGraphics (wid,hei);
3935 }
4036
41- void drawAll ()
37+ public void updateThis ()
4238 {
43- drawPG = createGraphics (wid,hei );
44- drawPG . beginDraw( );
39+ wid = int (canvasWid * zoom );
40+ hei = int (canvasHei * zoom );
4541 drawCanvas();
4642 drawElements();
47- drawPG. endDraw();
48- }
49-
50- void updateDraw()
51- {
5243 }
5344
54- void drawCanvas()
45+ public void drawCanvas()
5546 {
5647 drawPG. fill(150 );
5748 drawPG. rect(0 , 0 , wid, hei);
@@ -63,10 +54,10 @@ public class TemplateCanvas extends Panel
6354 {
6455 e. updatePosition();
6556
66- int cx = int (e. x);
67- int cy = int (e. y);
68- int cwid = int (e. wid);
69- int chei = int (e. hei);
57+ int cx = int (e. x * zoom );
58+ int cy = int (e. y * zoom );
59+ int cwid = int (e. wid * zoom );
60+ int chei = int (e. hei * zoom );
7061
7162 drawPG. noStroke();
7263 if (doContent && contentExample != NONE )
@@ -96,7 +87,7 @@ public class TemplateCanvas extends Panel
9687 {
9788 drawPG. fill(100 ,100 ,255 ,alpha);
9889 }
99- drawPG. rect(e. x, e. y, e. wid, e. hei);
90+ drawPG. rect( int ( e. x * zoom), int ( e. y * zoom), int ( e. wid * zoom), int ( e. hei * zoom) );
10091 }
10192
10293 void drawContent( Element e , int cx , int cy , int cwid , int chei )
@@ -117,7 +108,7 @@ public class TemplateCanvas extends Panel
117108 fontPlacer = createGraphics (int (cwid/ hSquish),chei);
118109 fontPlacer. beginDraw();
119110 fontPlacer. textFont(e. font);
120- fontPlacer. textSize(e. fontSize);
111+ fontPlacer. textSize(constrain ( e. fontSize * zoom, 0 ,chei) );
121112 fontPlacer. textAlign(LEFT ,TOP );
122113 fontPlacer. fill(e. col);
123114 try {
@@ -264,14 +255,18 @@ public class TemplateCanvas extends Panel
264255 lastMY = my;
265256 }
266257
267- void handleReleased( int mx, int my )
258+ void clickThis( )
268259 {
269260 if ( isDragging )
270261 {
271262 isDragging = false ;
272263 resizing[0 ] = NONE ;
273264 resizing[1 ] = NONE ;
274265 }
266+ else
267+ {
268+ println (" Clicked " , name);
269+ }
275270 }
276271
277272 void handleArrowPress(int selectId)
@@ -310,28 +305,6 @@ public class TemplateCanvas extends Panel
310305 }
311306 }
312307
313- // void zoomIn()
314- // {
315- // zoom *= 1.2;
316- // offsetX -= int(50 * canvas.zoom);
317- // offsetY -= int(50 * canvas.zoom);
318- // constrainOffsets();
319- // }
320- //
321- // void zoomOut()
322- // {
323- // canvas.zoom /= 1.2;
324- // canvas.offsetX += int(50 * canvas.zoom);
325- // canvas.offsetY += int(50 * canvas.zoom);
326- // constrainOffsets();
327- // }
328- //
329- // void constrainOffsets()
330- // {
331- // offsetX = constrain(offsetX , int(wid * zoom * -1) + 200, width - 200);
332- // offsetY = constrain(offsetY , int(hei * zoom * -1) + 200, height - 200);
333- // }
334-
335308 void setResizing( Element e, int mx, int my)
336309 {
337310 resizing[0 ] = NONE ;
0 commit comments