Skip to content

Commit

Permalink
update menu items for changing fading/sliding window/contrast
Browse files Browse the repository at this point in the history
when different modes are enabled
  • Loading branch information
Tobi Delbruck authored and Tobi Delbruck committed Mar 18, 2024
1 parent 415052a commit 43c3975
Showing 1 changed file with 33 additions and 6 deletions.
39 changes: 33 additions & 6 deletions src/net/sf/jaer/graphics/AEChipRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ public AEChipRenderer(AEChip chip) {
}
setColorScale(prefs.getInt("colorScale", 2)); // tobi changed default to 2 events full scale Apr 2013
slidingWindowPacketFifo = new SlidingWindowEventPacketFifo();
updateContrastActions();

colorModeMenu = contructColorModeMenu();
getSupport().addPropertyChangeListener(this);
Expand Down Expand Up @@ -727,10 +728,10 @@ public synchronized void setColorMode(ColorMode colorMode) {
public void showRenderingModeTextOnAeViewer() {
if (chip.getAeViewer() != null) {
String s = String.format("Color Mode: %s", colorMode.toString());
if(fadingEnabled){
s+="; "+getFadingDescription();
}else if(slidingWindowEnabled){
s+="; "+getSlidingWindowDescription();
if (fadingEnabled) {
s += "; " + getFadingDescription();
} else if (slidingWindowEnabled) {
s += "; " + getSlidingWindowDescription();
}
chip.getAeViewer().showActionText(s);
}
Expand Down Expand Up @@ -889,6 +890,7 @@ public void setFadingEnabled(boolean fadingEnabled) {
if (fadingEnabled && slidingWindowEnabled) {
toggleSlidingWindowAction.actionPerformed(null);
}
updateContrastActions();
}

/**
Expand Down Expand Up @@ -917,6 +919,7 @@ synchronized public void setSlidingWindowEnabled(boolean slidingWindowEnabled) {
toggleFadingAction.actionPerformed(null);
}
slidingWindowPacketFifo.clear();
updateContrastActions();
}

/**
Expand Down Expand Up @@ -987,7 +990,7 @@ private String getFadingDescription() {
}

private String getSlidingWindowDescription() {
float ms=(chip.getAeViewer().getAePlayer().getTimesliceUs()/1e6f)*getFadingOrSlidingFrames();
float ms = (chip.getAeViewer().getAePlayer().getTimesliceUs() / 1e6f) * getFadingOrSlidingFrames();
return String.format("Sliding window with %d frames (%ss)", getFadingOrSlidingFrames(), fmt.format(ms));
}

Expand Down Expand Up @@ -1030,6 +1033,19 @@ protected final float fadeToGray(float v, float fadeBy, float gray) {
return v;
}

private void updateContrastActions() {
if (!isFadingEnabled() && !isSlidingWindowEnabled()) {
increaseContrastAction.setName("Increase event contrast");
decreaseContrastAction.setName("Decrease event contrast");
} else if (isFadingEnabled()) {
increaseContrastAction.setName("Lengthen fading");
decreaseContrastAction.setName("Shorten fading");
} else if (isSlidingWindowEnabled()) {
increaseContrastAction.setName("Lengthen sliding window");
decreaseContrastAction.setName("Shorten sliding window");
}
}

abstract public class MyAction extends AbstractAction {

protected final String path = "/net/sf/jaer/graphics/icons/";
Expand Down Expand Up @@ -1061,6 +1077,15 @@ protected void showAction(String s) {
chip.getAeViewer().showActionText(s);
}
}

/**
* Sets the name, which is the menu item string
*
* @param name
*/
public void setName(String name) {
putValue(Action.NAME, name);
}
}

final public class ToggleAccumulation extends MyAction {
Expand Down Expand Up @@ -1094,7 +1119,8 @@ final public class ToggleFadingAction extends MyAction {

public ToggleFadingAction() {
super("Fade", "<html>Fade away display of past frames according to color scale."
+ "<p>To change the amount of fading,<br> increase or decrease contrast with the UP and DOWN arrow keys.");
+ "<p>To change the amount of fading with the UP and DOWN arrow keys."
+ "<p>Ajust contrast of events by disabling <i>Fade</i> mode and using UP and DOWN arrow keys.");
putValue(ACCELERATOR_KEY, javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, java.awt.event.InputEvent.CTRL_DOWN_MASK));
putValue(Action.SELECTED_KEY, isFadingEnabled());
}
Expand All @@ -1113,6 +1139,7 @@ protected void showAction() {
} else {
float fadingTauS = computeFadingTauS();
showAction(getFadingDescription());
updateContrastActions();
}
}

Expand Down

0 comments on commit 43c3975

Please sign in to comment.