-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuttons-controller.java
More file actions
569 lines (439 loc) · 20.2 KB
/
buttons-controller.java
File metadata and controls
569 lines (439 loc) · 20.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
import java.awt.BorderLayout;
import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeSelectionModel;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import javax.swing.JTextArea;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;
import smile.demo.classification.FLDDemo;
import smile.demo.classification.LDADemo;
import smile.demo.classification.LogisticRegressionDemo;
import smile.demo.classification.NeuralNetworkDemo;
import smile.demo.classification.QDADemo;
import smile.demo.classification.RBFNetworkDemo;
import smile.demo.classification.RDADemo;
import smile.demo.classification.SVMDemo;
import smile.demo.clustering.CLARANSDemo;
import smile.demo.clustering.DBSCANDemo;
import smile.demo.clustering.DENCLUEDemo;
import smile.demo.clustering.DeterministicAnnealingDemo;
import smile.demo.clustering.GMeansDemo;
import smile.demo.clustering.HierarchicalClusteringDemo;
import smile.demo.clustering.KMeansDemo;
import smile.demo.clustering.MECDemo;
import smile.demo.clustering.NeuralGasDemo;
import smile.demo.clustering.SIBDemo;
import smile.demo.clustering.SOMDemo;
import smile.demo.clustering.SpectralClusteringDemo;
import smile.demo.clustering.XMeansDemo;
import smile.demo.manifold.TSNEDemo;
import smile.demo.plot.BarPlotDemo;
import smile.demo.plot.BoxPlotDemo;
import smile.demo.plot.ContourDemo;
import smile.demo.plot.GridDemo;
import smile.demo.plot.HeatmapDemo;
import smile.demo.plot.HexmapDemo;
import smile.demo.plot.HistogramDemo;
import smile.demo.plot.LinePlotDemo;
import smile.demo.plot.QQPlotDemo;
import smile.demo.plot.ScatterPlotDemo;
import smile.demo.plot.StaircasePlotDemo;
import smile.demo.plot.SurfaceDemo;
import smile.demo.plot.SparseMatrixPlotDemo;
import smile.demo.interpolation.Interpolation1Demo;
import smile.demo.interpolation.Interpolation2Demo;
import smile.demo.interpolation.LaplaceInterpolationDemo;
import smile.demo.interpolation.ScatterDataInterpolationDemo;
import smile.demo.manifold.IsoMapDemo;
import smile.demo.manifold.LLEDemo;
import smile.demo.manifold.LaplacianEigenmapDemo;
import smile.demo.mds.IsotonicMDSDemo;
import smile.demo.vq.BIRCHDemo;
import smile.demo.vq.GrowingNeuralGasDemo;
import smile.demo.vq.NeuralMapDemo;
import smile.demo.mds.MDSDemo;
import smile.demo.mds.SammonMappingDemo;
import smile.demo.neighbor.ApproximateStringSearchDemo;
import smile.demo.neighbor.KNNDemo;
import smile.demo.neighbor.NearestNeighborDemo;
import smile.demo.neighbor.RNNSearchDemo;
import smile.demo.plot.Histogram3Demo;
import smile.demo.projection.GHADemo;
import smile.demo.projection.KPCADemo;
import smile.demo.projection.PCADemo;
import smile.demo.projection.PPCADemo;
import smile.demo.projection.RandomProjectionDemo;
import smile.demo.stat.distribution.BernoulliDistributionDemo;
import smile.demo.stat.distribution.BetaDistributionDemo;
import smile.demo.stat.distribution.BinomialDistributionDemo;
import smile.demo.stat.distribution.ChiSquareDistributionDemo;
import smile.demo.stat.distribution.EmpiricalDistributionDemo;
import smile.demo.stat.distribution.ExponentialDistributionDemo;
import smile.demo.stat.distribution.ExponentialFamilyMixtureDemo;
import smile.demo.stat.distribution.FDistributionDemo;
import smile.demo.stat.distribution.GammaDistributionDemo;
import smile.demo.stat.distribution.GaussianDistributionDemo;
import smile.demo.stat.distribution.GaussianMixtureDemo;
import smile.demo.stat.distribution.GeometricDistributionDemo;
import smile.demo.stat.distribution.HyperGeometricDistributionDemo;
import smile.demo.stat.distribution.LogNormalDistributionDemo;
import smile.demo.stat.distribution.LogisticDistributionDemo;
import smile.demo.stat.distribution.MultivariateGaussianDistributionDemo;
import smile.demo.stat.distribution.MultivariateGaussianMixtureDemo;
import smile.demo.stat.distribution.NegativeBinomialDistributionDemo;
import smile.demo.stat.distribution.PoissonDistributionDemo;
import smile.demo.stat.distribution.ShiftedGeometricDistributionDemo;
import smile.demo.stat.distribution.TDistributionDemo;
import smile.demo.stat.distribution.WeibullDistributionDemo;
import smile.demo.wavelet.BestLocalizedWaveletDemo;
import smile.demo.wavelet.CoifletWaveletDemo;
import smile.demo.wavelet.D4WaveletDemo;
import smile.demo.wavelet.DaubechiesWaveletDemo;
import smile.demo.wavelet.HaarWaveletDemo;
import smile.demo.wavelet.SymletWaveletDemo;
@SuppressWarnings("serial")
public class SmileDemo extends JPanel implements TreeSelectionListener {
private JTree tree;
private JTextArea logPane;
private JSplitPane workspace;
public SmileDemo() {
super(new GridLayout(1,0.1));
//Create the nodes.
DefaultMutableTreeNode top = new DefaultMutableTreeNode("Smile");
createNodes(top);
//Create a tree that allows one selection at a time.
tree = new JTree(top);
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
//Listen for when the selection changes.
tree.addTreeSelectionListener(this);
//Create the scroll pane and add the tree to it.
JScrollPane treeView = new JScrollPane(tree);
JPanel placeholder = new JPanel(new BorderLayout());
placeholder.setBackground(Color.white);
//Create the log pane.
logPane = new JTextArea();
logPane.setEditable(false);
JScrollPane logView = new JScrollPane(logPane);
redirectSystemStreams();
workspace = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
workspace.setTopComponent(placeholder);
workspace.setBottomComponent(logView);
workspace.setDividerLocation(700);
//Add the scroll panes to a split pane.
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
splitPane.setLeftComponent(treeView);
splitPane.setRightComponent(workspace);
Dimension minimumSize = new Dimension(100, 50);
placeholder.setMinimumSize(minimumSize);
logView.setMinimumSize(minimumSize);
workspace.setMinimumSize(minimumSize);
treeView.setMinimumSize(minimumSize);
splitPane.setDividerLocation(300);
splitPane.setPreferredSize(new Dimension(1000, 800));
//Add the split pane to this panel.
add(splitPane);
}
/** Required by TreeSelectionListener interface. */
@Override
public void valueChanged(TreeSelectionEvent e) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
if (node != null && node.isLeaf()) {
int pos = workspace.getDividerLocation();
workspace.setTopComponent((JPanel) node.getUserObject());
workspace.setDividerLocation(pos);
}
}
private void createNodes(DefaultMutableTreeNode top) {
DefaultMutableTreeNode category = null;
DefaultMutableTreeNode category2 = null;
DefaultMutableTreeNode algorithm = null;
category = new DefaultMutableTreeNode("Feature Extraction");
top.add(category);
algorithm = new DefaultMutableTreeNode(new PCADemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new KPCADemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new PPCADemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new GHADemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new smile.demo.projection.LDADemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new RandomProjectionDemo());
category.add(algorithm);
category = new DefaultMutableTreeNode("Multi-Dimensional Scaling");
top.add(category);
algorithm = new DefaultMutableTreeNode(new MDSDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new SammonMappingDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new IsotonicMDSDemo());
category.add(algorithm);
category = new DefaultMutableTreeNode("Manifold Learning");
top.add(category);
algorithm = new DefaultMutableTreeNode(new IsoMapDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new LLEDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new LaplacianEigenmapDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new TSNEDemo());
category.add(algorithm);
category = new DefaultMutableTreeNode("Classification");
top.add(category);
algorithm = new DefaultMutableTreeNode(new smile.demo.classification.KNNDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new LDADemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new FLDDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new QDADemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new RDADemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new LogisticRegressionDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new NeuralNetworkDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new RBFNetworkDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new SVMDemo());
category.add(algorithm);
category = new DefaultMutableTreeNode("Clustering");
top.add(category);
algorithm = new DefaultMutableTreeNode(new HierarchicalClusteringDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new KMeansDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new XMeansDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new GMeansDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new DeterministicAnnealingDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new SOMDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new NeuralGasDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new CLARANSDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new DBSCANDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new DENCLUEDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new SpectralClusteringDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new MECDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new SIBDemo());
category.add(algorithm);
category = new DefaultMutableTreeNode("Vector Quantization");
top.add(category);
algorithm = new DefaultMutableTreeNode(new GrowingNeuralGasDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new NeuralMapDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new BIRCHDemo());
category.add(algorithm);
category = new DefaultMutableTreeNode("Interpolation");
top.add(category);
algorithm = new DefaultMutableTreeNode(new Interpolation1Demo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new Interpolation2Demo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new ScatterDataInterpolationDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new LaplaceInterpolationDemo());
category.add(algorithm);
category = new DefaultMutableTreeNode("Nearest Neighbor Search");
top.add(category);
algorithm = new DefaultMutableTreeNode(new NearestNeighborDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new KNNDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new RNNSearchDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new ApproximateStringSearchDemo());
category.add(algorithm);
category = new DefaultMutableTreeNode("Distributions");
top.add(category);
category2 = new DefaultMutableTreeNode("Discrete");
category.add(category2);
algorithm = new DefaultMutableTreeNode(new BernoulliDistributionDemo());
category2.add(algorithm);
algorithm = new DefaultMutableTreeNode(new BinomialDistributionDemo());
category2.add(algorithm);
algorithm = new DefaultMutableTreeNode(new GeometricDistributionDemo());
category2.add(algorithm);
algorithm = new DefaultMutableTreeNode(new ShiftedGeometricDistributionDemo());
category2.add(algorithm);
algorithm = new DefaultMutableTreeNode(new HyperGeometricDistributionDemo());
category2.add(algorithm);
algorithm = new DefaultMutableTreeNode(new EmpiricalDistributionDemo());
category2.add(algorithm);
algorithm = new DefaultMutableTreeNode(new NegativeBinomialDistributionDemo());
category2.add(algorithm);
algorithm = new DefaultMutableTreeNode(new PoissonDistributionDemo());
category2.add(algorithm);
category2 = new DefaultMutableTreeNode("Continuous");
category.add(category2);
algorithm = new DefaultMutableTreeNode(new BetaDistributionDemo());
category2.add(algorithm);
algorithm = new DefaultMutableTreeNode(new ChiSquareDistributionDemo());
category2.add(algorithm);
algorithm = new DefaultMutableTreeNode(new ExponentialDistributionDemo());
category2.add(algorithm);
algorithm = new DefaultMutableTreeNode(new FDistributionDemo());
category2.add(algorithm);
algorithm = new DefaultMutableTreeNode(new GammaDistributionDemo());
category2.add(algorithm);
algorithm = new DefaultMutableTreeNode(new GaussianDistributionDemo());
category2.add(algorithm);
algorithm = new DefaultMutableTreeNode(new LogNormalDistributionDemo());
category2.add(algorithm);
algorithm = new DefaultMutableTreeNode(new LogisticDistributionDemo());
category2.add(algorithm);
algorithm = new DefaultMutableTreeNode(new TDistributionDemo());
category2.add(algorithm);
algorithm = new DefaultMutableTreeNode(new WeibullDistributionDemo());
category2.add(algorithm);
algorithm = new DefaultMutableTreeNode(new GaussianMixtureDemo());
category2.add(algorithm);
algorithm = new DefaultMutableTreeNode(new ExponentialFamilyMixtureDemo());
category2.add(algorithm);
category2 = new DefaultMutableTreeNode("Multivariate");
category.add(category2);
algorithm = new DefaultMutableTreeNode(new MultivariateGaussianDistributionDemo());
category2.add(algorithm);
algorithm = new DefaultMutableTreeNode(new MultivariateGaussianMixtureDemo());
category2.add(algorithm);
category = new DefaultMutableTreeNode("Wavelet");
top.add(category);
algorithm = new DefaultMutableTreeNode(new HaarWaveletDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new D4WaveletDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new DaubechiesWaveletDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new CoifletWaveletDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new SymletWaveletDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new BestLocalizedWaveletDemo());
category.add(algorithm);
category = new DefaultMutableTreeNode("Graphics");
top.add(category);
algorithm = new DefaultMutableTreeNode(new ScatterPlotDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new LinePlotDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new StaircasePlotDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new BarPlotDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new BoxPlotDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new HistogramDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new Histogram3Demo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new HeatmapDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new HexmapDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new ContourDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new QQPlotDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new GridDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new SurfaceDemo());
category.add(algorithm);
algorithm = new DefaultMutableTreeNode(new SparseMatrixPlotDemo());
category.add(algorithm);
}
private void updateTextArea(final String text) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
logPane.append(text);
}
});
}
private void redirectSystemStreams() {
OutputStream out = new OutputStream() {
@Override
public void write(int b) throws IOException {
updateTextArea(String.valueOf((char) b));
}
@Override
public void write(byte[] b, int off, int len) throws IOException {
updateTextArea(new String(b, off, len));
}
@Override
public void write(byte[] b) throws IOException {
write(b, 0, b.length);
}
};
System.setOut(new PrintStream(out, true));
System.setErr(new PrintStream(out, true));
}
/**
* Create the GUI and show it. For thread safety,
* this method should be invoked from the
* event dispatch thread.
*/
public static void createAndShowGUI(boolean exitOnClose) {
try {
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (Exception ex) {
try {
// If Nimbus is not available, try system look and feel.
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
System.err.println(e);
}
}
//Create and set up the window.
JFrame frame = new JFrame("Smile Demo");
frame.setSize(new Dimension(1000, 1000));
frame.setLocationRelativeTo(null);
if (exitOnClose)
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
else
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
//Add content to the window.
frame.add(new SmileDemo());
//Display the window.
frame.pack();
frame.setVisible(true);
}
public static void main(String[] args) {
//Schedule a job for the event dispatch thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
createAndShowGUI(true);
}
});
}
}