/** * Extract the plane at the different positions and concatenate the Dataset * * @param newValue * @return */ private CallbackTask<Void, Void> createSampleImage(File newValue) { return new CallbackTask<Void, Void>() .run( () -> { try { File fileTarget = workflowModel.getMapImages().get(newValue); Dataset datasetTarget = (Dataset) iOService.open(fileTarget.getAbsolutePath()); ImageDisplay imageDisplayTarget = new SilentImageDisplay(); context.inject(imageDisplayTarget); imageDisplayTarget.display(datasetTarget); selectPosition( imageDisplayTarget, workflowModel.getPositionLeft(), workflowModel.getPositionRight(), imageDisplayPaneRight); Dataset datasetSource = (Dataset) iOService.open(newValue.getAbsolutePath()); ImageDisplay imageDisplaySource = new SilentImageDisplay(); context.inject(imageDisplaySource); imageDisplaySource.display(datasetSource); selectPosition( imageDisplaySource, workflowModel.getPositionLeft(), workflowModel.getPositionRight(), imageDisplayPaneLeft); } catch (IOException ex) { Logger.getLogger(ProcessWorkflow.class.getName()).log(Level.SEVERE, null, ex); } }) .submit(loadingScreenService); }
/** Add the items and set the listener on change */ public void bindListView() { listViewItems.getItems().addAll(workflowModel.getMapImages().keySet()); listViewItems .getSelectionModel() .selectedItemProperty() .addListener( (ObservableValue<? extends File> observable, File oldValue, File newValue) -> { createSampleImage(newValue).start(); }); }
/** Compute the dataset */ public void process() { List<File> files = workflowModel.getFiles(); listViewItems.getItems().clear(); workflowModel.getMapImages().clear(); System.gc(); workflowModel .transformeImages(files, directory.getAbsolutePath()) .thenRunnable( () -> { files.sort( (File o1, File o2) -> { return o1.getName().compareTo(o2.getName()); }); listViewItems.getItems().addAll(files); }) .start(); }