@@ -238,7 +238,7 @@ public void createProgramViewFromNode(Node n) {
238
238
root .getChildren ().add (scrollPane );
239
239
maxX = 0 ;
240
240
maxY = 0 ;
241
- createProgramViewFromNodeRecursively (n , 50 , 125 , true );
241
+ createProgramViewFromNodeRecursively (n , 50 , 50 , true );
242
242
updateProgramViewSize ();
243
243
244
244
System .out .println ("----------------------------" );
@@ -248,14 +248,15 @@ public void createProgramViewFromNode(Node n) {
248
248
249
249
private int maxX ;
250
250
private int maxY ;
251
- public Point createProgramViewFromNodeRecursively (Node n , int x , int y , boolean first ) {
251
+ public BranchData createProgramViewFromNodeRecursively (Node n , int x , int y , boolean first ) {
252
+ BranchData thisBranch = new BranchData (x , y , 0 , 75 );
252
253
if (first ) {
253
- Rectangle r = insertDropTargetAtPosWithSize (x , y - 75 , 50 , 25 );
254
+ Rectangle r = insertDropTargetAtPosWithSize (x , y , 50 , 25 );
254
255
targetNodeMap .put (r , n );
255
256
targetFirstMap .put (r , true );
256
257
}
257
258
if (n .getComponent () == null ) {
258
- return new Point (x , y );
259
+ return new BranchData (x , y , 0 , 75 );
259
260
}
260
261
if (n .getComponent ().getClass () == DelayComponent .class ) {
261
262
// draw delay
@@ -267,29 +268,28 @@ public Point createProgramViewFromNodeRecursively(Node n, int x, int y, boolean
267
268
// draw loop
268
269
// draw extra targets
269
270
Loop loop = (Loop )n .getComponent ();
270
- Point loopSize = createProgramViewFromNodeRecursively (loop .getHeadOfContent (), x , y + 75 , true );
271
- y = loopSize .y ;
271
+ BranchData loopSize = createProgramViewFromNodeRecursively (loop .getHeadOfContent (), thisBranch .x , thisBranch .nextY (), true );
272
+ thisBranch .width = loopSize .width ;
273
+ thisBranch .height = loopSize .height + 75 ;
272
274
} else if (n .getComponent ().getClass () == IfComponent .class ) {
273
275
// draw if
274
276
IfComponent ifComponent = (IfComponent )n .getComponent ();
275
- Point ifSize = new Point (x , y );
276
277
for (Node ifNode : ifComponent .getHeadOfContents ()) {
277
- Point ifNodeSize = createProgramViewFromNodeRecursively (ifNode , ifSize . x , y + 75 , true );
278
- ifSize . x = Math . max ( ifNodeSize .x + 100 , ifSize . x ) ;
279
- ifSize . y = Math .max (ifNodeSize .y , ifSize . y );
278
+ BranchData ifNodeSize = createProgramViewFromNodeRecursively (ifNode , thisBranch . nextX (), thisBranch . y + 75 , true );
279
+ thisBranch . width += ifNodeSize .width + 100 ;
280
+ thisBranch . height = Math .max (ifNodeSize .height + 75 , thisBranch . height );
280
281
}
281
- y = ifSize . y ;
282
+ thisBranch . width -= 100 ;
282
283
}
283
284
// make target for after
284
- Rectangle r = insertDropTargetAtPosWithSize (x , y , 50 , 25 );
285
+ Rectangle r = insertDropTargetAtPosWithSize (thisBranch . x , thisBranch . nextY () , 50 , 25 );
285
286
targetNodeMap .put (r , n );
286
287
targetFirstMap .put (r , false );
287
288
if (n .getNext () != null ) {
288
- Point temp = createProgramViewFromNodeRecursively (n .getNext (), x , y + 75 , false );
289
- x = temp .x ;
290
- y = temp .y ;
289
+ BranchData temp = createProgramViewFromNodeRecursively (n .getNext (), thisBranch .x , thisBranch .nextY (), false );
290
+ thisBranch .height += temp .height ;
291
291
}
292
- return new Point ( x , y ) ;
292
+ return thisBranch ;
293
293
}
294
294
295
295
public void updateProgramViewSize () {
0 commit comments