
timeBench.ui.actions.ToggleFisheyeAction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of timebench Show documentation
Show all versions of timebench Show documentation
TimeBench, a flexible, easy-to-use, and reusable software library written in Java that provides foundational data structures and algorithms for time- oriented data in Visual Analytics.
The newest version!
package timeBench.ui.actions;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import javax.swing.AbstractAction;
import javax.swing.KeyStroke;
import timeBench.action.layout.timescale.FisheyeTimeScale;
/**
* Toggles the fisheye distortion of a given {@link FisheyeTimeScale}.
*
* @author peterw
*
*/
public class ToggleFisheyeAction extends AbstractAction {
private static final long serialVersionUID = 89670022822876252L;
public static final String SELECTED = "selected";
private FisheyeTimeScale timeScale;
public ToggleFisheyeAction() {
putValue(NAME, "Fisheye");
putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_F, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()
| KeyEvent.SHIFT_DOWN_MASK));
}
public void actionPerformed(ActionEvent e) {
if (getTimeScale() != null) {
getTimeScale().setFisheyeEnabled(!getTimeScale().isFisheyeEnabled());
firePropertyChange(SELECTED, !isSelected(), isSelected());
}
}
public FisheyeTimeScale getTimeScale() {
return timeScale;
}
public void setTimeScale(FisheyeTimeScale timeScale) {
boolean oldSelected = getTimeScale() != null && getTimeScale().isFisheyeEnabled();
this.timeScale = timeScale;
firePropertyChange(SELECTED, oldSelected, isSelected());
}
public boolean isSelected() {
if (getTimeScale() != null) {
return getTimeScale().isFisheyeEnabled();
}
return false;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy