public class IlvZoomToFitAction extends IlvAction
IlvZoomToFitAction
class implements an action that will zoom a
specified IlvHierarchyChart
to display its full extent.
There are two alternate modes by which the action can determine the best fit time interval:
setAreaCalculator(ilog.views.IlvManagerView.FitAreaCalculator)
method and supply an IlvManagerView.FitAreaCalculator
that only considers a subset of the graphics for
fitting. Because activity graphics are typically nonzoomable, the action will try to
converge on the best fit for the graphic bounding boxes, but may not be able to find
a perfect fit.setIntervalPolicy(ilog.views.gantt.action.IlvZoomToFitAction.IntervalPolicy)
method. In this
case, an IlvZoomToFitAction.IntervalPolicy
will be used to compute an exact time interval
from the contents of the chart's data model.Modifier and Type | Class and Description |
---|---|
static interface |
IlvZoomToFitAction.IntervalPolicy
The
IntervalPolicy interface defines an abstract strategy that an IlvZoomToFitAction can use for calculating the time interval of an IlvGanttModel . |
static class |
IlvZoomToFitAction.RootActivityIntervalPolicy
The
RootActivityIntervalPolicy class determines the time interval of a
Gantt data model from its root activity. |
changeSupport, enabled
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor and Description |
---|
IlvZoomToFitAction(IlvHierarchyChart chart,
String name,
Icon icon,
KeyStroke accelerator,
String shortDescription,
String longDescription)
Creates an
IlvZoomToFitAction for the specified IlvHierarchyChart . |
IlvZoomToFitAction(IlvHierarchyChart chart,
String name,
KeyStroke accelerator,
String shortDescription,
String longDescription)
Creates an
IlvZoomToFitAction for the specified IlvHierarchyChart using a default icon. |
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(ActionEvent event)
Performs the zoom to fit action on the
IlvHierarchyChart object. |
IlvManagerView.FitAreaCalculator |
getAreaCalculator()
Returns the
FitAreaCalculator that dynamically defines the area of the
Gantt sheet that should be fit by this action. |
IlvZoomToFitAction.IntervalPolicy |
getIntervalPolicy()
Returns the calculation policy that the action uses to calculate the time interval of
the chart's data model.
|
double |
getMargin()
Returns the horizontal margin used at both ends of the time interval as a
percentage of the Gantt sheet's width.
|
void |
perform()
Performs the zoom to fit action on the
IlvHierarchyChart object. |
void |
setAreaCalculator(IlvManagerView.FitAreaCalculator areaCalculator)
Sets the
FitAreaCalculator that dynamically defines the area of the
Gantt sheet that will be fit by this action. |
void |
setIntervalPolicy(IlvZoomToFitAction.IntervalPolicy intervalPolicy)
Sets the calculation policy that the action will to calculate the time interval of
the chart's data model.
|
void |
setMargin(double margin)
Sets the horizontal margin used at both ends of the time interval as a percentage
of the Gantt sheet's width.
|
getAccelerator, getAcceleratorText, getIcon, getLongDescription, getMnemonic, getName, getShortDescription, setAccelerator, setIcon, setIcon, setLongDescription, setMnemonic, setName, setShortDescription
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
public IlvZoomToFitAction(IlvHierarchyChart chart, String name, KeyStroke accelerator, String shortDescription, String longDescription)
IlvZoomToFitAction
for the specified IlvHierarchyChart
using a default icon.chart
- The chart that will be zoomed by the action.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.accelerator
- The action's optional keyboard accelerator.shortDescription
- The action's optional short description. This text, if not
null
, will be typically used for tooltips.longDescription
- The action's optional long description. This text, if not
null
, will be typically used for display in a
status bar.public IlvZoomToFitAction(IlvHierarchyChart chart, String name, Icon icon, KeyStroke accelerator, String shortDescription, String longDescription)
IlvZoomToFitAction
for the specified IlvHierarchyChart
.chart
- The chart that will be zoomed by the action.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's icon or null
to use the default
icon.accelerator
- The action's optional keyboard accelerator.shortDescription
- The action's optional short description. This text, if not
null
, will be typically used for tooltips.longDescription
- The action's optional long description. This text, if not
null
, will be typically used for display in a
status bar.public IlvZoomToFitAction.IntervalPolicy getIntervalPolicy()
null
indicates that the
action will instead best fit the bounding boxes of all the graphics displayed in the
Gantt sheet using the current FitAreaCalculator.IntervalPolicy
used to calculate the time interval from the
the chart's data model, or null
if the action best fits the
graphic bounding boxes.setIntervalPolicy(IntervalPolicy)
,
getAreaCalculator()
public void setIntervalPolicy(IlvZoomToFitAction.IntervalPolicy intervalPolicy)
intervalPolicy
- The IntervalPolicy
that will be used to calculate
the time interval from the the chart's data model, or
null
if the action will best fit the graphic
bounding boxes using the current FitAreaCalculator.getIntervalPolicy()
,
getAreaCalculator()
public IlvManagerView.FitAreaCalculator getAreaCalculator()
FitAreaCalculator
that dynamically defines the area of the
Gantt sheet that should be fit by this action. The default value is
null
, which indicates that the action will best fit the bounding boxes
of all the graphics displayed in the Gantt sheet. Note, that the action only usea
the FitAreaCalculator
and computes the best fit time interval from the
graphic bounding boxes if the interval policy
is
null
. Otherwise, the action uses the interval policy to compute an
exact time interval from the contents of the chart's data model.null
, then the bounding box of all visible graphics will
be used.setAreaCalculator(IlvManagerView.FitAreaCalculator)
,
getIntervalPolicy()
public void setAreaCalculator(IlvManagerView.FitAreaCalculator areaCalculator)
Sets the FitAreaCalculator
that dynamically defines the area of the
Gantt sheet that will be fit by this action. Note, that the action will only use the
FitAreaCalculator
and compute the best fit time interval from the
graphic bounding boxes if the interval policy
is
null
. Otherwise, the action will use the interval policy to compute an
exact time interval from the contents of the chart's data model.
For example, you could define the following area calculator to fit the currently selected graphics in the Gantt sheet:
IlvManagerView.FitAreaCalculator fcalc = new IlvManagerView.FitAreaCalculator() { public IlvRect getAreaToFit(IlvManagerView view) { IlvGanttSheet ganttSheet = (IlvGanttSheet) view; IlvTransformer t = ganttSheet.getTransformer(); IlvGraphic[] graphics = ganttSheet.getGanttConfiguration().getSelectedGraphics(); IlvRect rect = null; for (IlvGraphic graphic : graphics) { IlvRect bbox = graphic.boundingBox(t); if (rect == null) { rect = bbox; } else { rect.add(bbox); } } // If nothing is selected, then fit all return (rect == null) ? ganttSheet.computeBBox() : rect; } };
areaCalculator
- The calculator that dynamically defines the area of the Gantt
sheet to be fit, or null
to use the bounding box
of all visible graphics.getAreaCalculator()
,
getIntervalPolicy()
public double getMargin()
setMargin(double)
public void setMargin(double margin)
margin
- The margin, which must be < 0.50.getMargin()
public void actionPerformed(ActionEvent event)
IlvHierarchyChart
object. This
method invokes perform()
.event
- The ActionEvent
.public void perform()
IlvHierarchyChart
object.actionPerformed(ActionEvent)
© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.