Newer
Older
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
/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille
*
* ludovic.apvrille AT enst.fr
*
* This software is a computer program whose purpose is to allow the
* edition of TURTLE analysis, design and deployment diagrams, to
* allow the generation of RT-LOTOS or Java code from this diagram,
* and at last to allow the analysis of formal validation traces
* obtained from external tools, e.g. RTL from LAAS-CNRS and CADP
* from INRIA Rhone-Alpes.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package ui;
import avatartranslator.*;
import myutil.TraceManager;
import ui.avatarbd.*;
import ui.avatarsmd.*;
import java.awt.*;
import java.util.*;
import java.util.List;
/**
* Class AvatarPanelDrawer
* Possible states of TGComponent
* Creation: 12/06/2024
* @author Ludovic APVRILLE
* @see avatartranslator.AvatarSpecification
*/
public class AvatarPanelDrawer {
private boolean hasCrypto = false;
public AvatarPanelDrawer() {
}
public void drawPanel(AvatarSpecification avspec, AvatarDesignPanel adp, boolean useOriginalValuesFirst, boolean useOriginalPositionSMD) {
//
// Check Errors in AVSPEC
avspec.removeAnomalies();
TraceManager.addDev("Checking syntax of avatar spec.");
ArrayList<AvatarError> list = AvatarSyntaxChecker.checkSyntaxErrors(avspec);
for (AvatarError error : list) {
TraceManager.addDev("\n*********** Error: " + error.toString() + "\n\n");
}
//TraceManager.addDev("Check done. " + checkingErrors.size() + " errors found\nAvatar Spec:\n" + avspec.toString());
TraceManager.addDev("Avspec to be drawn:" + avspec.toStringRecursive(false));
// Go for drawing!
hasCrypto = false;
//Map<String, Set<String>> originDestMap = new HashMap<String, Set<String>>();
Map<String, AvatarBDBlock> blockMap = new HashMap<String, AvatarBDBlock>();
if (adp == null) {
return;
}
if (avspec == null) {
return;
}
AvatarBDPanel abd = adp.abdp;
abd.getTdmm().setOn(false);
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
//Find all blocks, create nested blocks starting from top left
int xpos = 10;
int ypos = 40;
// Create blocks recursively, starting from top level ones with no father
// Lowest level blocks should be 100x100, next should be 100x(number of children*100+50)...etc,
// Find level #, 0 refers to no father, etc
Map<AvatarBlock, Integer> blockLevelMap = new HashMap<AvatarBlock, Integer>();
Map<AvatarBlock, Integer> blockSizeMap = new HashMap<AvatarBlock, Integer>();
Map<AvatarBlock, Integer> blockIncMap = new HashMap<AvatarBlock, Integer>();
int maxLevel = 0;
for (AvatarBlock ab : avspec.getListOfBlocks()) {
int level = 0;
AvatarBlock block = ab;
while (block.getFather() != null) {
if (blockSizeMap.containsKey(block.getFather())) {
blockSizeMap.put(block.getFather(), blockSizeMap.get(block.getFather()) + 1);
} else {
blockSizeMap.put(block.getFather(), 1);
blockIncMap.put(block.getFather(), 10);
}
level++;
block = block.getFather();
}
if (level > maxLevel) {
maxLevel = level;
}
if (!blockSizeMap.containsKey(block)) {
blockSizeMap.put(block, 0);
blockIncMap.put(block, 10);
}
blockLevelMap.put(ab, level);
}
for (int level = 0; level < maxLevel + 1; level++) {
for (AvatarBlock ab : avspec.getListOfBlocks()) {
if (blockLevelMap.get(ab) == level) {
if (level == 0) {
TraceManager.addDev("New block at level 0");
AvatarBDBlock bl = new AvatarBDBlock(xpos, ypos, abd.getMinX(), abd.getMaxX(), abd.getMinY(), abd.getMaxY(), false,
null, abd);
if ((ab.getReferenceObject() != null) && (ab.getReferenceObject() instanceof CDElement)) {
CDElement cd = (CDElement) ab.getReferenceObject();
bl.setUserResize(cd.getX(), cd.getY(), cd.getWidth(), cd.getHeight());
abd.addComponent(bl, cd.getX(), cd.getY(), false, true);
} else {
abd.addComponent(bl, xpos, ypos, false, true);
bl.resize(100 * blockSizeMap.get(ab) + 100, 100 + (maxLevel - level) * 50);
}
drawBlockProperties(avspec, ab, bl, useOriginalValuesFirst);
AvatarSMDPanel smp = adp.getAvatarSMDPanel(bl.getValue());
smp.getTdmm().setOn(false);
//TraceManager.addDev("\nBuilding state machine of block " + ab.getName() + " smd:" + ab.getStateMachine().toString() + "\n" +
// "\n");
buildStateMachine(ab, bl, smp, useOriginalValuesFirst, useOriginalPositionSMD);
smp.getTdmm().setOn(true);
//TraceManager.addDev("Putting in block")
blockMap.put(bl.getValue().split("__")[bl.getValue().split("__").length - 1], bl);
xpos += 100 * blockSizeMap.get(ab) + 200;
} else {
TraceManager.addDev("New block at level " + level);
AvatarBDBlock father =
blockMap.get(ab.getFather().getName().split("__")[ab.getFather().getName().split("__").length - 1]);
TraceManager.addDev("Father name: " + father.getBlockName());
if (father == null) {
//
continue;
}
AvatarBDBlock bl = new AvatarBDBlock(father.getX() + blockIncMap.get(ab.getFather()), father.getY() + 10,
abd.getMinX(), abd.getMaxX(), abd.getMinY(), abd.getMaxY(), false, father, abd);
/*if ((ab.getReferenceObject() != null) && (ab.getReferenceObject() instanceof CDElement)) {
CDElement cd = (CDElement) ab.getReferenceObject();
bl.setUserResize(cd.getX(), cd.getY(), cd.getWidth(), cd.getHeight());
abd.addComponent(bl, cd.getX(), cd.getY(), false, true);
} else {*/
//abd.addComponent(bl, xpos, ypos, false, true);
//bl.resize(100 * blockSizeMap.get(ab) + 100, 100 + (maxLevel - level) * 50);
//}
abd.addComponent(bl, father.getX() + blockIncMap.get(ab.getFather()), father.getY() + 10, false, true);
int size = 100;
Ludovic Apvrille
committed
if ((ab.getReferenceObject() != null) && (ab.getReferenceObject() instanceof CDElement)) {
CDElement cd = (CDElement) ab.getReferenceObject();
bl.setUserResize(cd.getX(), cd.getY(), cd.getWidth(), cd.getHeight());
} else {
if (blockSizeMap.containsKey(ab)) {
size = 100 * blockSizeMap.get(ab) + 50;
}
bl.resize(size, 100 + (maxLevel - level) * 50);
}
drawBlockProperties(avspec, ab, bl, useOriginalValuesFirst);
abd.attach(bl);
AvatarSMDPanel smp = adp.getAvatarSMDPanel(bl.getValue());
buildStateMachine(ab, bl, smp, useOriginalValuesFirst, useOriginalPositionSMD);
blockMap.put(bl.getValue().split("__")[bl.getValue().split("__").length - 1], bl);
Ludovic Apvrille
committed
size = bl.getWidth();
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
for (AvatarRelation ar : avspec.getRelations()) {
String bl1 = ar.block1.getName();
String bl2 = ar.block2.getName();
bl1 = getLastKeyword(bl1);
bl2 = getLastKeyword(bl2);
Vector<Point> points = new Vector<Point>();
//TraceManager.addDev("bl1:" + bl1 + " bl2:" + bl2);
// Printing blockMap
/*for(String s: blockMap.keySet()) {
AvatarBDBlock block = blockMap.get(s);
TraceManager.addDev("String s:" + s + " / Block : " + block.getBlockName());
}*/
if ((blockMap.get(bl1) != null) && (blockMap.get(bl2) != null)) {
//TraceManager.addDev("Handling blocks");
AvatarBDBlock b1 = blockMap.get(bl1);
AvatarBDBlock b2 = blockMap.get(bl2);
//TGConnectingPoint p1 = blockMap.get(bl1).findFirstFreeTGConnectingPoint(true, true);
//TGConnectingPoint p2 = blockMap.get(bl2).findFirstFreeTGConnectingPoint(true, true);
TGConnectingPoint p1 = null, p2 = null;
if (ar.getOtherReferenceObjects() != null) {
if ((ar.getReferenceObject() instanceof AvatarBDPortConnector) && (ar.getOtherReferenceObjects().size() > 1)) {
//TraceManager.addDev("*----* Found reference objects before / after port connector");
AvatarBDPortConnector connOld = (AvatarBDPortConnector) (ar.getReferenceObject());
if ((ar.getOtherReferenceObjects().get(0) instanceof TGComponent) && (ar.getOtherReferenceObjects().get(1) instanceof TGComponent)) {
TGComponent tgc1 = (TGComponent) (ar.getOtherReferenceObjects().get(0));
TGComponent tgc2 = (TGComponent) (ar.getOtherReferenceObjects().get(1));
int index1 = tgc1.getIndexOfTGConnectingPoint(connOld.getTGConnectingPointP1());
int index2 = tgc2.getIndexOfTGConnectingPoint(connOld.getTGConnectingPointP2());
if ((index1 != -1) && (index2 != -1)) {
p1 = b1.getFreeTGConnectingPoint(index1);
p2 = b2.getFreeTGConnectingPoint(index2);
}
}
}
}
if (p1 == null)
Ludovic Apvrille
committed
p1 = b1.closerFreeTGConnectingPointNoOverlay(b2.getX(), b2.getY(), false, true);
Ludovic Apvrille
committed
p2 = b2.closerFreeTGConnectingPointNoOverlay(b1.getX(), b1.getY(), true, false);
if (p1 != null && p2 != null) {
p1.setFree(false);
p2.setFree(false);
/*if (bl2.equals(bl1)) {
// Add 2 point so the connection looks square
Point p = new Point(p1.getX(), p1.getY() - 10);
points.add(p);
p = new Point(p2.getX(), p2.getY() - 10);
points.add(p);
}*/
if (ar.getOtherReferenceObjects() != null) {
for (int i = 0; i < ar.getOtherReferenceObjects().size(); i++) {
Object o = ar.getOtherReferenceObjects().get(i);
if (o instanceof TGCPointOfConnector) {
TGCPointOfConnector op = (TGCPointOfConnector) o;
points.add(new Point(op.getX(), op.getY()));
}
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
}
}
AvatarBDPortConnector conn = new AvatarBDPortConnector(0, 0, 0, 0, 0, 0, true, null,
abd, p1, p2, points);
abd.addComponent(conn, 0, 0, false, true);
conn.setAsynchronous(ar.isAsynchronous());
conn.setSynchronous(!ar.isAsynchronous());
conn.setAMS(false);
conn.setBlocking(ar.isBlocking());
conn.setPrivate(ar.isPrivate());
conn.setSizeOfFIFO(ar.getSizeOfFIFO());
for (int indexSig = 0; indexSig < ar.getSignals1().size(); indexSig++) {
//TraceManager.addDev("Adding signal 1: " + ar.getSignal1(i).toString() + " of block " + ar.block1.getName());
conn.addSignal(ar.getSignal1(indexSig).toString(), ar.getSignal1(indexSig).getInOut() == 0, ar.block1.getName().contains(bl1));
//TraceManager.addDev("Adding signal 2:" + ar.getSignal2(i).toString() + " of block " + ar.block2.getName());
conn.addSignal(ar.getSignal2(indexSig).toString(), ar.getSignal2(indexSig).getInOut() == 0, !ar.block2.getName().contains(bl2));
conn.updateAllSignals();
}
conn.updateAllSignals();
}
}
}
xpos = 50;
ypos = 500;
for (AvatarDataType adt : avspec.getDataTypes()) {
AvatarBDDataType abdType = new AvatarBDDataType(xpos, ypos, abd.getMinX(), abd.getMaxX(), abd.getMinY(), abd.getMaxY(), false,
null, abd);
abdType.setDataTypeName(adt.getName());
// Adding attributes
for (AvatarAttribute attr : adt.getAttributes()) {
int type = 4;
if (attr.getType() == AvatarType.INTEGER) {
type = 0;
}
if (attr.getType() == AvatarType.TIMER) {
type = 9;
}
abdType.addAttribute(new TAttribute(0, attr.getName(), attr.getType().getDefaultInitialValue(), type));
}
// Drawing
if ((adt.getReferenceObject() != null) && (adt.getReferenceObject() instanceof CDElement)) {
CDElement cd = ((CDElement) (adt.getReferenceObject()));
abdType.setUserResize(cd.getX(), cd.getY(), cd.getWidth(), cd.getHeight());
abd.addComponent(abdType, cd.getX(), cd.getY(), false, true);
} else {
abd.addComponent(abdType, xpos, ypos, false, true);
}
}
//Add Pragmas
makeSecurityPragmas(avspec, adp);
/*
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
if (avspec.getPragmas().size() > 0) {
AvatarBDPragma pragma = new AvatarBDPragma(xpos, ypos, xpos, xpos * 2, ypos, ypos * 2, false, null, abd);
// String[] arr = new String[avspec.getPragmas().size()];
String s = "";
// int i=0;
for (AvatarPragma p : avspec.getPragmas()) {
// arr[i] = p.getName();
TraceManager.addDev("Handling pragma: " + p.getName());
String t = "";
String[] split = p.getName().split(" ");
if (p.getName().startsWith("Confidentiality")) {
for (String str : split) {
if (str.contains(".")) {
String tmp = str.split("\\.")[0];
String tmp2 = str.split("\\.")[1];
t = t.concat(tmp.split("__")[tmp.split("__").length - 1] +
"." + tmp2.split("__")[tmp2.split("__").length - 1] + " ");
} else {
t = t.concat(str + " ");
}
}
} else if (p.getName().startsWith("Authenticity")) {
t = p.getName();
} else if (p.getName().startsWith("Initial")) {
t = p.getName();
} else {
t = p.getName();
}
//TraceManager.addDev("1. pragma=" + t);
t = t.trim();
if (t.startsWith("Confidentiality") || t.startsWith("Authenticity")) {
t = "#" + t;
}
//TraceManager.addDev("2. pragma=" + t);
s = s + "\n";
s = s.concat(t);
// i++;
}
pragma.setValue(s);
pragma.makeValue();
abd.addComponent(pragma, xpos, ypos, false, true);
}*/
//Add message and key datatype if there is a cryptoblock
xpos = 50;
ypos += 200;
if (hasCrypto) {
AvatarBDDataType message = new AvatarBDDataType(xpos, ypos, xpos, xpos * 2, ypos, ypos * 2, false, null, abd);
message.setValue("Message");
abd.addComponent(message, xpos, ypos, false, true);
message.resize(200, 100);
xpos += 400;
AvatarBDDataType key = new AvatarBDDataType(xpos, ypos, xpos, xpos * 2, ypos, ypos * 2, false, null, abd);
key.setValue("Key");
TAttribute attr = new TAttribute(2, "data", "0", 8);
message.addAttribute(attr);
key.addAttribute(attr);
key.resize(200, 100);
abd.addComponent(key, xpos, ypos, false, true);
}
adp.getAvatarBDPanel().connectSignals();
// Safety and performance pragmas
makeSafetyPragmas(avspec, adp);
makePerformancePragmas(avspec, adp);
// Notes
makeNotes(avspec, adp);
abd.getTdmm().setOn(true);
adp.getAvatarBDPanel().repaint();
}
public void buildStateMachine(AvatarBlock ab, AvatarBDBlock bl, AvatarSMDPanel smp, boolean useOriginalValuesFirst,
boolean useOriginalPositionSMD) {
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
//TraceManager.addDev("Building state machine of " + ab.getName());
Map<AvatarTransition, TGComponent> tranSourceMap = new HashMap<AvatarTransition, TGComponent>();
Map<AvatarTransition, AvatarStateMachineElement> tranDestMap = new HashMap<AvatarTransition, AvatarStateMachineElement>();
Map<AvatarStateMachineElement, TGComponent> locMap = new HashMap<AvatarStateMachineElement, TGComponent>();
Map<AvatarStateMachineElement, TGComponent> SMDMap = new HashMap<AvatarStateMachineElement, TGComponent>();
Map<Object, TGComponent> refMap = new HashMap<>();
//Build the state machine
int smx = 400;
int smy = 40;
if (smp == null) {
return;
}
smp.removeAll();
AvatarStateMachine asm = ab.getStateMachine();
//TraceManager.addDev("\nState machine: " + asm.toString() + "\n\n");
//TraceManager.addDev("\nRecursive state machine: " + asm.toStringRecursive() + "\n\n");
//Remove the empty check states
AvatarStartState start = asm.getStartState();
addStates(start, ab, smx, smy, smp, bl, SMDMap, locMap, tranDestMap, tranSourceMap, refMap, useOriginalValuesFirst, useOriginalPositionSMD);
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
//TraceManager.addDev("\nState machine: " + asm.toString() + "\n\n");
//Add transitions
for (AvatarTransition t : tranSourceMap.keySet()) {
if (tranSourceMap.get(t) == null || tranDestMap.get(t) == null || locMap.get(tranDestMap.get(t)) == null) {
continue;
}
int x = tranSourceMap.get(t).getX() + tranSourceMap.get(t).getWidth() / 2;
int y = tranSourceMap.get(t).getY() + tranSourceMap.get(t).getHeight();
// TGConnectingPoint p1 = tranSourceMap.get(t).findFirstFreeTGConnectingPoint(true,false);
/*for(Object o: t.getReferenceObject()) {
}*/
TGConnectingPoint p1 = null, p2 = null;
if ((t.getOtherReferenceObjects() != null) && (t.getOtherReferenceObjects().size() > 4)) {
try {
Point p = (Point) (t.getOtherReferenceObjects().get(4));
TGComponent newTGC1 = refMap.get(t.getOtherReferenceObjects().get(2));
if (newTGC1 != null) {
p1 = newTGC1.getFreeTGConnectingPoint(p.x);
}
TGComponent newTGC2 = refMap.get(t.getOtherReferenceObjects().get(3));
if (newTGC2 != null) {
p2 = newTGC2.getFreeTGConnectingPoint(p.y);
}
} catch (Exception e) {
TraceManager.addDev("**** EXCEPTION: " + e.getMessage());
}
}
if ((p1 == null) || (p2 == null)) {
if (p1 == null) {
p1 = tranSourceMap.get(t).closerFreeTGConnectingPointNoOverlay(x, y, true, false);
//p1 = tranSourceMap.get(t).closerFreeTGConnectingPoint(x, y, false, true);
if (p1 == null) {
TraceManager.addDev("NULL P1 in " + tranSourceMap.get(t).getName() + "/" + tranSourceMap.get(t).getValue());
p1 = tranSourceMap.get(t).findFirstFreeTGConnectingPoint(true, false);
//p1=tranSourceMap.get(t).closerFreeTGConnectingPoint(x,y,true, true);
}
x = locMap.get(tranDestMap.get(t)).getX() + locMap.get(tranDestMap.get(t)).getWidth() / 2;
y = locMap.get(tranDestMap.get(t)).getY();
if (tranSourceMap.get(t).getY() > locMap.get(tranDestMap.get(t)).getY()) {
y = locMap.get(tranDestMap.get(t)).getY() + locMap.get(tranDestMap.get(t)).getHeight() / 2;
if (tranSourceMap.get(t).getX() < locMap.get(tranDestMap.get(t)).getX()) {
x = locMap.get(tranDestMap.get(t)).getX();
} else {
x = locMap.get(tranDestMap.get(t)).getX() + locMap.get(tranDestMap.get(t)).getWidth();
}
}
}
if (p2 == null) {
p2 = locMap.get(tranDestMap.get(t)).closerFreeTGConnectingPointNoOverlay(x, y, false, true);
//p2 = locMap.get(tranDestMap.get(t)).closerFreeTGConnectingPoint(x, y, true, false);
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
if (p2 == null) {
TraceManager.addDev("NULL P2 in " + locMap.get(tranDestMap.get(t)).getName() + "/" + locMap.get(tranDestMap.get(t)).getValue());
p2 = locMap.get(tranDestMap.get(t)).findFirstFreeTGConnectingPoint(false, true);
}
}
} else {
//TraceManager.addDev("Using original connecting points");
}
Vector<Point> points = new Vector<Point>();
if (p1 == null || p2 == null) {
TraceManager.addDev("Null P1 and P2");
return;
}
if (t.getOtherReferenceObjects() != null) {
for (int i = 0; i < t.getOtherReferenceObjects().size(); i++) {
Object o = t.getOtherReferenceObjects().get(i);
if (o instanceof TGCPointOfConnector) {
TGCPointOfConnector op = (TGCPointOfConnector) o;
points.add(new Point(op.getX(), op.getY()));
}
}
}
AvatarSMDConnector SMDCon = new AvatarSMDConnector(p1.getX(), p1.getY(), p1.getX(), p1.getY(), p1.getX(), p1.getY(), true, null, smp,
p1, p2, points);
//
///
p1.setFree(false);
p2.setFree(false);
String action = "";
if (t.getActions().size() == 0) {
action = "";
} else {
action = t.getAction(0, useOriginalValuesFirst).toString().replaceAll(" ", "");
}
// Delays
SMDCon.setTransitionTime(t.getMinDelay(useOriginalValuesFirst), t.getMaxDelay(useOriginalValuesFirst), t.getMinCompute(), t.getMaxCompute());
// Guard
SMDCon.setTransitionInfo(t.getGuard(useOriginalValuesFirst), action);
// Action
for (int i = 1; i < t.getActions().size(); i++) {
SMDCon.setTransitionInfo("", t.getAction(i, useOriginalValuesFirst).replaceAll(" ", ""));
}
SMDCon.setTransitionProbability(t.getDelayDistributionLaw(), t.getDelayExtra1(), t.getDelayExtra2());
smp.addComponent(SMDCon, p1.getX(), p1.getY(), false, true);
if (t.getOtherReferenceObjects() != null) {
for (int i = 0; i < t.getOtherReferenceObjects().size(); i++) {
Object o = t.getOtherReferenceObjects().get(i);
if (o instanceof AvatarSMDTransitionInfo) {
Ludovic Apvrille
committed
//TraceManager.addDev(" ----- Position transition x y width height");
AvatarSMDTransitionInfo tInfo = (AvatarSMDTransitionInfo) o;
SMDCon.getAvatarSMDTransitionInfo().setMoveCd(tInfo.getX(), tInfo.getY(), true);
SMDCon.getAvatarSMDTransitionInfo().resize(tInfo.getWidth(), tInfo.getHeight());
break;
}
}
}
}
}
public void addStates(AvatarStateMachineElement asme, AvatarBlock ab, int x, int y, AvatarSMDPanel smp, AvatarBDBlock bl,
Map<AvatarStateMachineElement, TGComponent> SMDMap, Map<AvatarStateMachineElement, TGComponent> locMap,
Map<AvatarTransition, AvatarStateMachineElement> tranDestMap, Map<AvatarTransition, TGComponent> tranSourceMap,
Map<Object, TGComponent> refMap,
boolean useOriginalValuesFirst, boolean useOriginalPositionSMD) {
// TGConnectingPoint tp = new TGConnectingPoint(null, x, y, false, false);
//Create dummy tgcomponent
if (asme == null) {
return;
}
//TGComponent tgcomp = new AvatarSMDStartState(x, y, smp.getMinX(), smp.getMaxX(), smp.getMinY(), smp.getMaxY(), false, null, smp);
TGComponent tgcomp = null;
//TraceManager.addDev("Block " + bl.getName() + " / " + bl.getValue() + " Found: " + asme.getExtendedName());
int newX = x;
int newY = y;
int width = 0;
int height = 0;
TGComponent tgc = null;
if ((asme.getReferenceObject() instanceof TGComponent) && useOriginalPositionSMD) {
tgc = (TGComponent) (asme.getReferenceObject());
newX = tgc.getX();
newY = tgc.getY();
width = tgc.getWidth();
height = tgc.getHeight();
} else {
newX = x;
newY = y;
}
if (asme instanceof AvatarStartState) {
//TraceManager.addDev("**** Found Avatar start state in block " + bl.getBlockName());
AvatarSMDStartState smdss = new AvatarSMDStartState(newX, newY, smp.getMinX(), smp.getMaxX(), smp.getMinY(), smp.getMaxY(), false, null,
smp);
tgcomp = smdss;
smp.addComponent(smdss, newX, newY, false, true);
if (tgc != null) smdss.resize(width, height);
SMDMap.put(asme, smdss);
// tp = smdss.tgconnectingPointAtIndex(0);
locMap.put(asme, smdss);
refMap.put(asme.getReferenceObject(), smdss);
}
if (asme instanceof AvatarTransition) {
//
}
if (asme instanceof AvatarRandom) {
AvatarSMDRandom smdr = new AvatarSMDRandom(newX, newY, smp.getMinX(), smp.getMaxX(), smp.getMinY(), smp.getMaxY(), false, null, smp);
Ludovic Apvrille
committed
AvatarRandom ar = (AvatarRandom) asme;
smdr.setVariable(ar.getVariable());
if (useOriginalValuesFirst && (ar.getOriginalMinValue() != null) && (ar.getOriginalMinValue().length() > 0)) {
smdr.setMinValue(ar.getOriginalMinValue());
} else {
smdr.setMinValue(ar.getMinValue());
}
if (useOriginalValuesFirst && (ar.getOriginalMaxValue() != null) && (ar.getOriginalMaxValue().length() > 0)) {
smdr.setMaxValue(ar.getOriginalMaxValue());
} else {
smdr.setMaxValue(ar.getMaxValue());
}
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
smp.addComponent(smdr, newX, newY, false, true);
if (tgc != null) smdr.resize(width, height);
tgcomp = smdr;
SMDMap.put(asme, smdr);
locMap.put(asme, smdr);
refMap.put(asme.getReferenceObject(), smdr);
}
if (asme instanceof AvatarQueryOnSignal) {
AvatarSMDQueryReceiveSignal smdqrs = new AvatarSMDQueryReceiveSignal(newX, newY, smp.getMinX(), smp.getMaxX(), smp.getMinY(),
smp.getMaxY(),
false, null,
smp);
smdqrs.setNames(((AvatarQueryOnSignal) asme).getAttribute().getName(), ((AvatarQueryOnSignal) asme).getSignal().getName());
smp.addComponent(smdqrs, newX, newY, false, true);
if (tgc != null) smdqrs.resize(width, height);
tgcomp = smdqrs;
SMDMap.put(asme, smdqrs);
locMap.put(asme, smdqrs);
refMap.put(asme.getReferenceObject(), smdqrs);
}
if (asme instanceof AvatarActionOnSignal) {
//TraceManager.addDev("Block " + bl.getName() + " / " + bl.getValue() + " Found AvatarActionOnSignal: " + asme.getExtendedName());
avatartranslator.AvatarSignal sig = ((AvatarActionOnSignal) asme).getSignal();
if (sig.isIn()) {
AvatarSMDReceiveSignal smdrs = new AvatarSMDReceiveSignal(newX, newY, smp.getMinX(), smp.getMaxX(), smp.getMinY(), smp.getMaxY(),
false,
null, smp);
tgcomp = smdrs;
if (asme.isCheckable() && asme.isChecked()) {
smdrs.setCheckableAccessibility(asme.isChecked());
}
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
smp.addComponent(smdrs, newX, newY, false, true);
// String name=sig.minString();
//
if (tgc != null) smdrs.resize(width, height);
AvatarActionOnSignal aaos = (AvatarActionOnSignal) asme;
String parameters = aaos.getAllOriginalVals();
//TraceManager.addDev("1. Parameters=" + parameters);
String parametersA = aaos.getAllVals();
if (parameters.length() == 0 && parametersA.length() > parameters.length()) {
parameters = parametersA;
} else if (!useOriginalValuesFirst) {
parameters = parametersA;
}
//TraceManager.addDev("2. Parameters=" + parameters);
/*if (((AvatarActionOnSignal) asme).getValues().size() > 0) {
parameters += ((AvatarActionOnSignal) asme).getValues().get(0);
for (int i = 1; i < ((AvatarActionOnSignal) asme).getValues().size(); i++) {
parameters = parameters + "," + ((AvatarActionOnSignal) asme).getValues().get(i);
}*/
String name = sig.getName() + "(" + parameters + ")";
smdrs.setValue(name);
// sig.setName(name);
smdrs.recalculateSize();
SMDMap.put(asme, smdrs);
// tp = smdrs.getFreeTGConnectingPoint(x+smdrs.getWidth()/2,y+smdrs.getHeight());
// TGConnectingPoint tp2 = smdrs.getFreeTGConnectingPoint(x+smdrs.getWidth()/2,y);
locMap.put(asme, smdrs);
refMap.put(asme.getReferenceObject(), smdrs);
if (bl.getAvatarSignalFromName(name) == null) {
//bl.addSignal(new ui.AvatarSignal(0, name, new String[0], new String[0]));
}
} else {
AvatarSMDSendSignal smdss = new AvatarSMDSendSignal(newX, newY, smp.getMinX(), smp.getMaxX(), smp.getMinY(), smp.getMaxY(), false,
null,
smp);
if (asme.isCheckable() && asme.isChecked()) {
smdss.setCheckableAccessibility(asme.isChecked());
}
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
tgcomp = smdss;
smp.addComponent(smdss, newX, newY, false, true);
if (tgc != null) smdss.resize(width, height);
AvatarActionOnSignal aaos = (AvatarActionOnSignal) asme;
String parameters = aaos.getAllOriginalVals();
//TraceManager.addDev("1. Parameters=" + parameters);
String parametersA = aaos.getAllVals();
if (parameters.length() == 0 && parametersA.length() > parameters.length()) {
parameters = parametersA;
} else if (!useOriginalValuesFirst) {
parameters = parametersA;
}
//TraceManager.addDev("2. Parameters=" + parameters);
/*String parameters = "";
if (((AvatarActionOnSignal) asme).getValues().size() > 0) {
parameters += ((AvatarActionOnSignal) asme).getValues().get(0);
for (int i = 1; i < ((AvatarActionOnSignal) asme).getValues().size(); i++) {
parameters = parameters + "," + ((AvatarActionOnSignal) asme).getValues().get(i);
}
}*/
String name = sig.getName() + "(" + parameters + ")";
//String name=sig.minString();
smdss.setValue(name);
smdss.recalculateSize();
SMDMap.put(asme, smdss);
// tp = smdss.getFreeTGConnectingPoint(x+smdss.getWidth()/2,y+smdss.getHeight());
// TGConnectingPoint tp2 = smdss.getFreeTGConnectingPoint(x+smdss.getWidth()/2,y);
locMap.put(asme, smdss);
refMap.put(asme.getReferenceObject(), smdss);
if (bl.getAvatarSignalFromName(name) == null) {
// bl.addSignal(new ui.AvatarSignal(1, name, new String[0], new String[0]));
}
}
}
if (asme instanceof AvatarStopState) {
AvatarSMDStopState smdstop = new AvatarSMDStopState(newX, newY, smp.getMinX(), smp.getMaxX(), smp.getMinY(), smp.getMaxY(), false, null,
smp);
tgcomp = smdstop;
SMDMap.put(asme, smdstop);
smp.addComponent(smdstop, newX, newY, false, true);
if (tgc != null) smdstop.resize(width, height);
// tp = smdstop.tgconnectingPointAtIndex(0);
locMap.put(asme, smdstop);
refMap.put(asme.getReferenceObject(), smdstop);
}
if (asme instanceof AvatarSetTimer) {
AvatarSMDSetTimer timerSet = new AvatarSMDSetTimer(newX, newY, smp.getMinX(), smp.getMaxX(), smp.getMinY(), smp.getMaxY(), false, null,
smp);
AvatarSetTimer ast = (AvatarSetTimer) asme;
Ludovic Apvrille
committed
String timerValue = ast.getTimerValue();
if (useOriginalValuesFirst) {
if ((ast.getTimerOriginalValue() != null) && (ast.getTimerOriginalValue().length() > 0)) {
timerValue = ast.getTimerOriginalValue();
}
}
timerSet.setComplexValue(ast.getTimer().getName(), timerValue);
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
tgcomp = timerSet;
SMDMap.put(asme, timerSet);
smp.addComponent(timerSet, newX, newY, false, true);
if (tgc != null) timerSet.resize(width, height);
// tp = smdstop.tgconnectingPointAtIndex(0);
locMap.put(asme, timerSet);
refMap.put(asme.getReferenceObject(), timerSet);
}
if (asme instanceof AvatarExpireTimer) {
AvatarSMDExpireTimer timerExpire = new AvatarSMDExpireTimer(newX, newY, smp.getMinX(), smp.getMaxX(), smp.getMinY(), smp.getMaxY(), false,
null,
smp);
timerExpire.setComplexValue(((AvatarExpireTimer) asme).getTimer().getName());
tgcomp = timerExpire;
SMDMap.put(asme, timerExpire);
smp.addComponent(timerExpire, newX, newY, false, true);
if (tgc != null) timerExpire.resize(width, height);
// tp = smdstop.tgconnectingPointAtIndex(0);
locMap.put(asme, timerExpire);
refMap.put(asme.getReferenceObject(), timerExpire);
}
if (asme instanceof AvatarResetTimer) {
AvatarSMDResetTimer timerReset = new AvatarSMDResetTimer(newX, newY, smp.getMinX(), smp.getMaxX(), smp.getMinY(), smp.getMaxY(), false,
null,
smp);
timerReset.setComplexValue(((AvatarResetTimer) asme).getTimer().getName());
tgcomp = timerReset;
SMDMap.put(asme, timerReset);
smp.addComponent(timerReset, newX, newY, false, true);
if (tgc != null) timerReset.resize(width, height);
// tp = smdstop.tgconnectingPointAtIndex(0);
locMap.put(asme, timerReset);
refMap.put(asme.getReferenceObject(), timerReset);
}
if (asme instanceof AvatarState) {
//check if empty checker state
/* if (asme.getName().contains("signalstate_")) {
//don't add the state, ignore next transition,
if (asme.getNexts().size()==1) {
AvatarStateMachineElement next = asme.getNext(0).getNext(0);
//Reroute transition
for (AvatarTransition at: tranDestMap.keySet()) {
if (tranDestMap.get(at) == asme) {
tranDestMap.put(at, next);
}
}
addStates(next, x, y, smp,bl, SMDMap, locMap, tranDestMap, tranSourceMap);
return;
}
}*/
AvatarSMDState smdstate = new AvatarSMDState(newX, newY, smp.getMinX(), smp.getMaxX(), smp.getMinY(), smp.getMaxY(), false, null, smp);
if (asme.isCheckable() && asme.isChecked()) {
smdstate.setCheckableAccessibility(asme.isChecked());
}
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
tgcomp = smdstate;
smp.addComponent(smdstate, newX, newY, false, true);
if (tgc != null) smdstate.resize(width, height);
smdstate.setValue(asme.getName());
//smdstate.recalculateSize();
SMDMap.put(asme, smdstate);
// tp = smdstate.getFreeTGConnectingPoint(x+smdstate.getWidth()/2,y+smdstate.getHeight());
// TGConnectingPoint tp2 = smdstate.getFreeTGConnectingPoint(x+smdstate.getWidth()/2,y);
locMap.put(asme, smdstate);
refMap.put(asme.getReferenceObject(), smdstate);
if (asme.getReferenceObjects() != null) {
for (Object o : asme.getReferenceObjects()) {
if ((o != asme.getReferenceObject()) && (o instanceof TGComponent)) {
TGComponent tmpT = (TGComponent) o;
//TraceManager.addDev("Drawing second state called " + asme.getName());
AvatarSMDState smdstateBis = new AvatarSMDState(tmpT.getX(), tmpT.getY(), smp.getMinX(), smp.getMaxX(), smp.getMinY(),
smp.getMaxY(), false, null, smp);
//tgcomp = smdstate;
smp.addComponent(smdstateBis, tmpT.getX(), tmpT.getY(), false, true);
smdstateBis.resize(tmpT.getWidth(), tmpT.getHeight());
smdstateBis.setValue(asme.getName());
refMap.put(o, smdstateBis);
}
}
}
}
int i = 0;
int diff = 300;
int ydiff = 50;
//int num = asme.nbOfNexts();
/*if (!(asme instanceof AvatarTransition)) {
//TraceManager.addDev("element asme: " + asme.toString());
if (asme.getNexts() != null) {
for (AvatarStateMachineElement el : asme.getNexts()) {
if (!(el instanceof AvatarTransition)) {
if ((asme.getReferenceObject() != null) && (asme.getReferenceObject() instanceof CDElement)) {
CDElement cd = (CDElement) asme.getReferenceObject();
tgcomp.setCd(cd.getX(), cd.getY());
}
}
}
}
}*/
if (asme.getNexts() != null) {
for (AvatarStateMachineElement el : asme.getNexts()) {
/*TraceManager.addDev("Block " + bl.getName() + " / " + bl.getValue() +
" Handling next of " + asme.getExtendedName() + ": " + el.getExtendedName());*/
if (el instanceof AvatarTransition) {
tranSourceMap.put((AvatarTransition) el, tgcomp);
} else {
if (asme instanceof AvatarTransition) {
AvatarTransition t = (AvatarTransition) asme;
tranDestMap.put(t, el);
}
}
if (!SMDMap.containsKey(el)) {
/*TraceManager.addDev("not in map: Block " + bl.getName() + " / " + bl.getValue() +
" Handling next of " + asme.getExtendedName() + ": " + el.getExtendedName());*/
addStates(el, ab, x + diff * i, y + ydiff, smp, bl, SMDMap, locMap, tranDestMap, tranSourceMap, refMap,
useOriginalValuesFirst, useOriginalPositionSMD);
//return;
}
// Considering internal elements
AvatarStartState avatarStartState = ab.getStateMachine().getStartStateOf(asme);
if (avatarStartState != null) {
TraceManager.addDev("\t-> Found composite state in block " + ab.getName());
if (!SMDMap.containsKey(avatarStartState)) {
addStates(avatarStartState, ab, x + diff * i, y + ydiff, smp, bl, SMDMap, locMap, tranDestMap, tranSourceMap, refMap,
useOriginalValuesFirst, useOriginalPositionSMD);
}
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
}
}
public void drawBlockProperties(AvatarSpecification as, AvatarBlock ab, AvatarBDBlock bl, boolean useOriginalValues) {
// Signals
for (avatartranslator.AvatarSignal sig : ab.getSignals()) {
String name = sig.getName().split("__")[sig.getName().split("__").length - 1];
// sig.setName(name);
String[] types;
String[] typeIds;
List<AvatarAttribute> listOfAttributes;
if (useOriginalValues && (sig.getListOfOriginalAttributes().size() > 0 || sig.getListOfOriginalReturnAttributes().size() > 0)) {
listOfAttributes = sig.getListOfOriginalAttributes();
} else {
listOfAttributes = sig.getListOfAttributes();
}
int i = 0;
types = new String[listOfAttributes.size()];
typeIds = new String[listOfAttributes.size()];
for (AvatarAttribute attr : listOfAttributes) {
if (attr.isDataType()) {
types[i] = attr.getDataType().getName();
} else {
types[i] = attr.getType().getStringType();
}
typeIds[i] = attr.getName();
i++;
}
//TraceManager.addDev("Adding signal " + sig + " with name=" + name);
bl.addSignal(new ui.AvatarSignal(sig.getInOut(), name, types, typeIds));
}
bl.setValueWithChange(ab.getName().split("__")[ab.getName().split("__").length - 1]);
TraceManager.addDev("Setting name of block: " + bl.getBlockName());
if (useOriginalValues) {
//TraceManager.addDev("** Attributes: Using original attributes");
for (AvatarAttribute attr : ab.getOriginalAttributes()) {
//TraceManager.addDev("Handling original attributes");
//TraceManager.addDev("\tHandling attribute: " + attr);
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
if (attr.isDataType()) {
bl.addAttribute(new TAttribute(0, attr.getName(), attr.getInitialValue(), attr.getDataType().getName()));
} else {
int type = TAttribute.OTHER;
if (attr.getType() == AvatarType.BOOLEAN) {
type = TAttribute.BOOLEAN;
}
if (attr.getType() == AvatarType.INTEGER) {
type = TAttribute.NATURAL;
}
if (attr.getType() == AvatarType.TIMER) {
type = TAttribute.TIMER;
}
if (attr.hasInitialValue()) {
bl.addAttribute(new TAttribute(0, attr.getName(), attr.getInitialValue(), type));
} else {
bl.addAttribute(new TAttribute(0, attr.getName(), attr.getType().getDefaultInitialValue(), type));
}
}
if (attr.getName().contains("key_") || attr.getName().contains("privKey_")) {
hasCrypto = true;
bl.addCryptoElements();
}
}
} else {
//TraceManager.addDev("** Handling regular attributes");
for (AvatarAttribute attr : ab.getAttributes()) {
//TraceManager.addDev("\tHandling attribute: " + attr);
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
int type = TAttribute.OTHER;
if (attr.getType() == AvatarType.BOOLEAN) {
type = TAttribute.BOOLEAN;
}
if (attr.getType() == AvatarType.INTEGER) {
type = TAttribute.NATURAL;
}
if (attr.getType() == AvatarType.TIMER) {
type = TAttribute.TIMER;
}
if (attr.hasInitialValue()) {
bl.addAttribute(new TAttribute(0, attr.getName(), attr.getInitialValue(), type));
} else {
bl.addAttribute(new TAttribute(0, attr.getName(), attr.getType().getDefaultInitialValue(), type));
}
if (attr.getName().contains("key_") || attr.getName().contains("privKey_")) {
hasCrypto = true;
bl.addCryptoElements();
}
}
}
for (AvatarAttribute attr : ab.getConstants()) {
int type = 5;
if (attr.getType() == AvatarType.BOOLEAN) {
type = 4;
}
if (attr.getType() == AvatarType.INTEGER) {
type = 0;
}
if (attr.hasInitialValue()) {
bl.addAttribute(new TAttribute(0, attr.getName(), attr.getInitialValue(), type));
} else {
bl.addAttribute(new TAttribute(0, attr.getName(), attr.getType().getDefaultInitialValue(), type));
}
if (attr.getName().contains("key_") || attr.getName().contains("privKey_")) {
hasCrypto = true;
bl.addCryptoElements();
}
}
for (avatartranslator.AvatarMethod method : ab.getMethods()) {
String methodId = "";
if (useOriginalValues) {
methodId = method.toOriginalString().replaceAll(" = 0", "");
} else {
methodId = method.toString().replaceAll(" = 0", "");
}
String result = methodId.replaceAll(" = false", "");
TraceManager.addDev("Adding method:" + result);
//TraceManager.addDev("Extra types are:" + as.getExtraTypes().toString());
bl.addMethodIfApplicable(result, as.getExtraTypes());
}
}
public String getLastKeyword(String s) {
return s.split("__")[s.split("__").length - 1];
}
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
public void makeSecurityPragmas(AvatarSpecification avspec, AvatarDesignPanel adp) {
AvatarBDPanel abd = adp.abdp;
int dec = 250;
int xPos = 100, yPos = 500;
TGComponent tgcO;
HashMap<Object, AvatarBDPragma> setOfNewSecurityPragmaComponent = new HashMap<>();
for (AvatarPragma p : avspec.getPragmas()) {
// arr[i] = p.getName();
TraceManager.addDev("Handling security pragma: " + p.getName());
Object o = p.getReferenceObject();
AvatarBDPragma comp = null;
if (o != null) {
//TraceManager.addDev(" - - - - Pragma " + pragmaS + " has reference object " + o.toString());
// already created?
comp = setOfNewSecurityPragmaComponent.get(o);
if ((o instanceof TGComponent) && (comp == null))
tgcO = (TGComponent)o;
else tgcO = null;
} else {
tgcO = null;
}
if (comp == null) {
// We must create it
if (tgcO != null) {
xPos = tgcO.getX();
yPos = tgcO.getY();
}
comp = new AvatarBDPragma(xPos, yPos, abd.getMinX(), abd.getMaxX(), abd.getMinY(), abd.getMaxY(), false, null, abd);
xPos = xPos + dec;
yPos = yPos + dec;
abd.addComponent(comp, xPos, yPos, false, true);
if (tgcO != null) {
comp.resize(tgcO.getWidth(), tgcO.getHeight());
}
setOfNewSecurityPragmaComponent.put(o, comp);
}
String value = comp.getValue();
value = value + "\n" + p.getAdvancedValue();
comp.setValue(value);
comp.makeValue();
}
}
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
public void makePerformancePragmas(AvatarSpecification avspec, AvatarDesignPanel adp) {
AvatarBDPanel abd = adp.abdp;
int dec = 250;
int xPos = 100, yPos = 500;
TGComponent tgcO;
HashMap<Object, AvatarBDPerformancePragma> setOfNewPerformancePragmaComponent = new HashMap<>();
for (AvatarPragmaLatency p : avspec.getLatencyPragmas()) {
// arr[i] = p.getName();
TraceManager.addDev("Handling performance pragma: " + p.getName());
Object o = p.getReferenceObject();
AvatarBDPerformancePragma comp = null;
if (o != null) {
//TraceManager.addDev(" - - - - Pragma " + pragmaS + " has reference object " + o.toString());
// already created?
comp = setOfNewPerformancePragmaComponent.get(o);
if ((o instanceof TGComponent) && (comp == null))
tgcO = (TGComponent)o;
else tgcO = null;
} else {
tgcO = null;
}
if (comp == null) {
// We must create it
if (tgcO != null) {
xPos = tgcO.getX();
yPos = tgcO.getY();
}
comp = new AvatarBDPerformancePragma(xPos, yPos, abd.getMinX(), abd.getMaxX(), abd.getMinY(), abd.getMaxY(), false, null, abd);
xPos = xPos + dec;
yPos = yPos + dec;
abd.addComponent(comp, xPos, yPos, false, true);
if (tgcO != null) {
comp.resize(tgcO.getWidth(), tgcO.getHeight());
}
setOfNewPerformancePragmaComponent.put(o, comp);
}
String value = comp.getValue();
value = value + "\n" + p.getAdvancedValue();
comp.setValue(value);
comp.makeValue();
}
}
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
public void makeNotes(AvatarSpecification avspec, AvatarDesignPanel adp) {
AvatarBDPanel abd = adp.abdp;
int dec = 250;
int xPos = 100, yPos = 500;
TGComponent tgcO = null;
TGCNote tgcNote;
for(AvatarNote note: avspec.getNotes()) {
Object o = note.getReferenceObject();
if ((o != null) && (o instanceof TGComponent)) {
tgcO = (TGComponent)o;
xPos = tgcO.getX();
yPos = tgcO.getY();
}
tgcNote = new TGCNote(xPos, yPos, abd.getMinX(), abd.getMaxX(), abd.getMinY(), abd.getMaxY(), false, null, abd);
xPos = xPos + dec;
yPos = yPos + dec;
abd.addComponent(tgcNote, xPos, yPos, false, true);
tgcNote.setValue(note.getValue());
tgcNote.makeValue();
if (tgcO != null) {
tgcNote.resize(tgcO.getWidth(), tgcO.getHeight());
}
}
}
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
public void makeSafetyPragmas(AvatarSpecification avspec, AvatarDesignPanel adp) {
AvatarBDPanel abd = adp.abdp;
int dec = 250;
int xPos = 100, yPos = 500;
TGComponent tgcO;
HashMap<Object, AvatarBDSafetyPragma> setOfNewSafetyPragmaComponent = new HashMap<>();
for(String pragmaS: avspec.getSafetyPragmas()) {
Object o = avspec.getReferenceObjectOfSafetyPragma(pragmaS);
AvatarBDSafetyPragma comp = null;
if (o != null) {
//TraceManager.addDev(" - - - - Pragma " + pragmaS + " has reference object " + o.toString());
// already created?
comp = setOfNewSafetyPragmaComponent.get(o);
if ((o instanceof TGComponent) && (comp == null))
tgcO = (TGComponent)o;
else tgcO = null;
} else {
tgcO = null;
}
if (comp == null) {
// We must create it
if (tgcO != null) {
xPos = tgcO.getX();
yPos = tgcO.getY();
}
comp = new AvatarBDSafetyPragma(xPos, yPos, abd.getMinX(), abd.getMaxX(), abd.getMinY(), abd.getMaxY(), false, null, abd);
xPos = xPos + dec;
yPos = yPos + dec;
abd.addComponent(comp, xPos, yPos, false, true);
if (tgcO != null) {
comp.resize(tgcO.getWidth(), tgcO.getHeight());
}
setOfNewSafetyPragmaComponent.put(o, comp);
}
String value = comp.getValue();
value = value + "\n" + pragmaS;
comp.setValue(value);
comp.makeValue();
}
}