Skip to content
Snippets Groups Projects
Commit f962b7ac authored by apvrille's avatar apvrille
Browse files

Update on block click management

parent e6b7508f
No related branches found
No related tags found
No related merge requests found
SRCS = generated_src/main.c generated_src/ObserverProp1.c generated_src/RemotelyControlledMicrowave.c generated_src/MicroWaveOven.c generated_src/Bell.c generated_src/ControlPanel.c generated_src/Controller.c generated_src/Magnetron.c generated_src/Door.c SRCS = generated_src/main.c generated_src/AlarmActuator.c generated_src/PressureSensor.c generated_src/PressureController.c generated_src/AlarmManager.c generated_src/MainController.c generated_src/Timer__alarmTimer__AlarmManager.c
\ No newline at end of file \ No newline at end of file
This diff is collapsed.
This diff is collapsed.
...@@ -68,7 +68,7 @@ import java.util.LinkedList; ...@@ -68,7 +68,7 @@ import java.util.LinkedList;
*/ */
public class AvatarBDBlock extends TGCScalableWithInternalComponent implements SwallowTGComponent, SwallowedTGComponent, GenericTree, AvatarBDStateMachineOwner { public class AvatarBDBlock extends TGCScalableWithInternalComponent implements SwallowTGComponent, SwallowedTGComponent, GenericTree, AvatarBDStateMachineOwner {
private static String GLOBAL_CODE_INFO = "(global code)"; private static String GLOBAL_CODE_INFO = "(block code)";
private int textY1 = 3; private int textY1 = 3;
private static String stereotype = "block"; private static String stereotype = "block";
...@@ -82,6 +82,7 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S ...@@ -82,6 +82,7 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S
private int limitName = -1; private int limitName = -1;
private int limitAttr = -1; private int limitAttr = -1;
private int limitMethod = -1; private int limitMethod = -1;
private int limitSignal = -1;
// Icon // Icon
private int iconSize = 15; private int iconSize = 15;
...@@ -186,6 +187,7 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S ...@@ -186,6 +187,7 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S
this.limitName = -1; this.limitName = -1;
this.limitAttr = -1; this.limitAttr = -1;
this.limitMethod = -1; this.limitMethod = -1;
this.limitSignal = y + height;
// h retains the coordinate along X where an element was last drawn // h retains the coordinate along X where an element was last drawn
int h = 0; int h = 0;
...@@ -317,7 +319,8 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S ...@@ -317,7 +319,8 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S
h += textY1; h += textY1;
// Attributes // Attributes
limitAttr = limitName;
for (TAttribute attr: this.myAttributes) { for (TAttribute attr: this.myAttributes) {
h += step; h += step;
if (h >= this.height - textX) { if (h >= this.height - textX) {
...@@ -364,10 +367,13 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S ...@@ -364,10 +367,13 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S
h += textY1; h += textY1;
// Methods // Methods
limitMethod = limitAttr;
limitSignal = limitAttr;
for (AvatarMethod method: this.myMethods) { for (AvatarMethod method: this.myMethods) {
h += step; h += step;
if (h >= this.height - textX) { if (h >= this.height - textX) {
this.limitMethod = this.y + this.height; this.limitMethod = this.y + this.height;
this.limitSignal = limitMethod;
return; return;
} }
...@@ -397,11 +403,15 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S ...@@ -397,11 +403,15 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S
h += graph.getFontMetrics ().getDescent () + textY1; h += graph.getFontMetrics ().getDescent () + textY1;
// Remember limit of methods if (h + textY1 >= this.height) {
this.limitMethod = this.y + h; limitMethod = this.y + this.height;
limitSignal = this.y + this.height;
if (h + textY1 >= this.height)
return; return;
}
// Remember limit of methods
this.limitMethod = this.y + h;
this.limitSignal = this.y + h;
graph.drawLine (this.x, this.y+h, this.x+this.width, this.y+h); graph.drawLine (this.x, this.y+h, this.x+this.width, this.y+h);
h += textY1; h += textY1;
...@@ -409,8 +419,10 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S ...@@ -409,8 +419,10 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S
// Signals // Signals
for (AvatarSignal signal: this.mySignals) { for (AvatarSignal signal: this.mySignals) {
h += step; h += step;
if (h >= this.height - textX) if (h >= this.height - textX) {
limitSignal = this.height + this.y;
return; return;
}
String signalString = "~ " + signal.toString (); String signalString = "~ " + signal.toString ();
w = graph.getFontMetrics ().stringWidth (signalString); w = graph.getFontMetrics ().stringWidth (signalString);
...@@ -442,21 +454,25 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S ...@@ -442,21 +454,25 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S
h += graph.getFontMetrics ().getDescent () + textY1; h += graph.getFontMetrics ().getDescent () + textY1;
if (h + textY1 >= this.height) if (h + textY1 >= this.height) {
limitSignal = this.height + this.y;
return; return;
}
// Global code // Global code
limitSignal = this.y+h;
if (hasGlobalCode()) { if (hasGlobalCode()) {
if (h+textY1+step >= this.height - textX) if (h+textY1+step >= this.height - textX)
return; return;
graph.drawLine (this.x, this.y+h, this.x+this.width, this.y+h); graph.drawLine (this.x, this.y+h, this.x+this.width, this.y+h);
h += textY1+step; h += textY1+step;
w = graph.getFontMetrics ().stringWidth (GLOBAL_CODE_INFO); w = graph.getFontMetrics ().stringWidth (GLOBAL_CODE_INFO);
if (w + 2*textX < this.width) if (w + 2*textX < this.width)
graph.drawString (GLOBAL_CODE_INFO, this.x + (this.width - w)/2, this.y + h); graph.drawString (GLOBAL_CODE_INFO, this.x + (this.width - w)/2, this.y + h);
} } else {
limitSignal = height;
}
} }
private void drawInfoAttachement(AvatarSignal _as, Graphics g, int _x, int _y) { private void drawInfoAttachement(AvatarSignal _as, Graphics g, int _x, int _y) {
...@@ -599,8 +615,36 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S ...@@ -599,8 +615,36 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S
} }
// And so -> attributes! // And so -> attributes!
int tab = 0; int tab = 0;
if (limitAttr != -1) {
TraceManager.addDev("limitAttr=" + limitAttr + " method=" + limitMethod + " limitSignal=" + limitSignal + " y=" + _y + " height=" + height);
if (limitMethod == -1) {
limitMethod = limitAttr;
}
if (limitSignal == -1) {
limitSignal = limitMethod;
}
if (limitAttr == -1) {
tab = 0;
} else {
if (_y < limitAttr) {
tab = 0;
} else if (_y < limitMethod){
tab = 1;
} else if (_y < limitSignal) {
tab = 2;
} else if (_y > limitSignal && hasGlobalCode()) {
tab = 3;
} else if (_y > limitSignal && !hasGlobalCode()) {
tab = 2;
}
}
/*if (limitAttr != -1) {
if (_y > limitAttr) { if (_y > limitAttr) {
if (limitMethod == -1) { if (limitMethod == -1) {
tab = 2; tab = 2;
...@@ -619,7 +663,7 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S ...@@ -619,7 +663,7 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S
if (this.mySignals.size() > 1) { if (this.mySignals.size() > 1) {
tab = 2; tab = 2;
} }
} }*/
String mainCode = null; String mainCode = null;
TDiagramPanel ttdp = getTDiagramPanel(); TDiagramPanel ttdp = getTDiagramPanel();
......
...@@ -544,7 +544,7 @@ public class JDialogAvatarBlock extends javax.swing.JDialog implements ActionLis ...@@ -544,7 +544,7 @@ public class JDialogAvatarBlock extends javax.swing.JDialog implements ActionLis
panelCode.add(jsp, c2); panelCode.add(jsp, c2);
panelCode.add(new JLabel("Global code of block:"), c7); panelCode.add(new JLabel("Global code of block:"), c7);
panelCode.add(new JLabel("To implement a method m of block B: \"userImplemented_B_m(...){...}\""), c7); panelCode.add(new JLabel("To implement a method m of block B: \"_userImplemented_B_m(...){...}\""), c7);
jtaGlobalCode = new JTextArea(); jtaGlobalCode = new JTextArea();
jtaGlobalCode.setEditable(true); jtaGlobalCode.setEditable(true);
jtaGlobalCode.setMargin(new Insets(10, 10, 10, 10)); jtaGlobalCode.setMargin(new Insets(10, 10, 10, 10));
......
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