use of sc.fiji.labkit.ui.labeling.LabelingSerializer in project labkit-ui by juglab.
the class InitialLabeling method openLabeling.
private static Labeling openLabeling(InputImage inputImage, Context context, String filename) throws IOException {
Labeling open = new LabelingSerializer(context).open(filename);
fixAxes(open, inputImage);
return open;
}
use of sc.fiji.labkit.ui.labeling.LabelingSerializer in project labkit-ui by juglab.
the class MeasureConnectedComponents method run.
@Override
public void run() {
try {
Labeling labeling = new LabelingSerializer(context).open(labelingFile.getAbsolutePath());
table = createTable(labeling, calibratedSize);
} catch (IOException e) {
e.printStackTrace();
}
}
use of sc.fiji.labkit.ui.labeling.LabelingSerializer in project labkit-ui by juglab.
the class LabeledImage method save.
/**
* Writes the labeling (if modified) to {@link #labelingFile}.
*/
public void save() {
if (!modified.get())
return;
if (imageLabelingModel == null) {
try {
Files.move(Paths.get(modifiedLabelingFile), Paths.get(labelingFile), StandardCopyOption.REPLACE_EXISTING);
storedIn.set(labelingFile);
} catch (IOException e) {
e.printStackTrace();
}
} else {
try {
new LabelingSerializer(context).save(imageLabelingModel.labeling().get(), labelingFile);
Files.deleteIfExists(Paths.get(modifiedLabelingFile));
storedIn.set(labelingFile);
} catch (IOException e) {
e.printStackTrace();
}
}
}
use of sc.fiji.labkit.ui.labeling.LabelingSerializer in project labkit-ui by juglab.
the class LabeledImage method close.
/**
* Closes the opened {@link ImageLabelingModel}. Changes to the labeling are
* saved to a temporary file.
*/
public void close() {
if (imageLabelingModel == null)
return;
imageLabelingModel.dataChangedNotifier().removeListener(onLabelingChangedConsumer);
imageLabelingModel.labeling().notifier().removeListener(onLabelingChanged);
if (storedIn.get() == null) {
try {
new LabelingSerializer(context).save(imageLabelingModel.labeling().get(), modifiedLabelingFile);
storedIn.set(modifiedLabelingFile);
imageLabelingModel = null;
} catch (IOException e) {
e.printStackTrace();
}
} else
imageLabelingModel = null;
}
Aggregations