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 = defaultFolderNodeConverterSee Also
Developer's Guide
API
- FoldingManager
Members
Constructors
Creates a new instance, optionally using all relevant values from the provided nodeDefaults objects.
nodeDefaults objects.Parameters
- nodeDefaults?: INodeDefaults
- An optional INodeDefaults implementation from which to initialize this instance's values from.
Properties
Gets or sets whether to copy the labels from the master item to the view item.
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
Developer's Guide
API
- FoldingLabelDefaults
Gets or sets what properties to initialize the FolderNodeState with when a folder node is initialized from its master node.
Gets or sets the FoldingLabelDefaults to which updating the nodes' labels will be delegated.
See Also
API
- copyLabels
Gets or sets the FoldingPortDefaults to which updating the nodes' ports will be delegated to.
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 = defaultFolderNodeConverterSee Also
API
- copyLabels
Property Value
true (the default) if the folder node style should be shared; false otherwise.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.
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.
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.
See Also
Methods
Creates the default INodeStyle to use in initializeState.
Initializes the initial labels of the collapsed group node.
Parameters
- 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.
null)Parameters
- 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.
Parameters
- 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.
initialize methods, only.Parameters
- state: FolderNodeState
- The state object to use for modifying the properties.
- masterNode: INode
- The node this folder node represents.
See Also
API
- updateState
Callback that updates the immediate labels of the node during updateState.
Parameters
- state: FolderNodeState
- The state object to write the values to
- masterNode: INode
- The node this folder node represents.
See Also
API
- labels
Updates the labels of the master group node to match the state of the folder node.
Parameters
- 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
API
- copyLabels
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
- 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.
Parameters
- 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.
Parameters
- 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.
update methods, only.Parameters
- state: FolderNodeState
- The state object to use for modifying the properties.
- masterNode: INode
- The node this folder node represents.