Skip to content

Commit

Permalink
allow modifying the icon from the prompts provider
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed May 31, 2024
1 parent ad494e8 commit 717d002
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/main/java/ai/nets/samj/ij/ui/IJ1PromptsProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,18 @@ public class IJ1PromptsProvider implements PromptsResultsDisplay, MouseListener,
* All the points being collected that reference the background (ctrl + alt)
*/
private List<Localizable> collecteNegPoints = new ArrayList<Localizable>();
/**
* Consumer to alter the state of the Rectangle ROI button
*/
private BooleanConsumer rectIconConsumer;
/**
* Consumer to alter the state of the Points ROI button
*/
private BooleanConsumer pointsIconConsumer;
/**
* Consumer to alter the state of the Freeline ROI button
*/
private BooleanConsumer freelineIconConsumer;
/**
* The number of words per line in the error message dialogs
*/
Expand Down Expand Up @@ -345,6 +357,19 @@ private void deRegisterListeners() {
*/
public void mouseReleased(MouseEvent e) {
if (!this.isRect && !this.isPoints && !this.isFreehand) return;
if (this.isRect && !IJ.getToolName().equals("rectangle")) {
this.rectIconConsumer.accept(false);
this.isRect = false;
return;
} else if (this.isPoints && !IJ.getToolName().equals("point") && !IJ.getToolName().equals("multipoint")) {
this.isPoints = false;
this.pointsIconConsumer.accept(false);
return;
} else if (this.isFreehand && !IJ.getToolName().equals("freeline")) {
this.freelineIconConsumer.accept(false);
this.isFreehand = false;
return;
}
final Roi roi = activeImage.getRoi();
if (roi == null) {
//TODO log.info("Image window: There's no ROI...");
Expand Down Expand Up @@ -614,6 +639,21 @@ public void improveExistingMask(File mask) {
throw new IllegalArgumentException("The file selected does not correspond to an image.");
}
}

@Override
public void setRectIconConsumer(BooleanConsumer consumer) {
this.rectIconConsumer = consumer;
}

@Override
public void setPointsIconConsumer(BooleanConsumer consumer) {
this.pointsIconConsumer = consumer;
}

@Override
public void setFreelineIconConsumer(BooleanConsumer consumer) {
this.freelineIconConsumer = consumer;
}

// ===== unused events =====
@Override
Expand Down

0 comments on commit 717d002

Please sign in to comment.