public final class GenericPortLocationModel extends Object implements IPortLocationModel, IMarkupExtensionConverter, IEnumerable<IPortLocationModelParameter>
IPortLocationModel that can be used to create custom port location models out of existing IPortLocationModelParameter
instances.
This class holds a number of parameters and serves as a container for these parameters.
Custom models can easily be created in the following way:
Note that in order to work, this model needs to have at least one
parameter added.
EMPTY| Constructor and Description |
|---|
GenericPortLocationModel()
Initializes a new instance of the
GenericPortLocationModel class. |
| Modifier and Type | Method and Description |
|---|---|
void |
add(IPortLocationModelParameter locationParameter)
This method simply delegates to
addParameter(IPortLocationModelParameter). |
IPortLocationModelParameter |
addParameter(IPortLocationModelParameter locationParameter)
Adds the given parameter to the
LocationParameters of this instance. |
boolean |
canConvert(IWriteContext context,
Object value)
Returns if the converter can convert the
value to a MarkupExtension in the current write context. |
MarkupExtension |
convert(IWriteContext context,
Object value)
Converts the
value to a MarkupExtension using the current write context. |
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.
|
IEnumerator<IPortLocationModelParameter> |
enumerator()
Returns an
IEnumerator over a set of elements of type T. |
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.
|
Iterable<IPortLocationModelParameter> |
getLocationParameters()
Gets all parameters that are associated with this instance.
|
<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, waitcreateDictionaryLookup, createDynamic, createSingle, createSingle, createWrapped, lookup, lookup, safeLookupconcat, concat, create, create, iterator, parallelStream, streamforEach, spliteratorpublic GenericPortLocationModel()
GenericPortLocationModel class.public final void add(IPortLocationModelParameter locationParameter)
addParameter(IPortLocationModelParameter).
It is there to allow for convenient initialization in code.
This method is used by the compiler if the collection initializer syntax is used.
locationParameter - The parameter to add to this instance.addParameter(IPortLocationModelParameter)public final IPortLocationModelParameter addParameter(IPortLocationModelParameter locationParameter)
LocationParameters of this instance.
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 modified, implicitly, too.
locationParameter - The parameter to add to this instance.add(IPortLocationModelParameter)public final boolean canConvert(IWriteContext context, Object value)
IMarkupExtensionConvertervalue to a MarkupExtension in the current write context.canConvert in interface IMarkupExtensionConvertercontext - The current write context.value - The object to convert.public final MarkupExtension convert(IWriteContext context, Object value)
IMarkupExtensionConvertervalue to a MarkupExtension using the current write context.convert in interface IMarkupExtensionConvertercontext - The current write context.value - The object to convert.MarkupExtension the value was converted to.public final IPortLocationModelParameter createParameter(IPortOwner owner, PointD location)
This implementation iterates over all LocationParameters to return the one that matches
the given location the best.
createParameter in interface IPortLocationModelowner - 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 IEnumerator<IPortLocationModelParameter> enumerator()
IEnumerableIEnumerator over a set of elements of type T.enumerator in interface IEnumerable<IPortLocationModelParameter>IEnumerator.public final ILookup getContext(IPort port, IPortLocationModelParameter locationParameter)
IPortLocationModellookup context for the given combination of port and parameter.getContext in interface IPortLocationModelport - 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)
IPortLocationModelgetLocation in interface IPortLocationModelport - 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 Iterable<IPortLocationModelParameter> getLocationParameters()
This enumerates the instances that wraps the parameters that have been added to this instance via
addParameter(IPortLocationModelParameter)
public final <TLookup> TLookup lookup(Class<TLookup> type)
ILookupnull.
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.