ilog.views.chart.action
Class IlvChartZoomAction

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by ilog.views.chart.action.IlvChartAction
          extended by ilog.views.chart.action.IlvChartZoomAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action

public class IlvChartZoomAction
extends IlvChartAction

This class implements an action that will zoom a chart. When an IlvChartZoomAction is created, it registers an internal, private event listener with the chart axis so that the action can automatically enable and disable itself appropriately. If, at a later time, you want to remove the action from the user interface and have it garbage-collected, you will need to explicitly call its IlvChartAction.setChart(ilog.views.chart.IlvChart) method with a null argument to detach the action from the chart, hence removing itself from the listener list.

Since:
JViews 5.0
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
 
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON
 
Constructor Summary
IlvChartZoomAction(String name)
          Creates a new IlvChartZoomAction with the specified name and a zoom factor of 2.
IlvChartZoomAction(String name, double zoomFactor)
          Creates a new IlvChartZoomAction with the specified name and zoom factor.
IlvChartZoomAction(String name, Icon icon)
          Creates a new IlvChartZoomAction with the specified name and icon and a zoom factor of 2.
IlvChartZoomAction(String name, Icon icon, double zoomFactor)
          Creates a new IlvChartZoomAction with the specified name, icon and zoom factor.
IlvChartZoomAction(String name, Icon icon, KeyStroke accelerator, String shortDescription, String longDescription, double zoomFactor)
          Creates a new IlvChartZoomAction.
 
Method Summary
 void actionPerformed(ActionEvent event)
          Called when an action occurred.
protected  void attach()
          Called when the action has been attached to a new chart.
protected  void computeEnabled()
          Called when a change occurs on the axis to refresh the enabled property.
protected  void detach()
          Called when the action is about to be detached from its associated chart.
 double getZoomFactor()
          Returns the zoom factor.
 boolean isXZoomAllowed()
          Returns whether zooming along the x-axis is allowed.
 boolean isYZoomAllowed()
          Returns whether zooming along the y-axis is allowed.
 boolean isZoomIn()
          Returns whether the zoom action is a zoom in or zoom out.
 void setXZoomAllowed(boolean canZoom)
          Sets whether zooming along the x-axis is allowed.
 void setYZoomAllowed(boolean canZoom)
          Sets whether zooming along the y-axis is allowed.
 void setZoomFactor(double zoomFactor)
          Sets the zoom factor.
 
Methods inherited from class ilog.views.chart.action.IlvChartAction
getAccelerator, getAcceleratorText, getChart, getCoordinateSystem, getIcon, getLongDescription, getShortDescription, getXAxis, getYAxis, getYAxisIndex, setAccelerator, setChart, setIcon, setIcon, setLongDescription, setShortDescription, setYAxisIndex
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlvChartZoomAction

public IlvChartZoomAction(String name)
Creates a new IlvChartZoomAction with the specified name and a zoom factor of 2.


IlvChartZoomAction

public IlvChartZoomAction(String name,
                          Icon icon)
Creates a new IlvChartZoomAction with the specified name and icon and a zoom factor of 2.


IlvChartZoomAction

public IlvChartZoomAction(String name,
                          double zoomFactor)
Creates a new IlvChartZoomAction with the specified name and zoom factor.


IlvChartZoomAction

public IlvChartZoomAction(String name,
                          Icon icon,
                          double zoomFactor)
Creates a new IlvChartZoomAction with the specified name, icon and zoom factor.


IlvChartZoomAction

public IlvChartZoomAction(String name,
                          Icon icon,
                          KeyStroke accelerator,
                          String shortDescription,
                          String longDescription,
                          double zoomFactor)
Creates a new IlvChartZoomAction.

Parameters:
name - The name of the action. If the action is added to a JMenu, the name will be used as the menu item text. If the action is added to a JToolBar, the name will be used as the button text.
icon - The action optional icon.
accelerator - The action optional keyboard accelerator.
shortDescription - The action optional short description. If not null, this text will be typically used for tooltips.
longDescription - The action optional long description. If not null, this text will be typically used for display in a status bar.
zoomFactor - The zoom factor to apply on the chart.
Method Detail

getZoomFactor

public double getZoomFactor()
Returns the zoom factor.


setZoomFactor

public void setZoomFactor(double zoomFactor)
Sets the zoom factor.


isXZoomAllowed

public final boolean isXZoomAllowed()
Returns whether zooming along the x-axis is allowed.


setXZoomAllowed

public void setXZoomAllowed(boolean canZoom)
Sets whether zooming along the x-axis is allowed.


isYZoomAllowed

public final boolean isYZoomAllowed()
Returns whether zooming along the y-axis is allowed.


setYZoomAllowed

public void setYZoomAllowed(boolean canZoom)
Sets whether zooming along the y-axis is allowed.


isZoomIn

public final boolean isZoomIn()
Returns whether the zoom action is a zoom in or zoom out.


detach

protected void detach()
Called when the action is about to be detached from its associated chart. The default implementation removes the action from the axis listeners if it is a zoom out action.

Overrides:
detach in class IlvChartAction

attach

protected void attach()
Called when the action has been attached to a new chart. The default implementation adds this action to the axis listeners if it is a zoom out action.

Overrides:
attach in class IlvChartAction

computeEnabled

protected void computeEnabled()
Called when a change occurs on the axis to refresh the enabled property. The default implementation enables the action unless no chart has been attached yet or in the case of a zoom out, if the visible range is smaller than the data range. You may override this method to add your own criteria.

Overrides:
computeEnabled in class IlvChartAction
See Also:
IlvChartAction.setChart(ilog.views.chart.IlvChart)

actionPerformed

public void actionPerformed(ActionEvent event)
Called when an action occurred. By default, compute the new visible range for both direction and zoom the chart.



Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.