Changeset 7108
- Timestamp:
- 10/21/10 21:10:51 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/maven/projects/slim-plugin/src/main/java/loci/slim/SLIMProcessor.java
r7088 r7108 70 70 import loci.slim.ui.IStartStopListener; 71 71 import loci.slim.ui.IUserInterfacePanel; 72 import loci.slim.ui.IUserInterfacePanelListener; 72 73 import loci.slim.ui.UserInterfacePanel; 73 74 import loci.common.DataTools; … … 124 125 125 126 private Object m_synchFit = new Object(); 127 private volatile boolean m_quit; 128 private volatile boolean m_cancel; 126 129 private volatile boolean m_fitInProgress; 127 130 private volatile boolean m_fitted; … … 189 192 190 193 public SLIMProcessor() { 194 m_quit = false; 195 m_cancel = false; 191 196 m_fitInProgress = false; 192 197 m_fitted = false; … … 195 200 public void processImage(Image<T> image) { 196 201 boolean success = false; 197 System.out.println("processImage " + image); 202 198 203 if (newLoadData(image)) { 199 204 // create a grayscale image from the data 200 205 createGlobalGrayScale(); 201 while (true) { 206 207 // show the UI; do fits 208 final IUserInterfacePanel uiPanel = new UserInterfacePanel(true); 209 uiPanel.setListener( 210 new IUserInterfacePanelListener() { 211 public void doFit() { 212 m_cancel = false; 213 getFitSettings(uiPanel); 214 fitData(); 215 uiPanel.reset(); 216 } 217 218 public void cancelFit() { 219 m_cancel = true; 220 } 221 222 } 223 ); 224 225 226 while (!m_quit) { 227 try { 228 Thread.sleep(1000); 229 } 230 catch (InterruptedException e) { 231 232 } 233 } 234 } 235 236 /* while (true) { 202 237 // ask what kind fo fit 203 238 if (!showFitDialog()) { … … 210 245 fitData(); 211 246 } 212 } 247 } */ 213 248 /* 214 249 m_width = ImageUtils.getWidth(image); … … 274 309 // create a grayscale image from the data 275 310 createGlobalGrayScale(); 276 while (true) { 311 312 // show the UI; do fits 313 final IUserInterfacePanel uiPanel = new UserInterfacePanel(true); 314 uiPanel.setListener( 315 new IUserInterfacePanelListener() { 316 public void doFit() { 317 m_cancel = false; 318 getFitSettings(uiPanel); 319 fitData(); 320 uiPanel.reset(); 321 } 322 323 public void cancelFit() { 324 m_cancel = true; 325 } 326 327 } 328 ); 329 330 while (!m_quit) { 331 try { 332 Thread.sleep(1000); 333 } 334 catch (InterruptedException e) { 335 336 } 337 } 338 339 340 341 342 343 344 /* while (true) { 277 345 // ask what kind fo fit 278 346 if (!showFitDialog()) { … … 284 352 } 285 353 fitData(); 286 } 287 } 354 } */ 355 } 356 } 357 358 private void getFitSettings(IUserInterfacePanel uiPanel) { 359 m_region = uiPanel.getRegion(); 360 m_algorithm = uiPanel.getAlgorithm(); 361 m_function = uiPanel.getFunction(); 362 363 m_x = uiPanel.getX(); 364 m_y = uiPanel.getY(); 365 m_startBin = uiPanel.getStart(); 366 m_stopBin = uiPanel.getStop(); 367 m_threshold = uiPanel.getThreshold(); 368 369 int components = uiPanel.getComponents(); 370 m_param = uiPanel.getParameters(); 371 m_free = uiPanel.getFree(); 288 372 } 289 373 … … 1180 1264 while (pixelIterator.hasNext()) { 1181 1265 ++pixelCount; 1266 if (m_cancel) { 1267 return; 1268 } 1182 1269 IJ.showProgress(pixelCount, m_height * m_width); 1183 1270 ChunkyPixel pixel = pixelIterator.next(); … … 1204 1291 } 1205 1292 } 1206 if ( 0 < pixelsToProcessCount) {1293 if (!m_cancel && 0 < pixelsToProcessCount) { 1207 1294 processPixels(dataColorizer, m_height, curveFitDataList.toArray(new ICurveFitData[0]), pixelList.toArray(new ChunkyPixel[0])); 1208 1295 } … … 1223 1310 for (int channel = 0; channel < m_channels; ++channel) { 1224 1311 if (channel != visibleChannel) { 1312 if (m_cancel) { 1313 return; 1314 } 1225 1315 if (wantFitted(bounds.x + x, bounds.y + y)) { 1226 1316 curveFitData = new CurveFitData(); … … 1248 1338 for (int y = 0; y < m_height; ++y) { 1249 1339 for (int x = 0; x < m_width; ++x) { 1340 if (m_cancel) { 1341 return; 1342 } 1250 1343 if (aboveThreshold(x, y)) { 1251 1344 curveFitData = new CurveFitData(); … … 1269 1362 //TODO break the fit up into chunks to lower memory requirements 1270 1363 ICurveFitData dataArray[] = curveFitDataList.toArray(new ICurveFitData[0]); 1364 if (m_cancel) { 1365 return; 1366 } 1271 1367 doFit(dataArray); 1272 1368 //TODO save results … … 1540 1636 if (0 < dataArray.length) { 1541 1637 //TODO need to be able to examine any fitted pixel; for now just show the last fitted pixel. // first! 1542 DecayGraph decayGraph = new DecayGraph(m_ timeRange, m_startBin, m_stopBin, dataArray[0]); //dataArray.length - 1]);1638 DecayGraph decayGraph = new DecayGraph(m_startBin, m_stopBin, m_timeBins, m_timeRange, dataArray[0]); //dataArray.length - 1]); 1543 1639 decayGraph.setStartStopListener(new MyListener()); 1544 JFrame window = new JFrame("SLIM"); 1545 JComponent component = decayGraph.getComponent(); 1546 window.getContentPane().add(component); 1547 window.setSize(450, 450); 1548 window.pack(); 1549 window.setVisible(true); 1640 JFrame frame = decayGraph.getFrame(); 1641 frame.setVisible(true); 1550 1642 } 1551 1643 … … 1787 1879 if (0 < dataArray.length) { 1788 1880 //TODO need to be able to examine any fitted pixel; for now just show the last fitted pixel. // first! 1789 DecayGraph decayGraph = new DecayGraph( curveFitter.getXInc(), m_startBin, m_stopBin, dataArray[0]); //dataArray.length - 1]);1881 DecayGraph decayGraph = new DecayGraph(m_startBin, m_stopBin, m_timeBins, curveFitter.getXInc(), dataArray[0]); //dataArray.length - 1]); 1790 1882 decayGraph.setStartStopListener(new MyListener()); 1791 JFrame window = new JFrame("SLIM"); 1792 JComponent component = decayGraph.getComponent(); 1793 window.getContentPane().add(component); 1794 window.setSize(450, 450); 1795 window.pack(); 1796 window.setVisible(true); 1883 JFrame frame = decayGraph.getFrame(); 1884 frame.setVisible(true); 1797 1885 } 1798 1886
Note: See TracChangeset
for help on using the changeset viewer.