Skip to content
Snippets Groups Projects
Commit 10e2e1d2 authored by Ludovic Apvrille's avatar Ludovic Apvrille
Browse files

Adding modification on AI

parent f0fe8bab
No related branches found
No related tags found
No related merge requests found
......@@ -428,6 +428,7 @@ public class AvatarPanelDrawer {
Map<AvatarStateMachineElement, TGComponent> locMap = new HashMap<>();
Map<AvatarStateMachineElement, TGComponent> SMDMap = new HashMap<>();
Map<TGComponent, TGComponent> newTGCtoOldOne = new HashMap<>();
Map<TGComponent, AvatarStateMachineElement> newTGCToAvatarElement = new HashMap<>();
Map<Object, TGComponent> refMap = new HashMap<>();
......@@ -449,7 +450,8 @@ public class AvatarPanelDrawer {
AvatarStartState start = asm.getStartState();
addStates(start, ab, smx, smy, smp, bl, SMDMap, newTGCtoOldOne, locMap, tranDestMap, tranSourceMap, refMap, useOriginalValuesFirst,
addStates(start, ab, smx, smy, smp, bl, SMDMap, newTGCtoOldOne, newTGCToAvatarElement, locMap, tranDestMap, tranSourceMap, refMap,
useOriginalValuesFirst,
useOriginalPositionSMD);
//TraceManager.addDev("\nState machine: " + asm.toString() + "\n\n");
......@@ -609,6 +611,8 @@ public class AvatarPanelDrawer {
}
}
// Handling extra attributes (colors, ...)
for(TGComponent newOne: newTGCtoOldOne.keySet()) {
TGComponent oldOne = newTGCtoOldOne.get(newOne);
......@@ -617,10 +621,22 @@ public class AvatarPanelDrawer {
}
}
// Setting characteristics from Avatar element
for(TGComponent newOne: newTGCToAvatarElement.keySet()) {
AvatarStateMachineElement asme = newTGCToAvatarElement.get(newOne);
String colorValue = asme.getCharacteristic("color");
if (colorValue != null) {
Color color = new Color(Integer.parseInt(colorValue));
newOne.setCurrentColor(color);
}
}
}
public void addStates(AvatarStateMachineElement asme, AvatarBlock ab, int x, int y, AvatarSMDPanel smp, AvatarBDBlock bl,
Map<AvatarStateMachineElement, TGComponent> SMDMap, Map<TGComponent, TGComponent> newTGCToOldOne,
Map<TGComponent, AvatarStateMachineElement> newTGCToAvatarElement,
Map<AvatarStateMachineElement, TGComponent> locMap,
Map<AvatarTransition, AvatarStateMachineElement> tranDestMap, Map<AvatarTransition, TGComponent> tranSourceMap,
Map<Object, TGComponent> refMap,
......@@ -661,6 +677,7 @@ public class AvatarPanelDrawer {
smp.addComponent(smdss, newX, newY, false, true);
if (tgc != null) smdss.resize(width, height);
SMDMap.put(asme, smdss);
newTGCToAvatarElement.put(smdss, asme);
if (tgc != null) {
newTGCToOldOne.put(smdss, tgc);
}
......@@ -689,6 +706,7 @@ public class AvatarPanelDrawer {
if (tgc != null) smdr.resize(width, height);
tgcomp = smdr;
SMDMap.put(asme, smdr);
newTGCToAvatarElement.put(smdr, asme);
if (tgc != null) {
newTGCToOldOne.put(smdr, tgc);
}
......@@ -706,6 +724,7 @@ public class AvatarPanelDrawer {
if (tgc != null) smdqrs.resize(width, height);
tgcomp = smdqrs;
SMDMap.put(asme, smdqrs);
newTGCToAvatarElement.put(smdqrs, asme);
if (tgc != null) {
newTGCToOldOne.put(smdqrs, tgc);
}
......@@ -756,6 +775,7 @@ public class AvatarPanelDrawer {
// sig.setName(name);
smdrs.recalculateSize();
SMDMap.put(asme, smdrs);
newTGCToAvatarElement.put(smdrs, asme);
if (tgc != null) {
newTGCToOldOne.put(smdrs, tgc);
}
......@@ -801,6 +821,7 @@ public class AvatarPanelDrawer {
smdss.setValue(name);
smdss.recalculateSize();
SMDMap.put(asme, smdss);
newTGCToAvatarElement.put(smdss, asme);
if (tgc != null) {
newTGCToOldOne.put(smdss, tgc);
}
......@@ -819,6 +840,7 @@ public class AvatarPanelDrawer {
smp);
tgcomp = smdstop;
SMDMap.put(asme, smdstop);
newTGCToAvatarElement.put(smdstop, asme);
if (tgc != null) {
newTGCToOldOne.put(smdstop, tgc);
}
......@@ -842,6 +864,7 @@ public class AvatarPanelDrawer {
timerSet.setComplexValue(ast.getTimer().getName(), timerValue);
tgcomp = timerSet;
SMDMap.put(asme, timerSet);
newTGCToAvatarElement.put(timerSet, asme);
if (tgc != null) {
newTGCToOldOne.put(timerSet, tgc);
}
......@@ -860,6 +883,7 @@ public class AvatarPanelDrawer {
tgcomp = timerExpire;
SMDMap.put(asme, timerExpire);
newTGCToAvatarElement.put(timerExpire, asme);
if (tgc != null) {
newTGCToOldOne.put(timerExpire, tgc);
}
......@@ -877,6 +901,7 @@ public class AvatarPanelDrawer {
timerReset.setComplexValue(((AvatarResetTimer) asme).getTimer().getName());
tgcomp = timerReset;
SMDMap.put(asme, timerReset);
newTGCToAvatarElement.put(timerReset, asme);
if (tgc != null) {
newTGCToOldOne.put(timerReset, tgc);
}
......@@ -913,6 +938,7 @@ public class AvatarPanelDrawer {
smdstate.setValue(asme.getName());
//smdstate.recalculateSize();
SMDMap.put(asme, smdstate);
newTGCToAvatarElement.put(smdstate, asme);
if (tgc != null) {
newTGCToOldOne.put(smdstate, tgc);
}
......@@ -929,6 +955,7 @@ public class AvatarPanelDrawer {
AvatarSMDState smdstateBis = new AvatarSMDState(tmpT.getX(), tmpT.getY(), smp.getMinX(), smp.getMaxX(), smp.getMinY(),
smp.getMaxY(), false, null, smp);
//tgcomp = smdstate;
newTGCToAvatarElement.put(smdstateBis, asme);
newTGCToOldOne.put(smdstateBis, tmpT);
smp.addComponent(smdstateBis, tmpT.getX(), tmpT.getY(), false, true);
smdstateBis.resize(tmpT.getWidth(), tmpT.getHeight());
......@@ -971,7 +998,9 @@ public class AvatarPanelDrawer {
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, newTGCToOldOne, locMap, tranDestMap, tranSourceMap, refMap,
addStates(el, ab, x + diff * i, y + ydiff, smp, bl, SMDMap, newTGCToOldOne, newTGCToAvatarElement,
locMap, tranDestMap,
tranSourceMap, refMap,
useOriginalValuesFirst, useOriginalPositionSMD);
}
i++;
......@@ -985,7 +1014,9 @@ public class AvatarPanelDrawer {
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, newTGCToOldOne, locMap, tranDestMap, tranSourceMap, refMap,
addStates(avatarStartState, ab, x + diff * i, y + ydiff, smp, bl, SMDMap, newTGCToOldOne, newTGCToAvatarElement,
locMap, tranDestMap
, tranSourceMap, refMap,
useOriginalValuesFirst, useOriginalPositionSMD);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment