/* * Licensed Materials - Property of Rogue Wave Software, Inc. * © Copyright Rogue Wave Software, Inc. 2014, 2017 * © Copyright IBM Corp. 2009, 2014 * © Copyright ILOG 1996, 2009 * All Rights Reserved. * * Note to U.S. Government Users Restricted Rights: * The Software and Documentation were developed at private expense and * are "Commercial Items" as that term is defined at 48 CFR 2.101, * consisting of "Commercial Computer Software" and * "Commercial Computer Software Documentation", as such terms are * used in 48 CFR 12.212 or 48 CFR 227.7202-1 through 227.7202-4, * as applicable. */ package interactor; import java.awt.event.*; import java.util.Locale; import ilog.views.chart.IlvAxis; import ilog.views.chart.IlvChartInteractor; import ilog.views.util.IlvResourceUtil; /** * An interactor that handles the scroll along the Y-axis using the keyboard. * <p>The registered name of this interactor is "YScroll". * @see IlvChartScrollInteractor */ public class IlvChartYScrollInteractor extends IlvChartScrollInteractor { // ============================ Metainformation ============================ static { IlvChartInteractor.register("YScroll", IlvChartYScrollInteractor.class); } /** * Returns a localized name for this interactor class. */ public static String getLocalizedName(Locale locale) { return IlvResourceUtil.getBundle("messages", IlvChartYScrollInteractor.class, locale) .getString("IlvChartYScrollInteractor"); } // ================ Overrides from IlvChartScrollInteractor ================ /** * Returns the axis scrolled by this interactor. The default implementation * returns the y-axis. */ Override protected IlvAxis getAxis() { return getYAxis(); } /** * Scrolls the chart along the Y-axis in the given direction. */ Override protected void scroll(int direction) { if (direction == IlvChartScrollInteractor.NEGATIVE_DIR) { getChart().scroll(0, -getDelta(), getYAxisIndex()); } else { getChart().scroll(0, getDelta(), getYAxisIndex()); } } // ============================= Constructors ============================= /** * Creates a new <code>IlvChartYScrollInteractor</code> object with the * negative direction associated with VK_DOWN and the positive direction * associated with VK_UP that scrolls 2 steps or 2 percent of the current * visible range, whether a steps definition for the Y-axis scale is * available. */ public IlvChartYScrollInteractor() { this(0, KeyEvent.VK_DOWN, KeyEvent.VK_UP, DEFAULT_STEP_VALUE); } /** * Creates a new <code>IlvChartYScrollInteractor</code> object. * @param yAxisIndex The Y-axis index. * @param negativeDirKey The key associated with a scroll in the negative * direction. * @param positiveDirKey The key associated with a scroll in the positive * direction. * @param step The number of Y-scale steps to scroll or the percentage of * the visible range to scroll whether a steps definition for * the Y-axis scale is available. */ public IlvChartYScrollInteractor(int yAxisIndex, int negativeDirKey, int positiveDirKey, int step) { super(yAxisIndex, negativeDirKey, positiveDirKey, step); } }