public class DefaultPortCandidate extends Object implements IPortCandidate
IPortCandidate
.
Subclasses need to override createInstance(IInputModeContext, IGraph, IPortLocationModelParameter, IPortStyle, Object)
if they don't set
a port instance.
Constructor and Description |
---|
DefaultPortCandidate(IPort port)
Creates a candidate using the given port as the template.
|
DefaultPortCandidate(IPortOwner owner)
Creates a candidate for the given
owner that uses the graph's defaults for the port's style and the given
locationParameter . |
DefaultPortCandidate(IPortOwner owner,
IPortLocationModel model)
Creates a candidate for the given
owner that uses the graph's defaults for the port's style and a default
parameter for the given model . |
DefaultPortCandidate(IPortOwner owner,
IPortLocationModelParameter locationParameter)
Creates a candidate for the given
owner that uses the graph's defaults for the port's style and the given
locationParameter . |
DefaultPortCandidate(IPortOwner owner,
IPortLocationModelParameter locationParameter,
PortCandidateValidity validity)
Creates a candidate for the given
owner that uses the graph's defaults for the port's style and the given
locationParameter . |
Modifier and Type | Method and Description |
---|---|
protected IPort |
createInstance(IInputModeContext context,
IGraph graph,
IPortLocationModelParameter locationParameter,
IPortStyle style,
Object tag)
Actually creates the
IPort instance. |
IPort |
createPort(IInputModeContext context)
This implementation will throw a
UnsupportedOperationException if the validity is
PortCandidateValidity.DYNAMIC . |
Object |
getCandidateTag()
Gets the tag for this candidate.
|
IPortLocationModelParameter |
getLocationParameter()
Gets the model parameter that will be used for the
LocationParameter if this
candidate is chosen. |
IPortLocationModel |
getModel()
The model that will be used by this instance to determine the new
LocationParameter if
the getPortCandidateAt(IInputModeContext, PointD) is called and the Validity is set to
PortCandidateValidity.DYNAMIC . |
IPortOwner |
getOwner()
Gets the owner of the port to be created.
|
IPort |
getPort()
Returns the instance provided to the constructor or to the
setter . |
IPortCandidate |
getPortCandidateAt(IInputModeContext context,
PointD location)
Returns a candidate that is derived from this instance that best fits the provided
location . |
Object |
getPortTag()
Gets the port tag to create the port with.
|
IPortStyle |
getStyle()
Gets the style to use for the newly created port.
|
PortCandidateValidity |
getValidity()
Determines whether this candidate is a valid one depending on the context it has been obtained from.
|
void |
setCandidateTag(Object value)
Sets the tag for this candidate.
|
void |
setInstance(IPort port)
Sets the instance that will be returned by
Port and createPort(IInputModeContext) . |
void |
setLocationParameter(IPortLocationModelParameter value)
Sets the model parameter that will be used for the
LocationParameter if this
candidate is chosen. |
void |
setModel(IPortLocationModel value)
The model that will be used by this instance to determine the new
LocationParameter if
the getPortCandidateAt(IInputModeContext, PointD) is called and the Validity is set to
PortCandidateValidity.DYNAMIC . |
void |
setOwner(IPortOwner value)
Sets the owner of the port to be created.
|
void |
setPortTag(Object value)
Sets the port tag to create the port with.
|
void |
setStyle(IPortStyle value)
Sets the style to use for the newly created port.
|
void |
setValidity(PortCandidateValidity value)
Determines whether this candidate is a valid one depending on the context it has been obtained from.
|
public DefaultPortCandidate(IPort port)
port
- The port to use.public DefaultPortCandidate(IPortOwner owner)
owner
that uses the graph's defaults for the port's style and the given
locationParameter
.
If no locationParameter
is given, the used candidate has a fixed location at PointD.ORIGIN
that does not
depend on the owner
.
owner
- The owner.public DefaultPortCandidate(IPortOwner owner, IPortLocationModel model)
owner
that uses the graph's defaults for the port's style and a default
parameter for the given model
.
The LocationParameter
is set to the parameter that best matches the origin
for the given model
.
owner
- The owner.model
- The model.public DefaultPortCandidate(IPortOwner owner, IPortLocationModelParameter locationParameter)
owner
that uses the graph's defaults for the port's style and the given
locationParameter
.
If no locationParameter
is given, the used candidate has a fixed location at PointD.ORIGIN
that does not
depend on the owner
.
owner
- The owner.locationParameter
- The location.public DefaultPortCandidate(IPortOwner owner, IPortLocationModelParameter locationParameter, PortCandidateValidity validity)
owner
that uses the graph's defaults for the port's style and the given
locationParameter
.
If no locationParameter
is given, the used candidate has a fixed location at PointD.ORIGIN
that does not
depend on the owner
.
owner
- The owner.locationParameter
- The location.validity
- The validity of the port candidate.protected IPort createInstance(IInputModeContext context, IGraph graph, IPortLocationModelParameter locationParameter, IPortStyle style, Object tag)
IPort
instance.
This method is called in response to a call to createPort(IInputModeContext)
on this instance and the instances
created by getPortCandidateAt(IInputModeContext, PointD)
.
context
- The input mode context.graph
- The graph to add the port to.locationParameter
- The parameter to use.style
- The style to use.tag
- The tag to use.public IPort createPort(IInputModeContext context)
UnsupportedOperationException
if the validity is
PortCandidateValidity.DYNAMIC
.
This implementation will delegate to the createInstance(IInputModeContext, IGraph, IPortLocationModelParameter, IPortStyle, Object)
method.
createPort
in interface IPortCandidate
context
- The input mode context for which the port will be created. Implementations can depend on it providing an IGraph
instance in the lookup of the instance.null
.IInputModeContext.getGraph()
,
IPortCandidate.getPort()
,
IPortCandidate.getPortCandidateAt(IInputModeContext, PointD)
public final Object getCandidateTag()
The interpretation of this value is implementation dependent and may be used for visual feedback or interactive behavior.
getCandidateTag
in interface IPortCandidate
setCandidateTag(Object)
public final IPortLocationModelParameter getLocationParameter()
LocationParameter
if this
candidate is chosen.
The parameter which may not be null
.
getLocationParameter
in interface IPortCandidate
setLocationParameter(IPortLocationModelParameter)
public final IPortLocationModel getModel()
LocationParameter
if
the getPortCandidateAt(IInputModeContext, PointD)
is called and the Validity
is set to
PortCandidateValidity.DYNAMIC
.setModel(IPortLocationModel)
public final IPortOwner getOwner()
getOwner
in interface IPortCandidate
setOwner(IPortOwner)
public IPort getPort()
setter
.getPort
in interface IPortCandidate
null
otherwise.createPort(IInputModeContext)
public IPortCandidate getPortCandidateAt(IInputModeContext context, PointD location)
location
.
The returned implementation will finally call createInstance(IInputModeContext, IGraph, IPortLocationModelParameter, IPortStyle, Object)
using the newly calculated LocationParameter
.
getPortCandidateAt
in interface IPortCandidate
context
- The input mode context for which a concrete candidate is queried.location
- The location for which a candidate should be returned.IPortCandidate
implementation whose Validity
is guaranteed to be
non-PortCandidateValidity.DYNAMIC
.getValidity()
public final Object getPortTag()
setPortTag(Object)
public final IPortStyle getStyle()
null
, the current default in the graph will be used.setStyle(IPortStyle)
public final PortCandidateValidity getValidity()
getValidity
in interface IPortCandidate
setValidity(PortCandidateValidity)
public final void setCandidateTag(Object value)
The interpretation of this value is implementation dependent and may be used for visual feedback or interactive behavior.
value
- The CandidateTag to set.getCandidateTag()
public void setInstance(IPort port)
Port
and createPort(IInputModeContext)
.port
- A port that already exists in the graph or null
.public final void setLocationParameter(IPortLocationModelParameter value)
LocationParameter
if this
candidate is chosen.
The parameter which may not be null
.
value
- The LocationParameter to set.getLocationParameter()
public final void setModel(IPortLocationModel value)
LocationParameter
if
the getPortCandidateAt(IInputModeContext, PointD)
is called and the Validity
is set to
PortCandidateValidity.DYNAMIC
.value
- The Model to set.getModel()
public final void setOwner(IPortOwner value)
value
- The Owner to set.getOwner()
public final void setPortTag(Object value)
value
- The port tag to use when the port is created.getPortTag()
public final void setStyle(IPortStyle value)
value
- The style. If this property is null
, the current default in the graph will be used.getStyle()
public final void setValidity(PortCandidateValidity value)
value
- The Validity to set.getValidity()