public void fineTuneNewBestResult( RegistrationResult result ) { if( progressWindow != null ) progressWindow.offerNewResult( result ); }
void updateDistance(double newDistance,String units) { distanceMoved.setText( "Moved: "+scoreFormatter.format(newDistance)+" "+units ); pack(); }
public synchronized void offerNewResult( RegistrationResult r ) { long timeCurrently = System.currentTimeMillis(); long timeSinceLastUpdate = timeCurrently - timeLastProgressUpdate; if( (bestSoFar == null) || (r.score < bestSoFar.score) ) { bestSoFar = r; updateLowestScore( r.score ); notShowingBest = true; System.out.println("Found a better one: "+r.score); if( (timeLastProgressUpdate == 0) || timeSinceLastUpdate > 1000 ) { System.out.println("Yeah, it's been "+(timeSinceLastUpdate / 1000.0)+ "seconds."); showBest(); timeLastProgressUpdate = timeCurrently; } } // But that might miss one, so check every 5 seconds // that the currently displayed on is the best. if( timeSinceLastUpdate > 5000 && notShowingBest ) { timeLastProgressUpdate = timeCurrently; showBest(); } }
public ProgressWindow(ImagePlus imp, ImageCanvas ic, NamePoints plugin) { super( imp, ic ); ImageCanvas icAfter = getCanvas(); if( (icAfter != null) && (ic instanceof ProgressCanvas) ) progressCanvas = (ProgressCanvas)ic; useThis.addActionListener(this); cancel.addActionListener(this); add( useThis ); add( cancel ); add( lowestScore ); add( triedSoFar ); add( moveToRefinedPoint ); add( moveToOriginalPoint ); add( distanceMoved ); pack(); width = imp.getWidth(); height = imp.getHeight();
false ); updateDistance(r.pointMoved,plugin.templateUnits); pack(); repaint();
ProgressCanvas progressCanvas = new ProgressCanvas( progressImagePlus ); progressWindow = new ProgressWindow( progressImagePlus, progressCanvas, this );
@Override public void actionPerformed( ActionEvent e ) { Object source = e.getSource(); if( source == useThis || source == cancel ) { cancel.setEnabled(false); useThis.setEnabled(false); if (source == useThis) { useTheResult = true; triedSoFar.setText("Finishing..."); plugin.stopFineTuneThreads(); } else if (source == cancel) { useTheResult = false; triedSoFar.setText("Cancelling..."); plugin.stopFineTuneThreads(); } close(); } else if (source == moveToOriginalPoint ) { imp.setSlice( progressCanvas.fixed_z + 1 ); } else if (source == moveToRefinedPoint ) { imp.setSlice( progressCanvas.transformed_z + 1 ); } }
progressWindow.offerNewResult( result ); updateBest( result );