|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
ilog.views.diagrammer.IlvDiagrammer
public class IlvDiagrammer
IlvDiagrammer is the main class of the ILOG JViews Diagrammer
product. It is the Swing component that lets you display and edit diagrams.
A diagram is a graph containing nodes and (optionally) links between nodes. A diagram is defined by the data that it represents (that is, the set of nodes and links), and by the graphical representation of this data.
The diagram data is described by a data model, similar to the Swing data
models. The data model is represented by the
IlvSDMModel interface, which defines the set of nodes
and links and their attributes.
Data models can come from different sources such as XML files or databases, or they
can directly represent in-memory application objects. The connection of
the diagram component to these data sources is implemented by the
IlvDiagrammerDataSource class and
its subclasses.
The graphical representation of the diagram is fully customizable through
style sheets. A style sheet is a text file containing style rules, each
rule defining the graphic objects that represent nodes or links according
to their type and their attributes. Style sheets are set using the
setStyleSheet method. Diagrammer style sheets use the syntax
of CSS level 2. Here is a short extract of a JViews Diagrammer style sheet:
node.activity {
class : "ilog.views.sdm.graphic.IlvGeneralNode";
shapeType : "RoundRectangle";
foreground : "black";
background : "blue";
}
A diagram is described by an instance of the class
IlvDiagrammerProject. A project
contains a data source configuration and one or more style sheets.
Projects are stored to XML files, usually with an .idpr suffix.
You set a project through the setProject method.
Here is an example of code that creates a diagram component and loads a
project file:
IlvDiagrammer diagrammer = new IlvDiagrammer();
diagrammer.setProject(
new IlvDiagrammerProject(
new URL("file:myproject.idpr")),
true); // display the diagram.
The easiest way to create a project file is by using the Designer application. The Designer is an editor that lets you load data from a data source, and then define the style of the nodes and links.
You can also create and customize a diagram through the API. For example, the following code creates a node and adds it to the diagram:
Object town1 = diagrammer.createNode("town");
diagrammer.setObjectProperty(town1, "x", new Float(100));
diagrammer.setObjectProperty(town1, "y", new Float(100));
diagrammer.addObject(town1, null);
IlvDiagrammer supports editing: you can not only
display diagrams, but also edit them interactively. Predefined actions
are available to create new nodes and links (see
IlvDiagrammerPaletteBar).
The IlvDiagrammer class also has a full set of editing methods:
cut, copy, paste,
undo, redo, and so on.
To help you develop Swing GUIs around a diagram component, ILOG JViews Diagrammer
provides a set of application components that are ready to connect to an
IlvDiagrammer instance: toolbars and menus containing predefined
Swing actions to control and edit the diagram, a property sheet, a tree view,
and more. These application components are contained in the
ilog.views.diagrammer.application package. This package also contains
a ready-to-execute application, IlvDiagrammerApplication,
that you can use to view your diagrams and do some simple editing.
The IlvDiagrammer class is a front-end that gives access to
the functionality provided by the underlying JViews packages: the Graphic Framework,
the Stylable Data Mapper (SDM), and the Graph Layout package. These underlying
packages can be accessed directly if you need to use advanced features
or if you want to extend the component. For example, the getEngine
method lets you access the SDM engine that handles the mapping from the
data model to the graphic view.
| Nested Class Summary | |
|---|---|
static interface |
IlvDiagrammer.PrinterExceptionHandler
This interface is used to pass back exceptions that occur during the asynchronous printing of a diagram component. |
| Nested classes/interfaces inherited from class javax.swing.JComponent |
|---|
JComponent.AccessibleJComponent |
| Nested classes/interfaces inherited from class java.awt.Container |
|---|
Container.AccessibleAWTContainer |
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary |
|---|
| Fields inherited from class javax.swing.JComponent |
|---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class java.awt.Component |
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
IlvDiagrammer()
Creates a new, empty ilog.views.diagrammer.IlvDiagrammer instance. |
|
IlvDiagrammer(IlvSDMView view)
Creates a new ilog.views.diagrammer.IlvDiagrammer instance
containing an existing SDM view. |
|
| Method Summary | |
|---|---|
void |
addObject(Object nodeOrLink,
Object parentNode)
Adds a node or a link to the diagram. |
void |
addStyleSheet(URL url)
Adds a style sheet to this diagram component. |
void |
alignBottom()
Aligns the bottom sides of the selected nodes. |
void |
alignHorizontalCenter()
Aligns the horizontal centers of the selected nodes. |
void |
alignLeft()
Aligns the left sides of the selected nodes. |
void |
alignRight()
Aligns the right sides of the selected nodes. |
void |
alignTop()
Aligns the top sides of the selected nodes. |
void |
alignVerticalCenter()
Aligns the vertical centers of the selected nodes. |
void |
assignProject(IlvDiagrammerProject project)
Sets the current project of diagrammer. |
boolean |
canAlign()
Returns true if the current selection can be aligned. |
boolean |
canDistribute()
Returns true if the current selection can be distributed. |
boolean |
canEdit()
Returns true if at least one object is selected in the diagram component. |
boolean |
canGroup()
Returns true if editing is allowed and several objects are selected. |
boolean |
canPaste()
Returns true if data has been copied to the clipboard through
the cut() or copy() methods. |
boolean |
canPrint()
Returns true if the diagram component can be printed, that is,
if the diagram is not empty. |
boolean |
canRedo()
Returns true if a change can be redone. |
boolean |
canResetZoom()
Returns true if the view is currently zoomed in or out,
or false if the view is at the initial zoom level (1:1). |
boolean |
canSelect()
Returns true if the diagram component is not empty. |
boolean |
canUndo()
Returns true if a change can be undone. |
boolean |
canUngroup()
Returns true if editing is allowed and
at least one group (a node that has children) is selected. |
boolean |
canZoomIn()
Returns true if the view can be zoomed in, or
false if the maximum zoom factor has been reached. |
boolean |
canZoomOut()
Returns true if the view can be zoomed out, or
false if the minimum zoom factor has been reached. |
void |
clearAdjusting()
Stop an editing sequence but prevents diagrammer from performing any computation regarding the changes. |
void |
clearPrintArea()
Clears the print area for this diagram component. |
void |
copy()
Copies the selected objects. |
Object |
createGroupParent()
Creates a parent node for group. |
Object |
createLink(String tag,
Object sourceNode,
Object targetNode)
Creates a new link in the diagram. |
Object |
createNode(String tag)
Creates a new node in the diagram. |
protected IlvXMLDataSource |
createXMLDataSource()
Creates an XML data source Factory. |
void |
cut()
Cuts the selected objects. |
void |
delete()
Deletes the selected objects. |
void |
deselectAll()
Deselects all the selected objects in the diagram. |
void |
distributeHorizontally()
Distributes selected nodes horizontally. |
void |
distributeVertically()
Distributes selected nodes vertically. |
void |
duplicate()
Duplicates the selected objects. |
void |
fitToContents()
Zooms the diagram in or out so that it fits the view size of the diagram component. |
Iterator |
getAllObjects()
Returns all the objects added to the diagram of this diagram component. |
Iterator |
getChildren(Object parentNode)
Returns the child objects added to the subgraph represented by the parentNode. |
static IlvDiagrammer |
getCurrentDiagrammer(Component component)
Returns the current diagram component for the hierarchy that contains the specified component. |
URL |
getDataFile()
Returns the URL of the XML file that has been loaded into this diagram component using setDataFile(java.net.URL). |
IlvDiagrammerDataSource |
getDataSource()
Returns the current data source of this diagram component. |
URL |
getDefaultStyleSheet()
Returns the default style sheet URL. |
IlvEditSDMLabelInteractor |
getEditLabelInteractor()
Returns the interactor used when the diagram component is in edit label mode. |
IlvSDMEngine |
getEngine()
Returns the SDM engine that is used internally by this diagram component. |
IlvGrid |
getGrid()
Returns the IlvGrid object displayed by this diagram component
when setGridVisible(true) is called. |
String |
getID(Object nodeOrLink)
Returns the identifier of a node or a link. |
double |
getMaximumZoom()
Returns the maximum zoom allowed. |
double |
getMinimumZoom()
Returns the minimum zoom allowed. |
Object |
getObject(String id)
Returns the object with the specified identifier, or null
if no object has this identifier. |
Object |
getObjectProperty(Object nodeOrLink,
String propertyName)
Gets a property of a node or a link of this diagram component. |
Iterator |
getObjects()
Returns the top-level objects added to the diagram of this diagram component. |
IlvDiagrammer |
getPalette()
Gets the "palette" for this diagram component. |
IlvPanInteractor |
getPanInteractor()
Returns the interactor used when the diagram component is in pan mode. |
Object |
getParent(Object nodeOrLink)
Returns the parent node of a node or a link. |
IlvManagerPrintingController |
getPrintingController()
Returns the printing controller that handles all the printing-related tasks for this diagram component. |
IlvDiagrammerProject |
getProject()
Returns the project currently loaded in this diagram component. |
Iterator |
getSelectedObjects()
Returns the nodes and links that are currently selected in the diagram component. |
IlvSelectInteractor |
getSelectInteractor()
Returns the interactor used when the diagram component is in select mode. |
Object |
getSourceNode(Object link)
Returns the source node of the specified link. |
URL |
getStyleSheet()
Returns the URL of the style sheet used by this diagram component to render the diagram. |
URL[] |
getStyleSheets()
Returns all the style sheets of this diagram component. |
String |
getTag(Object nodeOrLink)
Returns the tag of a node or a link, that is, the String that was passed to createNode(java.lang.String) or createLink(java.lang.String, java.lang.Object, java.lang.Object) to
create the object. |
Object |
getTargetNode(Object link)
Returns the target node of the specified link. |
IlvSDMUndoManager |
getUndoManager()
Returns the undo manager of this diagrammer. |
IlvSDMView |
getView()
Returns the SDM view that is used internally by this diagram component. |
double |
getZoomFactor()
Returns the zoom factor used by the zoomIn() and zoomOut() methods. |
IlvZoomViewInteractor |
getZoomInteractor()
Returns the interactor used when the diagram component is in zoom mode. |
void |
group()
Groups the selected objects into a subgraph. |
boolean |
hasFrameOrDialogAncestor()
Returns true if this diagram component is contained in a Frame or a Dialog ancestor. |
boolean |
isAdjusting()
Returns true if the diagram component
is currently in an editing sequence. |
boolean |
isAutoEditLabel()
Returns true if this diagram component switches automatically to
label editing mode when a new node is created interactively. |
static boolean |
isAutomaticCurrentDiagrammer()
Returns true if the automatic handling of the current diagram
component is enabled. |
boolean |
isAutomaticLabelLayout()
Returns true if the labels in the diagram are
laid out automatically whenever the diagram is modified. |
boolean |
isAutomaticLinkLayout()
Returns true if the links in the diagram are
laid out automatically whenever the diagram is modified. |
boolean |
isAutomaticNodeLayout()
Returns true if the nodes in the diagram are
laid out automatically whenever the diagram is modified. |
boolean |
isEditable()
Returns true if the data model of this diagram component
supports editing. |
boolean |
isEditingAllowed()
Returns true if the nodes in the diagram
can be edited, or false if the nodes cannot be edited. |
boolean |
isEditLabelMode()
Returns true if label editing is currently enabled. |
boolean |
isEmpty()
Tests if the diagrammer is empty. |
boolean |
isGridVisible()
Returns true if the grid of the diagram component is currently
visible. |
boolean |
isLabelLayoutAvailable()
Returns true if label layout is available for this diagram component,
that is, if the style sheets contain the configuration of a label layout
algorithm. |
boolean |
isLink(Object nodeOrLink)
Returns true if the specified object is a link, or
false if the object is a node. |
boolean |
isLinkLayoutAvailable()
Returns true if link layout is available for this diagram component,
that is, if the style sheet contains the configuration of a link layout
algorithm. |
boolean |
isModified()
Returns true if the diagram has been modified since
the last open or save operation. |
boolean |
isNodeLayoutAvailable()
Returns true if node layout is available for this diagram component,
that is, if the style sheet contains the configuration of a node layout
algorithm, and if editing is allowed in this diagram component. |
boolean |
isPanMode()
Returns true if panning is currently enabled. |
boolean |
isResizingAllowed()
Returns true if the user is allowed to resize nodes
interactively. |
boolean |
isScrollable()
Returns true if this diagram component allows scrolling or false
otherwise. |
boolean |
isSelected(Object nodeOrLink)
Returns true if the specified node or link is currently selected
in the diagram component, or false if the object is not selected. |
boolean |
isSelectMode()
Returns true if the selection of nodes and links in the diagram
is allowed, or false if selection is not allowed. |
boolean |
isStickyModes()
Returns the "sticky modes" flag of the diagram component. |
boolean |
isStyleApplicationComponents()
Specifies whether styling is enabled for the application components ( IlvDiagrammerTree,
(IlvDiagrammerPropertySheet,
(IlvDiagrammerTable,
(IlvDiagrammerOverview,
(IlvDiagrammerStatusBar)
associated with this diagram component. |
boolean |
isZoomMode()
Returns true if zooming is currently enabled. |
void |
layoutAllNodes()
Performs a layout of all the nodes in the diagram. |
void |
layoutLabels()
Performs a layout of the labels in the diagram. |
void |
layoutLinks()
Performs a layout of the links in the diagram. |
void |
layoutSelectedNodes()
Performs a layout of the selected nodes in the diagram only. |
void |
pageSetup()
Displays a page setup dialog for this diagram component. |
void |
paste()
Pastes the selected objects. |
void |
print(boolean showPrintDialog,
boolean asynchronous,
IlvDiagrammer.PrinterExceptionHandler exceptionHandler)
Prints this diagram component according to the page setup parameters and the print area. |
void |
printPreview()
Displays a print preview dialog for this diagram component. |
void |
printToBitmap(File file)
Prints this diagram component to a bitmap file, according to the page setup parameters and the print area. |
boolean |
processServerAction(int x,
int y)
This method can be called when the diagram component is used on the server-side of a web application, to process an action sent by the client-side. |
void |
redo()
Redoes the last change in the diagram component. |
void |
refresh()
Refreshes the diagram. |
void |
removeObject(Object nodeOrLink)
Removes a node or a link from the diagram. |
void |
removeStyleSheet(URL url)
Removes a style sheet from this diagram component. |
void |
resetZoom()
Resets the zoom of the diagram component to 1:1. |
void |
scrollToObject(Object object)
Makes sure that the specified object is visible in this diagram component. |
void |
selectAll()
Selects all the objects in the diagram. |
void |
setAdjusting(boolean adjusting)
Starts or stops an editing sequence. |
static void |
setAsRoot(Component component)
Defines the supplied component as the root component of a hierarchy with a diagrammer component. |
void |
setAutoEditLabel(boolean autoEditLabel)
Enables or disables automatic label editing when a new node is created in this diagram component. |
static void |
setAutomaticCurrentDiagrammer(boolean automatic)
Enables or disables the automatic handling of the current diagram component for each Swing hierarchy. |
void |
setAutomaticLabelLayout(boolean enabled)
Enables or disables the automatic layout of labels. |
void |
setAutomaticLinkLayout(boolean enabled)
Enables or disables the automatic layout of links. |
void |
setAutomaticNodeLayout(boolean enabled)
Enables or disables the automatic layout of nodes. |
static void |
setCurrentDiagrammer(Component component,
IlvDiagrammer diagrammer)
Sets the current diagram component for the hierarchy that contains the specified component. |
static void |
setCurrentDiagrammer(Component component,
IlvDiagrammer diagrammer,
boolean findCommonAncestor)
Sets the current diagram component for the hierarchy that contains the specified component. |
void |
setDataFile(URL url)
Loads the contents of the specified XML file into this diagram component. |
void |
setDataSource(IlvDiagrammerDataSource dataSource)
Sets the data source of this diagram component. |
void |
setEditingAllowed(boolean editingAllowed)
Allows or forbids the modifying (move, cut, copy, paste, and so on) of the nodes and links in the diagram. |
void |
setEditLabelInteractor(IlvEditSDMLabelInteractor editLabelInteractor)
Changes the interactor used when the diagram component is in edit label mode. |
void |
setEditLabelMode(boolean editLabel)
Enables or disables label editing. |
void |
setGrid(IlvGrid grid)
Changes the IlvGrid object displayed by this diagram component
when setGridVisible(true) is called. |
void |
setGridVisible(boolean visible)
Shows or hides the grid of the diagram component. |
void |
setGroupParent(IlvDiagrammer sourceDiagrammer,
Object sourceParent)
Sets the prototype of the object that will be used by the group() method
as a model to create the parent of the new group. |
void |
setID(Object nodeOrLink,
String id)
Sets the identifier of a node or a link. |
void |
setMaximumZoom(double maximumZoom)
Changes the maximum zoom allowed. |
void |
setMinimumZoom(double minimumZoom)
Changes the minimum zoom allowed. |
void |
setModified(boolean modified)
Sets the "modified" flag. |
void |
setObjectProperty(Object nodeOrLink,
String propertyName,
Object propertyValue)
Sets a property of a node or a link of this diagram component. |
void |
setPalette(IlvDiagrammer palette)
Sets the "palette bar" for this diagram component. |
void |
setPanInteractor(IlvPanInteractor panInteractor)
Changes the interactor used when the diagram component is in pan mode. |
void |
setPanMode(boolean pan)
Enables or disables panning. |
void |
setPrintArea()
Lets the user define the print area for this diagram component interactively. |
void |
setPrintingController(IlvManagerPrintingController printingController)
Changes the printing controller that handles all the printing-related tasks for this diagram component. |
void |
setProject(IlvDiagrammerProject project)
Loads a project in this diagram component. |
void |
setProject(IlvDiagrammerProject project,
boolean loadData)
Deprecated. replaced by setProject(IlvDiagrammerProject) |
void |
setResizingAllowed(boolean allowed)
Allows or forbids the user to resize nodes interactively. |
void |
setScrollable(boolean scrollable)
Specifies whether this diagram component should allow scrolling or not. |
void |
setSelected(Object nodeOrLink,
boolean selected)
Selects or deselects a node or a link in the diagram component. |
void |
setSelectInteractor(IlvSelectInteractor selectInteractor)
Changes the interactor used when the diagram component is in select mode. |
void |
setSelectMode(boolean selectMode)
Enables or disables the selection of objects in the diagram. |
void |
setSourceNode(Object link,
Object node)
Changes the source node of the specified link. |
void |
setStickyModes(boolean stickyModes)
Specifies whether the operating modes of this diagram component (for example, zoom, create node/link, and edit label) should be "sticky" or not. |
void |
setStyleApplicationComponents(boolean styleApplicationComponents)
Specifies whether styling is enabled or disabled for the application components associated with this diagram component: IlvDiagrammerTree,
IlvDiagrammerPropertySheet,
IlvDiagrammerTable. |
void |
setStyleSheet(URL url)
Sets the URL of the style sheet used by this diagram component to render the graph. |
void |
setTargetNode(Object link,
Object node)
Changes the target node of the specified link. |
void |
setZoomFactor(double zoomFactor)
Changes the zoom factor used by the zoomIn() and zoomOut() methods. |
void |
setZoomInteractor(IlvZoomViewInteractor zoomInteractor)
Changes the interactor used when the diagram component is in zoom mode. |
void |
setZoomMode(boolean zoom)
Enables or disables zooming. |
void |
undo()
Undoes the last change in the diagram component. |
void |
ungroup()
Ungroups the selected groups. |
void |
writeData()
Writes the diagram to the current data source. |
void |
writeDataFile(String filename)
Writes the current diagram to a data file. |
void |
writeDataFile(URL url)
Writes the current diagram to the specified data URL. |
void |
writeProjectFile(URL projectURL)
Writes the diagrammer project file to the specified URL. |
void |
zoomIn()
Zooms the diagram component view in (using the zoom factor specified by setZoomFactor(double)). |
void |
zoomOut()
Zooms the diagram component view out (using the inverse of the zoom factor specified by setZoomFactor(double)). |
| Methods inherited from class java.awt.Container |
|---|
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, |