use of sc.fiji.labkit.ui.labeling.Label in project labkit-ui by juglab.
the class ColoredLabelsModel method moveLabel.
public void moveLabel(Label label, int movement) {
Labeling labeling = model.labeling().get();
List<Label> oldOrder = new ArrayList<>(labeling.getLabels());
Function<Label, Double> priority = l -> oldOrder.indexOf(l) + (l == label ? movement + 0.5 * Math.signum(movement) : 0.0);
labeling.setLabelOrder(Comparator.comparing(priority));
fireLabelsChanged();
}
use of sc.fiji.labkit.ui.labeling.Label in project labkit-ui by juglab.
the class BrushCursor method drawOverlays.
@Override
public void drawOverlays(final Graphics g) {
if (visible) {
final Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setComposite(AlphaComposite.SrcOver);
Label label = model.selectedLabel().get();
if (label != null) {
Color color = new Color(label.color().get());
String title = label.name();
if (fontVisible)
drawTitle(g2d, color, title);
drawCircle(g2d, color);
}
}
}
use of sc.fiji.labkit.ui.labeling.Label in project labkit-ui by juglab.
the class LabelBrushController method makeLabelVisible.
private void makeLabelVisible() {
Label label = model.selectedLabel().get();
if (label == null)
return;
if (label.isVisible() && model.labelingVisibility().get())
return;
label.setVisible(true);
model.labelingVisibility().set(true);
model.labeling().notifier().notifyListeners();
}
use of sc.fiji.labkit.ui.labeling.Label in project labkit-ui by juglab.
the class SelectLabelController method click.
private void click(int x, int y) {
RealPoint globalPosition = new RealPoint(3);
viewer.displayToGlobalCoordinates(x, y, globalPosition);
model.labelTransformation().applyInverse(globalPosition, globalPosition);
globalPosition.move(PIXEL_CENTER_OFFSET);
RandomAccess<LabelingType<Label>> ra = labeling().randomAccess();
ra.setPosition(roundAndReduceDimension(globalPosition, ra.numDimensions()));
Optional<Label> label = nextLabel(ra.get(), model.selectedLabel().get());
label.ifPresent(model.selectedLabel()::set);
}
use of sc.fiji.labkit.ui.labeling.Label in project labkit-ui by juglab.
the class FloodFillTest method test3.
@Test
public void test3() {
Labeling labeling = Labeling.fromImgLabeling(exampleImgLabeling());
final Point seed = new Point(2, 2);
Label a = labeling.getLabel("a");
Label b = labeling.getLabel("b");
Label c = labeling.getLabel("c");
c.setVisible(false);
Label ab = labeling.addLabel("ab");
final Consumer<Set<Label>> operation = l -> l.add(ab);
FloodFill.doFloodFillOnActiveLabels((RandomAccessibleInterval) labeling, seed, operation);
assertLabelEqualsInterval(labeling, intervalA, a);
assertLabelEqualsInterval(labeling, intervalB, b);
assertLabelEqualsInterval(labeling, intervalC, c);
assertLabelEqualsInterval(labeling, intervalAintersectB, ab);
}
Aggregations