use of sc.fiji.labkit.ui.labeling.Label in project labkit-ui by juglab.
the class AddLabelingIoAction method addLabel.
// TODO: move to package Labeling
private void addLabel(Labeling labeling, Label label, IterableRegion<BitType> region) {
String newLabelName = suggestName(label.name(), labeling.getLabels().stream().map(Label::name).collect(Collectors.toList()));
if (newLabelName == null)
return;
Label newLabel = labeling.addLabel(newLabelName);
Cursor<Void> cursor = region.cursor();
RandomAccess<LabelingType<Label>> ra = labeling.randomAccess();
while (cursor.hasNext()) {
cursor.fwd();
ra.setPosition(cursor);
ra.get().add(newLabel);
}
}
use of sc.fiji.labkit.ui.labeling.Label in project labkit-ui by juglab.
the class ChangeLabel method actionPerformed.
@Override
public void actionPerformed(ActionEvent actionEvent) {
List<Label> labels = model.labeling().get().getLabels();
Label nextLabel = next(labels, model.selectedLabel().get());
if (nextLabel != null)
model.selectedLabel().set(nextLabel);
}
use of sc.fiji.labkit.ui.labeling.Label in project labkit-ui by juglab.
the class ColoredLabelsModel method addLabel.
public void addLabel() {
Holder<Labeling> holder = model.labeling();
Labeling labeling = holder.get();
String newName = suggestName(labeling.getLabels().stream().map(Label::name).collect(Collectors.toList()));
if (newName == null)
return;
Label newLabel = labeling.addLabel(newName);
model.selectedLabel().set(newLabel);
fireLabelsChanged();
}
use of sc.fiji.labkit.ui.labeling.Label in project labkit-ui by juglab.
the class SelectLabelController method nextLabel.
private Optional<Label> nextLabel(LabelingType<Label> labels, Label label) {
List<Label> visibleLabels = labels.stream().filter(Label::isVisible).collect(Collectors.toList());
visibleLabels.sort(Comparator.comparing(model.labeling().get().getLabels()::indexOf));
if (visibleLabels.contains(label)) {
int index = visibleLabels.indexOf(label);
return Optional.of(visibleLabels.get((index + 1) % visibleLabels.size()));
}
return visibleLabels.stream().findFirst();
}
use of sc.fiji.labkit.ui.labeling.Label in project labkit-ui by juglab.
the class ImageLabelingModel method labelingReplacedEvent.
private void labelingReplacedEvent() {
updateLabelTransform();
Label selectedLabel = selectedLabelHolder.get();
List<Label> labels = labelingHolder.get().getLabels();
if (!labels.contains(selectedLabel))
selectedLabelHolder.set(labels.isEmpty() ? null : labels.get(0));
}
Aggregations