Skip to content

Commit

Permalink
Incorporate ET suggestions for GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
tferr committed Oct 17, 2024
1 parent 0f37c8c commit fb41b15
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 13 deletions.
39 changes: 39 additions & 0 deletions src/main/java/sc/fiji/snt/BookmarkManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import ij.ImagePlus;
import ij.gui.ImageCanvas;
import ij.gui.Overlay;
import ij.gui.PointRoi;
import ij.gui.Roi;
import ij.plugin.frame.RoiManager;
Expand Down Expand Up @@ -206,6 +207,23 @@ private JPopupMenu importMenu() {
sntui.showStatus(model.getDataList().size() + " listed bookmarks ", true);
}
});
jmi = new JMenuItem("From Image Overlay");
jmi.setToolTipText("The Image Overlay is automatically saved in the image header of TIFF images");
menu.add(jmi);
jmi.addActionListener(e -> {
final ImagePlus imp = sntui.plugin.getImagePlus();
if (imp == null) {
sntui.guiUtils.error("No image is currently loaded.");
return;
}
if (imp.getOverlay() == null || imp.getOverlay().size() == 0) {
sntui.guiUtils.error("Image Overlay contains no ROIs.");
return;
}
load(imp.getOverlay().toArray());
sntui.showStatus(model.getDataList().size() + " listed bookmarks ", true);
recordCmd("load(snt.getInstance().getImagePlus().getOverlay().toArray())");
});
jmi = new JMenuItem("From ROI Manager");
menu.add(jmi);
jmi.addActionListener(e -> {
Expand Down Expand Up @@ -239,6 +257,22 @@ private JPopupMenu exportMenu() {
}
}
});
jmi = new JMenuItem("To Image Overlay");
jmi.setToolTipText("The Image Overlay is automatically saved in the image header of TIFF images");
menu.add(jmi);
jmi.addActionListener(e -> {
final ImagePlus imp = sntui.plugin.getImagePlus();
if (imp == null) {
sntui.guiUtils.error("No image is currently loaded.");
return;
}
table.clearSelection();
if (imp.getOverlay() == null) imp.setOverlay(new Overlay());
toOverlay(imp.getOverlay());
sntui.showStatus(model.getDataList().size() + " bookmarks exported to the Image Overlay", true);
recordCmd("clearSelection()");
recordCmd("toOverlay(snt.getInstance().getImagePlus().getOverlay())");
});
jmi = new JMenuItem("To ROI Manager");
menu.add(jmi);
jmi.addActionListener(e -> {
Expand Down Expand Up @@ -439,6 +473,11 @@ public List<Roi> getROIs(final boolean onlySelectedRows) {
return rois;
}

public void toOverlay(final Overlay overlay) {
for (final Roi roi : getROIs(table.getSelectedRows().length>0))
overlay.add(roi);
}

public void toRoiManager() {
RoiManager rm = RoiManager.getInstance2();
if (rm == null) rm = new RoiManager();
Expand Down
20 changes: 11 additions & 9 deletions src/main/java/sc/fiji/snt/SNTUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -380,11 +380,16 @@ public void windowClosing(final WindowEvent e) {
final GridBagConstraints dialogGbc = GuiUtils.defaultGbc();
add(statusPanel(), dialogGbc);
dialogGbc.gridy++;
add(new JLabel(" "), dialogGbc);
add(new JLabel(" "), dialogGbc); // tabbed pane top spacer
dialogGbc.gridy++;

add(tabbedPane, dialogGbc);
dialogGbc.gridy++;
dialogGbc.weighty = 1;
add(new JLabel(" "), dialogGbc); // tabbed pane bottom spacer
dialogGbc.gridy++;
dialogGbc.weighty = 0;
add(new JSeparator(SwingConstants.HORIZONTAL), dialogGbc);
dialogGbc.gridy++;
add(statusBar(), dialogGbc);
addFileDrop(this, guiUtils);
//registerCommandFinder(menuBar); // spurious addition if added here!?
Expand Down Expand Up @@ -3343,14 +3348,11 @@ private JPanel hideWindowsPanel() {
return hideWindowsPanel;
}

private JPanel statusBar() {
final JPanel statusBar = new JPanel();
statusBar.setLayout(new BoxLayout(statusBar, BoxLayout.X_AXIS));
private JLabel statusBar() {
statusBarText = GuiUtils.leftAlignedLabel("Ready to trace...", true);
statusBarText.setBorder(BorderFactory.createEmptyBorder(0, InternalUtils.MARGIN, InternalUtils.MARGIN / 2, 0));
statusBar.add(statusBarText);
statusBarText.setBorder(BorderFactory.createEmptyBorder(InternalUtils.MARGIN, InternalUtils.MARGIN, InternalUtils.MARGIN, 0));
refreshStatus();
statusBar.addMouseListener( new MouseAdapter() {
statusBarText.addMouseListener( new MouseAdapter() {
@Override
public void mousePressed(final MouseEvent e) {
if (e.getClickCount() == 2) {
Expand All @@ -3360,7 +3362,7 @@ public void mousePressed(final MouseEvent e) {
}
}
});
return statusBar;
return statusBarText;
}

boolean setFastMarchSearchEnabled(final boolean enable) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/sc/fiji/snt/gui/MeasureUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public boolean isCellEditable(final int row, final int column) {
// Enlarge default width of first column. Another option would be to have all
// columns to auto-fit at all times, e.g., https://stackoverflow.com/a/25570812.
// Maybe that would be better?
final String prototypeMetric = TreeStatistics.GRAPH_DIAMETER_ANGLE_XY;
final String prototypeMetric = TreeStatistics.N_BRANCH_NODES;
for (int i = 0; i < statsTable.getColumnCount(); ++i) {
final int width = SwingUtilities.computeStringWidth(statsTable.getFontMetrics(statsTable.getFont()),
(i == 0) ? prototypeMetric : MEAN);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/sc/fiji/snt/gui/SNTSearchableBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ private void addButton(final JPanel panel, final AbstractButton button) {

private JLabel statusLabel() {
_statusLabel = new JLabel(statusLabelPlaceholder);
_statusLabel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 0));
_statusLabel.addPropertyChangeListener("text", evt -> {
final String text = _statusLabel.getText();
if (text == null || text.isEmpty()) _statusLabel.setText(
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/sc/fiji/snt/viewer/Viewer3D.java
Original file line number Diff line number Diff line change
Expand Up @@ -3896,6 +3896,7 @@ public void actionPerformed(final ActionEvent e) {
fitToVisibleObjects(true, true);
return;
case LOG_TO_RECORDER:
openRecorder(false);
logSceneControls(true);
break;
case NONE:
Expand Down Expand Up @@ -3926,7 +3927,7 @@ public void actionPerformed(final ActionEvent e) {
keyController.showHelp(false);
return;
case RECORDER:
openRecorder();
openRecorder(true);
return;
case SNAPSHOT_DISK:
keyController.saveScreenshot();
Expand Down Expand Up @@ -3982,9 +3983,9 @@ private void showPanelAsNeeded() {
toggleControlPanel(); // e.g, if action called via cmdFinder
}

private void openRecorder() {
private void openRecorder(final boolean warnIfOpen) {
if (getRecorder(false) != null) {
guiUtils.error("Script Recorder is already open.");
if (warnIfOpen) guiUtils.error("Script Recorder is already open.");
return;
}
final StringBuilder sb = new StringBuilder();
Expand Down Expand Up @@ -5948,6 +5949,8 @@ public AllenCCFNavigator() {
tree.setClickInCheckBoxOnly(false);
searchableBar = new SNTSearchableBar(new TreeSearchable(tree));
searchableBar.setStatusLabelPlaceholder("CCF v"+ AllenUtils.VERSION);
searchableBar.setHighlightAll(false);
searchableBar.setShowMatchCount(true);
searchableBar.setVisibleButtons(
SNTSearchableBar.SHOW_NAVIGATION | SNTSearchableBar.SHOW_HIGHLIGHTS |
SNTSearchableBar.SHOW_SEARCH_OPTIONS | SNTSearchableBar.SHOW_STATUS);
Expand Down

0 comments on commit fb41b15

Please sign in to comment.