Skip to content

Commit 04d884e

Browse files
committed
fix lock flag settings for EDT
1 parent d1658d4 commit 04d884e

16 files changed

Lines changed: 108 additions & 77 deletions

src/main/java/bigtrace/BigTrace.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -468,15 +468,24 @@ public IntervalView<T> getTraceInterval(boolean bClippedInterval)
468468
}
469469

470470
public synchronized void setLockMode(boolean bLockMode)
471-
{
472-
471+
{
473472
boolean bState = !bLockMode;
474-
473+
System.out.println("inside SetLockMode1");
475474
GuiMisc.setPanelStatusAllComponents(roiManager, bState);
475+
System.out.println("inside SetLockMode2");
476+
476477
GuiMisc.setPanelStatusAllComponents(btPanel.roiMeasure, bState);
478+
System.out.println("inside SetLockMode3");
479+
477480
GuiMisc.setPanelStatusAllComponents(btPanel.btTracksPanel, bState);
481+
System.out.println("inside SetLockMode4");
482+
478483
GuiMisc.setPanelStatusAllComponents(btPanel.btAniPanel, bState);
484+
System.out.println("inside SetLockMode5");
485+
479486
btPanel.voxelSizePanel.allowVoxelSizeChange(bState);
487+
System.out.println("inside SetLockMode6");
488+
480489
btPanel.clipPanel.butExtractClipped.setEnabled( bState );
481490
//keep it on
482491
roiManager.butShowAll.setEnabled(true);
@@ -1452,7 +1461,7 @@ public ExtensionDescriptor[] getExtensionFunctions() {
14521461
}
14531462

14541463
@Override
1455-
public String handleExtension(String name, Object[] args)
1464+
public synchronized String handleExtension(String name, Object[] args)
14561465
{
14571466
return btMacro.handleExtension( name, args );
14581467
}

src/main/java/bigtrace/BigTraceMacro.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ public BigTraceMacro(final BigTrace<T> bt_)
5454
MacroExtension.ARG_NUMBER + MacroExtension.ARG_OPTIONAL);
5555
extensions[10] = ExtensionDescriptor.newDescriptor("btTest", bt);
5656
extensions[11] = ExtensionDescriptor.newDescriptor("btClose", bt);
57-
//extensions[7] = ExtensionDescriptor.newDescriptor("btTest", bt);
5857

5958
}
6059

@@ -319,7 +318,6 @@ public void macroLoadROIs(String sFileName, String input) throws InterruptedExce
319318
}
320319
ROIsIO.loadROIs( sFileName, nLoadMode, bt );
321320
IJ.log( "BigTrace ROIs loaded from " + sFileName);
322-
bt.bInputLock = false;
323321
}
324322

325323
public void macroSaveROIs(String sFileName, String output) throws InterruptedException
@@ -357,7 +355,6 @@ public void macroSaveROIs(String sFileName, String output) throws InterruptedExc
357355
}
358356
ROIsIO.saveROIs( sFileName, nLoadMode, bt );
359357
IJ.log( "BigTrace ROIs saved to " + sFileName);
360-
bt.bInputLock = false;
361358
}
362359

363360
void macroStraighten(final int nStraightenAxis, String sSaveDir, String sShape) throws InterruptedException

src/main/java/bigtrace/io/ROIsExportCSV.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,8 @@ public void setProgressState(String state_)
3939

