use of sc.fiji.labkit.ui.utils.progress.SwingProgressWriter in project labkit-ui by juglab.
the class CustomizedSegmentationComponentDemo method onSaveResultsClicked.
private void onSaveResultsClicked(ActionEvent actionEvent) {
SegmentationItem selectedSegmenter = segmentationModel.segmenterList().selectedSegmenter().get();
if (selectedSegmenter == null || !selectedSegmenter.isTrained()) {
JOptionPane.showMessageDialog(null, "Please select a segmentation algoritm and train it");
return;
}
ImageLabelingModel imageLabeling = segmentationModel.imageLabelingModel();
RandomAccessibleInterval<ShortType> segmentation = selectedSegmenter.results(imageLabeling).segmentation();
ParallelUtils.runInOtherThread(() -> {
ParallelUtils.populateCachedImg(segmentation, new SwingProgressWriter(null, "Calculate Entire Segmentation"));
JOptionPane.showMessageDialog(null, "Calculation completed");
BdvFunctions.show(segmentation, "Segmentation").setDisplayRange(0, 1);
});
}
use of sc.fiji.labkit.ui.utils.progress.SwingProgressWriter in project labkit-ui by juglab.
the class SwingProgressWriterDemo method main.
public static void main(String... args) throws InterruptedException {
ProgressWriter progressWriter = new SwingProgressWriter(null, "Swing Progress Writer Demo");
for (double progress = 0; progress < 1.0; progress += 0.01) {
if (progress > 0.5)
progressWriter.out().println("half done");
progressWriter.setProgress(progress);
Thread.sleep(50);
}
progressWriter.setProgress(1.0);
}
use of sc.fiji.labkit.ui.utils.progress.SwingProgressWriter in project labkit-ui by juglab.
the class HDF5SaverDemo method main.
public static <T extends RealType<T>> void main(String... args) throws SpimDataException, IOException {
String outputFilename = File.createTempFile("output-", ".xml").getAbsolutePath();
RandomAccessibleInterval<T> image = (RandomAccessibleInterval<T>) VirtualStackAdapter.wrap(new ImagePlus("https://imagej.nih.gov/ij/images/t1-head.zip"));
image = Views.interval(Views.extendPeriodic(image), new FinalInterval(1000, 1000, 1000));
RandomAccessibleInterval<UnsignedShortType> result = treshold(image);
HDF5Saver saver = new HDF5Saver(result, outputFilename);
saver.setProgressWriter(new SwingProgressWriter(null, "Save Huge Image"));
saver.writeAll();
}
use of sc.fiji.labkit.ui.utils.progress.SwingProgressWriter in project labkit-ui by juglab.
the class ParallelUtilsDemo method main.
public static void main(String... args) {
ProgressWriter progress = new SwingProgressWriter(null, "In progress");
CellLoader<ShortType> loader = cell -> Thread.sleep(1000);
Img<ShortType> img = new DiskCachedCellImgFactory<>(new ShortType()).create(new long[] { 40, 40, 40 }, loader);
ParallelUtils.populateCachedImg(img, progress);
System.out.println("done");
}
use of sc.fiji.labkit.ui.utils.progress.SwingProgressWriter in project labkit-ui by juglab.
the class TrainClassifier method train.
private static void train(List<Pair<ImgPlus<?>, Labeling>> trainingData, SegmentationItem item) {
SwingProgressWriter progressWriter = new SwingProgressWriter(null, "Training in Progress");
progressWriter.setVisible(true);
progressWriter.setProgressBarVisible(false);
progressWriter.setDetailsVisible(false);
try {
item.train(trainingData);
} catch (CancellationException e) {
progressWriter.setVisible(false);
JOptionPane.showMessageDialog(null, e.getMessage(), "Training Cancelled", JOptionPane.PLAIN_MESSAGE);
} catch (Throwable e) {
progressWriter.setVisible(false);
JOptionPane.showMessageDialog(null, e.toString(), "Training Failed", JOptionPane.WARNING_MESSAGE);
e.printStackTrace();
} finally {
progressWriter.setVisible(false);
}
}
Aggregations