public class IlvDiagrammerPaletteAction extends IlvDiagrammerAction
IlvDiagrammerPaletteAction
provides an easy way
to build "palettes" to create nodes and links interactively in a diagram component,
IlvDiagrammer
.
A palette is an IlvDiagrammerToolBar
whose
buttons represent various types of nodes
and links. The user clicks a button to choose the type of node or
link, then (s)he clicks in the view to create the node or link
in the diagram.
Here is an example showing how to create a palette toolbar:
IlvDiagrammer palette = new IlvDiagrammer(); palette.setDataFile(new URL("file:palette.xml")); palette.setStyleSheet(new URL("file:style.css")); Action[] actions = IlvDiagrammerPaletteAction.getActions(palette, new IlvDiagrammerHashFunction()); IlvDiagrammerToolBar paletteToolbar = new IlvDiagrammerToolBar(actions, JToolBar.HORIZONTAL);
Or, even simpler, you can use the class IlvDiagrammerPaletteBar
.
You can also add "palette" actions to an already populated toolbar as follows:
Action[] paletteActions = IlvDiagrammerPaletteAction.getActions("file:palette.xml", "file:style.css"); IlvDiagrammerToolBar editToolbar = new IlvDiagrammerToolBar(IlvDiagrammerToolbar.editActions, JToolBar.HORIZONTAL); editToolbar.addActions(paletteActions);
The icons associated with the actions are created automatically: they are
reduced versions of the nodes and links contained in the XML file passed
to the getActions(ilog.views.diagrammer.IlvDiagrammer, ilog.views.diagrammer.application.IlvDiagrammerHashFunction)
method, rendered using the specified style sheet.
The tooltip associated with each action displays a full-size version of
the node or link.
IlvDiagrammerAction.ErrorHandler, IlvDiagrammerAction.FileAction, IlvDiagrammerAction.Handler, IlvDiagrammerAction.StatusEvent, IlvDiagrammerAction.StatusListener, IlvDiagrammerAction.ToggleAction
_new, about, ABOUT_APPLICATION_NAME, alignBottom, alignHorizontalCenter, alignLeft, alignRight, alignTop, alignVerticalCenter, autoEditLabel, autoLabelLayout, autoLinkLayout, autoNodeLayout, callBuilder, clearPrintArea, close, copy, createLink, createNode, cut, delete, distributeHorizontally, distributeVertically, duplicate, editing, editLabel, exit, fitToContents, grid, gridSpacing, group, help, layoutAllNodes, layoutSelectedNodes, open, openStyleSheet, pageSetup, pan, paste, printPreview, printToBitmap, printWithDialog, printWithoutDialog, read, redo, refresh, resetZoom, resizing, save, saveAs, select, selectAll, setPrintArea, stickyModes, undo, ungroup, zoom, zoomIn, zoomOut
hideToolbarButtonBordersOnOceanTheme
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 |
---|
IlvDiagrammerPaletteAction(boolean link)
Creates a new action that creates a new type of node or link.
|
IlvDiagrammerPaletteAction(IlvDiagrammer palette,
Object object)
Creates a new action that creates a copy of the specified node or link.
|
Modifier and Type | Method and Description |
---|---|
static IlvDiagrammerAction[] |
getActions(IlvDiagrammer palette,
IlvDiagrammerHashFunction hashFunction)
Creates a set of palette actions.
|
IlvDiagrammer |
getPaletteDiagrammer()
Returns the diagram component used as the "source" from which nodes
or links are copied.
|
Object |
getPaletteObject()
Returns the source object that is copied when creating an object.
|
static int |
getSmallIconSize()
Returns the size of the icons in the Diagrammer toolbar.
|
void |
init()
Initializes the properties of the action.
|
protected boolean |
isEnabled(IlvDiagrammer diagrammer)
Returns
true if the target diagram component is not null . |
boolean |
isLink()
Returns
true if this action creates a link |
boolean |
isSelectable()
Always returns
true to state that this is a selectable action
that should be associated with a toggle button. |
protected boolean |
isSelected(IlvDiagrammer diagrammer)
Returns
true if this action is currently selected, that is,
if waiting for the user to create a node or link. |
void |
perform(ActionEvent e,
IlvDiagrammer diagrammer)
Installs a node or link creation interaction in the target diagram component.
|
static void |
setSmallIconSize(int smallIconSize)
Sets the size of the icons in the Diagrammer toolbar.
|
protected void |
update(IlvDiagrammer diagrammer)
Updates this action according to the state of the diagram component.
|
addActionToUpdate, addStatusListener, call, chooseFile, getActionFileChooser, getDefaultResourceBundle, getDefaultSelectedFile, getErrorHandler, getFileChooserDirectory, getString, isEnabled, isSelected, perform, removeActionToUpdate, removeStatusListener, setDefaultSelectedFile, setErrorHandler, setFileChooserDirectory, setHandler, update, updateActions
actionPerformed, addActionToUpdate, addPropertyChangeListener, addStatusListener, call, clone, createMenuItem, createToolBarButton, delayedUpdateActions, error, fireActionFinished, fireActionStarted, getActionErrorHandler, getPrefix, getResourceBundle, isSelected, removeActions, removeActionToUpdate, removeStatusListener, setActionErrorHandler, setHandler, setSelected, updateActions
firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
public IlvDiagrammerPaletteAction(IlvDiagrammer palette, Object object)
getActions(ilog.views.diagrammer.IlvDiagrammer, ilog.views.diagrammer.application.IlvDiagrammerHashFunction)
static method to
create a set of palette actions in a single operation.palette
- The diagram component used as the "source" from which nodes
or links are copied.object
- The node or link that will be copied when the user clicks in the
target diagram component.public IlvDiagrammerPaletteAction(boolean link)
link
- If true
, a link will be created, otherwise a
node is created.protected boolean isEnabled(IlvDiagrammer diagrammer) throws Exception
true
if the target diagram component is not null
.isEnabled
in class IlvDiagrammerAction
diagrammer
- The diagram component in which the object is to be created.Exception
- When an error occurs while getting the state of the action.public boolean isSelectable()
true
to state that this is a selectable action
that should be associated with a toggle button.isSelectable
in class ilog.views.util.swing.context.ComponentAction
public boolean isLink()
true
if this action creates a linkpublic final void perform(ActionEvent e, IlvDiagrammer diagrammer) throws Exception
perform
in class IlvDiagrammerAction
e
- action to processdiagrammer
- The target diagram component.Exception
- When an error occurs while performing the action.protected void update(IlvDiagrammer diagrammer)
update
in class IlvDiagrammerAction
diagrammer
- The target diagram component.protected boolean isSelected(IlvDiagrammer diagrammer) throws Exception
true
if this action is currently selected, that is,
if waiting for the user to create a node or link.isSelected
in class IlvDiagrammerAction
diagrammer
- The target diagram component.Exception
- When an error occurs while getting the action's state.public void init()
init
in class ilog.views.util.swing.context.ComponentAction
public static IlvDiagrammerAction[] getActions(IlvDiagrammer palette, IlvDiagrammerHashFunction hashFunction)
The resulting action array can be used to populate an IlvDiagrammerToolBar
as follows:
Action[] actions = IlvDiagrammerPaletteAction.getActions(palette, new IlvDiagrammerHashFunction); IlvDiagrammerToolBar paletteToolbar = new IlvDiagrammerToolBar(actions, JToolBar.HORIZONTAL);
You can pass an IlvDiagrammerHashFunction
to populate the
palette with only one instance of each "type" of node or link. Nodes
or links are considered equal if the hash function returns the same
hash code.
palette
- The diagram component containing the set of nodes and links to use as
"prototypes" in the palette.hashFunction
- The hash function used to filter equivalent nodes
and links. If a node or link is considered "equal"
to another node or link that is already in the
palette, it will not be added. Nodes or links are
considered equal if the hash function returns the same
hash code.public static void setSmallIconSize(int smallIconSize)
public static int getSmallIconSize()
public Object getPaletteObject()
public IlvDiagrammer getPaletteDiagrammer()
© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.