Search in sources :

Example 1 with LabelingSerializer

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;
}
Also used : LabelingSerializer(sc.fiji.labkit.ui.labeling.LabelingSerializer) Labeling(sc.fiji.labkit.ui.labeling.Labeling)

Example 2 with LabelingSerializer

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();
    }
}
Also used : LabelingSerializer(sc.fiji.labkit.ui.labeling.LabelingSerializer) IOException(java.io.IOException) Labeling(sc.fiji.labkit.ui.labeling.Labeling)

Example 3 with LabelingSerializer

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();
        }
    }
}
Also used : LabelingSerializer(sc.fiji.labkit.ui.labeling.LabelingSerializer) IOException(java.io.IOException)

Example 4 with LabelingSerializer

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;
}
Also used : LabelingSerializer(sc.fiji.labkit.ui.labeling.LabelingSerializer) IOException(java.io.IOException)

Aggregations

LabelingSerializer (sc.fiji.labkit.ui.labeling.LabelingSerializer)4 IOException (java.io.IOException)3 Labeling (sc.fiji.labkit.ui.labeling.Labeling)2