4040
@Override
4141
protected Void doInBackground() throws Exception {
42-
int nRoi, nRoiN;
4342

44-
bt.bInputLock = true;
45-
bt.setLockMode(true);
43+
int nRoi, nRoiN;
4644

4745
try {
4846
final File file = new File(sFilename);

src/main/java/bigtrace/io/ROIsExportSWC.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,13 @@ public String getProgressState()
3434
@Override
3535
public void setProgressState(String state_)
3636
{
37-
progressState=state_;
37+
progressState = state_;
3838
}
3939

4040
@Override
41-
protected Void doInBackground() throws Exception {
41+
protected Void doInBackground() throws Exception
42+
{
4243
int nRoi, nRoiN;
43-
44-
bt.bInputLock = true;
45-
bt.setLockMode(true);
4644

4745
try {
4846
final File file = new File(sFilename);
@@ -73,7 +71,7 @@ protected Void doInBackground() throws Exception {
7371
}
7472
writer.write( "#smooth_window "+Integer.toString( bt.btData.nSmoothWindow )+"\n" );
7573

76-
for(nRoi=0; nRoi<nRoiN; nRoi++)
74+
for(nRoi = 0; nRoi < nRoiN; nRoi++)
7775
{
7876

7977
//Sleep for up to one second.

src/main/java/bigtrace/io/ROIsIO.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,16 @@ public class ROIsIO
1111
{
1212
public static <T extends RealType< T > & NativeType< T > > void loadROIs(String filename, final int nLoadMode, final BigTrace<T> bt)
1313
{
14-
if(nLoadMode == 0 )
14+
if( nLoadMode == 0 )
1515
{
1616
bt.roiManager.groups = new ArrayList<>();
1717
bt.roiManager.rois.clear();
1818
bt.roiManager.listModel.clear();
1919
}
2020

21+
bt.bInputLock = true;
22+
bt.setLockMode(true);
23+
2124
ROIsLoadBG<T> loadTask = new ROIsLoadBG<>();
2225

2326
loadTask.sFilename = filename;

src/main/java/bigtrace/io/ROIsImportTrackMateBG.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ protected Void doInBackground() throws Exception {
5252
ArrayList<Roi3D> allRois = new ArrayList<>();
5353
Color cCurrentTrackColor = null;
5454
//enter locked mode
55-
bt.bInputLock = true;
56-
bt.setLockMode(true);
55+
5756
try
5857
{
5958

src/main/java/bigtrace/io/ROIsLoadBG.java

Lines changed: 45 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import java.io.IOException;
99
import java.util.ArrayList;
10+
import java.util.concurrent.ExecutionException;
1011

1112
import javax.swing.SwingWorker;
1213

@@ -33,7 +34,6 @@ public class ROIsLoadBG < T extends RealType< T > & NativeType< T > > extends Sw
3334
public String sFilename;
3435
public int nLoadMode;
3536
String sFinalOut = "";
36-
3737

3838
@Override
3939
public String getProgressState()
@@ -50,12 +50,14 @@ public void setProgressState(String state_)
5050
protected Void doInBackground() throws Exception {
5151
String[] line_array;
5252

53-
int nRoiN=1;
54-
int nVertN=0;
53+
int nRoiN = 1;
54+
55+
int nVertN = 0;
56+
5557
int i,j;
5658

57-
5859
ArrayList<RealPoint> vertices;
60+
5961
ArrayList<RealPoint> segment;
6062

6163
int nROIGroupInd = 0;
@@ -69,22 +71,20 @@ protected Void doInBackground() throws Exception {
6971
int nRenderType = 0;
7072
String sUnits = "";
7173
double [] globCalNew = new double [3];
72-
globCalNew[0]= Double.NaN;
73-
globCalNew[1]= Double.NaN;
74-
globCalNew[2]= Double.NaN;
74+
globCalNew[0] = Double.NaN;
75+
globCalNew[1] = Double.NaN;
76+
globCalNew[2] = Double.NaN;
7577

7678
Roi3DGroupManager<T> roiGM;
77-
78-
bt.bInputLock = true;
79-
bt.setLockMode(true);
79+
8080
try ( BufferedReader br = new BufferedReader(new FileReader(sFilename));)
8181
{
8282
String line = "";
8383
//read Groups first
8484
if(nLoadMode == 0)
8585
{
8686
roiGM = new Roi3DGroupManager<>(bt.roiManager);
87-
if(roiGM.loadGroups(br)<0)
87+
if(roiGM.loadGroups(br) < 0)
8888
{
8989
System.err.println("Not a BigTrace ROI Group file format or plugin/file version mismatch,\nloading Groups failed.\n"+
9090
"Try 'Append' loading mode.\n");
@@ -109,9 +109,11 @@ protected Void doInBackground() throws Exception {
109109
}
110110
line_array = line.split(",");
111111

112-
if(line_array.length==3 && line_array[0].equals("BigTrace_ROIs"))
112+
if(line_array.length == 3 && line_array[0].equals("BigTrace_ROIs"))
113113
{
114114
bBeginROIpart = true;
115+
116+
System.out.println("First ROI line ok! ");
115117
}
116118
else
117119
{
@@ -123,8 +125,8 @@ protected Void doInBackground() throws Exception {
123125
}
124126

125127
//initial part check
126-
127128
line_array = line.split(",");
129+
128130
if(!line_array[0].equals("BigTrace_ROIs"))
129131
{
130132
System.err.println("Not a BigTrace ROI file format, aborting");
@@ -243,8 +245,8 @@ protected Void doInBackground() throws Exception {
243245

244246
case "Vertices":
245247
nVertN = Integer.parseInt(line_array[1]);
246-
vertices =new ArrayList<>();
247-
for(i=0;i<nVertN;i++)
248+
vertices = new ArrayList<>();
249+
for(i = 0; i < nVertN; i++)
248250
{
249251
line = br.readLine();
250252
line_array = line.split(",");
@@ -288,14 +290,14 @@ protected Void doInBackground() throws Exception {
288290
line = br.readLine();
289291
line_array = line.split(",");
290292
int nTotSegm = Integer.parseInt(line_array[1]);
291-
for (i=0;i<nTotSegm;i++)
293+
for (i = 0; i < nTotSegm; i++)
292294
{
293295
//points number
294296
line = br.readLine();
295297
line_array = line.split(",");
296298
nVertN = Integer.parseInt(line_array[3]);
297299
segment = new ArrayList<>();
298-
for(j=0;j<nVertN;j++)
300+
for(j = 0; j < nVertN; j++)
299301
{
300302
line = br.readLine();
301303
line_array = line.split(",");
@@ -321,12 +323,13 @@ protected Void doInBackground() throws Exception {
321323

322324
}
323325
line = br.readLine();
324-
}
326+
System.out.println("lineoutside" + line);
327+
}
325328

326329
br.close();
327330
setProgress(100);
328-
329-
sFinalOut="loading ROIs done.";
331+
System.out.println("finished reading file");
332+
sFinalOut = "loading ROIs done.";
330333
setProgressState(sFinalOut);
331334

332335
/** load voxel calibration **/
@@ -336,7 +339,6 @@ protected Void doInBackground() throws Exception {
336339
bt.btData.sVoxelUnit = new String(sUnits);
337340
bt.btPanel.voxelSizePanel.setVoxelSize(globCalNew, sUnits);
338341
sFinalOut = "loading ROIs done (+voxel calibration).";
339-
340342
setProgressState(sFinalOut);
341343
}
342344
else
@@ -371,7 +373,28 @@ protected Void doInBackground() throws Exception {
371373
*/
372374
@Override
373375
public void done()
374-
{
376+
{
377+
//see if we have some errors
378+
try {
379+
380+
get();
381+
}
382+
catch (ExecutionException e)
383+
{
384+
e.getCause().printStackTrace();
385+
String msg = String.format("Unexpected error during ROI loading: %s",
386+
e.getCause().toString());
387+
System.out.println(msg);
388+
}
389+
catch (InterruptedException e)
390+
{
391+
System.out.println(e.toString());
392+
}
393+
catch (Exception e)
394+
{
395+
}
396+
System.out.println("done load lock thread");
397+
375398
//unlock user interaction
376399
bt.bInputLock = false;
377400
bt.setLockMode(false);

src/main/java/bigtrace/io/ROIsSaveBG.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,8 @@ public void setProgressState(String state_)
3636

3737
@Override
3838
protected Void doInBackground() throws Exception {
39-
int nRoi, nRoiN;
4039

41-
bt.bInputLock = true;
42-
bt.setLockMode(true);
40+
int nRoi, nRoiN;
4341

4442
//get the group manager to save groups
4543
Roi3DGroupManager<T> roiGM = new Roi3DGroupManager<>(bt.roiManager);
@@ -70,7 +68,7 @@ protected Void doInBackground() throws Exception {
7068

7169
nRoiN = bt.roiManager.rois.size();
7270
writer.write("ROIsNumber," + Integer.toString(nRoiN)+"\n");
73-
for(nRoi=0;nRoi<nRoiN;nRoi++)
71+
for(nRoi = 0; nRoi < nRoiN; nRoi++)
7472
{
7573
//Sleep for up to one second.
7674
try {

src/main/java/bigtrace/io/ViewsIO.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ public static < T extends RealType< T > & NativeType< T > > void saveView(final
164164
bt.bInputLock = false;
165165
bt.setLockMode(false);
166166
}
167+
167168
/** loading current view from csv **/
168169
public static < T extends RealType< T > & NativeType< T > > void loadView(final BigTrace<T> bt, String sFilename)
169170
{

src/main/java/bigtrace/measure/LineProfileBG.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,11 @@ public String getProgressState()
2626
@Override
2727
public void setProgressState(String state_)
2828
{
29-
progressState=state_;
29+
progressState = state_;
3030
}
3131
@Override
3232
protected Void doInBackground() throws Exception {
33-
bt.bInputLock = true;
34-
bt.setLockMode(true);
33+
3534
final int nRoiN = bt.roiManager.rois.size();
3635
setProgressState("measuring line profiles...");
3736
setProgress(0);

0 commit comments

Comments
 (0)