public class IlvStyleSheetRenderer extends IlvSDMRenderer implements IlvStylable
Note that the full hierarchy under the root node must be available (no delayed load).
Reaction to property changes means rematching the rules against the root node, and then applying graphic attributes to all nodes.
Nodes and links are instantiated from a class name specified by
the declaration "class". Instances may also be created by factory,
prototypes, and Java serialized beans (see
createNodeInstance(ilog.views.sdm.IlvSDMEngine, java.lang.Object, java.util.Map)
for more details).
IlvStyleSheetRenderer
defines the following renderer graphic
properties: x, y, width, height, Anchor, Layer. The first five are
ignored for links. "Anchor" means the object bounding box anchor,
as defined in IlvConstants
(for example, TOPLEFT,
CENTER). "Layer" is the insertion layer for nodes and link.
The "toolTipText" property can be used to set the tooltip of any node or link.
Pseudoclasses of IlvStyleSheetRenderer
are "renderer" and
"styleSheetRenderer". Here is an example of a rule that matches only this renderer:
node:styleSheetRenderer { Anchor : Center; }
The way CSS declarations are applied to IlvGraphic
s is
explained in customize(ilog.views.sdm.IlvSDMEngine, java.lang.Object, ilog.views.IlvGraphic, java.lang.String[])
.
To match CSS rules:
CSS type is "node" or "link", according to the model predicate isLink()
,
CSS ID matches getID()
on nodes,
CSS class matches node getTag()
or property "CSSclass" on node
(customizable). CSS classes must be " " separated.
CSS Attribute matches property of same name on node.
CSS Pseudoclasses match renderer pseudoclasses (in
getGraphicProperty()
).
Note concerning the base URL: The style sheet manages its own
base URL, which is updated while resolving import statements. The
starting base URL is deduced by the style sheet references in the
array given to setStyleSheets(String[])
, or is fixed by the
constructor. Base URL is needed to resolve the right-hand part of
declarations like "prop : url(relative-path);"
See also the User's Manual for more details.
Modifier and Type | Field and Description |
---|---|
static boolean |
_debug
Globally enables debug messages according to debug level if
true (default). |
static PrintStream |
_error
Debug output.
|
static int |
ACTUAL_LOCATION_MASK
Debug mask: shows node actual location (bbox centered).
|
static int |
CENTER
Link connector mode: Use
IlvSDMLinkConnector for all nodes. |
static int |
CLIP
Link connector mode: Use
IlvSDMClippingLinkConnector for all nodes. |
protected String |
defaultCSS
Fallback CSS.
|
static int |
FREE
Link connector mode: Use
IlvSDMFreeLinkConnector for all nodes. |
static int |
IMAGE_MASK
Debug mask: displays a clone of the node in a separate window.
|
static int |
LOCATION_MASK
Debug mask: shows node asked location (from the model).
|
PSEUDOCLASS_PREFIX
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 |
---|
IlvStyleSheetRenderer()
Creates a renderer to handle CSSs.
|
IlvStyleSheetRenderer(ilog.views.util.css.IlvCSSEngine engine)
Creates a renderer to handle CSSs.
|
IlvStyleSheetRenderer(Reader css,
URL baseURL)
Creates a renderer to handle CSSs.
|
Modifier and Type | Method and Description |
---|---|
void |
addLinkGraphic(IlvSDMEngine engine,
Object node,
IlvGraphic graphic,
boolean redraw)
Adds the graphic object returned by
createLinkGraphic()
to the grapher of the SDM engine. |
void |
addNodeGraphic(IlvSDMEngine engine,
Object node,
IlvGraphic graphic,
boolean redraw)
Adds the graphic object returned by
createNodeGraphic()
to the grapher of the SDM engine. |
void |
addPropertyChangeListener(PropertyChangeListener listener)
Adds a listener on property modification.
|
void |
clear()
Cleans up the renderer.
|
void |
clear(Object modelObject)
Clean-up cache information associated to the given object, if
any.
|
IlvGraphic |
createLinkGraphic(IlvSDMEngine engine,
Object node,
IlvGraphic from,
IlvGraphic to)
Creates an
IlvLinkImage object that represents an SDM link,
and customizes it. |
protected IlvGraphic |
createLinkInstance(IlvSDMEngine engine,
Object node,
IlvGraphic from,
IlvGraphic to,
Map decls)
Creates a link instance, according to the model and the style
sheet declarations.
|
protected IlvGraphic |
createNode(IlvSDMEngine engine,
Object node)
This method is called by the
addNode method. |
IlvGraphic |
createNodeGraphic(IlvSDMEngine engine,
Object node)
Creates an
IlvGraphic object that represents an SDM
node, customizes it, and sets its location. |
protected IlvGraphic |
createNodeInstance(IlvSDMEngine engine,
Object node,
Map decls)
Creates a node instance, according to the model and the style
sheet declarations.
|
void |
customize(IlvSDMEngine engine,
Object node,
IlvGraphic g,
String[] pseudoClass)
Sets the properties of a graphic object that represents a data
object.
|
Object |
customizeBean(IlvSDMModel model,
Object node,
Object bean,
String[] pseudos,
boolean init)
Creates and customizes a bean according to the style sheet and
the model state.
|
Object |
customizeBeanWithDeclarations(ilog.views.util.css.IlvApplicableDeclarationCollection decls,
IlvSDMModel model,
Object node,
Object bean,
String[] pseudos,
boolean init)
Same as
customizeBean(ilog.views.sdm.IlvSDMModel, java.lang.Object, java.lang.Object, java.lang.String[], boolean) , but provides the declarations to create and
customize the bean |
protected void |
customizeLayers(IlvSDMEngine engine,
Object node,
IlvGraphic g,
String[] pseudoClass)
Change the layer of the graphic object if needed.
|
static void |
flushFromCaches(Class c)
Clears the caches for bean infos.
|
int |
getBaseTextDirection()
Returns the global base direction of the text.
|
String |
getCssClassPropertyName()
Returns the name of the CSS class property.
|
ilog.views.util.cssbeans.IlvCSSBeans |
getCSSEngine()
Returns the internal css engine.
|
IlvCSSRule[] |
getCSSRules()
Returns the current CSS, with all cascadings and imports resolved.
|
Map<String,ilog.views.util.css.parser.Declaration> |
getDebugGraphicDecls(IlvSDMModel model,
Object node,
String[] pseudos,
Map<String,ilog.views.util.css.parser.Declaration> result)
Returns an hashtable String ->
Declaration of CSS declarations
found for a given model object. |
int |
getDebugMask()
Deprecated.
replaced by
getStyleSheetDebugMask() |
ilog.views.util.css.IlvApplicableDeclarationCollection |
getDeclarations(IlvSDMEngine engine,
Object object,
String[] pseudos)
This method is for internal use, it should not be called from application code.
|
IlvSDMCSSFunction |
getFunction(String name)
Gets a function to be resolved through a "@|" right-hand
declaration.
|
String |
getFunctionList()
Returns the functions to be resolved through a "@|" right-hand
declaration.
|
IlvSDMCSSFunction[] |
getFunctions()
Returns a copy of the function array that can be called in a "@|" construct
in CSS declaration.
|
Object |
getGraphicProperty(IlvSDMEngine engine,
Object node,
String property,
String[] pseudos,
Class targetClass)
Gets the value of a graphic property for the specified
application object.
|
static IlvStyleSheetRenderer |
getInstance(IlvSDMEngine engine)
Returns the IlvStyleSheetRenderer instance which belongs to the specified SDM engine.
|
IlvRect |
getLinkConnectionRectangle(IlvSDMEngine engine,
IlvGraphic graphic,
IlvTransformer t,
IlvLinkConnector lc)
Returns a rectangle on which the connection points
of the links to/from a node should be located.
|
int |
getLinkConnectorMode()
Returns the link connector mode.
|
int |
getLinksLayer()
Returns the manager layer in which this renderer
will place the SDM links that it creates.
|
int |
getNodesLayer()
Returns the manager layer in which this renderer
will place the SDM nodes that it creates.
|
String |
getStyleSheet()
Returns the value of "styleSheet", or the first of the cascading
style sheets if
setStyleSheets was used. |
int |
getStyleSheetDebugMask()
Returns the current debug mask.
|
String[] |
getStyleSheets()
Returns the cascaded style sheets.
|
String |
getStyleSheets(int index)
Returns one of the cascaded style sheets.
|
boolean |
isAddingLinkConnectors()
Returns
true if a link connector is added
on the nodes to compute the link connection points. |
boolean |
isLinkConnectorEnabled()
Deprecated.
Since JViews 8.1, use
getLinkConnectorMode() . |
static boolean |
isOptimizeRestylingMemoizingDependencies()
Returns true if restyling optimization is enabled.
|
void |
nodeGraphicBBoxChanged(IlvSDMEngine engine,
Object node,
IlvGraphic graphic,
IlvRect oldBBox,
IlvRect newBBox,
String[] pseudoClasses)
This method is called when the graphic object representing
a node of the data model has been moved and/or resized, either
by a user interaction or by a direct call to the Perforce JViews API.
|
void |
prepareRendering(IlvSDMEngine engine)
This method is called when the SDM engine starts
rendering a new SDM, before any
createNodeGraphic s
or createLinkGraphic s are called. |
void |
printCSS(PrintWriter out)
Prints the current CSS, with all cascadings and imports resolved.
|
void |
propertiesChanged(IlvSDMEngine engine,
Object node,
Collection<String> propertyNames,
IlvGraphic graphic)
Any property change means generating new CSS rules against the
model, and applying the rules to the whole hierarchy to which
the node belongs.
|
void |
registerFunction(IlvSDMCSSFunction function)
Adds a new function to be resolved through a "@|" right-hand
declaration.
|
void |
removeAll(IlvSDMEngine engine)
Cleans up the internal state of the renderer.
|
void |
removeLinkGraphic(IlvSDMEngine engine,
Object link,
IlvGraphic graphic,
boolean redraw)
Removes a graphic object representing a link of the SDM data model
from the grapher.
|
void |
removeNodeGraphic(IlvSDMEngine engine,
Object node,
IlvGraphic graphic,
boolean redraw)
Removes a graphic object representing a node of the SDM data model
from the grapher.
|
void |
removePropertyChangeListener(PropertyChangeListener listener)
Removes a listener on property modification.
|
void |
setAddingLinkConnectors(boolean add)
Sets whether a link connector is added
on the nodes to compute the link connection points.
|
void |
setBaseTextDirection(int baseTextDirection)
Changes the global base direction of the text.
|
void |
setCssClassPropertyName(String v)
Sets the value of "CSSclassPropertyName".
|
void |
setDebugMask(int val)
Deprecated.
replaced by
setStyleSheetDebugMask(int) |
void |
setEngine(IlvSDMEngine engine)
Sets the
IlvSDMEngine instance that has created
this renderer. |
void |
setFunctionList(String list)
Sets the new functions to be resolved through a "@|" right-hand
declaration.
|
void |
setFunctions(IlvSDMCSSFunction[] functions)
Sets the functions to be resolved through a "@|" right-hand
declaration.
|
void |
setLinkConnectorEnabled(boolean enabled)
Deprecated.
Since JViews 8.1, use
setLinkConnectorMode(int) . |
void |
setLinkConnectorMode(int mode)
Sets the link connector mode.
|
void |
setLinksLayer(int layer)
Changes the manager layer in which this renderer
will place the SDM links that it creates.
|
void |
setNodesLayer(int layer)
Changes the manager layer in which this renderer
will place the SDM nodes that it creates.
|
static void |
setOptimizeRestylingMemoizingDependencies(boolean optimize)
Specifies whether restyling operations are optimized, taking into account
the model properties which are referenced in the CSS rules for the
particular objects and the model properties which have actually changed
on the particular objects.
|
void |
setStyleSheet(String v)
Sets the value of "styleSheet".
|
void |
setStyleSheetDebugMask(int val)
Changes the debug level to help fix problems with the style
sheet.
|
void |
setStyleSheets(int index,
String css)
Changes one of the cascading style sheets.
|
void |
setStyleSheets(String[] css)
Set style sheets (implements cascading).
|
void |
unregisterFunction(IlvSDMCSSFunction function)
Removes given function
|
void |
updateObjectProperties(IlvSDMEngine engine,
Object object,
String property,
Object value,
String[] pseudos)
Sets a model property corresponding to the given graphic
property name.
|
addViewListeners, callMoveResizeNodeGraphic, computeBBox, convert, convert, getAlias, getAuxiliaryBean, getAuxiliaryBeans, getEncapsulatedGraphic, getEngine, getLinkConnectionRectangle, getLocation, getParameter, linkGraphicAdded, moveResizeNodeGraphic, needsViewListeners, nodeGraphicAdded, processServerAction, propertyChanged, removeViewListeners, renderingDone, setAlias, setLayerName, setParameter
protected String defaultCSS
public static final int CENTER
IlvSDMLinkConnector
for all nodes.
The links will be connected to the center of the rectangle
returned by getLinkConnectionRectangle(ilog.views.sdm.IlvSDMEngine, ilog.views.IlvGraphic, ilog.views.IlvTransformer, ilog.views.IlvLinkConnector)
.setLinkConnectorMode(int)
,
Constant Field Valuespublic static final int FREE
IlvSDMFreeLinkConnector
for all nodes.
The links will be connected to the border of the rectangle
returned by getLinkConnectionRectangle(ilog.views.sdm.IlvSDMEngine, ilog.views.IlvGraphic, ilog.views.IlvTransformer, ilog.views.IlvLinkConnector)
.setLinkConnectorMode(int)
,
Constant Field Valuespublic static final int CLIP
IlvSDMClippingLinkConnector
for all nodes.
The links will point to the the rectangle returned by
getLinkConnectionRectangle(ilog.views.sdm.IlvSDMEngine, ilog.views.IlvGraphic, ilog.views.IlvTransformer, ilog.views.IlvLinkConnector)
but end on the outline of the shape
of the node. How the outline of a node is calculated depends on the
implementation of IlvGraphic.getIntersectionWithOutline(ilog.views.IlvPoint, ilog.views.IlvPoint, ilog.views.IlvTransformer)
.setLinkConnectorMode(int)
,
Constant Field Valuespublic static boolean _debug
true
(default).setDebugMask(int)
public static final int IMAGE_MASK
public static final int LOCATION_MASK
public static final int ACTUAL_LOCATION_MASK
public static PrintStream _error
public IlvStyleSheetRenderer(Reader css, URL baseURL) throws IlvStylingException
IlvCSSEngine
.css
- A source that contains the CSS. It is consumed by this method,
but has to be closed by the caller.baseURL
- The CSS URL, if any. Used to resolve import statements.
definition.IlvStylingException
- if an error occurred while loading or
parsing the CSS.public IlvStyleSheetRenderer(ilog.views.util.css.IlvCSSEngine engine)
engine
- The CSS engine, with its own CSS.public IlvStyleSheetRenderer()
public static void setOptimizeRestylingMemoizingDependencies(boolean optimize)
IlvMutableSDMNode.getDependentProperties(String)
method.
This method can only be called before any IlvDiagrammer
or
IlvSDMEngine
has been created. It must not be called when
styling is already in use.
optimize
- Whether to enable the restyling optimization.public static boolean isOptimizeRestylingMemoizingDependencies()
public static IlvStyleSheetRenderer getInstance(IlvSDMEngine engine)
engine
- the SDM enginepublic void setEngine(IlvSDMEngine engine)
IlvSDMEngine
instance that has created
this renderer. This method is called by the SDM engine, you should not
call it directly.setEngine
in class IlvSDMRenderer
@Deprecated public void setDebugMask(int val)
setStyleSheetDebugMask(int)
val
- the new debug mask value@Deprecated public int getDebugMask()
getStyleSheetDebugMask()
public void setStyleSheetDebugMask(int val)
XXX_MASK
values. 0
means no debug.
Here is how to set the debug mask directly from the style sheet:
SDM { StyleSheet : true; } StyleSheet { debugMask : 1; // trace all object creations. styleSheets : @styleSheets; }
setStyleSheetDebugMask
in interface IlvStylable
val
- The debug level.IlvStylable.setStyleSheets(java.lang.String[])
,
IlvStylable.getStyleSheetDebugMask()
,
IlvStylable.APPLIED_RULE_MASK
,
IlvStylable.BAD_CLASS_MASK
,
IlvStylable.BAD_PROP_MASK
,
IlvStylable.BAD_PROP_WITH_STACK_MASK
,
IlvStylable.CREATED_MASK
,
IlvStylable.DECL_MASK
,
IlvStylable.DECL_VALUE_MASK
,
IlvStylable.FAILED_CONVERSIONS_MASK
,
IlvStylable.TIME_REPORT_MASK
,
IlvStylable.WARNING_PROP_MASK
public int getStyleSheetDebugMask()
getStyleSheetDebugMask
in interface IlvStylable
IlvStylable.setStyleSheetDebugMask(int)
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.
IlvSDMEngine.setBaseTextDirection(int, boolean)
to specify whether the value from the style sheet renderer should be
ignored or not.baseTextDirection
- The base text directiongetBaseTextDirection()
public int getBaseTextDirection()
setBaseTextDirection(int)
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 String getStyleSheet()
setStyleSheets
was used.public void setStyleSheet(String v) throws IlvSDMException
setStyleSheets()
.v
- The value to assign to "styleSheet".IlvSDMException
- if an exception occurs while
loading or parsing the style sheet.public void setStyleSheets(String[] css) throws IlvSDMException
setStyleSheet()
. The order is by priority (the last
CSS takes over).setStyleSheets
in interface IlvStylable
css
- An array of strings containing the URLs
or the file names of CSS files (usually with a .css
suffix).IlvSDMException
public void setStyleSheets(int index, String css) throws IlvSDMException
setStyleSheet()
.setStyleSheets
in interface IlvStylable
index
- The position of the cascading style sheet to change.css
- An array of strings containing the URLs
or the file names of CSS files (usually with a .css
suffix).IlvSDMException
IlvStylable.setStyleSheets(java.lang.String[])
public String getStyleSheets(int index)
getStyleSheets
in interface IlvStylable
index
- The position of the cascading style sheet to return.index
style sheet.public String[] getStyleSheets()
getStyleSheets
in interface IlvStylable
public String getCssClassPropertyName()
public void setCssClassPropertyName(String v)
v
- The value to assign to "cssClassPropertyName".public boolean isAddingLinkConnectors()
true
if a link connector is added
on the nodes to compute the link connection points.public void setAddingLinkConnectors(boolean add)
IlvSDMLinkConnector
is added on nodes. The connector class can be
overriden by the "LinkConnector" renderer property.add
- true
to add link connectorssetLinkConnectorEnabled(boolean)
,
IlvSDMLinkConnector
public int getLinkConnectorMode()
setAddingLinkConnectors(boolean)
.public void setLinkConnectorMode(int mode)
CENTER
-
Link connector mode: Use IlvSDMLinkConnector
for all nodes.
The links will be connected to the center of the rectangle
returned by getLinkConnectionRectangle(ilog.views.sdm.IlvSDMEngine, ilog.views.IlvGraphic, ilog.views.IlvTransformer, ilog.views.IlvLinkConnector)
.
FREE
-
Link connector mode: Use IlvSDMFreeLinkConnector
for all nodes.
The links will be connected to the border of the rectangle
returned by getLinkConnectionRectangle(ilog.views.sdm.IlvSDMEngine, ilog.views.IlvGraphic, ilog.views.IlvTransformer, ilog.views.IlvLinkConnector)
.
CLIP
-
Use IlvSDMClippingLinkConnector
for all nodes.
The links will point to the the rectangle returned by
getLinkConnectionRectangle(ilog.views.sdm.IlvSDMEngine, ilog.views.IlvGraphic, ilog.views.IlvTransformer, ilog.views.IlvLinkConnector)
but end on the outline of
the shape of the node. How the outline of a node is calculated
depends on the implementation of
IlvGraphic.getIntersectionWithOutline(ilog.views.IlvPoint, ilog.views.IlvPoint, ilog.views.IlvTransformer)
.
setAddingLinkConnectors
(false)
.
In that case, the links will be connected to the edges of the node's
bounding rectangle (and the rectangle returned by
getLinkConnectionRectangle(ilog.views.sdm.IlvSDMEngine, ilog.views.IlvGraphic, ilog.views.IlvTransformer, ilog.views.IlvLinkConnector)
will be ignored).@Deprecated public boolean isLinkConnectorEnabled()
getLinkConnectorMode()
.true
if the link connector that
computes the connection points of links
is enabled.setLinkConnectorEnabled(boolean)
@Deprecated public void setLinkConnectorEnabled(boolean enabled)
setLinkConnectorMode(int)
.
If the connector is enabled, it corresponds either to the FREE
mode or to the CLIP
mode, depending on the setting of
setLinkConnectorMode(int)
.
If the connector is disabled, it corresponds to the CENTER
mode of setLinkConnectorMode(int)
.
You can also choose not to set the link connector at all by calling
setAddingLinkConnectors
(false)
.
In that case, the links will be connected to the edges of the node's
bounding rectangle (and the rectangle returned by
getLinkConnectionRectangle(ilog.views.sdm.IlvSDMEngine, ilog.views.IlvGraphic, ilog.views.IlvTransformer, ilog.views.IlvLinkConnector)
will be ignored).
enabled
- true
to enable the link connector.public void setNodesLayer(int layer)
layer
- The index of the new node layer.public int getNodesLayer()
public void setLinksLayer(int layer)
layer
- The index of the new link layer.public int getLinksLayer()
public void addNodeGraphic(IlvSDMEngine engine, Object node, IlvGraphic graphic, boolean redraw)
createNodeGraphic()
to the grapher of the SDM engine.
This method adds the graphic object to the engine's grapher in the
layer specified by setNodesLayer
.
addNodeGraphic
in class IlvSDMRenderer
engine
- The SDM engine associated with the grapher in which
the graphic object will be added.node
- The node to translate into an IlvGraphic
.graphic
- The graphic object returned by createGraphic
.redraw
- If true
, the region covered by the new
graphic object must be redrawn.createNodeGraphic(ilog.views.sdm.IlvSDMEngine, java.lang.Object)
public void addLinkGraphic(IlvSDMEngine engine, Object node, IlvGraphic graphic, boolean redraw)
createLinkGraphic()
to the grapher of the SDM engine.
This method adds the graphic object to the engine's grapher in the
layer specified by setLinksLayer
.
addLinkGraphic
in class IlvSDMRenderer
engine
- The SDM engine associated with the grapher in which
the graphic object will be added.node
- The node to translate into an IlvGraphic
.graphic
- The graphic object returned by createGraphic
.redraw
- If true
, the region covered by the new
graphic object must be redrawn.createLinkGraphic(ilog.views.sdm.IlvSDMEngine, java.lang.Object, ilog.views.IlvGraphic, ilog.views.IlvGraphic)
public IlvGraphic createNodeGraphic(IlvSDMEngine engine, Object node)
IlvGraphic
object that represents an SDM
node, customizes it, and sets its location. It does not, however, add the
graphic object to the grapher.
This method calls the protected method createNode(ilog.views.sdm.IlvSDMEngine, java.lang.Object)
,
and tries to set a location on the created IlvGraphic
.
createNodeGraphic
in class IlvSDMRenderer
engine
- The SDM engine associated with the grapher in which
the graphic object will be added.node
- The node to translate into an IlvGraphic
.createNode(ilog.views.sdm.IlvSDMEngine, java.lang.Object)
public IlvRect getLinkConnectionRectangle(IlvSDMEngine engine, IlvGraphic graphic, IlvTransformer t, IlvLinkConnector lc)
null
as
link connector argument.
This basic implementation returns the bounding box of the node. It should be overridden by subclasses if the nodes contain text labels and/or decoration icons.
getLinkConnectionRectangle
in class IlvSDMRenderer
engine
- The SDM engine.graphic
- The graphic object returned by createNodeGraphic
.t
- The transformer of the view.lc
- The link connector from which this is called.
This can be null
.public IlvGraphic createLinkGraphic(IlvSDMEngine engine, Object node, IlvGraphic from, IlvGraphic to)
IlvLinkImage
object that represents an SDM link,
and customizes it.createLinkGraphic
in class IlvSDMRenderer
engine
- The SDM engine associated with the grapher in
which the graphic object will be added.node
- The data link to translate into an IlvGraphic
.from
- The graphic object associated with the source node of the link.to
- The graphic object associated with the destination node of the link.public void propertiesChanged(IlvSDMEngine engine, Object node, Collection<String> propertyNames, IlvGraphic graphic)
propertiesChanged
in class IlvSDMRenderer
engine
- The SDM engine associated with the grapher in
which the graphic object is displayed.node
- The data object whose property has changed.propertyNames
- The names of the properties that have been modified.graphic
- The graphic object associated with object
.public Object getGraphicProperty(IlvSDMEngine engine, Object node, String property, String[] pseudos, Class targetClass)
This method must be called by the SDM renderer to
get the properties of the graphic objects created by
addObject
.
getGraphicProperty
in class IlvSDMRenderer
engine
- The SDM engine associated with the grapher in which the graphic object will be added.node
- The model object.property
- The name of the graphic property.pseudos
- The pseudo classes are
interpreted as CSS pseudo classes. This parameter can be null
.targetClass
- The class of the object on which the property will be
set. The method can introspect the class to determine the type
of the property, and convert the value if necessary. If this argument
is null
, the property should be returned without conversion.public void updateObjectProperties(IlvSDMEngine engine, Object object, String property, Object value, String[] pseudos)
updateObjectProperties
in class IlvSDMRenderer
engine
- The SDM engine.object
- The data object.property
- The name of the graphic property.value
- The new value of the property.pseudos
- The pseudo classes of the objects.
This parameter can be null
.public void removeLinkGraphic(IlvSDMEngine engine, Object link, IlvGraphic graphic, boolean redraw)
This method is called when a link is removed from the data model,
or when a new graphic object must be created because of a state change,
but not when the grapher is cleaned up before loading
a new data model or a new style sheet. In such a case,
the removeAll(ilog.views.sdm.IlvSDMEngine)
method is called to cleanup
the renderer's internal state if needed, and all
the graphic objects are removed from the grapher all at once by the SDM engine.
The default implementation simply calls IlvGrapher.removeLink(ilog.views.IlvLinkImage, boolean)
.
removeLinkGraphic
in class IlvSDMRenderer
engine
- The SDM engine associated with the grapher from which
the graphic object will be removed.link
- The link that has been removed or modified in the data model.graphic
- The graphic object that must be removed from the grapher.redraw
- If true
, the region covered by the
graphic object must be redrawn.public void removeNodeGraphic(IlvSDMEngine engine, Object node, IlvGraphic graphic, boolean redraw)
This method is called when a node is removed from the data model,
or when a new graphic object must be created because of a state change,
but not when the grapher is cleaned up before loading
a new data model or a new style sheet. In such a case,
the removeAll(ilog.views.sdm.IlvSDMEngine)
method is called to cleanup
the renderer's internal state if needed, and all
the graphic objects are removed from the grapher all at once by the SDM engine.
The default implementation simply calls IlvGrapher.removeNode(ilog.views.IlvGraphic, boolean)
.
removeNodeGraphic
in class IlvSDMRenderer
engine
- The SDM engine associated with the grapher from which
the graphic object will be removed.node
- The node that has been removed or modified in the data model.graphic
- The graphic object that must be removed from the grapher.redraw
- If true
, the region covered by the
graphic object must be redrawn.public void prepareRendering(IlvSDMEngine engine)
createNodeGraphic
s
or createLinkGraphic
s are called.
prepareRendering
in class IlvSDMRenderer
engine
- The SDM engine.public void customize(IlvSDMEngine engine, Object node, IlvGraphic g, String[] pseudoClass)
This method finds out the declaration associated with the
node, and uses bean introspection to set IlvGraphic
property
values. If the IlvGraphic
is a prototype, the usual prototype
setter is used.
The method will deploy its best effort (that is, use
PropertyEditor
's setAsText()
) to convert the value into a
suitable type for the bean.
Prefix with '@' the right-hand side of the declaration to get the
value from the model object (or its ascendant in order, if it
is null
), instead of a direct literal. Special names @__ID
and
@__TAG
refer to getID()
and getTag()
of the model.
Prefix with '@#' the right-hand side of the declaration to recurse in the style sheet. The text after '@#' adds a dummy model object in an empty model whose ID is the text. It should match a rule in the style sheet whose declarations eventually create a bean. The bean will be customized before being assigned to the left-hand side property. The dummy node forwards model property requests to the source model object that contains the '@#'. This means that '@' constructions in '@#' rules refer to the '@#' originator.
Prefix with '@+' (e.g.: "@+name") the right-hand side of
the declaration to recurse in the style sheet like the '@#'
construct, except that the object is created if and only if
the property defined by the left hand has a null
value, or contains an object which class name is different
that the one defined in #name declarations. In this case the
object is created, customized, and assigned to the property
through the property setter, like with '@#'. Otherwise, the
previous value is only customized according to the CSS
declarations. In all cases, the setter is invoked.
This construction spares object creations, since the '@#' may
create a new bean upon each property change on the source model
object.
Prefix with '@=' the right-hand side of the declaration to
recurse in the style sheet like the '@#' construct, except that
the resulting object is shared. It is computed only the first
time it is needed and stored in an internal table for all
subsequent uses. The table is cleared when a new style sheet is
set (that is, one of the setStyleSheets()
methods
is called).
Prefix with '@|' the right-hand side of the declaration to
invoke an function. The function can have a comma-separated
list of arguments which are literals or other @-constructs,
except another function. For example: label :
'@|concat("name :",@name)';
.
See IlvSDMCSSFunction
.
If the right-hand side is the string "@", it means the property setting is cancelled. This operator simplifies the writing of the style sheet because it avoids negating CSS rule selectors. Example:
node {
color : orange;
}
node[kind = "ghost"] {
color : @ ;
}
is equivalent to
node[kind ~ "ghost"] { // ~ means "different" for strings.
color : orange;
}
customize
in class IlvSDMRenderer
engine
- The SDM engine.node
- The data object used to compute
the graphic properties to set.g
- The graphic object to customize.pseudoClass
- A list of symbolic names that identify
the context in which the graphic object must be customized.
For example, the pseudo class defines the "pseudo-classes"
in the style sheet renderer.public void nodeGraphicBBoxChanged(IlvSDMEngine engine, Object node, IlvGraphic graphic, IlvRect oldBBox, IlvRect newBBox, String[] pseudoClasses)
The style sheet renderer deals with the Anchor graphic property to compute back the right x,y,width,height values.
nodeGraphicBBoxChanged
in class IlvSDMRenderer
engine
- The SDM engine.node
- The data node that the graphic object represents.graphic
- The graphic object that has been moved and/or resized.oldBBox
- The bounding box of the graphic object before
the change.newBBox
- The bounding box of the graphic object after
the change.pseudoClasses
- The pseudo classes of the object.
This parameter can be null
.public Object customizeBean(IlvSDMModel model, Object node, Object bean, String[] pseudos, boolean init)
IlvSDMRenderer
interface.model
- The model.node
- The model object.bean
- The bean to customize, or null
if the method
creates it according to the "class" declaration.pseudos
- The pseudo classes. null
is correct.init
- The creating state. Forced to true
if the bean parameter is
null
. This value is currently not used, but will help improve
performance in the future.null
.public Object customizeBeanWithDeclarations(ilog.views.util.css.IlvApplicableDeclarationCollection decls, IlvSDMModel model, Object node, Object bean, String[] pseudos, boolean init)
customizeBean(ilog.views.sdm.IlvSDMModel, java.lang.Object, java.lang.Object, java.lang.String[], boolean)
, but provides the declarations to create and
customize the beandecls
- the declaration collectionmodel
- The model.node
- The model object.bean
- The bean to customize, or null
if the method
creates it according to the "class" declaration.pseudos
- The pseudo classes. null
is correct.init
- The creating state. Forced to true
if the bean parameter is
null
. This value is currently not used, but will help improve
performance in the future.null
.public void removeAll(IlvSDMEngine engine)
removeAll
in class IlvSDMRenderer
engine
- The SDM engine.public ilog.views.util.cssbeans.IlvCSSBeans getCSSEngine()
public Map<String,ilog.views.util.css.parser.Declaration> getDebugGraphicDecls(IlvSDMModel model, Object node, String[] pseudos, Map<String,ilog.views.util.css.parser.Declaration> result)
Declaration
of CSS declarations
found for a given model object.model
- the current SDM modelnode
- the current model objectpseudos
- the active pseudo-classesresult
- the hashtable which will be cleared and returned
(to spare an hashtable creation)protected IlvGraphic createNodeInstance(IlvSDMEngine engine, Object node, Map decls) throws ClassNotFoundException, InstantiationException, IllegalAccessException, IOException, InvocationTargetException
If the class name contains '#', the
remainder of the name is a prototype URL. This method will then
load the prototype and return an IlvGraphicGroup
instance.
If the class implements
IlvRectangularObjectFactory
, a
declaration IlvRect
is searched for to provide the factory's
createObject()
method with the initial rectangle.
The exceptions that may be thrown are explained in
Class.forName(java.lang.String)
and Class.newInstance()
.
engine
- The SDM engine associated with the grapher in
which the graphic object will be added.node
- The model object.decls
- Hashtable
of matched declarations from the CSS.ClassNotFoundException
InstantiationException
IllegalAccessException
InvocationTargetException
IOException
protected IlvGraphic createNode(IlvSDMEngine engine, Object node)
addNode
method. It
tries to create an instance of IlvGraphic
to render
the specified node
, and sets properties according
the CSS specifications.
This method does not add the graphic object to the grapher.
engine
- The SDM engine associated with the grapher in which the graphic object will be added.node
- The model object.protected IlvGraphic createLinkInstance(IlvSDMEngine engine, Object node, IlvGraphic from, IlvGraphic to, Map decls) throws ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException
IlvGraphic
s and a boolean
(oriented property, false)
as arguments.
The exceptions that may be thrown are explained in
Class
, methods forName()
, getDeclaredConstructor()
,
and newInstance()
.
engine
- The SDM engine associated with the grapher in
which the graphic object will be added.node
- The model object.from
- The source graphic.to
- The destination graphic.decls
- Hashtable
of matched declarations from the CSS.ClassNotFoundException
InstantiationException
IllegalAccessException
NoSuchMethodException
InvocationTargetException
public ilog.views.util.css.IlvApplicableDeclarationCollection getDeclarations(IlvSDMEngine engine, Object object, String[] pseudos)
engine
- object
- pseudos
- protected void customizeLayers(IlvSDMEngine engine, Object node, IlvGraphic g, String[] pseudoClass)
engine
- the Engine.node
- the node.g
- the graphic object.pseudoClass
- the pseudo classes.public IlvSDMCSSFunction getFunction(String name)
name
- The name of the function.registerFunction(ilog.views.sdm.renderer.IlvSDMCSSFunction)
public void registerFunction(IlvSDMCSSFunction function)
function
- The new function.public void unregisterFunction(IlvSDMCSSFunction function)
function
- the functionpublic void setFunctionList(String list) throws ClassNotFoundException, InstantiationException, IllegalAccessException, IOException
list
- A comma-separated list of IlvSDMCSSFunction
class
names.ClassNotFoundException
InstantiationException
- (unused)IllegalAccessException
- (unused)IOException
registerFunction(ilog.views.sdm.renderer.IlvSDMCSSFunction)
public String getFunctionList()
registerFunction(ilog.views.sdm.renderer.IlvSDMCSSFunction)
public void setFunctions(IlvSDMCSSFunction[] functions)
functions
- the list of functions.getFunctions()
public IlvSDMCSSFunction[] getFunctions()
setFunctions(IlvSDMCSSFunction[])
public IlvCSSRule[] getCSSRules()
public void printCSS(PrintWriter out)
out
- The output.public void clear()
public void clear(Object modelObject)
modelObject
- the object on which style informations will be computed
again at next use.public static void flushFromCaches(Class c)
c
- The bean class that must be removed from the bean info caches.© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.