All Downloads are FREE. Search and download functionalities are using the official Maven repository.

timeBench.ui.actions.RangePanAction Maven / Gradle / Ivy

Go to download

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.BoundedRangeModel;
import javax.swing.ImageIcon;
import javax.swing.KeyStroke;

import timeBench.action.layout.timescale.RangeAdapter;

/**
 * Pans a {@link RangeAdapter} by in/decreasing it's current value, as declared
 * in {@link BoundedRangeModel}.
 * 
 * 

* Added: 2012-05-17 / Peter Weishapl
* Modifications: 2010-08-24 / AR / make isLeft() protected
* 2012-06-14 / AR / constructor with RangeAdapter *

* * @author peterw * */ public class RangePanAction extends AbstractRangeAction { private static final long serialVersionUID = 405512961430470821L; private double d; /** *

* Creates a {@link RangePanAction} which pans the fiven * {@link RangeAdapter} by adding d to it's current value (see * {@link BoundedRangeModel#setValue(int)}. *

*

* Use positive values for right panning and negative values for left * panning. *

* * @param d * the amount of */ public RangePanAction(double d) { this.d = d; String dir = isLeft() ? "Left" : "Right"; putValue(NAME, "Pan " + dir); putValue(SMALL_ICON, new ImageIcon(getClass().getClassLoader().getResource("timeBench/ui/resources/" + "pan_" + dir.toLowerCase() + ".gif"))); putValue(ACCELERATOR_KEY, (isLeft() ? KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) : KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()))); } public RangePanAction(RangeAdapter rangeModel, double d) { this(d); super.setRangeModel(rangeModel); } protected boolean isLeft() { return d < 0; } public void actionPerformed(ActionEvent e) { if (getRangeModel() != null) { getRangeModel().setValue((int) (getRangeModel().getValue() + d)); } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy