Changeset 194 for trunk/EventBenchConsole/src
- Timestamp:
- 09/24/11 04:17:48 (13 years ago)
- Location:
- trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/swt
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/swt/GenerateSequencesDialog.java
r188 r194 3 3 import org.eclipse.swt.widgets.Dialog; 4 4 import org.eclipse.swt.widgets.Display; 5 import org.eclipse.swt.widgets.MessageBox; 5 6 import org.eclipse.swt.widgets.Shell; 6 7 import org.eclipse.swt.widgets.Group; … … 14 15 import org.eclipse.swt.layout.GridData; 15 16 17 import de.ugoe.cs.util.console.CommandExecuter; 18 19 import org.eclipse.swt.events.SelectionAdapter; 20 import org.eclipse.swt.events.SelectionEvent; 21 16 22 public class GenerateSequencesDialog extends Dialog { 17 23 24 private String processName; 25 26 protected Button btnNumberAll; 27 protected Button btnLengthAll; 28 protected Spinner numberSpinner; 29 protected Spinner iterationsSpinner; 30 protected Spinner minLengthSpinner; 31 protected Spinner maxLengthSpinner; 32 18 33 protected Object result; 19 34 protected Shell shlGenerateSequences; 20 private Text text;35 private Text sequencesNameText; 21 36 private final FormToolkit formToolkit = new FormToolkit(Display.getDefault()); 22 37 … … 53 68 private void createContents() { 54 69 shlGenerateSequences = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); 55 shlGenerateSequences.setSize(201, 248);70 shlGenerateSequences.setSize(201, 303); 56 71 shlGenerateSequences.setText("Generate Sequences"); 57 72 shlGenerateSequences.setLayout(new GridLayout(2, false)); … … 62 77 group.setLayout(new GridLayout(1, false)); 63 78 64 text = new Text(group, SWT.BORDER);65 text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));79 sequencesNameText = new Text(group, SWT.BORDER); 80 sequencesNameText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); 66 81 67 82 Group grpNumber = new Group(shlGenerateSequences, SWT.NONE); … … 70 85 grpNumber.setLayout(new GridLayout(2, false)); 71 86 72 Spinner spinner = new Spinner(grpNumber, SWT.BORDER); 73 spinner.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); 74 75 Button btnAll = new Button(grpNumber, SWT.CHECK); 76 btnAll.setText("All"); 87 numberSpinner = new Spinner(grpNumber, SWT.BORDER); 88 numberSpinner.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); 89 numberSpinner.setMinimum(1); 90 numberSpinner.setMaximum(Integer.MAX_VALUE); 91 92 btnNumberAll = new Button(grpNumber, SWT.CHECK); 93 btnNumberAll.addSelectionListener(new SelectionAdapter() { 94 @Override 95 public void widgetSelected(SelectionEvent e) { 96 numberSpinner.setEnabled(!btnNumberAll.getSelection()); 97 btnLengthAll.setEnabled(!btnNumberAll.getSelection()); 98 iterationsSpinner.setEnabled(!btnNumberAll.getSelection()); 99 } 100 }); 101 btnNumberAll.setText("All"); 102 103 Group grpIterations = new Group(shlGenerateSequences, SWT.NONE); 104 grpIterations.setLayout(new GridLayout(1, false)); 105 grpIterations.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1)); 106 grpIterations.setText("Iterations");; 107 108 iterationsSpinner = new Spinner(grpIterations, SWT.BORDER); 109 iterationsSpinner.setMinimum(1); 110 iterationsSpinner.setMaximum(Integer.MAX_VALUE); 111 iterationsSpinner.setSelection(100000); 112 iterationsSpinner.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); 77 113 78 114 Group grpLength = new Group(shlGenerateSequences, SWT.NONE); … … 81 117 grpLength.setLayout(new GridLayout(4, false)); 82 118 83 Button btnAll_1 = new Button(grpLength, SWT.CHECK); 84 btnAll_1.setText("All"); 119 btnLengthAll = new Button(grpLength, SWT.CHECK); 120 btnLengthAll.addSelectionListener(new SelectionAdapter() { 121 @Override 122 public void widgetSelected(SelectionEvent e) { 123 minLengthSpinner.setEnabled(!btnLengthAll.getSelection()); 124 maxLengthSpinner.setEnabled(!btnLengthAll.getSelection()); 125 } 126 }); 127 btnLengthAll.setText("All"); 85 128 new Label(grpLength, SWT.NONE); 86 129 new Label(grpLength, SWT.NONE); … … 91 134 label.setText("Min."); 92 135 93 Spinner spinner_2 = new Spinner(grpLength, SWT.BORDER); 94 spinner_2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); 136 minLengthSpinner = new Spinner(grpLength, SWT.BORDER); 137 minLengthSpinner.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); 138 minLengthSpinner.setMinimum(1); 95 139 96 140 Label label_1 = new Label(grpLength, SWT.NONE); … … 98 142 label_1.setText("Max."); 99 143 100 Spinner spinner_1 = new Spinner(grpLength, SWT.BORDER); 101 spinner_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); 102 spinner_1.setToolTipText("0 means no limitations"); 144 maxLengthSpinner = new Spinner(grpLength, SWT.BORDER); 145 maxLengthSpinner.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); 146 maxLengthSpinner.setToolTipText("0 means no limitations"); 147 maxLengthSpinner.setMinimum(1); 103 148 104 149 Button btnGenerate = formToolkit.createButton(shlGenerateSequences, "Generate!", SWT.NONE); 150 btnGenerate.addSelectionListener(new SelectionAdapter() { 151 @Override 152 public void widgetSelected(SelectionEvent e) { 153 if("".equals(sequencesNameText.getText())) { 154 MessageBox messageBox = new MessageBox(shlGenerateSequences, SWT.ERROR); 155 messageBox.setText("Error"); 156 messageBox.setMessage("Sequences name not defined!"); 157 messageBox.open(); 158 return; 159 } 160 String sequencesName = sequencesNameText.getText(); 161 int number = numberSpinner.getSelection(); 162 int minLength = minLengthSpinner.getSelection(); 163 int maxLength = maxLengthSpinner.getSelection(); 164 int maxIter = iterationsSpinner.getSelection(); 165 if( maxIter<=number ) { 166 maxIter = number; 167 } 168 String command = ""; 169 if( btnNumberAll.getSelection() ) { 170 if( minLength>maxLength ) { 171 MessageBox messageBox = new MessageBox(shlGenerateSequences, SWT.ERROR); 172 messageBox.setText("Error"); 173 messageBox.setMessage("Min. length must be smaller than or equal to max. length!"); 174 messageBox.open(); 175 return; 176 } 177 command = "generateFixedLengthSequences " + processName + " " + sequencesName + " " + minLength + " " + maxLength + " true"; 178 } else { 179 command = "generateRandomSequences " + processName + " " + sequencesName + " " + number + " " + maxIter; 180 if( !btnLengthAll.getSelection() ) { 181 if( minLength>maxLength ) { 182 MessageBox messageBox = new MessageBox(shlGenerateSequences, SWT.ERROR); 183 messageBox.setText("Error"); 184 messageBox.setMessage("Min. length must be smaller than or equal to max. length!"); 185 messageBox.open(); 186 return; 187 } 188 command += " " + minLength + " " + maxLength; 189 } 190 } 191 CommandExecuter.getInstance().exec(command); 192 shlGenerateSequences.dispose(); 193 } 194 }); 105 195 106 196 Button btnAbort = formToolkit.createButton(shlGenerateSequences, "Abort", SWT.NONE); 107 197 btnAbort.addSelectionListener(new SelectionAdapter() { 198 @Override 199 public void widgetSelected(SelectionEvent e) { 200 shlGenerateSequences.dispose(); 201 } 202 }); 203 204 } 205 206 public void setProcessName(String name) { 207 this.processName = name; 108 208 } 109 209 } -
trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/swt/ModelPropertiesDialog.java
r192 r194 3 3 import org.eclipse.swt.widgets.Dialog; 4 4 import org.eclipse.swt.widgets.Display; 5 import org.eclipse.swt.widgets.MessageBox; 5 6 import org.eclipse.swt.widgets.Shell; 6 7 import org.eclipse.swt.widgets.List; … … 13 14 import org.eclipse.swt.layout.FillLayout; 14 15 16 import de.ugoe.cs.eventbench.models.FirstOrderMarkovModel; 17 import de.ugoe.cs.eventbench.models.IStochasticProcess; 18 import org.eclipse.swt.events.SelectionAdapter; 19 import org.eclipse.swt.events.SelectionEvent; 20 15 21 public class ModelPropertiesDialog extends Dialog { 16 22 23 private IStochasticProcess process; 24 17 25 protected Object result; 18 26 protected Shell shlModelProperties; … … 63 71 64 72 List list = new List(grpEvents, SWT.BORDER | SWT.V_SCROLL); 73 for( String symbol : process.getSymbolStrings() ) { 74 list.add(symbol); 75 } 65 76 66 77 Group grpStatistics = new Group(shlModelProperties, SWT.NONE); … … 75 86 Label label = new Label(grpStatistics, SWT.RIGHT); 76 87 label.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1)); 77 label.setText(" ####");88 label.setText(""+process.getNumSymbols()); 78 89 79 90 Label lblNumTrieLeafs = new Label(grpStatistics, SWT.NONE); 80 91 lblNumTrieLeafs.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1)); 81 lblNumTrieLeafs.setText("Size ( #Trie Leafs)");92 lblNumTrieLeafs.setText("Size (Flattend FOM)"); 82 93 83 94 Label label_1 = new Label(grpStatistics, SWT.RIGHT); 84 95 label_1.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1)); 85 label_1.setText(" ####");96 label_1.setText(""+process.getNumFOMStates()); 86 97 87 98 Label lblEntropy = new Label(grpStatistics, SWT.NONE); … … 89 100 lblEntropy.setText("Entropy"); 90 101 91 Label label_2 = new Label(grpStatistics, SWT.RIGHT);92 label_2.setLayoutData(new GridData(SWT. RIGHT, SWT.TOP, false, false, 1, 1));102 final Label label_2 = new Label(grpStatistics, SWT.RIGHT); 103 label_2.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1)); 93 104 label_2.setText("####"); 94 105 95 106 Button btnCalculateEntropy = new Button(shlModelProperties, SWT.NONE); 107 btnCalculateEntropy.addSelectionListener(new SelectionAdapter() { 108 @Override 109 public void widgetSelected(SelectionEvent e) { 110 if( process instanceof FirstOrderMarkovModel) { 111 label_2.setText(""+((FirstOrderMarkovModel) process).calcEntropy()); 112 } else { 113 MessageBox messageBox = new MessageBox(shlModelProperties, SWT.NONE); 114 messageBox.setText("Feature Not Available"); 115 messageBox.setMessage("The feature is currently only available for first-order Markov models."); 116 messageBox.open(); 117 } 118 } 119 }); 96 120 btnCalculateEntropy.setText("Calculate Entropy"); 97 121 … … 100 124 101 125 } 126 127 public void setStochasticProcess(IStochasticProcess process) { 128 this.process = process; 129 } 102 130 } -
trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/swt/ModelsTabComposite.java
r192 r194 5 5 import org.eclipse.swt.widgets.Button; 6 6 import org.eclipse.swt.widgets.List; 7 import org.eclipse.swt.widgets.MessageBox; 7 8 import org.eclipse.swt.layout.GridLayout; 8 9 import org.eclipse.swt.layout.GridData; 9 10 10 11 import de.ugoe.cs.eventbench.data.GlobalDataContainer; 12 import de.ugoe.cs.eventbench.models.FirstOrderMarkovModel; 13 import de.ugoe.cs.eventbench.models.IDotCompatible; 14 import de.ugoe.cs.eventbench.models.IStochasticProcess; 15 import de.ugoe.cs.util.console.CommandExecuter; 16 11 17 import org.eclipse.swt.events.SelectionAdapter; 12 18 import org.eclipse.swt.events.SelectionEvent; … … 29 35 setLayout(new GridLayout(5, false)); 30 36 31 modelList = new List(this, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI);37 modelList = new List(this, SWT.BORDER | SWT.V_SCROLL); 32 38 modelList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 5, 1)); 33 39 34 40 Button btnShow = new Button(this, SWT.NONE); 41 btnShow.addSelectionListener(new SelectionAdapter() { 42 @Override 43 public void widgetSelected(SelectionEvent e) { 44 String[] selectedStrings = modelList.getSelection(); 45 if( selectedStrings.length==0 ) { 46 SWTHelpers.noSelectionError(getShell()); 47 return; 48 } 49 IStochasticProcess process = (IStochasticProcess) GlobalDataContainer.getInstance().getData(selectedStrings[0]); 50 if( process instanceof FirstOrderMarkovModel ) { 51 String command = "showMarkovModel " + selectedStrings[0]; 52 CommandExecuter.getInstance().exec(command); 53 } else { 54 MessageBox messageBox = new MessageBox(getShell(), SWT.NONE); 55 messageBox.setText("Feature Not Available"); 56 messageBox.setMessage("The feature is currently only available for first-order Markov models."); 57 messageBox.open(); 58 } 59 } 60 }); 35 61 btnShow.setText("Visualize"); 36 62 … … 49 75 50 76 Button btnGenSequences = new Button(this, SWT.NONE); 77 btnGenSequences.addSelectionListener(new SelectionAdapter() { 78 @Override 79 public void widgetSelected(SelectionEvent e) { 80 String[] selectedStrings = modelList.getSelection(); 81 if( selectedStrings.length==0 ) { 82 SWTHelpers.noSelectionError(getShell()); 83 return; 84 } 85 GenerateSequencesDialog generateSequencesDialog = new GenerateSequencesDialog(getShell(), SWT.NONE); 86 generateSequencesDialog.setProcessName(selectedStrings[0]); 87 generateSequencesDialog.open(); 88 } 89 }); 51 90 btnGenSequences.setText("Gen. Sequences"); 52 91 53 92 Button btnProperties = new Button(this, SWT.NONE); 93 btnProperties.addSelectionListener(new SelectionAdapter() { 94 @Override 95 public void widgetSelected(SelectionEvent e) { 96 String[] selectedStrings = modelList.getSelection(); 97 if( selectedStrings.length==0 ) { 98 SWTHelpers.noSelectionError(getShell()); 99 return; 100 } 101 IStochasticProcess process = (IStochasticProcess) GlobalDataContainer.getInstance().getData(selectedStrings[0]); 102 ModelPropertiesDialog modelPropertiesDialog = new ModelPropertiesDialog(getShell(), SWT.NONE); 103 modelPropertiesDialog.setStochasticProcess(process); 104 modelPropertiesDialog.open(); 105 } 106 }); 54 107 btnProperties.setText("Properties"); 55 108 56 109 Button btnCreateDot = new Button(this, SWT.NONE); 110 btnCreateDot.addSelectionListener(new SelectionAdapter() { 111 @Override 112 public void widgetSelected(SelectionEvent e) { 113 String[] selectedStrings = modelList.getSelection(); 114 if( selectedStrings.length==0 ) { 115 SWTHelpers.noSelectionError(getShell()); 116 return; 117 } 118 IStochasticProcess process = (IStochasticProcess) GlobalDataContainer.getInstance().getData(selectedStrings[0]); 119 String command = ""; 120 if( process instanceof IDotCompatible ) { 121 command = "printDot "; 122 } else { 123 command = "printTrieDot "; 124 } 125 command += selectedStrings[0]; 126 CommandExecuter.getInstance().exec(command); 127 } 128 }); 57 129 btnCreateDot.setText("Create DOT"); 58 130 } -
trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/swt/TrainModelDialog.java
r192 r194 17 17 18 18 import de.ugoe.cs.util.console.CommandExecuter; 19 import de.ugoe.cs.util.console.Console;20 19 21 20 public class TrainModelDialog extends Dialog { … … 172 171 messageBox.setText("Error"); 173 172 messageBox.setMessage("No modelname defined!"); 173 messageBox.open(); 174 174 return; 175 175 } … … 189 189 messageBox.setText("Error"); 190 190 messageBox.setMessage("Min. Order must be smaller than or equal to max. order!"); 191 messageBox.open(); 191 192 return; 192 193 } … … 196 197 messageBox.setText("Error"); 197 198 messageBox.setMessage("Escape probability must be in [0,1]!"); 199 messageBox.open(); 198 200 return; 199 201 }
Note: See TracChangeset
for help on using the changeset viewer.