public abstract class IlvLinkConnector extends Object implements Serializable, IlvPersistentObject
IlvLinkImage
) in a grapher (IlvGrapher
).
When a link is created between two nodes, it is attached to the
default connection point of each node (see the documentation of the
class IlvLinkImage
. Subclasses of the class
IlvLinkConnector
can be used to obtain different
connection points than the default ones.
An IlvLinkConnector
is associated with a node (returned
by the method getNode()
).
The implementation of the method getConnectionPoint(ilog.views.IlvLinkImage, boolean, ilog.views.IlvTransformer)
decides
where the connection point of a link (provided as an argument) should
be located.
An instance of IlvLinkConnector
can be specified for
each node of a grapher. To do this, simply create it using the constructor
IlvLinkConnector(IlvGraphic)
or use
the method attach(IlvGraphic, boolean)
. Notice that the same
instance of link connector cannot be shared by several nodes.
A link connector specified for a node controls the connection points
of all the links incident to this node. If you need the connection
points of the incident links to not all be computed in the same way
(that is, by the same link connector), you can specify a link connector
individually for each extremity of each link.
To do this, simply create it using the constructor
IlvLinkConnector(IlvLinkImage, boolean)
or use
the method attach(IlvLinkImage, boolean, boolean)
.
To get the instance of link connector actually used to compute the
connection point of a given link, use the method
Get(IlvLinkImage, boolean)
.
IlvGrapher
,
IlvLinkImage
,
Serialized FormConstructor and Description |
---|
IlvLinkConnector()
Creates an empty
IlvLinkConnector . |
IlvLinkConnector(IlvGraphic node)
Creates an
IlvLinkConnector attached to the node
node . |
IlvLinkConnector(IlvInputStream stream)
Reads the link object from an
IlvInputStream . |
IlvLinkConnector(IlvLinkImage link,
boolean origin)
Creates an
IlvLinkConnector attached to the
origin or destination of the link link . |
Modifier and Type | Method and Description |
---|---|
protected void |
allLinksRemoved()
Called when all the links are removed from the node.
|
boolean |
allowsConnectionPointMove(IlvLinkImage link,
boolean origin)
Indicates whether a connection point of a link can be moved by interactors.
|
void |
attach(IlvGraphic node,
boolean redraw)
Installs the link connector on the node
node . |
void |
attach(IlvLinkImage link,
boolean origin,
boolean redraw)
Installs the link connector for the origin or destination of
link . |
IlvLinkConnector |
attach(IlvLinkImage link,
boolean unshare,
boolean origin,
boolean redraw)
Installs the link connector, or a clone of itself,
for the origin or destination of
link . |
abstract void |
connectLink(IlvLinkImage link,
IlvPoint p,
boolean origin,
IlvTransformer t)
Connects a link to a specified connection point.
|
void |
detach(boolean redraw)
Detaches the link connector from the attached node and from the
attached links (if any).
|
void |
detach(IlvLinkImage link,
boolean origin,
boolean redraw)
Detaches the link connector from the origin or the destination
of a link.
|
void |
disconnectLink(IlvLinkImage link,
boolean origin)
Disconnects a link from the link connector.
|
void |
drawGhost(Graphics g,
IlvTransformer t,
Object orig,
Object dest,
Object linkOrClass,
boolean origin)
Draws the connection points.
|
static IlvLinkConnector |
Get(IlvGraphic node)
Deprecated.
Beginning with Rogue Wave JViews 5.5, link connectors can
be specified for both nodes and links. To get the link connector
actually used to compute the connection points of a particular link,
use the method
Get(IlvLinkImage, boolean) . To get the link
connector specified for a node, use the method GetAttached(IlvGraphic) .
Notice that the link connector returned by this method is actually used
only for links incident to node for which a specific link
connector has not been specified. The latter is returned by the method
GetAttached(IlvLinkImage, boolean) . |
static IlvLinkConnector |
Get(IlvLinkImage link,
boolean origin)
Returns the link connector that actually controls the connection point
on the origin or destination node of
link . |
static IlvLinkConnector |
GetAttached(IlvGraphic node)
|
static IlvLinkConnector |
GetAttached(IlvLinkImage link,
boolean origin)
Returns the link connector attached to the origin or destination
of
link using
attach(IlvLinkImage, boolean, boolean) , or null if none. |
abstract IlvPoint |
getClosestConnectionPoint(IlvPoint p,
Object orig,
Object dest,
Object linkOrClass,
boolean origin,
IlvTransformer t)
Returns the connection point that is closest to a particular point
p . |
abstract IlvPoint |
getConnectionPoint(IlvLinkImage link,
boolean origin,
IlvTransformer t)
Returns the position of the point where
link is
connected to the origin or destination node. |
abstract IlvRect |
getGhostBoundingBox(IlvTransformer t)
Returns the bounding box of the ghost of the connection points.
|
IlvGraphic |
getNode()
Returns the node associated with the link connector.
|
boolean |
isPersistent()
Indicates whether the link connector must be saved to an IVL file.
|
void |
linkRemoved(IlvLinkImage link)
Called when a link is removed from the node.
|
void |
read(IlvInputStream stream,
IlvLinkImage link,
boolean origin)
Reads information associated with a link from an
IlvInputStream . |
boolean |
supportsDrawGhost()
Returns
true if the link connector needs its
drawGhost(java.awt.Graphics, ilog.views.IlvTransformer, java.lang.Object, java.lang.Object, java.lang.Object, boolean) method to be called. |
void |
write(IlvOutputStream stream)
Writes the object to an
IlvOutputStream . |
void |
write(IlvOutputStream stream,
IlvLinkImage link,
boolean origin)
Writes information associated with a link to an
IlvOutputStream . |
protected abstract boolean |
zoomable()
Returns
true if the connection points are zoomable;
otherwise it returns false . |
public IlvLinkConnector()
IlvLinkConnector
. It can be
attached either to a node (using
attach(IlvGraphic, boolean)
) or to an extremity
of a link (using
attach(IlvLinkImage,boolean,boolean)
).public IlvLinkConnector(IlvGraphic node)
IlvLinkConnector
attached to the node
node
.
The constructor calls the method attach(IlvGraphic, boolean)
,
passing thenode
argument and the argument
redraw
at true
.
attach(IlvGraphic,boolean)
,
detach(boolean)
public IlvLinkConnector(IlvLinkImage link, boolean origin)
IlvLinkConnector
attached to the
origin or destination of the link link
.
If the argument origin
is true
,
this creates a link connector for the origin of link
.
If the argument origin
is false
,
this creates a link connector for the destination of link
.
The constructor calls the method
attach(IlvLinkImage, boolean, boolean)
, passing the
link
and origin
arguments and with
the argument redraw
at true
.
attach(IlvLinkImage, boolean, boolean)
,
detach(IlvLinkImage, boolean, boolean)
public IlvLinkConnector(IlvInputStream stream) throws IlvReadFileException
IlvInputStream
.
Note that a subclass that overrides the method isPersistent()
to return true
must be public
and must provide
a constructor with an IlvInputStream
argument.
The first line of the constructor must be super(stream)
.
stream
- The input stream.IlvReadFileException
- if the format is not correct.read(ilog.views.io.IlvInputStream, IlvLinkImage, boolean)
,
write(ilog.views.io.IlvOutputStream)
,
isPersistent()
public void attach(IlvGraphic node, boolean redraw)
node
.
After installation, this link connector controls the connection
points of all the links incident to node
, except those
for which a specific link connector has been installed on the
corresponding extremity of the link. The method getNode()
returns the node node
.
The method detach(boolean)
is automatically called
to detach the old attached node, if any. Also, if any other
link connector was attached to this node, it gets detached.
Notice that you are not allowed to call this method for a link
connector that has been already installed for a link (that is,
using the method attach(IlvLinkImage, boolean, boolean)
.
node
- The node.redraw
- If true
, the node to which the connector is
attached and its adjacent links will be redrawn.detach(boolean)
,
attach(IlvLinkImage, boolean, boolean)
public void attach(IlvLinkImage link, boolean origin, boolean redraw)
link
.
After installation, this link connector controls the origin or
destination point of link
. The corresponding origin or
destination node of link
is returned by the method
getNode()
.
The method detach(IlvLinkImage, boolean, boolean)
is automatically called to detach the old attached link, if any.
Also, if any other link connector was installed for the origin or
destination of link
, it gets detached.
link
- The link.origin
- If true
, the link connector is installed
for the origin node of link
. Otherwise, it is
installed for the destination node of link
.redraw
- If true
, the node to which the connector is
attached and its adjacent links will be redrawn.detach(IlvLinkImage, boolean, boolean)
public IlvLinkConnector attach(IlvLinkImage link, boolean unshare, boolean origin, boolean redraw)
link
.
See attach(IlvLinkImage, boolean, boolean)
for details.
If the parameter unshare
is false, it tries to install this
link connector but may fail, since link connectors cannot be shared
among multiple links in certain circumstances.
If the parameter unshare
is true, it attaches this link
connector only if it is not yet attached. If this link connector is
already attached, it clones the link connector, attaches the cloned link
connector and returns it.
Cloning a link connector works only if the link connector implements
the IlvPersistentObject
interface, which is the case for
all predefined link connectors.link
- The link.unshare
- Whether the link connector is unshared by allocating a
clone.origin
- If true
, the link connector is installed
for the origin node of link
. Otherwise, it is
installed for the destination node of link
.redraw
- If true
, the node to which the connector is
attached and its adjacent links will be redrawn.null
.attach(IlvLinkImage, boolean, boolean)
public void detach(boolean redraw)
When you attach a new node to a link connector already attached
to a node, it is not necessary to detach the old node because
this is done automatically when you call
attach(IlvGraphic, boolean)
.
When you attach a new link to a link connector already attached to
a different link but for the same extremity,
it is not necessary to detach the old link because
this is done automatically when you call
attach(IlvLinkImage, boolean, boolean)
.
If this link connector has been attached on a node (using
attach(IlvGraphic, boolean)
, the method simply
detaches the link connector from the node.
If this link connector has been attached to at least one link
(using attach(IlvLinkImage, boolean, boolean)
), this method
calls detach(IlvLinkImage, boolean, boolean)
for each link
incident to the node returned by getNode()
to which this link
connector has been attached. However, this operation can be
done only in the usual case, when the node is still contained in
an IlvGrapher
. If the node is not contained in an IlvGrapher
,
the method raises a RuntimeException
, to indicate that
the detachment from the attached links could not be performed.
Note that you can detach link connectors from individual links
using the method detach(IlvLinkImage, boolean, boolean)
even
if the node (and link) are no longer contained in an IlvGrapher
.
redraw
- If true
, the node to which the connector is
attached and its adjacent links will be redrawn.attach(IlvGraphic, boolean)
,
detach(IlvLinkImage, boolean, boolean)
public void detach(IlvLinkImage link, boolean origin, boolean redraw)
When you attach a new link to a link connector already attached to
a different link but for the same extremity,
it is not necessary to detach the old link because
this is done automatically when you call
attach(IlvLinkImage, boolean, boolean)
.
link
- The link from which the link connector is detached.origin
- If true
, the link connector is detached
from the origin of link
. Otherwise, it is detached
from the destination of link
.redraw
- If true
, the node to which the connector is
attached and its adjacent links will be redrawn.attach(IlvLinkImage, boolean, boolean)
,
detach(boolean)
public static IlvLinkConnector GetAttached(IlvGraphic node)
node
using
attach(IlvGraphic, boolean)
, or null
if none.
Note that the link connector that actually controls the connection
point of a given link is returned by the method
Get(IlvLinkImage, boolean)
.Get(IlvLinkImage, boolean)
,
GetAttached(IlvLinkImage, boolean)
public static IlvLinkConnector GetAttached(IlvLinkImage link, boolean origin)
link
using
attach(IlvLinkImage, boolean, boolean)
, or null
if none.
Note that the link connector that actually controls the connection
point of a given link is returned by the method
Get(IlvLinkImage, boolean)
.Get(IlvLinkImage, boolean)
,
GetAttached(IlvGraphic)
public void write(IlvOutputStream stream) throws IOException
IlvOutputStream
.
You must override this method if specific data is to be stored.
Note that the first instruction in your implementation of the method must
be super.write(stream)
.
You should not call this method directly; instead, you should use
the write
methods of the IlvGrapher
that contains
the node or link to which the link connector is attached.
write
in interface IlvPersistentObject
stream
- The output stream.IOException
- thrown when an exception occurs during
the write operation for this object.read(ilog.views.io.IlvInputStream, IlvLinkImage, boolean)
,
write(ilog.views.io.IlvOutputStream, IlvLinkImage, boolean)
,
isPersistent()
public void write(IlvOutputStream stream, IlvLinkImage link, boolean origin) throws IOException
IlvOutputStream
. The default implementation of the method
does nothing.
You must override this method if specific data is to be stored.
Note that the first instruction in your implementation of the method must
be super.write(stream, link, origin)
.
You should not call this method directly; instead, you should use
the write
methods of the IlvGrapher
that contains
the node or link to which the link connector is attached.
stream
- The output stream.link
- The link.origin
- If true
,
information about the connection of the origin of link
is written. Otherwise, the method writes information about
the destination of link
.IOException
write(ilog.views.io.IlvOutputStream)
,
read(ilog.views.io.IlvInputStream, IlvLinkImage, boolean)
,
isPersistent()
public void read(IlvInputStream stream, IlvLinkImage link, boolean origin) throws IlvReadFileException
IlvInputStream
.
The default implementation of the method does nothing.
You must override this method if specific data is to be read.
Note that the first instruction in your implementation of the method must
besuper.read(stream, link, origin)
.
You should not call this method directly; instead, you should use the
read
methods of the IlvGrapher
that contains the node
or link to which the link connector is attached.
stream
- The input stream.link
- The link.origin
- If true
,
information about the connection of the origin of link
is read. Otherwise, the method reads information about
the destination of link
.IlvReadFileException
write(ilog.views.io.IlvOutputStream, IlvLinkImage, boolean)
,
isPersistent()
public boolean isPersistent()
true
, the link connector
is saved; otherwise it is not saved.
The default implementation always returns false
.
Note that if a subclass overrides this method to return
true
, it must be public
and must provide a
constructor with an IlvInputStream
argument.
The first line of the constructor must be super(stream)
.
write(ilog.views.io.IlvOutputStream)
,
write(ilog.views.io.IlvOutputStream, IlvLinkImage, boolean)
public final IlvGraphic getNode()
attach(IlvGraphic, boolean)
, the method returns
this node.
For link connectors attached to a link (using
attach(IlvLinkImage, boolean, boolean)
, the method
returns the corresponding end node of the link.@Deprecated public static IlvLinkConnector Get(IlvGraphic node)
Get(IlvLinkImage, boolean)
. To get the link
connector specified for a node, use the method GetAttached(IlvGraphic)
.
Notice that the link connector returned by this method is actually used
only for links incident to node
for which a specific link
connector has not been specified. The latter is returned by the method
GetAttached(IlvLinkImage, boolean)
.public static IlvLinkConnector Get(IlvLinkImage link, boolean origin)
link
.
The method returns:
link
(see
attach(IlvLinkImage, boolean, boolean)
, if any has been attached
and if the corresponding origin or destination node of the link is not
contained in a collapsed parent (see IlvLinkImage.getVisibleFrom()
,
IlvLinkImage.getVisibleTo()
), or
IlvLinkImage.getVisibleFrom()
,
IlvLinkImage.getVisibleTo()
) of link
, if any.
null
.public abstract IlvPoint getConnectionPoint(IlvLinkImage link, boolean origin, IlvTransformer t)
link
is
connected to the origin or destination node.
You must implement this method in a subclass to give the
position of the connection point of the link.
Beginning with JViews 5.5, the implementation of that method
may return null
instead of an IlvPoint
instance. In that case the point computation is delegated to the
default mechanism.
Note that, when link connectors are used to control the connection
points of a link, the bounding box of the link depends on the connection
point.
Therefore, once a link connector has been attached to a node or a link
contained in an IlvGrapher
, the connection point must
be changed only using the method IlvManager.applyToObject(ilog.views.IlvGraphic, ilog.views.IlvApplyObject, java.lang.Object, boolean)
.
link
- The link.origin
- If true
, the position of
the connection point for the link origin is determined. Otherwise the
position of the connection point for the link destination is determined.t
- The transformer that is used to draw the node.null
.protected abstract boolean zoomable()
true
if the connection points are zoomable;
otherwise it returns false
.
A connection point is zoomable if calling the method
getConnectionPoint(ilog.views.IlvLinkImage, boolean, ilog.views.IlvTransformer)
with a transformer gives
the same result as calling it with a null
(identity)
transformer and then applying the transformer to the result.
Note that an instance of a link connector must return the same value during its lifetime.
public abstract IlvPoint getClosestConnectionPoint(IlvPoint p, Object orig, Object dest, Object linkOrClass, boolean origin, IlvTransformer t)
p
.p
- The transformed point.orig
- The graphic object origin of the link or the class of the
origin object. This depends on whether the link has already been
created or not.dest
- The graphic object destination of the link or the class of
the destination object. This depends on whether the link has already
been created or not.linkOrClass
- An instance of IlvLinkImage
or
an instance of the class.
This parameter enables you to allow or inhibit connection points,
depending on the link or the class of link. The class is useful when the
link is not already created.origin
- If true
, the position of the link
connection point for the link origin is determined. Otherwise the
position of the link connection point
for the link destination is found.t
- The transformer used to draw the node.public abstract void connectLink(IlvLinkImage link, IlvPoint p, boolean origin, IlvTransformer t)
link
- The link to be connected.p
- The point where the link must be connected. The point must be
transformed by the transformer t
.origin
- If true
, the origin of the link will be
connected; otherwise, it is the destination.t
- The transformer that is used to draw the node.allowsConnectionPointMove(ilog.views.IlvLinkImage, boolean)
public void disconnectLink(IlvLinkImage link, boolean origin)
The default implementation does nothing.
In subclasses of IlvLinkConnector
, if the
implementation of connectLink(ilog.views.IlvLinkImage, ilog.views.IlvPoint, boolean, ilog.views.IlvTransformer)
stores information
about the link, the method disconnectLink
must be
overridden to clear this data when the link is no longer connected
to the link connector.
link
- The link to be disconnected.origin
- If set to true
, the origin of the link
is disconnected. If false
the destination link is
disconnected.connectLink(ilog.views.IlvLinkImage, ilog.views.IlvPoint, boolean, ilog.views.IlvTransformer)
public boolean allowsConnectionPointMove(IlvLinkImage link, boolean origin)
If the argument origin
is true
, the method returns
true
if the connection point of link
on the origin
node can be moved by interactors, and returns false
otherwise.
If the argument origin
is false
, the method returns
true
if the connection point of link
on the destination
node can be moved by interactors, and returns false
otherwise.
The default implementation always returns true
. Subclasses can
override this method to indicate to the interactors that either all or some
connection points cannot be moved.
public void linkRemoved(IlvLinkImage link)
connectLink(ilog.views.IlvLinkImage, ilog.views.IlvPoint, boolean, ilog.views.IlvTransformer)
stores
information for the link, this method should be overridden to
clean out this information when the link is no longer connected to
the node.protected void allLinksRemoved()
connectLink(ilog.views.IlvLinkImage, ilog.views.IlvPoint, boolean, ilog.views.IlvTransformer)
stores
information for the link, this method should be overridden to
clean out this information when the link is no longer connected to
the node.public void drawGhost(Graphics g, IlvTransformer t, Object orig, Object dest, Object linkOrClass, boolean origin)
supportsDrawGhost()
returns true
.
You should not call this method directly, but you
may override it to do your own type of drawing.
The default implementation does nothing.
g
- A Graphics to perform the drawings.t
- The transformation used to draw the connection points.orig
- The graphic object origin of the link or the class of the
origin object. This depends on whether the link has already been
created or not.dest
- The graphic object destination of the link or the class of
the destination object. This depends on whether the link has already
been created or not.linkOrClass
- An instance of
IlvLinkImage
or an instance of a Class
object.
This parameter enables you to allow or inhibit connection points,
depending on the link or the class of link. The class is useful when the
link is not already created.origin
- If true
, the position of the link
connection point for the link origin is determined; otherwise, the
position of the link connection point is determinedsupportsDrawGhost()
,
getGhostBoundingBox(ilog.views.IlvTransformer)
public abstract IlvRect getGhostBoundingBox(IlvTransformer t)
This method is called when creating or editing a link, if
the method supportsDrawGhost()
returns true
.
You should not call this method directly.
If a subclass of IlvLinkConnector
does not draw a ghost,
the implementation of the method can return anything. In this case, the
method supportsDrawGhost()
must return false
and the
Rogue Wave JViews library never calls this method.
Subclasses of IlvLinkConnector
that draw a ghost must
implement this method to return the bounding rectangle of the ghost.
In this case, the method supportsDrawGhost()
must be overridden
to return true
.
t
- The transformer used to draw the connection points.supportsDrawGhost()
,
drawGhost(java.awt.Graphics, ilog.views.IlvTransformer, java.lang.Object, java.lang.Object, java.lang.Object, boolean)
public boolean supportsDrawGhost()
true
if the link connector needs its
drawGhost(java.awt.Graphics, ilog.views.IlvTransformer, java.lang.Object, java.lang.Object, java.lang.Object, boolean)
method to be called.
The default implementation always returns false
.
© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.