Merge lp:~tapaal-contributor/tapaal/constants-blink-1853902 into lp:tapaal

Proposed by Peter Haahr Taankvist
Status: Merged
Approved by: Jiri Srba
Approved revision: 1036
Merged at revision: 1039
Proposed branch: lp:~tapaal-contributor/tapaal/constants-blink-1853902
Merge into: lp:tapaal
Diff against target: 230 lines (+73/-5)
6 files modified
src/dk/aau/cs/model/tapn/Constant.java (+9/-0)
src/pipe/gui/graphicElements/tapn/TimedInhibitorArcComponent.java (+1/-0)
src/pipe/gui/graphicElements/tapn/TimedInputArcComponent.java (+12/-0)
src/pipe/gui/graphicElements/tapn/TimedPlaceComponent.java (+7/-2)
src/pipe/gui/graphicElements/tapn/TimedTransportArcComponent.java (+12/-1)
src/pipe/gui/widgets/ConstantsPane.java (+32/-2)
To merge this branch: bzr merge lp:~tapaal-contributor/tapaal/constants-blink-1853902
Reviewer Review Type Date Requested Status
Jiri Srba Approve
Peter Haahr Taankvist (community) Needs Resubmitting
Review via email: mp+376477@code.launchpad.net

Commit message

Make constants blink when selected in the side panel

To post a comment you must log in.
Revision history for this message
Jiri Srba (srba) wrote :

There is a problem if you move fast through constants, so that at the end some constants
say highlighted in blue, even though they are not selected. To reproduce, open webserver.tapm
example net, selection periodB constant and then quickly press four time arrow up, so that we move through the other constants. Now there are several blue names, even if they are not "deadline".

Also, the blinking is not very visible as it only changes colour. I would suggest to clear and redraw the text (not only the colour) when it is blinking (like in the simulation mode when we select a transition), so that the change is visually more noticable.

review: Needs Fixing
Revision history for this message
Peter Haahr Taankvist (ptaank) wrote :

Set the text visible/invisible instead of changing the color. Also fixed the bug by having a global timer. When one is selected while one is still blinking, it will stop the blinking, recolor and start blinking the newly selected.

review: Needs Resubmitting
Revision history for this message
Jiri Srba (srba) wrote :

Works very nice.

review: Approve
Revision history for this message
Jiri Srba (srba) wrote :

Actually, there is still a problem with tran-level-crossing example. Open the example and move down the constants.Once you reach to minTimeToLeveler it will not blink, but once you move to maxTimeToLever it does blink.

review: Needs Fixing
1036. By Peter Taankvist <email address hidden>

fixed bug relating to upper/lower bound constants cancelling each other out

Revision history for this message
Peter Haahr Taankvist (ptaank) wrote :

fixed bug relating to upper/lower bound constants cancelling each other out.

When you had a guard with both a constant in the upper and the lower bound, and you clicked the one in the lower bound, it would be set invisible, but when checking the one in the upper bound it would instantly be set visible again.

Seems to work now

review: Needs Resubmitting
Revision history for this message
Jiri Srba (srba) wrote :

