Skip to content

Commit a684b0c

Browse files
committed
Curation assistant: Fix navivationTo() on display canvas...
... while at it, cull dead code
1 parent 7e7bb28 commit a684b0c

3 files changed

Lines changed: 22 additions & 32 deletions

File tree

‎src/main/java/sc/fiji/snt/BookmarkManager.java‎

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,7 +1219,7 @@ public Component getTableCellRendererComponent(final JTable table, final Object
12191219
/**
12201220
* Editor for the Tag/Color column - shows color chooser on click
12211221
*/
1222-
class ColorCellEditor extends AbstractCellEditor implements javax.swing.table.TableCellEditor {
1222+
static class ColorCellEditor extends AbstractCellEditor implements javax.swing.table.TableCellEditor {
12231223
private final JButton editorButton;
12241224
private final JPopupMenu colorChooserPopMenu;
12251225
private Color currentColor;
@@ -1268,21 +1268,6 @@ static String getColorName(Color color) {
12681268
});
12691269
}
12701270

1271-
private Color getCustomColor(final Color initialColor) {
1272-
final Color[] result = new Color[1];// holder for result
1273-
final JColorChooser chooser = GuiUtils.colorChooser(initialColor);
1274-
final JDialog dialog = JColorChooser.createDialog(
1275-
SwingUtilities.getWindowAncestor(BookmarkTable.this),// parent
1276-
"Choose Tag Color", // title
1277-
true, // modal
1278-
chooser, // the chooser instance
1279-
e -> result[0] = chooser.getColor(), // OK button listener
1280-
e -> result[0] = null // Cancel button listener
1281-
);
1282-
dialog.setVisible(true);
1283-
return result[0];
1284-
}
1285-
12861271
@Override
12871272
public Object getCellEditorValue() {
12881273
return currentColor;
@@ -1350,10 +1335,6 @@ void setDataList(final List<Bookmark> dataList) {
13501335
fireTableDataChanged();
13511336
}
13521337

1353-
String[] getHeader() {
1354-
return HEADER;
1355-
}
1356-
13571338
String getUniqueLabel(final String candidate) {
13581339
final String base = (candidate == null || candidate.isBlank())
13591340
? (bvvMode ? "Marker" : String.format("Bookmark %02d", 1 + getDataList().size()))

‎src/main/java/sc/fiji/snt/SNT.java‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,9 +1615,8 @@ else if (editing && !editingPath.isEditableNodeLocked()) {
16151615
if (editing && editingPath.getEditableNodeIndex() > -1) {
16161616
statusMessage = "Node " + editingPath.getEditableNodeIndex() + ", ";
16171617
}
1618-
statusMessage += "World: (" + SNTUtils.formatDouble(ix * x_spacing, 2) + ", " +
1619-
SNTUtils.formatDouble(iy * y_spacing, 2) + ", " + SNTUtils.formatDouble(iz *
1620-
z_spacing, 2) + ");";
1618+
1619+
statusMessage += String.format("World: (%.2f, %.2f, %.2f);", ix * x_spacing, iy * y_spacing, iz * z_spacing);
16211620
if (labelData != null) {
16221621
final byte b = labelData[iz][iy * width + ix];
16231622
final int m = b & 0xFF;

‎src/main/java/sc/fiji/snt/util/ImpUtils.java‎

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -547,15 +547,25 @@ public static void zoomTo(final ImagePlus imp, final double zoomMagnification, f
547547
public static void zoomTo(final ImagePlus imp, final double zoomMagnification,
548548
final PointInImage location, final Path path) {
549549
if (imp == null || location == null) return;
550-
final Calibration cal = imp.getCalibration();
551-
final PointInCanvas offset = (path != null)
552-
? path.getCanvasOffset()
553-
: new PointInCanvas(0, 0, 0);
554-
final int px = (int) (cal.getRawX(location.x) + offset.x);
555-
final int py = (int) (cal.getRawY(location.y) + offset.y);
556-
final int pz = (int) (cal.getRawZ(location.z) + offset.z);
557-
imp.setPosition(imp.getC(), pz + 1, imp.getT());
558-
zoomTo(imp, zoomMagnification, px, py);
550+
if (location.onPath != null) {
551+
zoomToPointInCanvas(imp, zoomMagnification, location.getUnscaledPoint());
552+
} else if (path != null) {
553+
final PointInImage loc = location.clone();
554+
loc.onPath = path;
555+
zoomToPointInCanvas(imp, zoomMagnification, loc.getUnscaledPoint());
556+
} else {
557+
final Calibration cal = imp.getCalibration();
558+
final int px = (int) (cal.getRawX(location.x));
559+
final int py = (int) (cal.getRawY(location.y));
560+
final int pz = (int) (cal.getRawZ(location.z));
561+
imp.setPosition(imp.getC(), pz + 1, imp.getT());
562+
zoomTo(imp, zoomMagnification, px, py);
563+
}
564+
}
565+
566+
private static void zoomToPointInCanvas(final ImagePlus imp, final double zoomMagnification, final PointInCanvas pic) {
567+
imp.setPosition(imp.getC(), (int) pic.z + 1, imp.getT());
568+
zoomTo(imp, zoomMagnification, (int) pic.x, (int) pic.y);
559569
}
560570

561571
/**

0 commit comments

Comments
 (0)