diff --git a/src/net/sf/jaer/graphics/AEChipRenderer.java b/src/net/sf/jaer/graphics/AEChipRenderer.java index e994628d2..4b5d3a4fb 100644 --- a/src/net/sf/jaer/graphics/AEChipRenderer.java +++ b/src/net/sf/jaer/graphics/AEChipRenderer.java @@ -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); @@ -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); } @@ -889,6 +890,7 @@ public void setFadingEnabled(boolean fadingEnabled) { if (fadingEnabled && slidingWindowEnabled) { toggleSlidingWindowAction.actionPerformed(null); } + updateContrastActions(); } /** @@ -917,6 +919,7 @@ synchronized public void setSlidingWindowEnabled(boolean slidingWindowEnabled) { toggleFadingAction.actionPerformed(null); } slidingWindowPacketFifo.clear(); + updateContrastActions(); } /** @@ -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)); } @@ -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/"; @@ -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 { @@ -1094,7 +1119,8 @@ final public class ToggleFadingAction extends MyAction { public ToggleFadingAction() { super("Fade", "Fade away display of past frames according to color scale." - + "

To change the amount of fading,
increase or decrease contrast with the UP and DOWN arrow keys."); + + "

To change the amount of fading with the UP and DOWN arrow keys." + + "

Ajust contrast of events by disabling Fade 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()); } @@ -1113,6 +1139,7 @@ protected void showAction() { } else { float fadingTauS = computeFadingTauS(); showAction(getFadingDescription()); + updateContrastActions(); } }