11package projections .Tools .CommunicationOverTime ;
22
3- import java .awt .Checkbox ;
4- import java .awt .CheckboxGroup ;
53import java .awt .Component ;
64import java .awt .Cursor ;
75import java .awt .GridBagConstraints ;
86import java .awt .GridBagLayout ;
97import java .awt .Paint ;
108import java .awt .event .ActionEvent ;
119import java .awt .event .ActionListener ;
12- import java .awt .event .ItemEvent ;
13- import java .awt .event .ItemListener ;
1410import java .text .DecimalFormat ;
11+ import java .util .Enumeration ;
1512import java .util .LinkedList ;
1613import java .util .SortedSet ;
1714import java .util .TreeSet ;
1815
19- import javax .swing .JButton ;
20- import javax .swing .JLabel ;
21- import javax .swing .JMenuItem ;
22- import javax .swing .JPanel ;
23- import javax .swing .SwingWorker ;
16+ import javax .swing .*;
2417
2518import projections .analysis .TimedProgressThreadExecutor ;
2619import projections .gui .GenericGraphColorer ;
3326
3427
3528public class CommTimeWindow extends GenericGraphWindow
36- implements ItemListener , ActionListener
29+ implements ActionListener
3730{
3831
3932 // Temporary hardcode. This variable will be assigned appropriate
@@ -51,25 +44,25 @@ public class CommTimeWindow extends GenericGraphWindow
5144 private IntervalChooserPanel intervalPanel ;
5245
5346 private JPanel graphPanel ;
54- private JPanel checkBoxPanel ;
47+ private JPanel viewSelectPanel ;
5548 private JPanel controlPanel ;
5649
5750 private JButton setRanges ;
5851 private JLabel totalCount ;
5952 // private JButton epSelection;
6053
61- private CheckboxGroup cbg ;
62- private Checkbox sentMsgs ;
63- private Checkbox sentBytes ;
64- private Checkbox receivedMsgs ;
65- private Checkbox receivedBytes ;
66- //private Checkbox sentExternalMsgs;
67- //private Checkbox sentExternalBytes;
68- private Checkbox receivedExternalMsgs ;
69- private Checkbox receivedExternalBytes ;
54+ private ButtonGroup btg ;
55+ private JRadioButton sentMsgs ;
56+ private JRadioButton sentBytes ;
57+ private JRadioButton receivedMsgs ;
58+ private JRadioButton receivedBytes ;
59+ //private JRadioButton sentExternalMsgs;
60+ //private JRadioButton sentExternalBytes;
61+ private JRadioButton receivedExternalMsgs ;
62+ private JRadioButton receivedExternalBytes ;
7063
71- private Checkbox receivedExternalNodeMsgs ;
72- private Checkbox receivedExternalNodeBytes ;
64+ private JRadioButton receivedExternalNodeMsgs ;
65+ private JRadioButton receivedExternalNodeBytes ;
7366
7467 private int startInterval ;
7568 private int endInterval ;
@@ -180,33 +173,50 @@ private void createLayout() {
180173 gbc .fill = GridBagConstraints .BOTH ;
181174 mainPanel .setLayout (gbl );
182175
183- // checkbox panel items
184- cbg = new CheckboxGroup ();
185- sentMsgs = new Checkbox ("Msgs Sent" , cbg , true );
186- sentMsgs .addItemListener (this );
187- sentBytes = new Checkbox ("Bytes Sent" , cbg , false );
188- sentBytes .addItemListener (this );
189- receivedMsgs = new Checkbox ("Msgs Recv" , cbg , false );
190- receivedMsgs .addItemListener (this );
191- receivedBytes = new Checkbox ("Bytes Recv" , cbg , false );
192- receivedBytes .addItemListener (this );
193- receivedExternalMsgs = new Checkbox ("External Msgs Recv" , cbg , false );
194- receivedExternalMsgs .addItemListener (this );
195- receivedExternalBytes = new Checkbox ("External Bytes Recv" , cbg , false );
196- receivedExternalBytes .addItemListener (this );
197- receivedExternalNodeMsgs = new Checkbox ("External Node Msgs Recv" , cbg , false );
198- receivedExternalNodeMsgs .addItemListener (this );
199- receivedExternalNodeBytes = new Checkbox ("External Node Bytes Recv" , cbg , false );
200- receivedExternalNodeBytes .addItemListener (this );
201- checkBoxPanel = new JPanel ();
202- Util .gblAdd (checkBoxPanel , sentMsgs , gbc , 0 ,0 , 1 ,1 , 1 ,1 );
203- Util .gblAdd (checkBoxPanel , sentBytes , gbc , 1 ,0 , 1 ,1 , 1 ,1 );
204- Util .gblAdd (checkBoxPanel , receivedMsgs , gbc , 2 ,0 , 1 ,1 , 1 ,1 );
205- Util .gblAdd (checkBoxPanel , receivedBytes , gbc , 3 ,0 , 1 ,1 , 1 ,1 );
206- Util .gblAdd (checkBoxPanel , receivedExternalMsgs , gbc , 4 ,0 , 1 ,1 , 1 ,1 );
207- Util .gblAdd (checkBoxPanel , receivedExternalBytes , gbc , 5 ,0 , 1 ,1 , 1 ,1 );
208- Util .gblAdd (checkBoxPanel , receivedExternalNodeMsgs , gbc , 6 ,0 , 1 ,1 , 1 ,1 );
209- Util .gblAdd (checkBoxPanel , receivedExternalNodeBytes , gbc , 7 ,0 , 1 ,1 , 1 ,1 );
176+ sentMsgs = new JRadioButton ("Msgs Sent" , true );
177+ sentMsgs .addActionListener (this );
178+ sentMsgs .setToolTipText ("Number of messages sent anywhere, including to same PE" );
179+ sentBytes = new JRadioButton ("Bytes Sent" );
180+ sentBytes .addActionListener (this );
181+ sentBytes .setToolTipText ("Number of bytes sent anywhere, including to same PE" );
182+ receivedMsgs = new JRadioButton ("Msgs Recv" );
183+ receivedMsgs .addActionListener (this );
184+ receivedMsgs .setToolTipText ("Number of messages received from anywhere, including from same PE" );
185+ receivedBytes = new JRadioButton ("Bytes Recv" );
186+ receivedBytes .addActionListener (this );
187+ receivedBytes .setToolTipText ("Number of bytes received from anywhere, including from same PE" );
188+ receivedExternalMsgs = new JRadioButton ("External Msgs Recv" );
189+ receivedExternalMsgs .addActionListener (this );
190+ receivedExternalMsgs .setToolTipText ("Number of messages received from a different PE" );
191+ receivedExternalBytes = new JRadioButton ("External Bytes Recv" );
192+ receivedExternalBytes .addActionListener (this );
193+ receivedExternalBytes .setToolTipText ("Number of bytes received from a different PE" );
194+ receivedExternalNodeMsgs = new JRadioButton ("External Node Msgs Recv" );
195+ receivedExternalNodeMsgs .addActionListener (this );
196+ receivedExternalNodeMsgs .setToolTipText ("Number of messages received from a different process" );
197+ receivedExternalNodeBytes = new JRadioButton ("External Node Bytes Recv" );
198+ receivedExternalNodeBytes .addActionListener (this );
199+ receivedExternalNodeBytes .setToolTipText ("Number of bytes received from a different process" );
200+
201+ btg = new ButtonGroup ();
202+ btg .add (sentMsgs );
203+ btg .add (sentBytes );
204+ btg .add (receivedMsgs );
205+ btg .add (receivedBytes );
206+ btg .add (receivedExternalMsgs );
207+ btg .add (receivedExternalBytes );
208+ btg .add (receivedExternalNodeMsgs );
209+ btg .add (receivedExternalNodeBytes );
210+
211+ viewSelectPanel = new JPanel ();
212+ Util .gblAdd (viewSelectPanel , sentMsgs , gbc , 0 ,0 , 1 ,1 , 1 ,1 );
213+ Util .gblAdd (viewSelectPanel , sentBytes , gbc , 1 ,0 , 1 ,1 , 1 ,1 );
214+ Util .gblAdd (viewSelectPanel , receivedMsgs , gbc , 2 ,0 , 1 ,1 , 1 ,1 );
215+ Util .gblAdd (viewSelectPanel , receivedBytes , gbc , 3 ,0 , 1 ,1 , 1 ,1 );
216+ Util .gblAdd (viewSelectPanel , receivedExternalMsgs , gbc , 4 ,0 , 1 ,1 , 1 ,1 );
217+ Util .gblAdd (viewSelectPanel , receivedExternalBytes , gbc , 5 ,0 , 1 ,1 , 1 ,1 );
218+ Util .gblAdd (viewSelectPanel , receivedExternalNodeMsgs , gbc , 6 ,0 , 1 ,1 , 1 ,1 );
219+ Util .gblAdd (viewSelectPanel , receivedExternalNodeBytes , gbc , 7 ,0 , 1 ,1 , 1 ,1 );
210220
211221 // control panel items
212222 setRanges = new JButton ("Select New Range" );
@@ -223,19 +233,10 @@ private void createLayout() {
223233
224234 graphPanel = getMainPanel ();
225235 Util .gblAdd (mainPanel , graphPanel , gbc , 0 ,1 , 1 ,1 , 1 ,1 );
226- Util .gblAdd (mainPanel , checkBoxPanel , gbc , 0 ,2 , 1 ,1 , 0 ,0 );
236+ Util .gblAdd (mainPanel , viewSelectPanel , gbc , 0 ,2 , 1 ,1 , 0 ,0 );
227237 Util .gblAdd (mainPanel , controlPanel , gbc , 0 ,3 , 1 ,0 , 0 ,0 );
228238 }
229239
230- public void itemStateChanged (ItemEvent ae ){
231- if (ae .getSource () instanceof Checkbox ){
232- setCursor (new Cursor (Cursor .WAIT_CURSOR ));
233- Checkbox cb = (Checkbox )ae .getSource ();
234- setCheckboxData (cb );
235- setCursor (new Cursor (Cursor .DEFAULT_CURSOR ));
236- }
237- }
238-
239240 public long accumulateArray (double arr [][]) {
240241 double total = 0 ;
241242 for (int i = 0 ; i < arr .length ; i ++) {
@@ -248,7 +249,7 @@ public long accumulateArray(double arr[][]) {
248249 return Math .round (total * intervalSize / 1000 );
249250 }
250251
251- public void setCheckboxData ( Checkbox cb ) {
252+ public void changeView ( JRadioButton cb ) {
252253 if (cb == sentMsgs ) {
253254 setDataSource ("Messages Sent Over Time" , sentMsgOutput ,
254255 commTimeColors , this );
@@ -357,8 +358,14 @@ public Object doInBackground() {
357358 }
358359 public void done () {
359360 setOutputGraphData ();
360- Checkbox cb = cbg .getSelectedCheckbox ();
361- setCheckboxData (cb );
361+ for (Enumeration <AbstractButton > buttons = btg .getElements (); buttons .hasMoreElements (); ) {
362+ AbstractButton button = buttons .nextElement ();
363+
364+ if (button .isSelected ()) {
365+ changeView ((JRadioButton ) button );
366+ }
367+ }
368+
362369 thisWindow .setVisible (true );
363370 thisWindow .repaint ();
364371 }
@@ -579,20 +586,6 @@ else if(currentArrayName.equals("receivedExternalNodeByteCount")) {
579586 public void actionPerformed (ActionEvent e ) {
580587 if (e .getSource () instanceof JButton ) {
581588 JButton b = (JButton )e .getSource ();
582- // if (b == epSelection) {
583- // if (entryDialog == null) {
584- // entryDialog =
585- // new EntrySelectionDialog(this,
586- // typeLabelNames,
587- // stateArray,colorArray,
588- // existsArray,entryNames);
589- // }
590- // entryDialog.showDialog();
591- // setOutputGraphData();
592- // Checkbox cb = cbg.getSelectedCheckbox();
593- // setCheckboxData(cb);
594- // }
595-
596589 if (b == setRanges ) {
597590 showDialog ();
598591 }
@@ -605,6 +598,11 @@ public void actionPerformed(ActionEvent e) {
605598 showDialog ();
606599 }
607600 }
601+ else if (e .getSource () instanceof JRadioButton ) {
602+ setCursor (new Cursor (Cursor .WAIT_CURSOR ));
603+ changeView ((JRadioButton )e .getSource ());
604+ setCursor (new Cursor (Cursor .DEFAULT_CURSOR ));
605+ }
608606 }
609607
610608 public void repaint () {
0 commit comments