public class IlvSDMEngine extends Object implements IlvStylable, ilog.views.util.cssbeans.IlvCSSCompatible, Serializable
IlvSDMEngine
is the main class in the
Stylable Data Mapper package. An SDM engine controls
the process of rendering a set of application objects
as a graph in a Perforce JViews grapher.
An SDM engine has two input sources: a data model, and a style sheet. The engine matches the data against the style sheet to produce a graphic view of the data.
IlvSDMModel
.
The SDM data model is similar to the JFC/Swing Table, Tree, or List models.
It is the interface between the SDM engine and the application data.
It contains the methods that let the engine fetch the data objects
and retrieve their properties. The data model also allows the
application to notify the engine of changes in the data set.
The SDM package contains a predefined implementation of the
data model: the class IlvDefaultSDMModel
.
This simple data model stores data objects in memory. The objects
are instances of the classes IlvDefaultSDMNode
and IlvDefaultSDMLink
.
Instead of using the predefined model, you can implement the
IlvSDMModel
interface directly to wrap existing
data of your application. For this, you
can use IlvBasicSDMModel
as a base class.
The SDM engine provides support for reading and writing the contents
of a data model in XML, through the methods
setXMLFile(java.lang.String)
and
writeXML(String)
.
Style sheets conform to the CSS syntax (which is a recommendation of the W3C). The semantics, though, are slightly different from the original use of CSS: instead of styling web documents in a browser, the SDM engine styles a data model in a Perforce JViews grapher.
A style sheet contains a set of style rules. Each rule is formed by a left-hand part (the "selector"), and a right-hand part (the "declarations"). The selector specifies which objects match the rule. The declarations specify the properties of the graphic objects that will represent the matching data objects. Here is a simple example:
node.activity { class : "ilog.views.sdm.graphic.IlvGeneralNode"; shapeType : "RoundRectangle"; foreground : "black"; background : "blue"; }
Node.activity
is the selector, the
rest of the rule forms the declarations.
"node"
if
the object is a node, or "link"
if the object is a link between
two nodes.getTag
.node | Matches all the nodes. |
node.activity | Matches all the nodes whose tag is "activity" . |
node.activity.style1 | Matches all the nodes whose tag is "activity"
and whose style class is "style1" . |
node:selected | Matches all the nodes whose pseudo-class is "selected" . |
node.activity[implementation="manual"] | Matches all the nodes whose
tag is "activity" and whose implementation property has the value
"manual" . |
property : value;
. These assignments define a Perforce JViews graphic
object that will represent the data object matched by the rule's selector.
The class of the graphic object must be specified by the special property
class
. The other properties specify either the graphic object
properties (in the sense of JavaBean properties), or special properties
that are interpreted by the SDM engine.
Example:
node.activity { class : "ilog.views.sdm.graphic.IlvGeneralNode"; icon : "activity.gif"; label : "@name"; layer : 10; }These declarations tell the SDM engine that the activity nodes must be represented by graphic objects of the class
IlvGeneralNode
. When the graphic object is
created, the engine will set its icon
and
label
properties to the specified values. The
"@name"
notation means that the label
of the node must be set to the value of the name
property of the data object. The layer
property
is a special property, which is interpreted by the SDM engine,
and which specifies the manager layer in which the graphic
object will be added.
These options are defined by an SDM rule, and possibly by additional option rules.
The SDM rule must have the selector SDM
(or #SDM
). It defines the options for the SDM engine.
The declarations of the SDM rule can either affect the properties
of the SDM engine (in the sense of JavaBean properties), or they
can be special properties interpreted internally by the SDM engine.
Example:
SDM { baseURL : "file:/home/user/mydata/"; Map : "usa.ivl" LinkLayout : true; }In this example, the
baseURL
declaration calls the method setBaseURL
of the SDM engine. On the other hand,
the Map
and LinkLayout
declarations
are interpreted internally by the SDM engine. The Map
option tells the SDM engine that it must display a background map,
and that the objects must be placed on the map according to
their latitude and longitude properties. The LinkLayout
options tells the engine to apply an automatic layout algorithm
to reshape the links orthogonally and to avoid crossings.
Some options can be further customized through additional
rules. For example, the LinkLayout
option
has additional parameters that can be configured as follows:
LinkLayout { linkOffset : 5; }The SDM engine provides many other predefined rendering options. Here is a list of the available options:
Animation | Shows an animation during the rendering process. |
Coloring | Allocates colors to objects automatically. |
Decoration | Adds decoration objects to the grapher. |
ExpandCollapse | Allows you to expand and collapse subgraphs. |
HalfZooming | Prevents the nodes from zooming past a given level. |
InfoBalloon | Opens an info balloon showing some property values of the objects. |
Legend | Displays a legend for the graphic objects. |
DrillDown | Shows more and more objects when zooming in. |
Map | Displays a background map and places objects in a geo-referenced way. |
GraphLayout | Applies a layout algorithm to the nodes. |
LinkLayout | Applies a layout algorithm to the links. |
LabelLayout | Minimizes the overlap of labels attached to nodes and links. |
StyleSheet | Allows you to customize the style sheet engine. |
IlvSDMRenderer
. The renderers attached
to an SDM engine form a chained list. It is possible to create and
configure the renderers by code (see the method setRenderer
,
but the preferred way is by setting options in the style sheet
as explained above.
Read the user documentation for a more detailed description of each renderer and its parameters.
The XML data file simply contains two nodes of tag
"activity"
connected by a link of tag
"transition"
:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE SDM> <SDM> <activity id="1"> <property name="label">Activity 1</property> <property name="x">291.125</property> <property name="y">56.375</property> </activity> <activity id="2"> <property name="label">Activity 2</property> <property name="x">195.33594</property> <property name="y">87.375</property> </acivity> <transition id="3" islink="true" from="1" to="2" /> </SDM>
Here is an example of a style sheet file:
SDM { LinkLayout : true; } node.activity { class : "ilog.views.sdm.graphic.IlvGeneralNode"; shapeType : RoundRectangle; icon : "activity.gif"; label : "@label"; fillColor1 : brown; } link.transition { class : "ilog.views.sdm.graphic.IlvGeneralLink"; mode : "MODE_GRADIENT"; foreground : orange; oriented : true; } node:selected { fillColor1 : red; } link:selected { foreground : red; mode : "MODE_NEON"; }
Finally, here is the code needed to set up the engine:
// Create the SDM engine: IlvSDMEngine engine = new IlvSDMEngine(); // Set up a manager view: IlvManagerView view = new IlvManagerView(engine.getGrapher()); // ... create GUI around the manager view... // Set style sheet and XML data file: try { engine.setStyleSheets(new String[] { "file:example.css" }); engine.setXMLFile("file:example.xml"); } catch(IOException ex){ ex.printStackTrace(); } catch(IlvSDMException ex){ ex.printStackTrace(); }To make things even simpler, rather than creating an
IlvSDMEngine
,
you can create an IlvSDMView
that will create an instance of IlvSDMEngine
internally.IlvSDMModel
,
IlvSDMView
,
IlvGeneralNode
,
IlvGeneralLink
,
Serialized FormModifier and Type | Field and Description |
---|---|
static int |
ALWAYS
Used as a parameter to
setRenderingDoneMode(int) , specifies that
the IlvSDMRenderer.renderingDone(ilog.views.sdm.IlvSDMEngine)
method must always be called on selection or property changes. |
static String |
HIGH_CONTRAST
The pseudoclass "high-contrast" that indicates a high contrast theme.
|
static String |
HIGH_DETAIL_LEVEL
The pseudoclass "high-detail-level" that indicates a high level of detail.
|
static int |
IF_BBOX_CHANGED
Used as a parameter to
setRenderingDoneMode(int) , specifies that
the IlvSDMRenderer.renderingDone(ilog.views.sdm.IlvSDMEngine)
method must called on selection or property changes only when the bounding
box of a graphic object has changed. |
static String |
LOW_DETAIL_LEVEL
The pseudoclass "low-detail-level" that indicates a low level of detail.
|
static String |
MEDIUM_DETAIL_LEVEL
The pseudoclass "medium-detail-level" that indicates a medium level of detail.
|
static int |
NEVER
Used as a parameter to
setRenderingDoneMode(int) , specifies that
the IlvSDMRenderer.renderingDone(ilog.views.sdm.IlvSDMEngine)
method must never be called on selection or property changes. |
static String |
NORMAL_CONTRAST
The pseudoclass "normal-contrast" that indicates a normal contrast theme.
|
APPLIED_RULE_MASK, BAD_CLASS_MASK, BAD_PROP_MASK, BAD_PROP_WITH_STACK_MASK, CREATED_MASK, DECL_MASK, DECL_VALUE_MASK, FAILED_CONVERSIONS_MASK, TIME_REPORT_MASK, WARNING_PROP_MASK
Constructor and Description |
---|
IlvSDMEngine()
Creates an SDM engine for a new grapher
with a default data model,
which is an instance of the class
IlvDefaultSDMModel . |
IlvSDMEngine(IlvGrapher grapher,
IlvSDMModel model)
Creates an SDM engine with a specified grapher
and data model.
|
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(PropertyChangeListener listener)
Adds a listener on property modification.
|
void |
addPseudoClass(Object object,
String pseudoClass)
Adds a pseudo-class to the specified
data object.
|
void |
addSDMEngineDataLoadingListener(SDMEngineDataLoadingListener listener)
Adds an
SDMEngineDataLoadingListener
to this SDM engine. |
void |
addSDMEngineSelectionListener(SDMEngineSelectionListener listener)
Adds an
SDMEngineSelectionListener
to this SDM engine. |
void |
addSDMEngineStyleSheetListener(SDMEngineStyleSheetListener listener)
Adds an
SDMEngineStyleSheetListener
to this SDM engine. |
Object |
applyStyle(Object bean,
Object nodeOrLink,
String[] pseudoClasses)
Applies the current style sheet(s) of this SDM engine to a bean.
|
Object |
applyStyle(Object bean,
String ruleName,
String[] pseudoClasses)
Applies the current style sheet(s) of this SDM engine to a bean.
|
boolean |
canPaste()
|
void |
clearAdjusting()
Stops an editing sequence and prevents JViews Diagrammer from performing
any computation regarding the changes.
|
void |
copy()
Copies the selected objects of the data model to the
system clipboard.
|
void |
customizeAllObjects()
Recustomizes all the graphic objects corresponding to
the data objects returned by the SDM model.
|
void |
cut()
Copies the selected objects of the data model to the
system clipboard, and removes them from the data model.
|
void |
delete()
Removes the selected objects.
|
void |
deselectAllObjects()
Deselects all the graphic objects that represent
objects of the data model.
|
void |
duplicate()
Duplicates the selected data objects.
|
Enumeration<?> |
getAllObjects()
Returns an enumeration of all the objects of
the model (including all descendants of the
top-level objects) in pre-order (that is,
a parent is returned before its children).
|
int |
getBaseTextDirection()
Return default base text direction of engine.
|
String |
getBaseURL()
Returns the base URL used by this SDM engine
to find its resources, such as the map files or
the bitmap files.
|
ComponentOrientation |
getComponentOrientation(IlvSDMModel model,
Object obj,
ComponentOrientation fallBackComponentOrientation)
Returns the component orientation for a model object, from the subgrapher
that will contain the graphic object or from the context.
|
String |
getContrastAccessibilityTheme()
Returns the pseudoclass that represents the current contrast theme.
|
ilog.views.util.css.IlvCSSDebugHandler |
getCSSDebugHandler()
Returns the current css debugger.
|
Object |
getCSSInternal()
This method is for internal use; you should not call it directly.
|
String |
getDetailLevel()
Returns the pseudoclass that represents the current level of detail.
|
IlvGrapher |
getGrapher()
Returns the grapher associated with this SDM engine.
|
ilog.views.sdm.internal.IlvGrapherCleanerHandler |
getGrapherCleanerHandler()
Returns the current grapher cleaner handler.
|
IlvGraphic |
getGraphic(Object object,
boolean createIfNeeded)
Returns the JViews graphic object associated with
an application object.
|
String |
getID(Object obj)
Returns the identifier of a data object.
|
IlvLabelLayoutRenderer |
getLabelLayoutRenderer()
Returns the graph layout renderer that is responsible for the layout of labels.
|
IlvGraphLayoutRenderer |
getLinkLayoutRenderer()
Returns the graph layout renderer that is responsible for the layout of links.
|
IlvSDMModel |
getModel()
Returns the current data model.
|
IlvGraphLayoutRenderer |
getNodeLayoutRenderer()
Returns the graph layout renderer that is responsible for the layout of nodes.
|
Object |
getObject(IlvGraphic graphic)
Returns the data object (that is,
the object returned by the SDM model)
associated with a graphic object, or
null if the specified graphic object
does not represent an object of the data model. |
Object |
getObject(IlvPoint p,
IlvManagerView view)
Returns the data object associated
with the graphic object at a specified point in a
manager view.
|
Object |
getObject(IlvPoint p,
IlvManagerView view,
boolean traverse)
Returns the data object associated
with the graphic object at a specified point in a
manager view.
|
Object |
getObject(String id)
Looks up the data model for an object with the specified identifier.
|
Enumeration<?> |
getObjectsWithPseudoClass(String pseudoClass)
Returns all the objects of the model that have a given
pseudo-class.
|
Object |
getParent(IlvManagerView view,
double x,
double y,
boolean managerCoordinates)
Returns the parent object located at the specified coordinates
in the view.
|
String[] |
getPseudoClasses()
Returns the pseudoclasses associated with all
data objects.
|
String[] |
getPseudoClasses(Object object)
Returns the pseudo-classes associated with the specified
data object.
|
IlvManagerView |
getReferenceView()
Returns the reference view of this SDM engine.
|
double |
getReferenceZoom()
Returns the reference zoom factor.
|
IlvSDMRenderer |
getRenderer()
Returns the root of the renderer chain.
|
int |
getRenderingDoneMode()
Returns the flag that determines the way the
IlvSDMRenderer.renderingDone(ilog.views.sdm.IlvSDMEngine)
method is called on selection or property changes. |
static IlvSDMEngine |
getSDMEngine(IlvGrapher grapher)
Returns the SDM engine associated with the specified
grapher, or
null if no SDM engine is associated
with the specified grapher. |
static IlvSDMEngine |
getSDMEngine(IlvGraphic graphic)
Returns the SDM engine associated with the grapher
in which the specified graphic object is contained,
or
null if the graphic is not contained in
a grapher or if the grapher has no associated SDM engine. |
Enumeration<?> |
getSelectedObjects()
Returns an enumeration containing the data objects
represented by the graphic objects currently
selected in the grapher.
|
String |
getSelectionPseudoClass()
Returns the pseudo-class used to style selected objects.
|
String |
getStringFromClipboard()
For internal use only.
|
int |
getStyleSheetDebugMask()
Returns the debug level of the current configuration style sheet.
|
String[] |
getStyleSheets()
Returns the style sheet(s) used by this SDM engine
to map the data model to Perforce JViews graphic objects.
|
String |
getStyleSheets(int index)
Returns one of the style sheets used by this SDM engine
to map the data model to Perforce JViews graphic objects.
|
com.ibm.icu.util.ULocale |
getULocale(IlvSDMModel model,
Object obj,
com.ibm.icu.util.ULocale fallBackLocale)
Returns the locale for a model object, from the subgrapher that will
contain the graphic object or from the context.
|
IlvXMLConnector |
getXMLConnector()
Returns the
IlvXMLConnector
object used to read and write the contents of the
SDM data model from/to XML files. |
String |
getXMLFile()
Returns the URL of the XML file currently being displayed
by the SDM engine.
|
String |
getXMLProcessingInstructionProperty(String property)
Returns a property to be saved in the XML processing instruction
for SDM.
|
void |
group(Object parent)
Groups the selected objects.
|
boolean |
hasPseudoClass(Object object,
String pseudoClass)
Returns
true if and only if the specified object has
the specified pseudo-class. |
boolean |
isAdjusting()
Returns
true if and only if the SDM engine
is currently in an editing sequence. |
boolean |
isCompiledSymbolAutoLoad()
Returns true if compiled symbols are loaded if available.
|
boolean |
isDropToGroupEnabled()
Returns
true if dropping or duplicating a node in
an existing subgraph will make the node a child of this
subgraph, or false otherwise. |
boolean |
isEmptySubgraphAllowed()
Returns
true if empty subgraphs are allowed. |
boolean |
isHighlightingSelection()
Returns
true if "selection by highlighting" is enabled,
or false if the usual selection handles are used to show
selected objects. |
boolean |
isJavaColorNamesFirst()
Returns
true if Java color names are to be used instead of SVG color names when there is a conflict. |
boolean |
isLabelLayoutEnabled()
Returns the enabled state of the automatic layout algorithm for labels.
|
boolean |
isLayoutRunning()
Returns the flag indicating that a layout algorithm is running.
|
boolean |
isLinkLayoutEnabled()
Returns the enabled state of the automatic layout algorithm for links.
|
boolean |
isLinkLayoutEnabledWhileMoving()
Returns
true if the automatic link layout is enabled while
moving a node. |
boolean |
isLinkNodeVisibilityCoupled()
Returns
true if the links are visible (if and only if origin and
destination nodes are visible). |
boolean |
isManagerListenerPlugged()
Returns true if SDM reacts to manager content changes.
|
boolean |
isMetadataEnabled()
Returns
true if metadata are enabled. |
boolean |
isModelListenerPlugged()
Returns true if SDM reacts to model changes.
|
boolean |
isNodeLayoutEnabled()
Returns the enabled state of the automatic layout algorithm for nodes.
|
boolean |
isOpaqueMove()
Returns the Opaque Move mode of the select
interactor attached to the views of this SDM engine.
|
boolean |
isResizingAllowed()
Returns
true if the user is allowed to resize nodes
interactively. |
boolean |
isSelected(Object object)
Returns
true if and only if the graphic
representation of the specified object is selected. |
boolean |
isSelectionListenerPlugged()
Returns true if SDM reacts to selection changes.
|
boolean |
isUseBaseTextDirectionFromStyleSheetRenderer()
Returns whether the base text direction specified in the style sheet
renderer, or specified in CSS in the StyleSheet section, it taken
into account.
|
boolean |
isViewListenerPlugged()
Returns true if SDM reacts to View changes.
|
void |
loadData()
Loads the data described by the current model
using the current renderer.
|
void |
moveObject(Object object,
double x,
double y,
IlvTransformer t,
int alignment,
boolean redraw)
Deprecated.
Beginning with JViews 2002, this method is deprecated
because it does not work properly when the object is contained in
a subgraph. Use the method
moveObject(java.lang.Object,ilog.views.IlvManagerView,double,double,boolean,int,boolean)
instead. |
void |
moveObject(Object object,
IlvManagerView view,
double x,
double y,
boolean translate,
int alignment,
boolean redraw)
Moves or translates an object to a specified view position.
|
void |
paste()
Reads the data objects currently contained in the system
clipboard (as an XML string) and adds them to the
data model.
|
void |
performLabelLayout()
Performs a graph layout algorithm on the labels of the graph.
|
void |
performLinkLayout()
Performs a layout algorithm on the links of the graph.
|
void |
performNodeLayout()
Performs a layout algorithm on the nodes of the graph.
|
void |
plugAllListeners(boolean on)
Installs or uninstalls all SDM engine listeners at once.
|
void |
plugManagerListener(boolean on)
Installs or uninstalls listener on Manager.
|
void |
plugModelListener(boolean on)
Installs or uninstalls listener on model.
|
void |
plugSelectionListener(boolean on)
Installs or uninstalls listener on manager selection.
|
void |
plugViewListener(boolean on)
Installs or uninstalls listener on View.
|
boolean |
processServerAction(int x,
int y,
IlvManagerView view)
This method can be called when the SDM engine is used on the server-side of a web
application, to process an action sent by the client-side.
|
protected void |
processXMLProcessingInstructionProperty(String property,
String value,
String url,
boolean insert)
Processes a property read from the SDM processing instruction
in an XML file.
|
void |
putStringToClipboard(String data)
For internal use only.
|
void |
readDOM(Document document)
Reads an SDM data model from a DOM document.
|
void |
readDOM(Document document,
boolean add)
Reads an SDM data model from a DOM document.
|
void |
readXML(InputStream stream)
Reads an XML description of an SDM data model
from an input stream.
|
void |
readXML(InputStream stream,
boolean add)
Reads an XML description of an SDM data model
from an input stream.
|
void |
readXML(Reader reader)
Reads an XML description of an SDM data model
from a
Reader . |
void |
readXML(Reader reader,
boolean add)
Reads an XML description of an SDM data model
from a
Reader . |
void |
readXML(String url)
Reads an XML description of an SDM data model
from a URL.
|
void |
readXML(String url,
boolean add)
Reads an XML description of an SDM data model
from a URL.
|
IlvGraphic |
recreateObject(Object object,
boolean redraw,
boolean oneLevel)
Re-creates a graphic representation of a model object.
|
void |
removePropertyChangeListener(PropertyChangeListener listener)
Removes a listener on property modification.
|
void |
removePseudoClass(Object object,
String pseudoClass)
Removes a pseudo-class from the specified
data object.
|
void |
removeSDMEngineDataLoadingListener(SDMEngineDataLoadingListener listener)
Removes an
SDMEngineDataLoadingListener
from this SDM engine. |
void |
removeSDMEngineSelectionListener(SDMEngineSelectionListener listener)
Removes an
SDMEngineSelectionListener
from this SDM engine. |
void |
removeSDMEngineStyleSheetListener(SDMEngineStyleSheetListener listener)
Removes an
SDMEngineStyleSheetListener
from this SDM engine. |
void |
renderingDone()
This method calls the
renderingDone
method of the renderer. |
void |
scrollToObject(Object object)
Makes sure that an object is visible in the reference
view of this SDM engine.
|
void |
selectAllObjects()
Selects all the graphic objects that represent
objects of the data model.
|
void |
setAdjusting(boolean adjusting)
Starts or stops an editing sequence.
|
void |
setAllSelectedObjects(Collection<?> objects)
Selects the graphic objects that represent the model objects given as
arguments, and deselects all other graphic objects that represent objects
of the data model.
|
void |
setBaseTextDirection(int baseTextDirection)
Set default base text direction of engine.
|
void |
setBaseTextDirection(int baseTextDirection,
boolean draw)
Set default base text direction of engine.
|
void |
setBaseURL(String url)
Sets the base URL used by this SDM engine
to find its resources, such as the map files or
the bitmap files.
|
void |
setCompiledSymbolAutoLoad(boolean on)
Controls whether compiled symbols should be loaded (if available), instead of interpreted CSS version
when a class declaration involving symbol is found.
|
void |
setContrastAccessibilityTheme(String theme)
Sets the current contrast theme.
|
void |
setCSSDebugHandler(ilog.views.util.css.IlvCSSDebugHandler handler)
Sets the css debugger handler, or null if no debugger is activated.
|
void |
setDetailLevel(String level)
Sets the current level of detail.
|
void |
setDropToGroupEnabled(boolean enabled)
Specifies whether or not dropping or duplicating a node in
an existing subgraph will make the node a child of this
subgraph.
|
void |
setEmptySubgraphAllowed(boolean allowed)
Allows or disallows empty subgraphs.
|
void |
setGrapher(IlvGrapher grapher)
Sets the grapher associated with this SDM engine.
|
void |
setGrapherCleanerHandler(ilog.views.sdm.internal.IlvGrapherCleanerHandler handler)
Sets the grapher cleaner handler, which is called when SDM wants to
remove its objects.
|
void |
setHighlightingSelection(boolean yes)
Enables "selection by highlighting".
|
void |
setJavaColorNamesFirst(boolean val)
Specifies whether to use Java color names or SVG color names when there is a conflict.
|
void |
setLabelLayoutEnabled(boolean enabled)
Enables or disables the automatic layout of labels.
|
void |
setLayoutRunning(boolean running)
Sets the flag indicating that a layout algorithm is running.
|
void |
setLinkLayoutEnabled(boolean enabled)
Enables or disables the automatic layout of links.
|
void |
setLinkLayoutEnabledWhileMoving(boolean enabled)
Enables or disables the automatic link layout while moving nodes.
|
void |
setLinkNodeVisibilityCoupled(boolean coupled)
Sets whether link visibility is coupled to node visibility.
|
void |
setMetadataEnabled(boolean on)
Controls whether metadata are enabled or not.
|
void |
setModel(IlvSDMModel model)
Changes the data model used by this SDM engine.
|
void |
setModel(IlvSDMModel model,
boolean reload)
Changes the data model used by this SDM engine.
|
void |
setNodeLayoutEnabled(boolean enabled)
Enables or disables the automatic layout of nodes.
|
void |
setOpaqueMove(boolean opaque)
Sets the Opaque Move mode of the select
interactor attached to the views of this SDM engine.
|
void |
setPseudoClasses(String[] classes)
Sets the pseudoclasses associated with all
data objects.
|
void |
setReferenceView(IlvManagerView view)
Sets the reference view of this SDM engine.
|
void |
setReferenceZoom(double zoom)
Sets the initial zoom factor that is used as a reference
to compute zoom-related behavior.
|
void |
setRenderer(IlvSDMRenderer renderer)
Changes the root of the renderer chain.
|
void |
setRenderingDoneMode(int renderingDoneMode)
Determines the way the
IlvSDMRenderer.renderingDone(ilog.views.sdm.IlvSDMEngine)
method is called on selection or property changes. |
void |
setResizingAllowed(boolean allowed)
Allows or forbids the user to resize nodes interactively.
|
static void |
setSDMEngine(IlvGrapher grapher,
IlvSDMEngine engine)
Associates an SDM engine with the specified grapher.
|
void |
setSelected(Object[] objects,
boolean selected)
Selects or deselects the graphic objects representing
the specified array of data objects.
|
void |
setSelected(Object object,
boolean selected)
Selects or deselects the graphic object representing
a specified data object.
|
void |
setSelectionPseudoClass(String selectionPseudoClass)
Changes the pseudo-class used to style selected objects.
|
void |
setStyleSheetDebugMask(int v)
Sets the debug flag while parsing the configuration style
sheet.
|
void |
setStyleSheets(int index,
String css)
Changes one of the cascading style sheets.
|
void |
setStyleSheets(int index,
String css,
boolean reload)
Same as
setStyleSheets(int, String) , with the possibility to not recreate
the diagram. |
void |
setStyleSheets(String[] css)
Sets the style sheet(s) used by this SDM engine
to map the data model to Perforce JViews graphic objects.
|
void |
setStyleSheets(String[] css,
boolean reload,
boolean recreate)
Sets the style sheet(s) used by this SDM engine
to map the data model to Perforce JViews graphic objects.
|
void |
setUseBaseTextDirectionFromStyleSheetRenderer(boolean use)
Sets whether the base text direction specified in the style sheet
renderer, or specified in CSS in the StyleSheet section, it taken
into account.
|
void |
setXMLConnector(IlvXMLConnector connector)
Sets the
IlvXMLConnector
object used to read and write the contents of the
SDM data model from/to XML files. |
void |
setXMLFile(String xmlFile)
Sets the XML file containing the data to display.
|
void |
setXMLProcessingInstructionProperty(String property,
String value)
Sets a property to be saved in the XML processing instruction
for SDM.
|
void |
ungroup()
Ungroups the selected objects.
|
void |
updateNodePositions()
Saves the positions of all the nodes in the data.
|
void |
updateNodePositions(Iterator<Object> nodes)
Saves the positions of nodes in the data.
|
void |
updateObjectProperties(Object object,
String property,
Object value,
String[] pseudoClasses)
This method calls
IlvSDMRenderer.updateObjectProperties(ilog.views.sdm.IlvSDMEngine, java.lang.Object, java.lang.String, java.lang.Object, java.lang.String[])
on the root renderer of the SDM engine. |
void |
writeDOM(Document document)
Writes the data contained in the current data model
to a DOM document.
|
void |
writeXML(OutputStream stream)
Writes the data contained in the current data model
to a stream.
|
void |
writeXML(String filename)
Writes the data contained in the current data model
to an XML file.
|
void |
writeXML(Writer writer)
Writes the data contained in the current data model
to a
Writer . |
public static final String HIGH_DETAIL_LEVEL
public static final String MEDIUM_DETAIL_LEVEL
public static final String LOW_DETAIL_LEVEL
public static final String HIGH_CONTRAST
public static final String NORMAL_CONTRAST
public static final int IF_BBOX_CHANGED
setRenderingDoneMode(int)
, specifies that
the IlvSDMRenderer.renderingDone(ilog.views.sdm.IlvSDMEngine)
method must called on selection or property changes only when the bounding
box of a graphic object has changed.public static final int NEVER
setRenderingDoneMode(int)
, specifies that
the IlvSDMRenderer.renderingDone(ilog.views.sdm.IlvSDMEngine)
method must never be called on selection or property changes.public static final int ALWAYS
setRenderingDoneMode(int)
, specifies that
the IlvSDMRenderer.renderingDone(ilog.views.sdm.IlvSDMEngine)
method must always be called on selection or property changes.public IlvSDMEngine(IlvGrapher grapher, IlvSDMModel model)
grapher
- The grapher.model
- The data model.public IlvSDMEngine()
IlvDefaultSDMModel
.
The default model is initially empty.IlvDefaultSDMModel
,
IlvStyleSheetRenderer
public void addPropertyChangeListener(PropertyChangeListener listener)
addPropertyChangeListener
in interface IlvStylable
listener
- The listener to add.public void removePropertyChangeListener(PropertyChangeListener listener)
removePropertyChangeListener
in interface IlvStylable
listener
- The listener to remove.public void setStyleSheets(String[] css) throws IlvSDMException
The CSS documents in
the css
array are concatenated. The
style sheets with a higher index in the array have
a higher priority.
This call will re-create the SDM renderers and
all the graphic objects. See also the variant
setStyleSheets(java.lang.String[],boolean,boolean)
that lets you control how the style sheets are applied.
See the class description for an explanation of the contents of the style sheet files.
setStyleSheets
in interface IlvStylable
css
- An array of strings containing the URLs
or the file names of CSS files (usually with a .css
suffix). A direct String representing the CSS document itself is allowed,
too.IlvSDMException
setStyleSheets(int,java.lang.String)
,
setStyleSheets(java.lang.String[],boolean,boolean)
public void setStyleSheets(String[] css, boolean reload, boolean recreate) throws IlvSDMException
This method is similar to setStyleSheets(java.lang.String[])
but provides two additional parameters, reload
and recreate
,
that control how the new style sheets are applied.
The reload
parameter specifies whether or not the graphic objects
representing the SDM data model will be updated.
The recreate
parameter specifies whether the graphic objects
representing the SDM data model will be re-created or if the new style sheets
will simply be applied to the existing graphic objects. This also applies to
the SDM renderers: if recreate
is true
, the renderers
defined in the style sheet are re-created; otherwise their properties are simply
set according to the new style sheets.
Setting recreate
to false
lets you update the display
much more quickly, but there are some limitations:
"@#"
construct) will be re-created as usual.css
- An array of strings representing the CSS document (usually
with a file or URL with .css
suffix).reload
- If this parameter is true
, the graphic objects
representing the current SDM data model are updated according
to the new style sheets. If this parameter is false
, the graphic objects
are not updated. They can be updated later by calling loadData()
or
customizeAllObjects()
.
The way the graphic objects are updated depends on the
recreate
parameter.recreate
- If this parameter is true
, all the graphic objects
and the SDM renderers are re-created according to the new style sheets.
If this parameter is false
, the graphic objects and the SDM renderers
are not re-created. Instead, their properties are set according to the new style sheets.IlvSDMException
- if an SDM exception occurspublic void setStyleSheets(int index, String css) throws IlvSDMException
setStyleSheets(java.lang.String[])
.
It lets you change one particular style sheet file, instead of setting
the whole style sheet array.
This call will reload the data model and re-create all the graphic objects. Warning, this method will override the current renderers.
This is a bound property. It means the implementation should
fire a PropertyChange
event to all registered
PropertyChangeListener
s after setting the new value.
The old and new value arguments of the event represent the whole array.
setStyleSheets
in interface IlvStylable
index
- The index of the style sheet to replace.css
- A String representing the CSS document (usually
a file name or URL with .css
suffix).IlvSDMException
- if there is a problem with the specified
CSS.setStyleSheets(java.lang.String[])
public void setStyleSheets(int index, String css, boolean reload) throws IlvSDMException
setStyleSheets(int, String)
, with the possibility to not recreate
the diagram.index
- The index of the style sheet to replace.css
- A String representing the CSS document (usually
a filename or a URL with the .css
suffix).reload
- If false
, do not recreate the diagram.IlvSDMException
- if there is a problem with the specified
CSS.public String getStyleSheets(int index)
getStyleSheets
in interface IlvStylable
index
- The position of the style sheet.index
-th
style sheet.setStyleSheets(java.lang.String[])
,
getStyleSheets()
public String[] getStyleSheets()
getStyleSheets
in interface IlvStylable
setStyleSheets(java.lang.String[])
,
getStyleSheets(int)
public void setStyleSheetDebugMask(int v)
setStyleSheets
to debug problems during
configuration. The default value traces bad class names and
"set" methods that raise an exception.setStyleSheetDebugMask
in interface IlvStylable
v
- The debug mask, as defined in IlvStyleSheetRenderer
.IlvStyleSheetRenderer.setDebugMask(int)
,
setStyleSheets(String[])
,
getStyleSheetDebugMask()
public int getStyleSheetDebugMask()
getStyleSheetDebugMask
in interface IlvStylable
setStyleSheetDebugMask(int)
public void setCSSDebugHandler(ilog.views.util.css.IlvCSSDebugHandler handler)
handler
- public ilog.views.util.css.IlvCSSDebugHandler getCSSDebugHandler()
public Object applyStyle(Object bean, String ruleName, String[] pseudoClasses)
This method gives direct access to the styling engine and is useful to style any JavaBean of an application.
This variant styles a bean independently of the SDM data model, that
is, a bean that is not associated with any node or link of
the graph. The rule that is used to style the bean is specified by
the ruleName
parameter. See also the other variant
applyStyle(java.lang.Object,java.lang.Object,java.lang.String[])
that styles a bean using a node or link rule.
Example
Here is how you could style a JTree
of your GUI:
IlvSDMEngine engine = ... JTree tree = new JTree(); engine.applyStyle(tree, "JTree", null);And here is a rule that could be used in the style sheet:
JTree { editable : "true"; // calls tree.setEditable(true); rootVisible : "false"; // calls tree.setRootVisible(false); }
bean
- The JavaBean to which the style sheets will be applied.
If this parameter is null
, and if the rule contains a
declaration for the "class"
property, an instance
of this class will be created and returned by this method.ruleName
- The name of the style rule that will be applied.pseudoClasses
- The pseudo-classes used to select the style rule to
apply. This parameter can be null
.bean
parameter, or the new bean created if the
bean
parameter was null and rule
contained a
declaration for the "class"
property.public Object applyStyle(Object bean, Object nodeOrLink, String[] pseudoClasses)
This method gives direct access to the styling engine and is useful to style any JavaBean of an application.
This variant styles a bean associated with a node or a link of
the graph. The style rule that is used to style the bean is the rule that
matches the specified node or link. See also the other variant
applyStyle(java.lang.Object,java.lang.String,java.lang.String[])
that styles a bean using a fixed rule name.
Example
Here is how you could style the cell renderer of a JList
displaying the nodes and links of the SDM model:
final IlvSDMEngine engine = new IlvSDMEngine(); DefaultListModel listModel = new DefaultListModel(); Enumeration en = engine.getAllObjects(); while(en.hasMoreElements()) listModel.addElement(en.nextElement()); JList list = new JList(listModel); list.setCellRenderer(new DefaultListCellRenderer(){ public Component getListCellRendererComponent(JList list, Object nodeOrLink, int index, boolean isSelected, boolean cellHasFocus) { Component c = super.getListCellRendererComponent(list, nodeOrLink, index, isSelected, cellHasFocus); String[] pseudoClasses; if(isSelected) pseudoClasses = new String[]{ "listCellRenderer", "selected" }; else pseudoClasses = new String[]{ "listCellRenderer" }; engine.applyStyle(c, nodeOrLink, pseudoClasses); return c; } });And here are the rules that could be used in the style sheet:
node:listCellRenderer { background : "white"; // calls c.setBackground(Color.white); foreground : "black"; // calls c.setForeground(Color.black); } node:listCellRenderer:selected { background : "lightblue"; // calls c.setBackground([lightblue]); }Note the use of the pseudo-classes to style the list cell differently according to the list selection.
bean
- The JavaBean to which the style sheets will be applied.
This parameter must not be null
.nodeOrLink
- The object of the SDM data model that is used to select
the style rule to apply to the bean.pseudoClasses
- The pseudo-classes used to select the style rules to
apply. This parameter can be null
.bean
parameter.public void setJavaColorNamesFirst(boolean val)
A global Color property editor which understands both Java color names and SVG color names (see SVG color keywords). is registered by default to handle properties of type Color. Unfortunately, there are some name clashes between Java and SVG. For example, the color name "green" means #00FF00 for Java, but #008000 for SVG. Therefore a choice must be made.
If the specified Boolean value is true
, the Java value will be used, for example, the
"green" color set in the style sheet will be the value #00FF00.
The default Boolean value is false
, which specifies the use of SVG color names.
val
- The Boolean value. If true
, use Java color names. If false
, use
SVG color names.
public boolean isJavaColorNamesFirst()
true
if Java color names are to be used instead of SVG color names when there is a conflict.public void plugAllListeners(boolean on)
on
- true to install (automatically done) or false to uninstallplugModelListener(boolean)
,
plugViewListener(boolean)
,
plugSelectionListener(boolean)
,
plugManagerListener(boolean)
public void plugModelListener(boolean on)
on
- true to install (automatically done) or false to uninstallpublic boolean isModelListenerPlugged()
plugModelListener(boolean)
public void plugViewListener(boolean on)
on
- true to install (automatically done) or false to uninstallpublic boolean isViewListenerPlugged()
plugViewListener(boolean)
public void plugSelectionListener(boolean on)
on
- true to install (automatically done) or false to uninstallpublic boolean isSelectionListenerPlugged()
plugSelectionListener(boolean)
public void plugManagerListener(boolean on)
on
- true to install (automatically done) or false to uninstallpublic boolean isManagerListenerPlugged()
plugManagerListener(boolean)
public void setGrapher(IlvGrapher grapher)
grapher
- The new grapher in which this SDM engine will render
its data model.public IlvGrapher getGrapher()
public com.ibm.icu.util.ULocale getULocale(IlvSDMModel model, Object obj, com.ibm.icu.util.ULocale fallBackLocale)
This method is for internal use; you should not call it directly.
model
- A model.obj
- An object in this model.fallBackLocale
- This locale is returned if the object does not
correspond to a graphic object or is not contained in any
grapher.public ComponentOrientation getComponentOrientation(IlvSDMModel model, Object obj, ComponentOrientation fallBackComponentOrientation)
This method is for internal use; you should not call it directly.
model
- A model.obj
- An object in this model.fallBackComponentOrientation
- This component orientation is returned
if the object does not
correspond to a graphic object or is not contained in any
grapher.public void setBaseTextDirection(int baseTextDirection)
IlvBidiUtil.COMPONENT_DIRECTION
:
the base text direction is calculated from the
component orientation.
IlvBidiUtil.LEFT_TO_RIGHT
:
the base text direction is left-to-right.
IlvBidiUtil.RIGHT_TO_LEFT
:
the base text direction is right-to-left.
IlvBidiUtil.CONTEXTUAL_DIRECTION
:
the base test direction is determined from the text
that is displayed according to the standard Bidi
algorithm, if the text contains at least one character
with a strong left-to-right or right-to-left direction.
If the text doesn't contain any character with a strong
direction, the real text direction is determined from
the current component orientation of the object.
setUseBaseTextDirectionFromStyleSheetRenderer(boolean)
with a
false
argument to disable that the base text direction
of the renderer is taken into account.baseTextDirection
- The base text directionpublic void setBaseTextDirection(int baseTextDirection, boolean draw)
IlvBidiUtil.COMPONENT_DIRECTION
:
the base text direction is calculated from the
component orientation.
IlvBidiUtil.LEFT_TO_RIGHT
:
the base text direction is left-to-right.
IlvBidiUtil.RIGHT_TO_LEFT
:
the base text direction is right-to-left.
IlvBidiUtil.CONTEXTUAL_DIRECTION
:
the base test direction is determined from the text
that is displayed according to the standard Bidi
algorithm, if the text contains at least one character
with a strong left-to-right or right-to-left direction.
If the text doesn't contain any character with a strong
direction, the real text direction is determined from
the current component orientation of the object.
setUseBaseTextDirectionFromStyleSheetRenderer(boolean)
with a
false
argument to disable that the base text direction
of the renderer is taken into account.baseTextDirection
- The base text directiondraw
- Whether to draw the manager.public int getBaseTextDirection()
public void setUseBaseTextDirectionFromStyleSheetRenderer(boolean use)
setBaseTextDirection(int)
on the SDM Engine has only
an intermediate effect, since the next full styling will override it
with the setting in the style sheet renderer.
If the option is set to false, the CSS specification
StyleSheet {
baseTextDirection: ...;
}
has no effect anymore.use
- Whether the setting at the style sheet renderer is used.public boolean isUseBaseTextDirectionFromStyleSheetRenderer()
public static void setSDMEngine(IlvGrapher grapher, IlvSDMEngine engine)
grapher
- The grapher whose associated SDM engine is requested.engine
- The SDM engine.public static IlvSDMEngine getSDMEngine(IlvGrapher grapher)
null
if no SDM engine is associated
with the specified grapher.grapher
- The grapher whose associated SDM engine is requested.public static IlvSDMEngine getSDMEngine(IlvGraphic graphic)
null
if the graphic is not contained in
a grapher or if the grapher has no associated SDM engine.graphic
- The graphic object whose associated SDM engine is requested.public void setCompiledSymbolAutoLoad(boolean on)
class : '@|symbolResource(ilog/views/palettes/CompileTest/symbols/RoundOrange.css,Symbol,Symbols.RoundOrange,ilog/views/palettes/CompileTest/palette.xml,file:/E:/My Documents/CompileTest.jar'; is interpreted as class : 'ilog.views.palettes.CompileTest.RoundOrange';Remember to have the compiled symbol in the classpath.
public boolean isCompiledSymbolAutoLoad()
public IlvSDMModel getModel()
public void setModel(IlvSDMModel model)
This call causes the data model to be loaded and rendered by the engine.
model
- The new data model to use.setModel(ilog.views.sdm.IlvSDMModel, boolean)
public void setModel(IlvSDMModel model, boolean reload)
This call causes the data model to be loaded and rendered
only if the reload
parameter is true
model
- The new data model to use.reload
- If true
, causes the data to be
reloaded by the SDM engine.setModel(ilog.views.sdm.IlvSDMModel)
public void setXMLFile(String xmlFile) throws IlvSDMException, IOException, MalformedURLException
The XML file is parsed, and its contents are rendered graphically by the SDM engine.
If the XML file contains a processing instruction of the form:
<?sdm stylesheet="example.css"?>then the specified style sheet is used to display the data. Warning: This will override the current renderer.
Otherwise, the current style sheet is used.
xmlFile
- The URL of the XML file.IlvSDMException
- if an error occurred while opening or
reading the XML file.IOException
- if an I/O error occurred while opening or
reading the XML file.MalformedURLException
- if xmlFile is not an URLIlvXMLConnector
public String getXMLFile()
null
if the current model does not support XML or if
no XML file is currently displayed.public void readXML(String url) throws IlvSDMException, IOException, MalformedURLException
url
- The URL to read the XML description from.IlvSDMException
- if a SDM exception occursIOException
- if an IOException occursMalformedURLException
- if url is malformedreadXML(java.lang.String,boolean)
,
readXML(java.io.Reader,boolean)
public void readXML(String url, boolean add) throws IlvSDMException, IOException, MalformedURLException
This method is similar to readXML(java.lang.String)
,
except that it has an additional add
parameter
that allows you to add the contents of the XML file to
the current data model.
url
- The URL to read the XML description from.add
- If this parameter is false
, the SDM data model
is cleared before reading the XML file. If this parameter is true
,
the contents of the XML file are added to the SDM data model.IlvSDMException
- if a SDM exception occursIOException
- if an IOException occursMalformedURLException
- if url is malformedpublic void readXML(InputStream stream) throws IlvSDMException, IOException
stream
- The XML formatted input stream.IlvSDMException
- if a SDM exception occursIOException
- if an IOException occursreadXML(java.io.InputStream,boolean)
,
readXML(java.io.Reader,boolean)
public void readXML(Reader reader, boolean add) throws IlvSDMException, IOException
Reader
.
This method is similar to readXML(java.io.Reader)
,
except that it has an additional add
parameter
that allows you to add the contents of the XML file to
the current data model.
reader
- The XML-formatted reader.add
- If this parameter is false
, the SDM data model
is cleared before reading the XML file. If this parameter is true
,
the contents of the XML file are added to the SDM data model.IlvSDMException
- if a SDM exception occursIOException
- if an IOException occursreadXML(java.io.InputStream,boolean)
public void readXML(Reader reader) throws IlvSDMException, IOException
Reader
.reader
- The XML-formatted reader.IlvSDMException
- if a SDM exception occursIOException
- if an IOException occursreadXML(java.io.Reader,boolean)
,
readXML(java.io.InputStream,boolean)
public void readXML(InputStream stream, boolean add) throws IlvSDMException, IOException
This method is similar to readXML(java.io.InputStream)
,
except that it has an additional add
parameter
that allows you to add the contents of the XML stream to
the current data model.
stream
- The XML-formatted input stream.add
- If this parameter is false
, the SDM data model
is cleared before reading the XML stream. If this parameter is true
,
the contents of the XML stream are added to the SDM data model.IlvSDMException
- if a SDM exception occursIOException
- if an IOException occurspublic void readDOM(Document document) throws IlvSDMException, IOException
readXML(java.io.InputStream)
,
but the parsing is done entirely in memory: no temporary file is used.
This method is useful to create an SDM model from an existing DOM document. For example, you might have an existing DOM document that does not have the right format for SDM. You can process this document through an XSLT engine and pass the output document to the SDM engine using this method.
document
- The DOM document containing the description
of the SDM data model.IlvSDMException
- if a SDM exception occursIOException
- if an IOException occursreadDOM(org.w3c.dom.Document,boolean)
public void readDOM(Document document, boolean add) throws IlvSDMException, IOException
This method is similar to readDOM(org.w3c.dom.Document)
,
except that it has an additional add
parameter
that allows you to add the contents of the DOM document to
the current data model.
document
- The DOM document containing the description
of the SDM data model.add
- If this parameter is false
, the SDM data model
is cleared before reading the document. If this parameter is true
,
the contents of the document are added to the SDM data model.IlvSDMException
- if a SDM exception occursIOException
- if an IOException occurspublic void writeXML(String filename) throws IOException
filename
- The path of the XML file.IOException
- if an error occurred while opening the file or writing the data.public void writeXML(OutputStream stream) throws IOException
stream
- The output stream to write the data to.IOException
- if an error occurred while writing the data.writeXML(java.io.Writer)
public void writeXML(Writer writer) throws IOException
Writer
.writer
- The Writer
to write the data to.IOException
- if an error occurred while writing the data.writeXML(java.io.OutputStream)
public void writeDOM(Document document)
This method is useful when you want to process the SDM data, for example, using an XSLT engine.
document
- The DOM document to write the SDM data to.public void setXMLConnector(IlvXMLConnector connector)
IlvXMLConnector
object used to read and write the contents of the
SDM data model from/to XML files.
By default, the contents of an SDM model are read and written
by an instance of the class
IlvXMLConnector
, which
defines its own XML format as explained in the
class description.
If you want to read and write XML files in
another format, you can subclass IlvXMLConnector
and set the SDM engine's XML connector to an instance
of your subclass.
connector
- The new
IlvXMLConnector
object.public IlvXMLConnector getXMLConnector()
IlvXMLConnector
object used to read and write the contents of the
SDM data model from/to XML files.
If no custom XML connector has been specified, an
instance of the class
IlvXMLConnector
is
returned.
setXMLConnector(ilog.views.sdm.util.IlvXMLConnector)
public void setXMLProcessingInstructionProperty(String property, String value)
<?sdm property1="value1" property2="value2" ... ?>
When an XML file is read, each property found in the processing
instruction is interpreted by the method processXMLProcessingInstructionProperty(java.lang.String, java.lang.String, java.lang.String, boolean)
.
By default, only the property "stylesheet"
is understood.
property
- The name of the processing instruction property.value
- The value of the processing instruction property.public String getXMLProcessingInstructionProperty(String property)
property
- The name of the processing instruction property.setXMLProcessingInstructionProperty(java.lang.String, java.lang.String)
protected void processXMLProcessingInstructionProperty(String property, String value, String url, boolean insert) throws IlvSDMException
By default, only the property "stylesheet"
is understood.
When this property is present in the XML file, it causes the specified
style sheets to be applied to the XML data. The value of the
"stylesheet"
property is a list of comma-separated URLs.
The list can contain a '+'
character: in that case, the
current style sheets of the SDM engine are inserted at the specified
position. Duplicate style sheets are removed during this process.
Examples: The following processing instruction applies the
style sheets a.css
and b.css
to the data
objects read from the XML files.
<?sdm stylesheet="a.css,b.css" ?>
The following processing instruction cascades the
style sheets a.css
and b.css
after the
current style sheet(s) of the SDM engine:
<?sdm stylesheet="+,a.css,b.css" ?>
property
- The name of the processing instruction property.
The default implementation handles the property "stylesheet"
,
and ignores any other property.value
- The value of the processing instruction property.url
- The URL from which the XML data was read.insert
- This parameter is true
if the XML
file has been inserted in the current SDM data model. It is
false
if the XML file has replaced the current
contents of the data model.IlvSDMException
- if an SDM exception occurspublic IlvSDMRenderer getRenderer()
getRenderer()
public void setRenderer(IlvSDMRenderer renderer)
The renderers attached
to an SDM engine form a chained list. This method is used to set the first element
of this list. All but the last element of the list are instances of
IlvFilterSDMRenderer
. The next element
in the list is defined by the method
setFilteredRenderer
.
The last element of the list is usually an instance of
IlvStyleSheetRenderer
.
Note that the preferred way to customize the renderers attached to an SDM engine
is through the style sheet, by setting options
(for example: LinkLayout : "true";
, and so on). Calling this method
will completely replace the renderers configured in the style sheet. Inversely,
when a new style sheet is loaded, the current renderer list will be completely
replaced by the renderers declared in the style sheet.
When this method is called, the data model is reloaded and the graph is rebuilt.
renderer
- The new root SDM renderer.public void setBaseURL(String url)
The base URL is set automatically when you
call the setStyleSheets(java.lang.String[])
method.
url
- The new base URL.public String getBaseURL()
public void setReferenceZoom(double zoom)
zoom
- The reference zoom factor.public double getReferenceZoom()
public String getID(Object obj)
obj
- The data object (an object returned by the data model
attached to this engine) whose identifier is requested.public Object getObject(String id)
id
- The identifier of the requested object.null
if it does not exist.public String[] getPseudoClasses(Object object)
object
- The data object whose pseudo-classes are queried.setPseudoClasses(String[])
.public void setPseudoClasses(String[] classes)
The pseudoclasses defined here are merged with object pseudoclasses
set in addPseudoClass(Object, String)
.
Warning: Changing the pseudoclasses does not refresh automatically the diagram.
classes
- An array of strings that identify the pseudoclasses
to associate with all the data objects.public String[] getPseudoClasses()
public void addPseudoClass(Object object, String pseudoClass)
object
- The data object.pseudoClass
- A string that identifies a pseudo-class
to add to the classes already associated with the data object.public void removePseudoClass(Object object, String pseudoClass)
object
- The data object.pseudoClass
- A string that identifies a pseudo-class
to remove from the classes associated with the data object.public boolean hasPseudoClass(Object object, String pseudoClass)
true
if and only if the specified object has
the specified pseudo-class.object
- The data object.pseudoClass
- The pseudo-class.public Enumeration<?> getObjectsWithPseudoClass(String pseudoClass)
pseudoClass
- The pseudo-class.public String getDetailLevel()
HIGH_DETAIL_LEVEL
, MEDIUM_DETAIL_LEVEL
, or
LOW_DETAIL_LEVEL
(respectively,
"high-detail-level", "medium-detail-level", or "low-detail-level").public void setDetailLevel(String level)
Nodes and links can be rendered differently depending on the level of detail. In the CSS rules, the pseudoclasses "high-detail-level", "medium-detail-level", and "low-detail-level" are used to specify the rendering. For instance:
node { ... settings that affect all detail levels ... } node:high-detail-level { ... settings that affect only the high detail level ... } node:medium-detail-level { ... settings that affect only the medium detail level ... } node:low-detail-level { ... settings that affect only the low detail level ... }Note: it is the callers responsibility to update the graphic objects that are impacted by the level change. This can be done by calling
loadData()
to trigger a restyling.level
- Set to one of the following:
HIGH_DETAIL_LEVEL
- high-detail-level (the default)MEDIUM_DETAIL_LEVEL
- medium-detail-levelLOW_DETAIL_LEVEL
- low-detail-levelpublic String getContrastAccessibilityTheme()
NORMAL_CONTRAST
or HIGH_CONTRAST
(respectively, "normal-contrast", or "high-contrast").public void setContrastAccessibilityTheme(String theme)
Nodes and links can be rendered differently depending on the contrast theme. In the CSS rules, the pseudoclasses "high-contrast" and "normal-contrast" are used to specify the rendering. For instance:
node { ... settings that are independent from the contrast theme ... } node:high-contrast { ... settings that affect only the high contrast theme ... } node:normal-contrast { ... settings that affect only the normal contrast theme ... }Note: On Windows, the high contrast theme can be choosen by the operating system. In this case, the engine is initialized with high contrast theme, otherwise it is initialized with normal contrast theme. The initial setting can be changed through this API. In this case, it is the callers responsibility to update the graphic objects that are impacted by the theme change. This can be done by calling
loadData()
to trigger a restyling.theme
- Set to one of the following:
HIGH_CONTRAST
- high-contrastNORMAL_CONTRAST
- normal-contrastpublic IlvGraphic recreateObject(Object object, boolean redraw, boolean oneLevel)
object
- The model object.redraw
- If true
, the object will be redisplayed.oneLevel
- If false
, the child objects are also re-created.public void loadData()
This method is called automatically when the model
fires a dataChanged
event, but it can
also be called explicitly to load or reload
the data.
This method removes all the graphic objects from the grapher before loading the new data.
public ilog.views.sdm.internal.IlvGrapherCleanerHandler getGrapherCleanerHandler()
public void setGrapherCleanerHandler(ilog.views.sdm.internal.IlvGrapherCleanerHandler handler)
handler
- the new handlerpublic void customizeAllObjects()
This method can be used instead of loadData()
to
update the display more quickly. As opposed to loadData()
,
the graphic objects are not re-created. Instead, the current style
sheets are reapplied to the existing graphic objects.
This method is called by setStyleSheets(java.lang.String[],boolean,boolean)
when the reload
parameter is true
and the recreate
parameter is false
.
Note that you do not usually need to call this method, since the SDM display is updated automatically when the data model or the style sheets are modified.
public void renderingDone()
renderingDone
method of the renderer.public IlvGraphic getGraphic(Object object, boolean createIfNeeded)
createIfNeeded
is true
,
then the graphic object is created.object
- The application object
to translate into an IlvGraphic
.createIfNeeded
- Specifies whether the graphic object should
be created if it does not exist yet.public Object getObject(IlvGraphic graphic)
null
if the specified graphic object
does not represent an object of the data model.graphic
- The graphic object.public Object getObject(IlvPoint p, IlvManagerView view)
p
- The location of the point in view coordinates.view
- The manager view.null
.public Object getObject(IlvPoint p, IlvManagerView view, boolean traverse)
p
- The location of the point in view coordinates.view
- The manager view.traverse
- If true
, this method will recursively
traverse the subgraphs to find the graphic object located at the
specified point.null
.public void setReferenceView(IlvManagerView view)
view
- The manager view.public IlvManagerView getReferenceView()
setReferenceView(ilog.views.IlvManagerView)
, this view is returned.
Otherwise, the first view associated with the
engine's grapher is returned. If the grapher has
no view, the method returns null
.public Enumeration<?> getAllObjects()
public boolean isLinkNodeVisibilityCoupled()
true
if the links are visible (if and only if origin and
destination nodes are visible).
Returns false
if the links can be made visible or invisible
independently of the visibility of their end nodes.true
if link visibility is coupled with node visibility.setLinkNodeVisibilityCoupled(boolean)
public void setLinkNodeVisibilityCoupled(boolean coupled)
If coupled, links are visible if and only if origin and destination nodes are visible. In this case, specifying the visibility of a link in CSS has no effect.
If uncoupled, links can be made visible or invisible independently from the visibility of their end nodes. In this case, it is possible to specify the visibility of links in CSS.
It is recommended to change this option only when the grapher of the engine is still empty.
coupled
- If true
, links are visible if and only if
origin and destination nodes are visible.setLinkNodeVisibilityCoupled(boolean)
public void setHighlightingSelection(boolean yes)
When selection by highlighting is enabled, the selected graphic objects
are not shown using the usual square handles. Instead, the SDM engine
fetches the properties to set on the graphic objects from the style sheet.
The highlighting properties are fetched using the selected
pseudo-class.
For example, the style sheet could contain the following rules:
node:selected { foreground : "yellow"; } link:selected { mode : "MODE_NEON"; }With these rules, the selected nodes will be yellow, and the selected links will be displayed with a neon-like gradient.
yes
- If true
, selected objects
are highlighted. Otherwise, the usual JViews selection handles are used.public boolean isHighlightingSelection()
true
if "selection by highlighting" is enabled,
or false
if the usual selection handles are used to show
selected objects.public boolean isResizingAllowed()
true
if the user is allowed to resize nodes
interactively.setResizingAllowed(boolean)
public void setResizingAllowed(boolean allowed)
allowed
- If true
, selected nodes have "handles"
that the user can drag to resize them. If false
, selected
nodes have no handles, and the user can only move them.public void updateObjectProperties(Object object, String property, Object value, String[] pseudoClasses)
IlvSDMRenderer.updateObjectProperties(ilog.views.sdm.IlvSDMEngine, java.lang.Object, java.lang.String, java.lang.Object, java.lang.String[])
on the root renderer of the SDM engine.object
- The data object.property
- The name of the rendering property.value
- The new value of the property.pseudoClasses
- The pseudo classes of the object.
This parameter can be null
.IlvSDMRenderer.updateObjectProperties(ilog.views.sdm.IlvSDMEngine, java.lang.Object, java.lang.String, java.lang.Object, java.lang.String[])
public void setOpaqueMove(boolean opaque)
opaque
- The new Opaque Move mode.IlvSelectInteractor.setOpaqueMove(boolean)
public boolean isOpaqueMove()
setOpaqueMove(boolean)
public void setLinkLayoutEnabledWhileMoving(boolean enabled)
enabled
- new valuesetLinkLayoutEnabled(boolean)
public boolean isLinkLayoutEnabledWhileMoving()
true
if the automatic link layout is enabled while
moving a node.setLinkLayoutEnabledWhileMoving(boolean)
,
setLinkLayoutEnabled(boolean)
public int getRenderingDoneMode()
IlvSDMRenderer.renderingDone(ilog.views.sdm.IlvSDMEngine)
method is called on selection or property changes.setRenderingDoneMode(int)
public void setRenderingDoneMode(int renderingDoneMode)
IlvSDMRenderer.renderingDone(ilog.views.sdm.IlvSDMEngine)
method is called on selection or property changes.
The IlvSDMRenderer.renderingDone(ilog.views.sdm.IlvSDMEngine)
method is always called when a graph is loaded, or when objects are
created, deleted or moved by a user interaction. The
IlvSDMRenderer.renderingDone(ilog.views.sdm.IlvSDMEngine)
method
is also always called at the end of an adjustment sequence
(see setAdjusting(boolean)
).
Calling IlvSDMRenderer.renderingDone(ilog.views.sdm.IlvSDMEngine)
will typically perform a graph or a link layout.
It may be necessary, though, to call this method also when an object is
selected or deselected, or when a single property of a data object is
changed. This flag determines whether
IlvSDMRenderer.renderingDone(ilog.views.sdm.IlvSDMEngine)
will be called
in these cases or not.
renderingMode
is IF_BBOX_CHANGED
, the
IlvSDMRenderer.renderingDone(ilog.views.sdm.IlvSDMEngine)
method
will be called on selection or property changes only if the bounding
box of a graphic object has changed. This mode is the default, and
is suitable for most cases, because the graph or link layout
generally depends only on the position and size of the objects.renderingMode
is ALWAYS
, the
IlvSDMRenderer.renderingDone(ilog.views.sdm.IlvSDMEngine)
method
will be called on every selection or property change, even if no
bounding boxes have changed. This mode can be used if the style sheet
contains advanced settings such that the layout depends on the
selected state or on a particular property value.renderingMode
is NEVER
, the
IlvSDMRenderer.renderingDone(ilog.views.sdm.IlvSDMEngine)
method
will never be called on selection or property changes. This mode can
be used to get better performances, but you should use it only
if you are sure that no relayout is necessary when an object is
selected or when a property is changed.renderingDoneMode
- One of IF_BBOX_CHANGED
,
ALWAYS
or NEVER
.getRenderingDoneMode()
public void updateNodePositions()
This is particularly useful if you use an automatic graphic layout
algorithm (through the IlvGraphLayoutRenderer
)
to save the positions computed by the layout algorithm
in the data model.
public void updateNodePositions(Iterator<Object> nodes)
This is particularly useful if you use an automatic graphic layout
algorithm (through the IlvGraphLayoutRenderer
)
to save the positions computed by the layout algorithm
in the data model.
nodes
- The SDM model nodes to be handled.IlvGraphLayoutRenderer.setSavingNodePositions(boolean)
public void moveObject(Object object, IlvManagerView view, double x, double y, boolean translate, int alignment, boolean redraw)
If the object does not have a graphic representation, this method does nothing.
object
- The data object to modify.view
- The manager view in which the object is moved.
If view
is non-null
, the x
and
y
coordinates are relative to that view. If view
is null
, the coordinates are relative to the
top-level grapher.x
- The new horizontal position, in view coordinates.y
- The new vertical position, in view coordinates.translate
- If true
, the object is just translated.
In that case, the x
and y
parameters are the
offsets by which the object is to be translated.alignment
- The alignment of the new bounding box of
the object with respect to the point. This can be one of
IlvDirection.Center
,
IlvDirection.Top
,
IlvDirection.Bottom
,
IlvDirection.Left
,
IlvDirection.Right
,
IlvDirection.TopLeft
,
IlvDirection.BottomLeft
,
IlvDirection.TopRight
, or
IlvDirection.BottomRight
. If translate is true, this argument is ignored.redraw
- If true
, the regions
covered by the old and new positions of the object are refreshed.@Deprecated public void moveObject(Object object, double x, double y, IlvTransformer t, int alignment, boolean redraw)
moveObject(java.lang.Object,ilog.views.IlvManagerView,double,double,boolean,int,boolean)
instead.If the object does not have a graphic representation, this method does nothing.
object
- The data object to modify.x
- The new horizontal position, in view coordinates.y
- The new vertical position, in view coordinates.t
- The transformer of the view.alignment
- The alignment of the new bounding box of
the object with respect to the point. This can be one of
IlvDirection.Center
,
IlvDirection.Top
,
IlvDirection.Bottom
,
IlvDirection.Left
,
IlvDirection.Right
,
IlvDirection.TopLeft
,
IlvDirection.BottomLeft
,
IlvDirection.TopRight
, or
IlvDirection.BottomRight
.redraw
- If true
, the regions
covered by the old and new positions of the object are refreshed.public Enumeration<?> getSelectedObjects()
setAllSelectedObjects(Collection)
public void setSelected(Object object, boolean selected)
object
- The data object whose graphic representation
must be selected or deselected.selected
- Specifies if the object must be selected or
deselected.public void setSelected(Object[] objects, boolean selected)
objects
- The data objects whose graphic representations
must be selected or deselected.selected
- Specifies whether the objects must be selected or
deselected.setAllSelectedObjects(Collection)
public boolean isSelected(Object object)
true
if and only if the graphic
representation of the specified object is selected.object
- The data object whose graphic representation's
selected state is queried.public void selectAllObjects()
public void deselectAllObjects()
public void setAllSelectedObjects(Collection<?> objects)
objects
- A set of data model objects.getSelectedObjects()
public void scrollToObject(Object object)
object
- The object of the SDM data model that must be made visible.public String getSelectionPseudoClass()
setSelectionPseudoClass(java.lang.String)
public void setSelectionPseudoClass(String selectionPseudoClass)
The default selection pseudo-class is "selected"
,
so selected objects can be styled differently from non-selected
objects by adding rules like this in the style sheet:
node:selected { foreground : "red"; }
You do not usually need to change the selection pseudo-class; this method is reserved for advanced uses.
selectionPseudoClass
- The new pseudo-class used to style selected
objects. If this parameter is null
, the default pseudo-class
("selected"
) is restored.public void setDropToGroupEnabled(boolean enabled)
IlvMakeSDMNodeInteractor
and
IlvSDMDropTarget
classes,paste()
and duplicate()
methods.enabled
- If true
,
dropping or duplicating a node in
an existing subgraph will make the node a child of this
subgraph. Otherwise, the node is added at the top level
of the graph.public boolean isDropToGroupEnabled()
true
if dropping or duplicating a node in
an existing subgraph will make the node a child of this
subgraph, or false
otherwise.setDropToGroupEnabled(boolean)
public Object getParent(IlvManagerView view, double x, double y, boolean managerCoordinates)
isDropToGroupEnabled()
returns true
, to find the parent group in which a
new node is created.view
- The manager view.x
- The X-coordinate of the point where the new object is dropped.y
- The Y-coordinate of the point where the new object is dropped.managerCoordinates
- If this parameter is true
, the x
and y
parameters are considered as manager coordinates. Otherwise,
they are considered as view coordinates.public void setAdjusting(boolean adjusting)
This method is used to tell the SDM engine that a sequence of modifications of the data model should be considered as a whole. The SDM engine will then be able to optimize its internal updating mechanism, and will render the changes more efficiently at the end of the editing sequence.
Editing sequences can be nested. For example, consider the following calls:
engine.setAdjusting(true); // edit data model... engine.setAdjusting(true); // more edits of the data model... engine.setAdjusting(false); engine.setAdjusting(false);The engine will update the display only on the last
setAdjusting(false)
call.
Calls to setAdjusting(true)
and setAdjusting(false)
must be balanced.
adjusting
- If true
,
and if the engine was not already in an editing sequence,
a new sequence is started. If false
,
and if this call matches the first setAdjusting(true)
,
then the editing sequence ends, and the engine updates the
display.public void clearAdjusting()
Use this method instead of setAdjusting(false)
to validate model changes without spending time refreshing the modified
objects. For example, call this method when the changes do not impact the
graphical representations.
setAdjusting(boolean)
public boolean isAdjusting()
true
if and only if the SDM engine
is currently in an editing sequence.setAdjusting(boolean)
public void copy()
public void cut()
public void paste()
If isDropToGroupEnabled()
returns true
,
and if only one subgraph is selected, the pasted objects are
created as children of the selected subgraph.
If isDropToGroupEnabled()
returns true
,
and several objects are selected, the pasted objects are
created as children of the common ancestor of the selected objects.
If isDropToGroupEnabled()
returns false
,
or if no objects are selected, the pasted objects are
created at the top level of the graph.
The graphic representations of the new objects are selected and translated down and to the right by 20 pixels.
public void duplicate()
If isDropToGroupEnabled()
returns true
,
the duplicated objects are
created as children of the common ancestor of the selected objects.
If isDropToGroupEnabled()
returns false
,
or if no objects are selected, the duplicated objects are
created at the top level of the graph.
The graphic representations of the new objects are selected and translated down and to the right by 20 pixels.
public void setEmptySubgraphAllowed(boolean allowed)
IlvSDMEngine
also removes their empty parent subgraphs. This is the default behavior.isEmptySubgraphAllowed()
public boolean isEmptySubgraphAllowed()
true
if empty subgraphs are allowed.true
if empty subgraphs are allowed.setEmptySubgraphAllowed(boolean)
public void delete()
public void group(Object parent)
This method makes the selected objects children of the specified parent object.
parent
- The object that will become the parent
of the new group. Note: The parent must not have
already been added to the data model. This method will
add it itself.public void ungroup()
The children of each selected object(s)
are removed from the data model, and added back
at the top level of the model (that is, with a null
parent).
Note that the parent objects are removed from the data model.
public String getStringFromClipboard()
public void putStringToClipboard(String data)
data
- public boolean canPaste()
public IlvGraphLayoutRenderer getNodeLayoutRenderer()
null
if no node layout
renderer is attached to this SDM engine.public void setNodeLayoutEnabled(boolean enabled)
enabled
- If true
,
the node layout algorithm will be enabled; otherwise it will be
disabled.public boolean isNodeLayoutEnabled()
false
.public void performNodeLayout()
This method is useful to perform a "one-shot" layout on the nodes of the graph. It is useful only if the SDM style sheet specifies a node layout algorithm.
Note: In versions prior to JViews 5.5, this method performed an incremental layout if some nodes were selected and the layout algorithm was a hierarchical layout. This is no longer true beginning with JViews 5.5.
public IlvGraphLayoutRenderer getLinkLayoutRenderer()
null
if no link layout
renderer is attached to this engine.public void setLinkLayoutEnabled(boolean enabled)
enabled
- If true
,
the link layout algorithm will be enabled; otherwise it will be
disabled.public boolean isLinkLayoutEnabled()
false
.public void performLinkLayout()
This method is useful to perform a "one-shot" layout on the links of the graph. It is useful only if the SDM style sheet specifies a link layout algorithm, and if the link layout is not enabled by default.
public IlvLabelLayoutRenderer getLabelLayoutRenderer()
null
if no label layout
renderer is attached to this engine.public void setLabelLayoutEnabled(boolean enabled)
enabled
- If true
,
the label layout algorithm will be enabled; otherwise it will be
disabled.public boolean isLabelLayoutEnabled()
false
.public void performLabelLayout()
This method is useful to perform a "one-shot" layout on the labels of the graph. It is useful only if the SDM style sheet specifies a label layout algorithm, and if the label layout is not enabled by default.
public void setLayoutRunning(boolean running)
running
- The new value of the flag.public boolean isLayoutRunning()
public void setMetadataEnabled(boolean on)
true
, an IlvRDFSDMModel
is added to
the model pipeline to
handle metadata. Metadata are identified as namespaced property
names (for example "sdm:x"). Note that metadata are automatically
enabled if an XML file is loaded and it contains RDF
descriptions.
WARNING: This method should be called before the
model is indeed loaded, because metadata are dispatched to a
special SDM model. Also, when turned off during a session, the
loaded metadata are no longer reachable.on
- Enables metadata if true
, and disables
metadata if false
.IlvRDFSDMModel
,
isMetadataEnabled()
public boolean isMetadataEnabled()
true
if metadata are enabled.setMetadataEnabled(boolean)
public void addSDMEngineDataLoadingListener(SDMEngineDataLoadingListener listener)
SDMEngineDataLoadingListener
to this SDM engine.listener
- The listener to add.public void removeSDMEngineDataLoadingListener(SDMEngineDataLoadingListener listener)
SDMEngineDataLoadingListener
from this SDM engine.listener
- The listener to remove.public void addSDMEngineStyleSheetListener(SDMEngineStyleSheetListener listener)
SDMEngineStyleSheetListener
to this SDM engine.listener
- The listener to add.public void removeSDMEngineStyleSheetListener(SDMEngineStyleSheetListener listener)
SDMEngineStyleSheetListener
from this SDM engine.listener
- The listener to remove.public void addSDMEngineSelectionListener(SDMEngineSelectionListener listener)
SDMEngineSelectionListener
to this SDM engine.listener
- The listener to add.public void removeSDMEngineSelectionListener(SDMEngineSelectionListener listener)
SDMEngineSelectionListener
from this SDM engine.listener
- The listener to remove.public boolean processServerAction(int x, int y, IlvManagerView view)
The SDM engine will call the
IlvSDMRenderer.processServerAction(int, int, ilog.views.IlvManagerView)
method of the renderer chain. Each renderer will decide if and how
it wishes to process the action.
x
- The X coordinate of the point where the user clicked on the client-side,
in view coordinates.y
- The y coordinate of the point where the user clicked on the client-side,
in view coordinates.view
- The view used to render the graph image.true
if the action was processed,
false
if the action was not processed.public Object getCSSInternal()
getCSSInternal
in interface ilog.views.util.cssbeans.IlvCSSCompatible
© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.