Packagecom.yworks.graph.model
Classpublic class DefaultPortCandidate
InheritanceDefaultPortCandidate Inheritance Object
Implements IPortCandidate

A simple default implementation of an IPortCandidate.

Subclasses need to override createInstance if they don't set a port instance.



Public Properties
 PropertyDefined By
  candidateTag : Object
Gets or set the tag of this candidate.
DefaultPortCandidate
  locationModelParameter : IPortLocationModelParameter
Gets or sets the model parameter that will be used for the port if this candidate is chosen.
DefaultPortCandidate
  model : IPortLocationModel
The model that will be used by this instance to determine the new locationModelParameter if getPortCandidateAt is called and the validity is set to PortCandidateValidity.DYNAMIC.
DefaultPortCandidate
  owner : IPortOwner
Gets or sets the owner of the port to be created.
DefaultPortCandidate
  style : IPortStyle
Gets or tsets the style to use for the newly created port.
DefaultPortCandidate
  validity : PortCandidateValidity
Determines whether this candidate is valid depending on the context it has been obtained from.
DefaultPortCandidate
Public Methods
 MethodDefined By
  
DefaultPortCandidate(owner:IPortOwner, locationModelParameter:IPortLocationModelParameter = null, useExistingPort:Boolean = true)
Creates a new instance.
DefaultPortCandidate
  
[static] Creates a candidate using the given port as the template.
DefaultPortCandidate
  
[static] Creates a dynamic candidate for the given owner using the specified model.
DefaultPortCandidate
  
This implementation will throw an IllegalOperationError if the validity is PortCandidateValidity.DYNAMIC.
DefaultPortCandidate
  
Returns the instance provided to the constructor or to the setter.
DefaultPortCandidate
  
Returns a candidate that is derived from this instance that best fits the provided location.
DefaultPortCandidate
  
setInstance(port:IPort):void
Sets the instance that will be returned by getInstance and createInstance.
DefaultPortCandidate
Protected Methods
 MethodDefined By
  
Actually create the IPort instance.
DefaultPortCandidate
Property Detail
candidateTagproperty
candidateTag:Object

Gets or set the tag of this candidate.

The interpretation of this value is implementation dependent and may be used for visual feedback or interactive behavior.

The default value is null.


Implementation
    public function get candidateTag():Object
    public function set candidateTag(value:Object):void
locationModelParameterproperty 
locationModelParameter:IPortLocationModelParameter

Gets or sets the model parameter that will be used for the port if this candidate is chosen.


Implementation
    public function get locationModelParameter():IPortLocationModelParameter
    public function set locationModelParameter(value:IPortLocationModelParameter):void
modelproperty 
model:IPortLocationModel

The model that will be used by this instance to determine the new locationModelParameter if getPortCandidateAt is called and the validity is set to PortCandidateValidity.DYNAMIC.


Implementation
    public function get model():IPortLocationModel
    public function set model(value:IPortLocationModel):void

See also

ownerproperty 
owner:IPortOwner

Gets or sets the owner of the port to be created.


Implementation
    public function get owner():IPortOwner
    public function set owner(value:IPortOwner):void
styleproperty 
style:IPortStyle

Gets or tsets the style to use for the newly created port. If this property is null, the current default in the graph will be used.


Implementation
    public function get style():IPortStyle
    public function set style(value:IPortStyle):void
validityproperty 
validity:PortCandidateValidity

Determines whether this candidate is valid depending on the context it has been obtained from.

The default value is PortCandidateValidity#VALID.


Implementation
    public function get validity():PortCandidateValidity
    public function set validity(value:PortCandidateValidity):void
Constructor Detail
DefaultPortCandidate()Constructor
public function DefaultPortCandidate(owner:IPortOwner, locationModelParameter:IPortLocationModelParameter = null, useExistingPort:Boolean = true)

Creates a new instance.

Parameters
owner:IPortOwner — The port owner.
 
locationModelParameter:IPortLocationModelParameter (default = null) — the port location model parameter. If null, the location model parameter of the first port of the owner is used.
 
useExistingPort:Boolean (default = true) — If true and no locationModelParameter is passed, the first port of the owner is set as instance and it's locationModelParameter is used.

See also

Method Detail
create()method
public static function create(port:IPort):DefaultPortCandidate

Creates a candidate using the given port as the template.

Parameters

port:IPort — The port to use as template.

Returns
DefaultPortCandidate
createDynamic()method 
public static function createDynamic(owner:IPortOwner, model:IPortLocationModel):DefaultPortCandidate

Creates a dynamic candidate for the given owner using the specified model.

Parameters

owner:IPortOwner — The port owner.
 
model:IPortLocationModel — The port location model used in getPortCandidateAt to create parameters.

Returns
DefaultPortCandidate

See also

PortCandidateValidity.DYNAMIC
createInstance()method 
public function createInstance(context:IInputModeContext):IPort

This implementation will throw an IllegalOperationError if the validity is PortCandidateValidity.DYNAMIC. This implementation will delegate to the

Parameters

context:IInputModeContext

Returns
IPort — The port instance to use if this candidate has been chosen. This method may return null to indicate that the client should create an appropriate port itself.
createInstanceCore()method 
protected function createInstanceCore(context:IInputModeContext, graph:IGraph, parameter:IPortLocationModelParameter, style:IPortStyle):IPort

Actually create the IPort instance. This method is called in response to a call to createInstance on this instance and the instances created by getPortCandidateAt.

Parameters

context:IInputModeContext — The input mode context.
 
graph:IGraph — The graph to add the port to.
 
parameter:IPortLocationModelParameter — The parameter to use.
 
style:IPortStyle — The style to use.

Returns
IPort — The newly created port.

See also

getInstance()method 
public function getInstance():IPort

Returns the instance provided to the constructor or to the setter.

Returns
IPort — The instance to use or null otherwise.

See also

getPortCandidateAt()method 
public function getPortCandidateAt(context:IInputModeContext, location:IPoint):IPortCandidate

Returns a candidate that is derived from this instance that best fits the provided location. The returned implementation will finally call createInstance using the newly created locationModelParameter.

Parameters

context:IInputModeContext — The input mode context for which a concrete candidate is queried.
 
location:IPoint — The location for which a candidate should be returned.

Returns
IPortCandidate — An IPortCandidate implementation whose validity is guaranteed to be non-PortCandidateValidity.DYNAMIC.

See also

setInstance()method 
public function setInstance(port:IPort):void

Sets the instance that will be returned by getInstance and createInstance.

Parameters

port:IPort — A port that already exists in the graph or null.