Skip to content

Commit

Permalink
point toggle with g (must click on image first)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeynep committed Feb 12, 2024
1 parent b129a4c commit 63c2aa7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
9 changes: 2 additions & 7 deletions CoordinateExporter/src/main/java/File_Uploader.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@ public void actionPerformed(ActionEvent e) {
panel.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_TAB) { //tab to toggle selected ROI
RoiManager coords = RoiManager.getRoiManager();
coords.select(img, coords.getSelectedIndex() == 0 ? 1 : 0);
}

if (e.getKeyCode() == KeyEvent.VK_Q && ((e.getModifiersEx() & InputEvent.CTRL_DOWN_MASK) != 0)
&& ((e.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK) != 0)) {
openForExport(); //ctrl + shift + Q to open export
Expand All @@ -90,6 +85,7 @@ public void keyPressed(KeyEvent e) {
}

public void openForImport() {
log.setText("Log: Importing...");
imported.setCurrentDirectory(new File(System.getProperty("user.home")));
imported.setFileFilter(new FileNameExtensionFilter("JSON files", "json"));
int returnValue = imported.showOpenDialog(null);
Expand All @@ -99,11 +95,11 @@ public void openForImport() {
String filePath = file.getAbsolutePath();
coordControl.importCoords(filePath);
importText.setText("Imported: " + filePath);
log.setText("Log: Importing...");
}
}

public void openForExport() {
log.setText("Log: Exporting...");
exported.setCurrentDirectory(new File(System.getProperty("user.home")));
exported.setFileFilter(new FileNameExtensionFilter("JSON files", "json"));
int returnValue = exported.showOpenDialog(null);
Expand All @@ -114,7 +110,6 @@ public void openForExport() {
try {
coordControl.exportCoords(filePath);
exportText.setText("Exported: " + filePath);
log.setText("Log: Exporting...");
} catch (IOException ex) {
throw new RuntimeException(ex);
}
Expand Down
9 changes: 6 additions & 3 deletions CoordinateExporter/src/main/java/PointSwapListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

/**
* Listens for a double click, and will search out the nearest point within a certain range to swap
* its ROI between the "valid" and "invalid" ROIs.
* its ROI between the "valid" and "invalid" ROIs, or will swap the selected ROI.
*/
public class PointSwapListener extends PointListener implements KeyListener {

Expand All @@ -27,6 +27,7 @@ public PointSwapListener(JLabel log) {

@Override
public void mouseClicked(MouseEvent e) {
KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
if (qKeyPressed && this.toString().equals(address)) {
changeClosestPoint(e.getX(), e.getY());
}
Expand Down Expand Up @@ -99,8 +100,10 @@ public void changeClosestPoint(int x, int y) {
}

@Override
public void keyTyped(KeyEvent e) {
//NULL
public void keyTyped(KeyEvent e) { //Putting this here since it's just a single key press
if ((e.getKeyChar() == 'g' || e.getKeyChar() == 'G') && this.toString().equals(address)) {
roiManager.select(img, roiManager.getSelectedIndex() == 0 ? 1 : 0);
}
}

@Override
Expand Down

0 comments on commit 63c2aa7

Please sign in to comment.