public class IlvFreeLinkConnector extends IlvCachingLinkConnector
connectLink(ilog.views.IlvLinkImage, ilog.views.IlvPoint, boolean, ilog.views.IlvTransformer)
. The connection
points will be preserved with respect to the bounding box of the node
for any change of the bounding box of the node. If the node is translated,
the connection point is translated with the same distance. If the node grows
or shrinks, the connection point moves proportionally.
Note that, for links that have not been connected using
connectLink(ilog.views.IlvLinkImage, ilog.views.IlvPoint, boolean, ilog.views.IlvTransformer)
and for disconnected links (see disconnectLink(ilog.views.IlvLinkImage, boolean)
and disconnectAllLinks()
), the method IlvCachingLinkConnector.getConnectionPoint(ilog.views.IlvLinkImage, boolean, ilog.views.IlvTransformer)
returns null
.
In this case, IlvLinkImage
computes the connection point of the link
using the default rules, at the center of one of the sides of the bounding
box of the node or at its center.
This link connector can be used with the graph layout algorithms that need to change the connection points of the links.
Constructor and Description |
---|
IlvFreeLinkConnector()
Creates an empty
IlvFreeLinkConnector . |
IlvFreeLinkConnector(IlvGraphic node)
Creates an
IlvFreeLinkConnector attached to the node
node . |
IlvFreeLinkConnector(IlvInputStream stream)
Reads the object from an
IlvInputStream . |
IlvFreeLinkConnector(IlvLinkImage link,
boolean origin)
Creates an
IlvFreeLinkConnector attached to the
origin or destination of the link link . |
Modifier and Type | Method and Description |
---|---|
protected void |
allLinksRemoved()
Called when all 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.
|
protected IlvPoint |
calcConnectionPoint(IlvLinkImage link,
boolean origin,
IlvTransformer transformer)
Calculates the connection point of
link . |
void |
connectionPointMoveAllowed(boolean allow)
Deprecated.
Beginning with Rogue Wave JViews 8.1, use the method
setConnectionPointMoveAllowed(boolean) instead. |
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.
|
void |
detach(IlvLinkImage link,
boolean origin,
boolean redraw)
Detaches the link connector from the origin or the destination
of a link.
|
void |
disconnectAllLinks()
Disconnects all the links connected to the link connector.
|
void |
disconnectLink(IlvLinkImage link,
boolean origin)
Disconnects a link from the link connector.
|
IlvPoint |
getClosestConnectionPoint(IlvPoint p,
Object orig,
Object dest,
Object linkOrClass,
boolean origin,
IlvTransformer transformer)
Returns the connection point that is closest to a particular point.
|
IlvRect |
getGhostBoundingBox(IlvTransformer t)
Implements an abstract method of
IlvLinkConnector
to return an empty IlvRect . |
protected IlvRect |
getNodeBoundingBox(IlvTransformer t)
Called by the
IlvFreeLinkConnector
when it needs to compute the bounding rectangle of the node. |
boolean |
isConnectionPointMoveAllowed()
Specifies whether the interactors are allowed to move the connection points
of the links connected to the node to which this link connector is
attached.
|
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 . |
void |
setConnectionPointMoveAllowed(boolean allow)
Allows or forbids the interactors to move the connection points
of the links connected to the node to which this link connector is
attached.
|
protected boolean |
useCache()
Return
true because this link connector uses the cache. |
void |
write(IlvOutputStream stream)
Writes the object to an
IlvOutputStream . |
void |
write(IlvOutputStream stream,
IlvLinkImage link,
boolean origin)
Writes the information associated
with a link to an
IlvOutputStream . |
protected boolean |
zoomable()
Indicates that this link connector is zoomable.
|
cleanCache, cleanCache, getCacheSize, getConnectionPoint, linkChanged, LinkChanged, LinkRemoved, setCacheSize, useCache
attach, attach, attach, drawGhost, Get, Get, GetAttached, GetAttached, getNode, supportsDrawGhost
public IlvFreeLinkConnector()
IlvFreeLinkConnector
. It can be
attached either to a node (using
IlvLinkConnector.attach(ilog.views.IlvGraphic,boolean)
) or to an extremity
of a link (using
IlvLinkConnector.attach(ilog.views.IlvLinkImage,boolean,boolean)
).public IlvFreeLinkConnector(IlvGraphic node)
IlvFreeLinkConnector
attached to the node
node
.public IlvFreeLinkConnector(IlvLinkImage link, boolean origin)
IlvFreeLinkConnector
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
.public IlvFreeLinkConnector(IlvInputStream stream) throws IlvReadFileException
IlvInputStream
.
Note that any subclass (except one that overrides the method
isPersistent()
to return false
) 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.write(ilog.views.io.IlvOutputStream)
,
isPersistent()
,
IlvLinkConnector.attach(IlvGraphic, boolean)
,
detach(boolean)
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
to which the link connector is attached.
write
in interface IlvPersistentObject
write
in class IlvCachingLinkConnector
stream
- The output stream.IOException
- thrown when an exception occurs during
the write operation for this object.isPersistent()
protected boolean useCache()
true
because this link connector uses the cache.useCache
in class IlvCachingLinkConnector
public void detach(boolean redraw)
attach
.
For details, see the documentation of the method in the parent class.
detach
in class IlvCachingLinkConnector
redraw
- If true
, the node to which the connector is
attached and its adjacent links will be redrawn.IlvLinkConnector.attach(IlvGraphic, 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
IlvLinkConnector.attach(IlvLinkImage, boolean, boolean)
.
detach
in class IlvCachingLinkConnector
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.IlvLinkConnector.attach(IlvLinkImage, boolean, boolean)
,
detach(boolean)
public void write(IlvOutputStream stream, IlvLinkImage link, boolean origin) throws IOException
IlvOutputStream
.
If origin
is true
, the method saves the
information about the connection point of the origin of link
.
Otherwise, it saves the information about the connection point of the
destination of link
.
The method does nothing if link
is not connected to
the node using the method
connectLink(ilog.views.IlvLinkImage, ilog.views.IlvPoint, boolean, ilog.views.IlvTransformer)
.
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. You should use the write
methods of the IlvGrapher
that contains the node
to which the link connector is attached.
write
in class IlvLinkConnector
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
read(ilog.views.io.IlvInputStream, ilog.views.IlvLinkImage, boolean)
,
isPersistent()
public void read(IlvInputStream stream, IlvLinkImage link, boolean origin) throws IlvReadFileException
IlvInputStream
.
You must override this method if specific data is to be read.
Note that the first instruction in your implementation of the method must
be super.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
to which the link connector is attached.
read
in class IlvLinkConnector
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
IlvLinkConnector.write(ilog.views.io.IlvOutputStream, IlvLinkImage, boolean)
,
IlvLinkConnector.isPersistent()
public boolean isPersistent()
.ivl
file.
If this method returns true
, the link connector
is saved; otherwise, it is not saved.
The default implementation always returns true
.
isPersistent
in class IlvLinkConnector
write(ilog.views.io.IlvOutputStream)
protected IlvPoint calcConnectionPoint(IlvLinkImage link, boolean origin, IlvTransformer transformer)
link
.calcConnectionPoint
in class IlvCachingLinkConnector
link
- The link.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.transformer
- The transformer that is used to draw the node.public void connectLink(IlvLinkImage link, IlvPoint p, boolean origin, IlvTransformer t)
Notice that, for links that have not been connected using
connectLink(ilog.views.IlvLinkImage, ilog.views.IlvPoint, boolean, ilog.views.IlvTransformer)
and for disconnected links (see
disconnectLink(ilog.views.IlvLinkImage, boolean)
and disconnectAllLinks()
),
the method IlvCachingLinkConnector.getConnectionPoint(ilog.views.IlvLinkImage, boolean, ilog.views.IlvTransformer)
returns null
.
In this case, IlvLinkImage
computes the connection point of the
link using the default rules, at the center of one of the sides of the
bounding box of the node or at its center.
Note also that, once a link connector has been attached to a node or a link
contained in an IlvGrapher
, this method must be called
using the method IlvManager.applyToObject(ilog.views.IlvGraphic, ilog.views.IlvApplyObject, java.lang.Object, boolean)
.
connectLink
in class IlvLinkConnector
link
- The link to be connected.p
- The point where the link must be connected. The point
must be transformed by 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.disconnectLink(ilog.views.IlvLinkImage, boolean)
,
disconnectAllLinks()
public void disconnectLink(IlvLinkImage link, boolean origin)
Notice that, for disconnected links and for links that have not been
connected using connectLink(ilog.views.IlvLinkImage, ilog.views.IlvPoint, boolean, ilog.views.IlvTransformer)
, the method
IlvCachingLinkConnector.getConnectionPoint(ilog.views.IlvLinkImage, boolean, ilog.views.IlvTransformer)
returns null
.
In this case, IlvLinkImage
computes the connection point of the
link using the default rules, at the center of one of the sides of the
bounding box of the node or at its center.
Note also that, once a link connector has been attached to a node or a link
contained in an IlvGrapher
, this method must be called
using the method IlvManager.applyToObject(ilog.views.IlvGraphic, ilog.views.IlvApplyObject, java.lang.Object, boolean)
.
disconnectLink
in class IlvCachingLinkConnector
link
- The link to be disconnected.origin
- If true
, the origin of the link will be
disconnected. Otherwise, it is the destination.connectLink(ilog.views.IlvLinkImage, ilog.views.IlvPoint, boolean, ilog.views.IlvTransformer)
,
disconnectAllLinks()
public void disconnectAllLinks()
Notice that, for disconnected links and for links that have not been
connected using connectLink(ilog.views.IlvLinkImage, ilog.views.IlvPoint, boolean, ilog.views.IlvTransformer)
, the method
IlvCachingLinkConnector.getConnectionPoint(ilog.views.IlvLinkImage, boolean, ilog.views.IlvTransformer)
returns null
.
In this case, IlvLinkImage
computes the connection point of the
link using the default rules, at the center of one of the sides of the
bounding box of the node or at its center.
Note also that, once a link connector has been attached to a node or a link
contained in an IlvGrapher
, this method must be called
using the method IlvManager.applyToObject(ilog.views.IlvGraphic, ilog.views.IlvApplyObject, java.lang.Object, boolean)
.
public boolean allowsConnectionPointMove(IlvLinkImage link, boolean origin)
In this class, the default implementation of the method always returns
the value that was set using the method connectionPointMoveAllowed(boolean)
.
Note that by default the connection points cannot be moved using the
interactors. When this method returns false
, only the
interactors (namely, IlvLinkImageEditInteractor
) are not
allowed to move the connection points. The points can always be moved
by calls to the method connectLink(ilog.views.IlvLinkImage, ilog.views.IlvPoint, boolean, ilog.views.IlvTransformer)
.
Subclasses can override this method to indicate that only the connection points of some links can (or cannot) be moved by the interactors.
allowsConnectionPointMove
in class IlvLinkConnector
connectionPointMoveAllowed(boolean)
,
IlvLinkImage.allowsPointMove(int)
,
isConnectionPointMoveAllowed()
@Deprecated public void connectionPointMoveAllowed(boolean allow)
setConnectionPointMoveAllowed(boolean)
instead.
By default, moving a connection point using the interactors
is not allowed.
To enable the interactors to move connection points, call this
method with a true
argument.
Note that subclasses can override the method
allowsConnectionPointMove(ilog.views.IlvLinkImage, boolean)
to indicate that only the connection points of some links can (or cannot)
be moved using the interactors.
public final void setConnectionPointMoveAllowed(boolean allow)
By default, moving a connection point using the interactors
is not allowed.
To enable the interactors to move connection points, call this
method with a true
argument.
Note that subclasses can override the method
allowsConnectionPointMove(ilog.views.IlvLinkImage, boolean)
to indicate that only the connection points of some links can (or cannot)
be moved using the interactors.
public final boolean isConnectionPointMoveAllowed()
Note that, for each individual connection point, the
interactors decide whether they are allowed to move the connection
point by calling the method
allowsConnectionPointMove(IlvLinkImage, boolean)
.
The default implementation of this method relies on the value returned
by isConnectionPointMoveAllowed()
, but subclasses
can provide an overridden implementation.
protected boolean zoomable()
true
.zoomable
in class IlvLinkConnector
public IlvPoint getClosestConnectionPoint(IlvPoint p, Object orig, Object dest, Object linkOrClass, boolean origin, IlvTransformer transformer)
p
without any transformation.getClosestConnectionPoint
in class IlvLinkConnector
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.transformer
- The transformer used to draw the node.public void linkRemoved(IlvLinkImage link)
linkRemoved
in class IlvCachingLinkConnector
protected void allLinksRemoved()
allLinksRemoved
in class IlvCachingLinkConnector
protected IlvRect getNodeBoundingBox(IlvTransformer t)
IlvFreeLinkConnector
when it needs to compute the bounding rectangle of the node. By default,
it returns getNode().boundingBox(t)
. You can
override this method to return a different bounding rectangle. This is
useful, in particular, if you use a link layout algorithm and you
specified an IlvNodeBoxInterface
.t
- The transformer used to compute the bounding rectangle of
the node.public IlvRect getGhostBoundingBox(IlvTransformer t)
IlvLinkConnector
to return an empty IlvRect
. This method is not called
since IlvLinkConnector.supportsDrawGhost()
returns false
for this class.getGhostBoundingBox
in class IlvLinkConnector
t
- The transformer used to draw the connection points.IlvLinkConnector.supportsDrawGhost()
,
IlvLinkConnector.drawGhost(java.awt.Graphics, ilog.views.IlvTransformer, java.lang.Object, java.lang.Object, java.lang.Object, boolean)
© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.