Works very nice.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/dk/aau/cs/model/tapn/Constant.java'
2--- src/dk/aau/cs/model/tapn/Constant.java 2016-04-28 13:18:00 +0000
3+++ src/dk/aau/cs/model/tapn/Constant.java 2020-02-03 20:24:41 +0000
4@@ -13,6 +13,7 @@
5 private int upperBound;
6 private boolean isUsed;
7 private boolean isFocused;
8+ private boolean visible = true;
9
10 public Constant(String name, int value) {
11 setName(name);
12@@ -50,6 +51,14 @@
13 public void setFocused(boolean focused){
14 isFocused = focused;
15 }
16+
17+ public void setVisible(boolean visible) {
18+ this.visible = visible;
19+ }
20+
21+ public boolean getVisible() {
22+ return visible;
23+ }
24
25 public String name() {
26 return name;
27
28=== modified file 'src/pipe/gui/graphicElements/tapn/TimedInhibitorArcComponent.java'
29--- src/pipe/gui/graphicElements/tapn/TimedInhibitorArcComponent.java 2019-05-06 12:21:58 +0000
30+++ src/pipe/gui/graphicElements/tapn/TimedInhibitorArcComponent.java 2020-02-03 20:24:41 +0000
31@@ -90,6 +90,7 @@
32 if(((ConstantWeight) getWeight()).constant().hasFocus()){
33 focusedConstant = true;
34 }
35+ pnName.setVisible(((ConstantWeight) getWeight()).constant().getVisible());
36 }
37 if(focusedConstant){
38 pnName.setForeground(Pipe.SELECTION_TEXT_COLOUR);
39
40=== modified file 'src/pipe/gui/graphicElements/tapn/TimedInputArcComponent.java'
41--- src/pipe/gui/graphicElements/tapn/TimedInputArcComponent.java 2019-05-06 12:21:58 +0000
42+++ src/pipe/gui/graphicElements/tapn/TimedInputArcComponent.java 2020-02-03 20:24:41 +0000
43@@ -138,26 +138,38 @@
44
45 // Handle constant highlighting
46 boolean focusedConstant = false;
47+ boolean isvisible = true;
48 if(inputArc.interval().lowerBound() instanceof ConstantBound){
49 if(((ConstantBound) inputArc.interval().lowerBound()).constant().hasFocus()){
50 focusedConstant = true;
51 }
52+
53+ if(!((ConstantBound) inputArc.interval().lowerBound()).constant().getVisible()) {
54+ isvisible = false;
55+ }
56 }
57 if(inputArc.interval().upperBound() instanceof ConstantBound){
58 if(((ConstantBound) inputArc.interval().upperBound()).constant().hasFocus()){
59 focusedConstant = true;
60 }
61+ if(!((ConstantBound) inputArc.interval().upperBound()).constant().getVisible()){
62+ isvisible = false;
63+ }
64 }
65 if(getWeight() instanceof ConstantWeight){
66 if(((ConstantWeight) getWeight()).constant().hasFocus()){
67 focusedConstant = true;
68 }
69+ if(((ConstantWeight) getWeight()).constant().getVisible()){
70+ isvisible = false;
71+ }
72 }
73 if(focusedConstant){
74 pnName.setForeground(Pipe.SELECTION_TEXT_COLOUR);
75 }else{
76 pnName.setForeground(Pipe.ELEMENT_TEXT_COLOUR);
77 }
78+ pnName.setVisible(isvisible);
79
80 }
81 this.setLabelPosition();
82
83=== modified file 'src/pipe/gui/graphicElements/tapn/TimedPlaceComponent.java'
84--- src/pipe/gui/graphicElements/tapn/TimedPlaceComponent.java 2019-03-13 07:17:48 +0000
85+++ src/pipe/gui/graphicElements/tapn/TimedPlaceComponent.java 2020-02-03 20:24:41 +0000
86@@ -34,6 +34,8 @@
87 import dk.aau.cs.gui.Context;
88 import dk.aau.cs.gui.undo.Command;
89 import dk.aau.cs.model.tapn.Bound.InfBound;
90+import dk.aau.cs.model.tapn.Constant;
91+import dk.aau.cs.model.tapn.Bound;
92 import dk.aau.cs.model.tapn.ConstantBound;
93 import dk.aau.cs.model.tapn.TimeInvariant;
94 import dk.aau.cs.model.tapn.TimedArcPetriNet;
95@@ -363,10 +365,13 @@
96
97 // Handle constant highlighting
98 boolean focusedConstant = false;
99- if(place.invariant().upperBound() instanceof ConstantBound){
100- if(((ConstantBound) place.invariant().upperBound()).constant().hasFocus()){
101+ Bound bound = place.invariant().upperBound();
102+ if(bound instanceof ConstantBound){
103+ Constant constant = ((ConstantBound) bound).constant();
104+ if(constant.hasFocus()){
105 focusedConstant = true;
106 }
107+ pnName.setVisible(constant.getVisible());
108 }
109 if(focusedConstant){
110 pnName.setForeground(Pipe.SELECTION_TEXT_COLOUR);
111
112=== modified file 'src/pipe/gui/graphicElements/tapn/TimedTransportArcComponent.java'
113--- src/pipe/gui/graphicElements/tapn/TimedTransportArcComponent.java 2019-05-06 12:21:58 +0000
114+++ src/pipe/gui/graphicElements/tapn/TimedTransportArcComponent.java 2020-02-03 20:24:41 +0000
115@@ -117,26 +117,37 @@
116
117 // Handle constant highlighting
118 boolean focusedConstant = false;
119+ boolean isvisible = true;
120 if(underlyingTransportArc.interval().lowerBound() instanceof ConstantBound){
121 if(((ConstantBound) underlyingTransportArc.interval().lowerBound()).constant().hasFocus()){
122 focusedConstant = true;
123 }
124+ if(!((ConstantBound) underlyingTransportArc.interval().lowerBound()).constant().getVisible()){
125+ focusedConstant = false;
126+ }
127 }
128 if(underlyingTransportArc.interval().upperBound() instanceof ConstantBound){
129- if(((ConstantBound) underlyingTransportArc.interval().upperBound()).constant().hasFocus()){
130+ if(((ConstantBound) underlyingTransportArc.interval().upperBound()).constant().getVisible()){
131 focusedConstant = true;
132 }
133+ if(!((ConstantBound) underlyingTransportArc.interval().upperBound()).constant().getVisible()){
134+ isvisible = false;
135+ }
136 }
137 if(getWeight() instanceof ConstantWeight){
138 if(((ConstantWeight) getWeight()).constant().hasFocus()){
139 focusedConstant = true;
140 }
141+ if(!((ConstantWeight) getWeight()).constant().hasFocus()){
142+ isvisible = false;
143+ }
144 }
145 if(focusedConstant){
146 pnName.setForeground(Pipe.SELECTION_TEXT_COLOUR);
147 }else{
148 pnName.setForeground(Pipe.ELEMENT_TEXT_COLOUR);
149 }
150+ pnName.setVisible(isvisible);
151
152 } else if (!isInPreSet) {
153 pnName.setText(" : " + String.valueOf(getGroup()));
154
155=== modified file 'src/pipe/gui/widgets/ConstantsPane.java'
156--- src/pipe/gui/widgets/ConstantsPane.java 2019-01-24 20:01:38 +0000
157+++ src/pipe/gui/widgets/ConstantsPane.java 2020-02-03 20:24:41 +0000
158@@ -30,6 +30,7 @@
159 import javax.swing.JScrollPane;
160 import javax.swing.ListModel;
161 import javax.swing.ListSelectionModel;
162+import javax.swing.Timer;
163 import javax.swing.event.ListDataEvent;
164 import javax.swing.event.ListDataListener;
165 import javax.swing.event.ListSelectionEvent;
166@@ -67,6 +68,7 @@
167 private final static String toolTipMoveUp = "Move the selected constant up";
168 private final static String toolTipMoveDown = "Move the selected constant down";
169 //private static final String toolTipGlobalConstantsLabel = "Here you can define a global constant for reuse in different places.";
170+ Timer timer;
171
172
173 public ConstantsPane(boolean enableAddButton, TabContent currentTab) {
174@@ -236,13 +238,19 @@
175 private void highlightConstant(int index){
176 ListModel model = constantsList.getModel();
177 Constant c = (Constant) model.getElementAt(index);
178-
179+ if(timer != null) {
180+ timer.stop();
181+ }
182 if(c != null && !c.hasFocus()){
183 for(int i = 0; i < model.getSize(); i++){
184 ((Constant) model.getElementAt(i)).setFocused(false);
185 }
186+ for(int i = 0; i < model.getSize(); i++){
187+ ((Constant) model.getElementAt(i)).setVisible(true);
188+ }
189 c.setFocused(true);
190 CreateGui.getCurrentTab().drawingSurface().repaintAll();
191+ blinkConstant(c);
192 }
193 }
194
195@@ -257,6 +265,29 @@
196 // It is okay, the tab has just been closed
197 }
198 }
199+
200+ private void blinkConstant(final Constant c) {
201+ timer = new Timer(300, new ActionListener() {
202+ long startTime = System.currentTimeMillis();
203+ @Override
204+ public void actionPerformed(ActionEvent e) {
205+ if(System.currentTimeMillis() - startTime < 2100) {
206+ if(!c.getVisible()) {
207+ c.setVisible(true);
208+ CreateGui.getCurrentTab().drawingSurface().repaintAll();
209+ } else {
210+ c.setVisible(false);
211+ CreateGui.getCurrentTab().drawingSurface().repaintAll();
212+ }
213+ } else {
214+ ((Timer) e.getSource()).stop();
215+ }
216+ }
217+ });
218+ timer.setRepeats(true);
219+ timer.setCoalesce(true);
220+ timer.restart();
221+ }
222
223 private void addConstantsButtons(boolean enableAddButton) {
224 editBtn = new JButton("Edit");
225@@ -449,5 +480,4 @@
226 constantsList.setSelectedIndex(0);
227
228 }
229-
230 }

Subscribers

People subscribed via source and target branches