public final class SegmentRatioPortLocationModel extends Object implements IPortLocationModel
Modifier and Type | Field and Description |
---|---|
static SegmentRatioPortLocationModel |
INSTANCE
A static immutable global instance of this class.
|
Constructor and Description |
---|
SegmentRatioPortLocationModel() |
Modifier and Type | Method and Description |
---|---|
IPortLocationModelParameter |
createFromSource(double ratio,
int segmentIndex)
Creates the a new parameter for the specified segment index and ratio.
|
IPortLocationModelParameter |
createFromTarget(double ratio,
int segmentIndex)
Creates the a new parameter for the specified segment index counted from the target end of the edge and the provided
ratio.
|
IPortLocationModelParameter |
createParameter(IPortOwner owner,
PointD location)
Factory method that creates a parameter for the given port that tries to match the provided location in absolute world
coordinates.
|
ILookup |
getContext(IPort port,
IPortLocationModelParameter locationParameter)
Provides a
lookup context for the given combination of port and parameter. |
PointD |
getLocation(IPort port,
IPortLocationModelParameter locationParameter)
Determines the location of the port for the given parameter.
|
<TLookup> TLookup |
lookup(Class<TLookup> type)
Returns an instance that implements the given type or
null . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
createDictionaryLookup, createDynamic, createSingle, createSingle, createWrapped, lookup, lookup, safeLookup
public static final SegmentRatioPortLocationModel INSTANCE
public final IPortLocationModelParameter createFromSource(double ratio, int segmentIndex)
ratio
- The ratio for the segment, with 0
being at the start of the segment and 1
at the end.segmentIndex
- The index of the segment.public final IPortLocationModelParameter createFromTarget(double ratio, int segmentIndex)
ratio
- The ratio for the segment, with 0
being at the start of the segment and 1
at the end.segmentIndex
- The index of the segment counted from the target end.public final IPortLocationModelParameter createParameter(IPortOwner owner, PointD location)
IPortLocationModel
createParameter
in interface IPortLocationModel
owner
- The port owner that will own the port for which the parameter shall be created.location
- The location in the world coordinate system that should be matched as best as possible.IPort
at the given owner
.public final ILookup getContext(IPort port, IPortLocationModelParameter locationParameter)
IPortLocationModel
lookup context
for the given combination of port and parameter.getContext
in interface IPortLocationModel
port
- The port to use in the context.locationParameter
- The parameter to use for the port in the context.ILookup
interface that can be used to query additional aspects of the port/parameter
combination.public final PointD getLocation(IPort port, IPortLocationModelParameter locationParameter)
IPortLocationModel
getLocation
in interface IPortLocationModel
port
- The port to determine the location for.locationParameter
- The parameter to use. The parameter can be expected to be created by this instance having the Model
property set to this instance..public final <TLookup> TLookup lookup(Class<TLookup> type)
ILookup
null
.
Typically, this method will be called in order to obtain a different view or
aspect of the current instance. This is quite similar to casting or using
a super type or interface of this instance, but is not limited to inheritance or
compile time constraints. An instance implementing this method is not
required to return non-null
implementations for the types, nor does it
have to return the same instance any time. Also it depends on the
type and context whether the instance returned stays up to date or needs to
be reobtained for subsequent use.