-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path_ModelGui.java
More file actions
910 lines (779 loc) · 35.5 KB
/
Copy path_ModelGui.java
File metadata and controls
910 lines (779 loc) · 35.5 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
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
/********************************************************************************
* Copyright (c) 2020 Marcel Austenfeld
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
********************************************************************************/
import java.io.File;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.bindings.keys.KeyStroke;
import org.eclipse.jface.bindings.keys.ParseException;
import org.eclipse.jface.fieldassist.ContentProposalAdapter;
import org.eclipse.jface.fieldassist.ControlDecoration;
import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
import org.eclipse.jface.fieldassist.SimpleContentProposalProvider;
import org.eclipse.jface.fieldassist.TextContentAdapter;
import org.eclipse.jface.resource.FontDescriptor;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DropTarget;
import org.eclipse.swt.dnd.DropTargetAdapter;
import org.eclipse.swt.dnd.DropTargetEvent;
import org.eclipse.swt.dnd.FileTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.wizards.IWizardDescriptor;
import com.eco.bio7.batch.Bio7Dialog;
import com.eco.bio7.batch.FileRoot;
import com.eco.bio7.console.Bio7Console;
import com.eco.bio7.image.CanvasView;
import com.eco.bio7.image.RImageMethodsView;
import com.eco.bio7.image.Util;
import ij.IJ;
import ij.ImagePlus;
import ij.gui.Roi;
import ij.gui.RoiListener;
import org.eclipse.wb.swt.SWTResourceManager;
public class _ModelGui extends Composite implements RoiListener {
protected boolean convolve;
protected boolean gaussian;
protected boolean median;
protected boolean mean;
protected boolean maximum;
protected boolean minimum;
protected boolean edges;
protected String convolveOption = "text1=[\n-1 -1 -1 -1 -1\n-1 -1 -1 -1 -1\n-1 -1 24 -1 -1\n-1 -1 -1 -1 -1\n-1 -1 -1 -1 -1\n] normalize";
protected String medianOption = "2";
protected String channelOption = "";
protected String gaussianOption = "2";
protected String meanOption = "2";
protected String maximumOption = "2";
protected String minimumOption = "2";
private Main model;
protected Text channelSelectionText;
protected Text optionGaussian;
protected Text optionMedian;
protected Text optionConvolve;
protected Text optionsMean;
protected Text optionsMaximum;
protected Text optionsMinimum;
protected Button checkGaussianFilter;
protected Button checkMedian;
protected Button checkConvolve;
protected Button checkMaximum;
protected Button checkMean;
protected Button checkMinimum;
protected Button checkEdges;
private CTabFolder tabFolder;
private CTabItem tabItemFeatures;
private Composite composite;
private CTabItem tbtmMore;
private Composite composite_1;
private Button btnLoadConfiguration;
private Button btnNewButton_4;
protected Text txtTrainingRScript;
private Button btnNewButton_5;
private Button btnRClassificationScript;
protected Text txtClassificationRScript;
protected String pathTrainingScript;
protected String pathClassificationScript;
protected Button checkConvertToHsb;
protected boolean toHsb;
private ScrolledComposite scrolledComposite;
protected Button checkGradientHessian;
protected Text optionGradientHessian;
protected Button checkLaplacian;
protected Text optionLaplacian;
protected boolean gradientHessian;
protected String gradientHessianOption;
protected boolean laplacian;
protected String laplacianOption;
protected Button checkVariance;
protected Text optionsVariance;
protected boolean variance;
protected String varianceOption;
protected Text optionsEdges;
protected Text optionDiffGaussian;
protected Button checkDifferenceOfGaussian;
protected boolean diffOfGaussian;
protected String diffGaussianOption;
protected Button checkLipschitz;
protected Text optionLipschitz;
protected Button checkGabor;
protected Text optionGabor;
protected boolean lipschitz;
protected String lipschitzOption;
protected boolean gabor;
protected String gaborOption;
protected Button checkUseImportMacro;
protected Text textImageJMacro;
protected boolean useImportMacro;
protected String textOptionMacro;
protected String pathpostImageJMacro;
private Button buttonMacro;
protected Button checkTopHat;
protected Text optionsTopHat;
protected boolean topHat;
protected String topHatOption;
protected Button checkKuwahara;
protected Text optionsKuwahara;
protected boolean kuwahara;
protected String kuwaharaOption;
protected String edgesOption;
protected Button checkUseDirectory;
protected boolean useDirectoryDialog;
protected Button checkConvertToLab;
protected boolean toLab;
private Label transferTypeLabel;
protected Combo transferTypeCombo;
protected int transferType;
protected boolean interruptBatch;
private Button interruptButton;
protected Button checkOpenStack;
protected boolean openStack;
protected Button checkUseGroups;
protected boolean useGroups;
protected Button checkGeneratePreview;
protected boolean generatePreview;
private Label scriptsLabel;
private Label featureLabel;
private Label previewLabel;
private Label classificationOpenLabel;
protected Button checkRetrainPreview;
protected boolean retrainPreview;
private Label lblNewLabel;
private Label lblLutToApply;
protected Text optionOpacity;
protected Text optionLUT;
protected String lutOption;
protected String opacityOption;
private ScrolledComposite scrolledCompositeSettings;
private Button btnClassificationProject;
private Label lblClassified;
protected Button checkShowInImagej;
protected boolean showClassifiedInImageJ;
private Label lblFeatures;
private Label lblColor;
protected Button checkApplyPostImagejMacro;
protected Text textPostMacro;
private Button btnMacro;
protected boolean applyPostImageJMacro;
private Label lblTrainAndClassify;
public _ModelGui(Composite parent, Main model, int style) {
super(parent, SWT.NONE);
this.model = model;
setLayout(new FillLayout(SWT.HORIZONTAL));
tabFolder = new CTabFolder(this, SWT.BORDER);
/* Add drag and drop for the Configuration file! */
DropTarget dt = new DropTarget(tabFolder, DND.DROP_DEFAULT | DND.DROP_MOVE);
dt.setTransfer(new Transfer[] { FileTransfer.getInstance() });
dt.addDropListener(new DropTargetAdapter() {
public void drop(DropTargetEvent event) {
FileTransfer ft = FileTransfer.getInstance();
if (ft.isSupportedType(event.currentDataType)) {
String[] fileList = (String[]) event.data;
for (int i = 0; i < fileList.length; i++) {
// System.out.println(fileList[i]);
new _Settings(_ModelGui.this).loadScript(fileList[0]);
}
}
}
});
// tabFolder.setSelectionBackground(
// Display.getCurrent().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT));
tabItemFeatures = new CTabItem(tabFolder, SWT.NONE);
tabItemFeatures.setText("Features");
tabFolder.setSelection(tabItemFeatures);
scrolledComposite = new ScrolledComposite(tabFolder, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
tabItemFeatures.setControl(scrolledComposite);
scrolledComposite.setExpandHorizontal(true);
scrolledComposite.setExpandVertical(false);
composite = new Composite(scrolledComposite, SWT.NONE);
composite.setSize(300, 1350);
scrolledComposite.setContent(composite);
composite.setLayout(new GridLayout(2, true));
btnClassificationProject = new Button(composite, SWT.NONE);
btnClassificationProject.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
IWizardDescriptor descriptor = PlatformUI.getWorkbench().getNewWizardRegistry()
.findWizard("com.eco.bio7.wizard.reproducible");
IWizard wizard = null;
try {
wizard = descriptor.createWizard();
} catch (CoreException e1) {
e1.printStackTrace();
}
WizardDialog wd = new WizardDialog(Util.getShell(), wizard);
wd.setTitle(wizard.getWindowTitle());
wd.open();
boolean doOpen = Bio7Dialog.decision("Copy the train and classify scripts to the new project folder.\n"
+ "Adjust the paths to the scripts and save a configuration file\n"
+ "in the project folder!\n\n"
+ "Would you like to copy the R scripts for customization (simply drag and drop to the project)?");
if (doOpen) {
org.eclipse.swt.program.Program.launch(new File(txtTrainingRScript.getText()).getParent());
}
}
});
btnClassificationProject.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
btnClassificationProject.setText("Create Classification Project");
Button btnNewButton_1 = new Button(composite, SWT.NONE);
btnNewButton_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
btnNewButton_1.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
model.executeSelection(2);
}
});
btnNewButton_1.setText("Select Features (1)");
Button btnNewButton = new Button(composite, SWT.NONE);
btnNewButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
btnNewButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
model.executeSelection(1);
}
});
btnNewButton.setText("Create Features (2)");
Button btnNewButton_2 = new Button(composite, SWT.NONE);
btnNewButton_2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
btnNewButton_2.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
model.executeSelection(3);
}
});
btnNewButton_2.setText("Train Script (3)");
Button btnNewButton_3 = new Button(composite, SWT.NONE);
btnNewButton_3.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
btnNewButton_3.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
model.executeSelection(4);
}
});
btnNewButton_3.setText("Classify Script (4)");
btnLoadConfiguration = new Button(composite, SWT.NONE);
btnLoadConfiguration.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
btnLoadConfiguration.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
new _Settings(_ModelGui.this).loadScript(null);
}
});
btnLoadConfiguration.setText("Load Configuration");
btnNewButton_4 = new Button(composite, SWT.NONE);
btnNewButton_4.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
btnNewButton_4.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
new _Settings(_ModelGui.this).saveScript();
}
});
btnNewButton_4.setText("Save Configuration");
interruptButton = new Button(composite, SWT.NONE);
interruptButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
interruptBatch = true;
boolean answer = Bio7Dialog.decision("Should the R process be interrupted (if possible)?");
if (answer) {
if (Util.getOS().equals("Win")) {
Bio7Console.sendWinCtrlBreak();
} else {
Bio7Console.sendLinCtrlC();
}
}
}
});
interruptButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
interruptButton.setText("Interrupt Classification");
lblColor = new Label(composite, SWT.NONE);
lblColor.setAlignment(SWT.CENTER);
lblColor.setBackground(SWTResourceManager.getColor(SWT.COLOR_GRAY));
FontDescriptor boldDescriptor = FontDescriptor.createFrom(lblColor.getFont()).setStyle(SWT.BOLD);
Font boldFont = boldDescriptor.createFont(lblColor.getDisplay());
lblColor.setFont(boldFont);
lblColor.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
lblColor.setText("Color & Channels");
checkConvertToHsb = new Button(composite, SWT.CHECK);
checkConvertToHsb.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
checkConvertToLab.setSelection(false);
}
});
checkConvertToHsb.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
checkConvertToHsb.setText("Convert to HSB");
checkConvertToLab = new Button(composite, SWT.CHECK);
checkConvertToLab.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
checkConvertToHsb.setSelection(false);
}
});
checkConvertToLab.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
checkConvertToLab.setText("Convert to LAB");
new Label(composite, SWT.NONE);
new Label(composite, SWT.NONE);
Label lblSelectChannels = new Label(composite, SWT.NONE);
lblSelectChannels.setAlignment(SWT.CENTER);
GridData gd_lblSelectChannels = new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1);
gd_lblSelectChannels.widthHint = 279;
lblSelectChannels.setLayoutData(gd_lblSelectChannels);
lblSelectChannels.setText("Select Channels (1,2,... - Leave blank for all!)\r\n");
channelSelectionText = new Text(composite, SWT.BORDER);
channelSelectionText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
lblFeatures = new Label(composite, SWT.NONE);
lblFeatures.setBackground(SWTResourceManager.getColor(SWT.COLOR_GRAY));
lblFeatures.setAlignment(SWT.CENTER);
lblFeatures.setFont(boldFont);
lblFeatures.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
lblFeatures.setText("Features");
checkGaussianFilter = new Button(composite, SWT.CHECK);
checkGaussianFilter.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
checkGaussianFilter.setText("Gaussian Blur");
checkDifferenceOfGaussian = new Button(composite, SWT.CHECK);
checkDifferenceOfGaussian.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
checkDifferenceOfGaussian.setText("Difference of Gaussian");
optionGaussian = new Text(composite, SWT.BORDER);
optionGaussian.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
optionGaussian.setText("2");
optionDiffGaussian = new Text(composite, SWT.BORDER);
optionDiffGaussian.setText("2,4");
optionDiffGaussian.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
checkMean = new Button(composite, SWT.CHECK);
checkMean.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
checkMean.setText("Mean");
checkMedian = new Button(composite, SWT.CHECK);
checkMedian.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
checkMedian.setText("Median");
optionsMean = new Text(composite, SWT.BORDER);
optionsMean.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
optionsMean.setText("2");
optionMedian = new Text(composite, SWT.BORDER);
optionMedian.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
optionMedian.setText("2");
checkMinimum = new Button(composite, SWT.CHECK);
checkMinimum.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
checkMinimum.setText("Minimum");
checkVariance = new Button(composite, SWT.CHECK);
checkVariance.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
checkVariance.setText("Variance");
optionsMinimum = new Text(composite, SWT.BORDER);
GridData gd_optionsMinimum = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
gd_optionsMinimum.widthHint = 167;
optionsMinimum.setLayoutData(gd_optionsMinimum);
optionsMinimum.setText("2");
optionsVariance = new Text(composite, SWT.BORDER);
optionsVariance.setText("2");
optionsVariance.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
checkMaximum = new Button(composite, SWT.CHECK);
checkMaximum.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
checkMaximum.setText("Maximum");
checkGradientHessian = new Button(composite, SWT.CHECK);
checkGradientHessian.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
checkGradientHessian.setText("Gradient");
optionsMaximum = new Text(composite, SWT.BORDER);
optionsMaximum.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
optionsMaximum.setText("2");
optionGradientHessian = new Text(composite, SWT.BORDER);
optionGradientHessian.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
checkLaplacian = new Button(composite, SWT.CHECK);
checkLaplacian.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
checkLaplacian.setText("Laplacian");
checkEdges = new Button(composite, SWT.CHECK);
checkEdges.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
checkEdges.setText("Sobel Edge");
optionLaplacian = new Text(composite, SWT.BORDER);
optionLaplacian.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
optionsEdges = new Text(composite, SWT.BORDER);
optionsEdges.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
checkLipschitz = new Button(composite, SWT.CHECK);
checkLipschitz.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
checkLipschitz.setText("Lipschitz");
checkGabor = new Button(composite, SWT.CHECK);
checkGabor.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
checkGabor.setText("Gabor");
optionLipschitz = new Text(composite, SWT.BORDER);
optionLipschitz.setText("true,true,10");
optionLipschitz.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
optionGabor = new Text(composite, SWT.BORDER);
optionGabor.setText("3,4.0,0.6,1.0,2.0,0.3");
optionGabor.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
}
});
optionGabor.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
checkTopHat = new Button(composite, SWT.CHECK);
checkTopHat.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
checkTopHat.setText("Top Hat");
checkKuwahara = new Button(composite, SWT.CHECK);
checkKuwahara.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
checkKuwahara.setText("Kuwahara");
optionsTopHat = new Text(composite, SWT.BORDER);
optionsTopHat.setText("2");
optionsTopHat.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
optionsKuwahara = new Text(composite, SWT.BORDER);
optionsKuwahara.setText("2");
optionsKuwahara.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
new Label(composite, SWT.NONE);
new Label(composite, SWT.NONE);
checkConvolve = new Button(composite, SWT.CHECK);
checkConvolve.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
checkConvolve.setText("Convolve");
new Label(composite, SWT.NONE);
optionConvolve = new Text(composite, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.MULTI);
GridData gd_optionConvolve = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
gd_optionConvolve.widthHint = 189;
optionConvolve.setLayoutData(gd_optionConvolve);
optionConvolve.setText(
"text1=[\n-1 -1 -1 -1 -1\n-1 -1 -1 -1 -1\n-1 -1 24 -1 -1\n-1 -1 -1 -1 -1\n-1 -1 -1 -1 -1\n] normalize");
tbtmMore = new CTabItem(tabFolder, SWT.NONE);
tbtmMore.setText("Settings");
scrolledCompositeSettings = new ScrolledComposite(tabFolder, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
tbtmMore.setControl(scrolledCompositeSettings);
scrolledCompositeSettings.setExpandHorizontal(true);
scrolledCompositeSettings.setExpandVertical(false);
composite_1 = new Composite(scrolledCompositeSettings, SWT.NONE);
composite_1.setSize(300, 600);
scrolledCompositeSettings.setContent(composite_1);
composite_1.setLayout(new GridLayout(2, true));
classificationOpenLabel = new Label(composite_1, SWT.NONE);
classificationOpenLabel.setBackground(SWTResourceManager.getColor(SWT.COLOR_GRAY));
classificationOpenLabel.setAlignment(SWT.CENTER);
classificationOpenLabel.setFont(boldFont);
classificationOpenLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
classificationOpenLabel.setText("Classify Images");
checkUseDirectory = new Button(composite_1, SWT.CHECK);
GridData gd_checkUseDirectory = new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1);
gd_checkUseDirectory.heightHint = 25;
checkUseDirectory.setLayoutData(gd_checkUseDirectory);
checkUseDirectory.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
}
});
checkUseDirectory.setText("Open images from folders");
lblTrainAndClassify = new Label(composite_1, SWT.NONE);
lblTrainAndClassify.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
lblTrainAndClassify.setAlignment(SWT.CENTER);
lblTrainAndClassify.setFont(boldFont);
lblTrainAndClassify.setBackground(SWTResourceManager.getColor(SWT.COLOR_GRAY));
lblTrainAndClassify.setText("Files");
checkUseImportMacro = new Button(composite_1, SWT.CHECK);
checkUseImportMacro.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
checkUseImportMacro.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
}
});
checkUseImportMacro.setText("Open files with ImageJ Macro");
textImageJMacro = new Text(composite_1, SWT.BORDER);
textImageJMacro.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
textImageJMacro.setText(FileRoot.getCurrentCompileDir() + "/_Macro/IJMacro.ijm");
buttonMacro = new Button(composite_1, SWT.NONE);
buttonMacro.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String path = Bio7Dialog.openFile();
path = path.replace("\\", "/");
textImageJMacro.setText(path);
}
});
buttonMacro.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
buttonMacro.setText("Macro");
scriptsLabel = new Label(composite_1, SWT.NONE);
scriptsLabel.setBackground(SWTResourceManager.getColor(SWT.COLOR_GRAY));
scriptsLabel.setAlignment(SWT.CENTER);
scriptsLabel.setFont(boldFont);
scriptsLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
scriptsLabel.setText("Scripts");
txtTrainingRScript = new Text(composite_1, SWT.BORDER);
txtTrainingRScript.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
txtTrainingRScript.setText(FileRoot.getCurrentCompileDir() + "/_R/Train.R");
btnNewButton_5 = new Button(composite_1, SWT.NONE);
btnNewButton_5.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String path = Bio7Dialog.openFile();
path = path.replace("\\", "/");
txtTrainingRScript.setText(path);
}
});
btnNewButton_5.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
btnNewButton_5.setText("Training Script");
txtClassificationRScript = new Text(composite_1, SWT.BORDER);
txtClassificationRScript.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
txtClassificationRScript.setText(FileRoot.getCurrentCompileDir() + "/_R/Classify.R");
btnRClassificationScript = new Button(composite_1, SWT.NONE);
btnRClassificationScript.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String path = Bio7Dialog.openFile();
path = path.replace("\\", "/");
txtClassificationRScript.setText(path);
}
});
btnRClassificationScript.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
btnRClassificationScript.setText("Classification Script");
featureLabel = new Label(composite_1, SWT.NONE);
featureLabel.setBackground(SWTResourceManager.getColor(SWT.COLOR_GRAY));
featureLabel.setAlignment(SWT.CENTER);
featureLabel.setFont(boldFont);
featureLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
featureLabel.setText("Feature Options");
checkOpenStack = new Button(composite_1, SWT.CHECK);
checkOpenStack.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
}
});
checkOpenStack.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
checkOpenStack.setText("Open Feature Stack");
checkUseGroups = new Button(composite_1, SWT.CHECK);
checkUseGroups.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
}
});
checkUseGroups.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
checkUseGroups.setText("Use Group Signature");
transferTypeLabel = new Label(composite_1, SWT.CENTER);
transferTypeLabel.setBackground(SWTResourceManager.getColor(SWT.COLOR_GRAY));
transferTypeLabel.setFont(boldFont);
GridData gd_transferTypeLabel = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1);
gd_transferTypeLabel.widthHint = 254;
transferTypeLabel.setLayoutData(gd_transferTypeLabel);
transferTypeLabel.setText("Select Transfer Type");
transferTypeCombo = new Combo(composite_1, SWT.NONE);
GridData gd_transferTypeCombo = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1);
gd_transferTypeCombo.widthHint = 269;
transferTypeCombo.setLayoutData(gd_transferTypeCombo);
transferTypeCombo.setItems(new String[] { "Double", "Integer", "Byte" });
transferTypeCombo.select(0);
transferTypeCombo.setText("Double");
previewLabel = new Label(composite_1, SWT.NONE);
previewLabel.setBackground(SWTResourceManager.getColor(SWT.COLOR_GRAY));
previewLabel.setAlignment(SWT.CENTER);
previewLabel.setFont(boldFont);
previewLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
previewLabel.setText("Preview Overlay");
checkGeneratePreview = new Button(composite_1, SWT.CHECK);
checkGeneratePreview.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (checkGeneratePreview.getSelection() == true) {
Roi.addRoiListener(_ModelGui.this);
} else {
Roi.removeRoiListener(_ModelGui.this);
IJ.run("Remove Overlay", "");
}
}
});
GridData gd_checkGeneratePreview = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
gd_checkGeneratePreview.widthHint = 247;
checkGeneratePreview.setLayoutData(gd_checkGeneratePreview);
checkGeneratePreview.setText("Selection Preview");
checkRetrainPreview = new Button(composite_1, SWT.CHECK);
checkRetrainPreview.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
checkRetrainPreview.setText("Retrain for Preview");
lblNewLabel = new Label(composite_1, SWT.NONE);
lblNewLabel.setLayoutData(new GridData(SWT.CENTER, SWT.FILL, true, false, 1, 1));
lblNewLabel.setText("Opacity");
lblLutToApply = new Label(composite_1, SWT.NONE);
lblLutToApply.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1));
lblLutToApply.setText("LUT");
optionOpacity = new Text(composite_1, SWT.BORDER);
optionOpacity.setText("0.4");
optionOpacity.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
optionLUT = new Text(composite_1, SWT.BORDER);
optionLUT.setText("Spectrum");
setLutCompletion(optionLUT);
optionLUT.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
lblClassified = new Label(composite_1, SWT.NONE);
lblClassified.setBackground(SWTResourceManager.getColor(SWT.COLOR_GRAY));
lblClassified.setAlignment(SWT.CENTER);
lblClassified.setFont(boldFont);
lblClassified.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
lblClassified.setText("Classified Images");
checkShowInImagej = new Button(composite_1, SWT.CHECK);
checkShowInImagej.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, true, false, 1, 1));
checkShowInImagej.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
}
});
checkShowInImagej.setSelection(true);
checkShowInImagej.setText("Show in ImageJ");
checkApplyPostImagejMacro = new Button(composite_1, SWT.CHECK);
checkApplyPostImagejMacro.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, true, false, 1, 1));
checkApplyPostImagejMacro.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
}
});
checkApplyPostImagejMacro.setText("Apply ImageJ Macro");
textPostMacro = new Text(composite_1, SWT.BORDER);
textPostMacro.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
textPostMacro.setText(FileRoot.getCurrentCompileDir() + "/_Macro/IJPostMacro.ijm");
btnMacro = new Button(composite_1, SWT.NONE);
btnMacro.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String path = Bio7Dialog.openFile();
path = path.replace("\\", "/");
textPostMacro.setText(path);
}
});
btnMacro.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
btnMacro.setText("Macro");
transferTypeCombo.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
int index = transferTypeCombo.getSelectionIndex();
RImageMethodsView.getTransferTypeCombo().select(index);
}
});
}
/* Add code completion to the LUT textfield! */
private void setLutCompletion(Text lutText) {
String[] lutProposals = IJ.getLuts();
final ControlDecoration controlDecor = new ControlDecoration(lutText, SWT.TOP | SWT.RIGHT);
Image image = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION)
.getImage();
controlDecor.setDescriptionText("Use CTRL + SPACE for available LUTs!");
controlDecor.setImage(image);
// always show decoration
controlDecor.setShowOnlyOnFocus(false);
// hide the decoration if the text widget has content
/*
* lutText.addModifyListener(e -> { Text source = (Text) e.getSource(); if
* (!source.getText().isEmpty()) { controlDecor.hide(); } else {
* controlDecor.show(); } });
*/
char[] activChars = new char[] { ' ' };
KeyStroke keystr;
try {
keystr = KeyStroke.getInstance("Ctrl+Space");
ContentProposalAdapter adapter = new ContentProposalAdapter(lutText, new TextContentAdapter(),
new SimpleContentProposalProvider(lutProposals), keystr, activChars);
adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
} catch (ParseException e1) {
e1.printStackTrace();
}
}
/*
* A method to access all options wrapped in a syncExec for SWT widgets access!
*/
public void getFeatureOptions() {
Display display = Util.getDisplay();
display.syncExec(() -> {
toHsb = checkConvertToHsb.getSelection();
toLab = checkConvertToLab.getSelection();
useImportMacro = checkUseImportMacro.getSelection();
useDirectoryDialog = checkUseDirectory.getSelection();
openStack = checkOpenStack.getSelection();
useGroups = checkUseGroups.getSelection();
transferType = transferTypeCombo.getSelectionIndex();
generatePreview = checkGeneratePreview.getSelection();
lutOption = optionLUT.getText();
opacityOption = optionOpacity.getText();
retrainPreview = checkRetrainPreview.getSelection();
showClassifiedInImageJ = checkShowInImagej.getSelection();
applyPostImageJMacro = checkApplyPostImagejMacro.getSelection();
channelOption = channelSelectionText.getText();
gaussian = checkGaussianFilter.getSelection();
gaussianOption = optionGaussian.getText();
diffOfGaussian = checkDifferenceOfGaussian.getSelection();
diffGaussianOption = optionDiffGaussian.getText();
median = checkMedian.getSelection();
medianOption = optionMedian.getText();
mean = checkMean.getSelection();
meanOption = optionsMean.getText();
variance = checkVariance.getSelection();
varianceOption = optionsVariance.getText();
maximum = checkMaximum.getSelection();
maximumOption = optionsMaximum.getText();
minimum = checkMinimum.getSelection();
minimumOption = optionsMinimum.getText();
edges = checkEdges.getSelection();
edgesOption = optionsEdges.getText();
convolve = checkConvolve.getSelection();
convolveOption = optionConvolve.getText();
gradientHessian = checkGradientHessian.getSelection();
gradientHessianOption = optionGradientHessian.getText();
laplacian = checkLaplacian.getSelection();
laplacianOption = optionLaplacian.getText();
lipschitz = checkLipschitz.getSelection();
lipschitzOption = optionLipschitz.getText();
gabor = checkGabor.getSelection();
gaborOption = optionGabor.getText();
topHat = checkTopHat.getSelection();
topHatOption = optionsTopHat.getText();
kuwahara = checkKuwahara.getSelection();
kuwaharaOption = optionsKuwahara.getText();
});
}
/* Return the path to the training script! */
public String getPathTrainingScript() {
Display display = Util.getDisplay();
display.syncExec(() -> pathTrainingScript = txtTrainingRScript.getText());
return pathTrainingScript;
}
/* Return the path to the classification script! */
public String getPathClassificationScript() {
Display display = Util.getDisplay();
display.syncExec(() -> pathClassificationScript = txtClassificationRScript.getText());
return pathClassificationScript;
}
public String getMacroTextOption() {
Display display = Util.getDisplay();
display.syncExec(() -> textOptionMacro = textImageJMacro.getText());
return textOptionMacro;
}
/* Return the path to the classification script! */
public String getPathImageJMacroPostScript() {
Display display = Util.getDisplay();
display.syncExec(() -> pathpostImageJMacro = textPostMacro.getText());
return pathpostImageJMacro;
}
/* Here we layout the ImageJ panel! */
public void layout() {
CanvasView canvasView = CanvasView.getCanvas_view();
canvasView.updatePlotCanvas();
}
@Override
/*
* If the ImageJ ROI has changed this method will be called for preview. A job
* avoids a recall if the job is busy to update the preview!
*/
public void roiModified(ImagePlus imp, int id) {
/* Call update method in main class! */
model.roiModified(imp, id);
}
}