A helper class that provides configuration options and helper methods that can be used in the context of initializing and updating folder nodes.
Remarks
This class can be used to manage and synchronize the state of folder nodes in implementations of the IFolderNodeConverter interfaces. Start by configuring the initializeOptions, updateFoldingOptions, and updateMasterOptions, as well as copyLabels, to match your synchronization requirements and use the style and other properties to set a default value for the initialization. The labels property can be configured to recursively define the behavior for the immediate labels at the node. Likewise, the ports property is used to synchronize the ports and their labels at the folder node. For custom requirements, this class may be sub-classed and implement a more customized synchronization behavior.
FolderNodeConverter delegates to an instance of this class.
Examples
const defaultFolderNodeConverter = new FolderNodeConverter()
// set a gray rectangle to initialize a freshly collapsed group node with
defaultFolderNodeConverter.folderNodeDefaults.style = new ShapeNodeStyle({
stroke: 'gray',
})
// use the same instance for all folders
defaultFolderNodeConverter.folderNodeDefaults.shareStyleInstance = true
// configure label handling: copy the labels
defaultFolderNodeConverter.folderNodeDefaults.copyLabels = true
// initialize labels on a freshly collapsed group node with a default style
defaultFolderNodeConverter.folderNodeDefaults.labels.style =
new LabelStyle()
// share the same style instance
defaultFolderNodeConverter.folderNodeDefaults.labels.shareStyleInstance =
true
// copy all properties from the group node labels to the folder node labels
defaultFolderNodeConverter.folderNodeDefaults.labels.initializeOptions =
FoldingSynchronizationOptions.ALL
// copy all properties from the group node labels to the folder node labels
defaultFolderNodeConverter.folderNodeDefaults.labels.updateFoldingOptions =
FoldingSynchronizationOptions.LABEL_TEXT
// upon subsequent collapse and expand: only synchronize the text
defaultFolderNodeConverter.folderNodeDefaults.labels.updateMasterOptions =
FoldingSynchronizationOptions.LABEL_TEXT
// adjust the preferred size to the new text
defaultFolderNodeConverter.folderNodeDefaults.labels.autoAdjustPreferredSize =
true
manager.folderNodeConverter = defaultFolderNodeConverter
Type Details
- yFiles module
- view
See Also
Constructors
Creates a new instance, optionally using all relevant values from the provided nodeDefaults
objects.
Parameters
A map of options to pass to the method.
- nodeDefaults - INodeDefaults
- An optional INodeDefaults implementation from which to initialize this instance's values from.
- initializeOptions - FoldingSynchronizationOptions
- What properties to initialize the FolderNodeState with when a folder node is initialized from its master node. This option sets the initializeOptions property on the created object.
- updateFoldingOptions - FoldingSynchronizationOptions
- What properties to update the FolderNodeState with when a folder node is updated to reflect changes made to its master item. This option sets the updateFoldingOptions property on the created object.
- updateMasterOptions - FoldingSynchronizationOptions
- What properties to backpropagate from the FolderNodeState when a master node is updated to reflect changes made to its folding variant. This option sets the updateMasterOptions property on the created object.
- copyLabels - boolean
- Whether to copy the labels from the master item to the view item. This option sets the copyLabels property on the created object.
- style - INodeStyle
- The INodeStyle to use for the collapsed group nodes. This option sets the style property on the created object.
- shareStyleInstance - boolean
- A value indicating whether the node style instance should be shared referentially or cloned. This option sets the shareStyleInstance property on the created object.
- ports - FoldingPortDefaults
- The FoldingPortDefaults to which updating the nodes' ports will be delegated to. This option either sets the value directly or recursively sets properties to the instance of the ports property on the created object.
- labels - FoldingLabelDefaults
- The FoldingLabelDefaults to which updating the nodes' labels will be delegated. This option either sets the value directly or recursively sets properties to the instance of the labels property on the created object.
- size - Size
Properties
Gets or sets whether to copy the labels from the master item to the view item.
Remarks
false
if you need to implement your own logic. Otherwise, this feature can be used to initially create a copy of the labels of the master (if any) and subsequently synchronize the labels with changes to the master. The default is false
for new instances of this type.See Also
Gets or sets what properties to initialize the FolderNodeState with when a folder node is initialized from its master node.
Remarks
Gets or sets the FoldingLabelDefaults to which updating the nodes' labels will be delegated.
Remarks
See Also
Gets or sets the FoldingPortDefaults to which updating the nodes' ports will be delegated to.
Remarks
Examples
const defaultFolderNodeConverter = new FolderNodeConverter()
defaultFolderNodeConverter.folderNodeDefaults.ports.copyLabels = true
// initialize: copy all label properties (the default)
// but update only the text after initialization
defaultFolderNodeConverter.folderNodeDefaults.ports.labels.updateFoldingOptions =
FoldingSynchronizationOptions.LABEL_TEXT
defaultFolderNodeConverter.folderNodeDefaults.ports.updateMasterOptions =
FoldingSynchronizationOptions.LABEL_TEXT
defaultFolderNodeConverter.folderNodeDefaults.ports.copyLabels = true
// copy all port properties upon initialization (the default)
// but update only the layout afterward
defaultFolderNodeConverter.folderNodeDefaults.ports.updateFoldingOptions =
FoldingSynchronizationOptions.LAYOUT
defaultFolderNodeConverter.folderNodeDefaults.ports.updateMasterOptions =
FoldingSynchronizationOptions.LAYOUT
manager.folderNodeConverter = defaultFolderNodeConverter
See Also
Sets the initial size of the layout of the collapsed group node that will be assigned during the creation of the appearance of the collapsed group node.
Remarks
null
values will make the initial layout of the collapsed node become the given size assigned. The default is null
, keeping the size of the expanded node.Gets or sets the INodeStyle to use for the collapsed group nodes.
Remarks
Depending on the shareStyleInstance property, initializeState will assign a clone to the property or this instance. The default is null
.
A value of null
(the default) will leave the style property unmodified from the expanded node.
This value will be used during initializeState, only.
Gets or sets what properties to update the FolderNodeState with when a folder node is updated to reflect changes made to its master item.
Remarks
See Also
Gets or sets what properties to backpropagate from the FolderNodeState when a master node is updated to reflect changes made to its folding variant.
Remarks
See Also
Methods
Creates the default INodeStyle to use in initializeState.
Returns
- ↪INodeStyle?
- The style or a clone of it depending on shareStyleInstance. This method may return
null
to indicate that the style should be obtained from the master node.
Initializes the initial labels of the collapsed group node.
Remarks
Parameters
A map of options to pass to the method.
- state - FolderNodeState
- The node view state whose labels should be synchronized.
- masterNode - INode
- The master node that the folder node represents.
See Also
Initializes the layout of the collapsed group node.
Remarks
null
)Parameters
A map of options to pass to the method.
- state - FolderNodeState
- The node view state whose layout should be synchronized.
- masterNode - INode
- The master node that is represented by the local group node.
Called by initializeState to initialize the appearance of the representatives of the master ports at the collapsed group node.
Remarks
Parameters
A map of options to pass to the method.
- state - FolderNodeState
- The node view state whose ports should be synchronized.
- masterNode - INode
- The master group node.
Called by implementations of the IFolderNodeConverter to initialize the state of a folder node in the folding view.
Remarks
initialize
methods, only.Parameters
A map of options to pass to the method.
- state - FolderNodeState
- The state object to use for modifying the properties.
- masterNode - INode
- The node this folder node represents.
See Also
Callback that updates the immediate labels of the node during updateState.
Remarks
Parameters
A map of options to pass to the method.
- state - FolderNodeState
- The state object to write the values to
- masterNode - INode
- The node this folder node represents.
See Also
Updates the labels of the master group node to match the state of the folder node.
Remarks
Parameters
A map of options to pass to the method.
- masterGraph - IGraph
- The graph to use for modifying the master labels.
- state - FolderNodeState
- The state of the folder node and its labels to synchronize with.
- masterNode - INode
- The master node to synchronize.
See Also
Called in response to updateGroupNodeState to optionally update the various properties on the master group node according to the state of the folder node.
Parameters
A map of options to pass to the method.
- state - FolderNodeState
- The state of the folder node.
- masterGraph - IGraph
- The master graph to use for modifying the
masterNode
. - masterNode - INode
- The master group node to potentially synchronize the state.
See Also
Updates the ports of the master group node to match the state of the folder node.
Remarks
Parameters
A map of options to pass to the method.
- masterGraph - IGraph
- The graph to use for modifying the master ports.
- state - FolderNodeState
- The state of the folder node and its ports to synchronize with.
- masterNode - INode
- The master node to synchronize.
Called by updateState to update the appearance of the representatives of the master ports at the collapsed group node.
Remarks
Parameters
A map of options to pass to the method.
- state - FolderNodeState
- The node view state whose ports should be synchronized.
- masterNode - INode
- The master group node.
Called by implementations of the IFolderNodeConverter to update the state of a folder node in the folding view, once it has changed.
Remarks
update
methods, only.Parameters
A map of options to pass to the method.
- state - FolderNodeState
- The state object to use for modifying the properties.
- masterNode - INode
- The node this folder node represents.