An implementation of IPortLocationModel that can be used to create custom port location models out of existing IPortLocationModelParameter instances.
Remarks
Examples
Custom models can easily be created in the following way:
const compositeModel = new CompositePortLocationModel()
compositeModel.addParameter(FreeNodePortLocationModel.CENTER)
compositeModel.addParameter(FreeNodePortLocationModel.BOTTOM)
compositeModel.addParameter(FreeNodePortLocationModel.TOP)
compositeModel.addParameter(FreeNodePortLocationModel.RIGHT)
compositeModel.addParameter(FreeNodePortLocationModel.LEFT)
graph.nodeDefaults.ports.locationParameter =
compositeModel.locationParameters.first()!
Note that in order to work, this model needs to have at least one parameter added.
Type Details
- yFiles module
- view
See Also
Constructors
Initializes a new instance of the CompositePortLocationModel class.
Properties
Gets all parameters that are associated with this instance.
Remarks
Property Value
Methods
addParameter
(locationParameter: IPortLocationModelParameter, side?: CompositePortLocationModelPortSide, cost?: number, capacity?: number) : CompositePortLocationModelParameterAdds the given parameter to the locationParameters of this instance.
Remarks
Note that this will create a new parameter instance that is then actually bound to this instance and returned. The instance is stored by reference, so if this is a mutable instance, this instance will be implicitly modified, too.
The side
, cost
, and capacity
are only used by the layout executor to automatically create port candidates for layout algorithms.
Parameters
A map of options to pass to the method.
- locationParameter - IPortLocationModelParameter
- The parameter to add to this instance.
- side - CompositePortLocationModelPortSide
- The side an attached edge should enter or leave the port after an automatic layout.
- cost - number
- The cost to take this location by an automatic layout.
- capacity - number
- The capacity how many edges may be assigned to the described location by an automatic layout.
Returns
- ↪CompositePortLocationModelParameter
- The parameter to use with this model that wraps the given parameter.
Factory method that creates a parameter for the given owner
that tries to match the provided location in absolute world coordinates.
Remarks
Parameters
A map of options to pass to the method.
- owner - IPortOwner
- The port owner that will own the port for which the parameter shall be created.
- location - Point
- The location in the world coordinate system that should be matched as best as possible.
Returns
- ↪IPortLocationModelParameter
- A new instance that can be used to describe the location of an IPort at the given
owner
.
Throws
- Exception({ name: 'ArgumentError' })
owner
is not supported by one of the added parameters.- Exception({ name: 'ArgumentError' })
location
contains one or more NaN values.
Implements
Provides a lookup context for the given port.
Determines the location of the port for the given parameter.
Parameters
A map of options to pass to the method.
- port - IPort
- The port to determine the location for.
- locationParameter - IPortLocationModelParameter
- The parameter to use. The parameter can be expected to be created by this instance having the model property set to this instance.
Returns
- ↪Point
- The calculated location of the port.