public class IlvPinLinkConnector extends IlvCachingLinkConnector
IlvLinkImage
in a grapher (IlvGrapher
) using
pins (IlvGrapherPin
).
The links can be attached to pins using the method
connectLink(IlvLinkImage, IlvGrapherPin, boolean)
.
Pins can be added using the method addPin(ilog.views.linkconnector.IlvGrapherPin)
.
IlvGrapherPin
,
IlvGrapher
,
Serialized FormModifier and Type | Field and Description |
---|---|
static int |
IlvPinCircle
The Circle pin type.
|
static int |
IlvPinCross
The Cross pin type.
|
static int |
IlvPinDiamond
The Diamond pin type.
|
static int |
IlvPinFilledCircle
The Filled Circle pin type.
|
static int |
IlvPinFilledDiamond
The Filled Diamond pin type.
|
static int |
IlvPinFilledSquare
The Filled Square pin type.
|
static int |
IlvPinFilledTriangle
The Filled Triangle pin type.
|
static int |
IlvPinPlus
The Plus pin type.
|
static int |
IlvPinSquare
The Square pin type.
|
static int |
IlvPinTriangle
The Triangle pin type.
|
Constructor and Description |
---|
IlvPinLinkConnector()
Creates an empty
IlvPinLinkConnector , with no pins. |
IlvPinLinkConnector(IlvGraphic node)
Creates an
IlvPinLinkConnector attached to the node
node , with no pins. |
IlvPinLinkConnector(IlvInputStream stream)
Reads the link connector from an
IlvInputStream . |
IlvPinLinkConnector(IlvLinkImage link,
boolean origin)
Creates an
IlvPinLinkConnector attached to the
origin or destination of the link link , with no pins. |
Modifier and Type | Method and Description |
---|---|
void |
addPin(IlvGrapherPin pin)
Adds an
IlvGrapherPin . |
protected void |
allLinksRemoved()
Detaches all the pins from the links when all links are removed.
|
IlvPoint |
calcConnectionPoint(IlvLinkImage link,
boolean origin,
IlvTransformer t)
Calculates the connection point of
link . |
void |
connectLink(IlvLinkImage link,
IlvGrapherPin pin,
boolean origin)
Connects a link to a particular pin.
|
void |
connectLink(IlvLinkImage link,
IlvPoint p,
boolean origin,
IlvTransformer t)
Connects the link to the pin that is closest to point
p . |
void |
disconnectLink(IlvLinkImage link,
boolean origin)
Disconnects a link from its pin.
|
void |
disConnectLink(IlvLinkImage link,
boolean origin)
Deprecated.
Beginning with Perforce JViews 6.0, use the method
disconnectLink(IlvLinkImage, boolean) instead. |
void |
drawGhost(Graphics g,
IlvTransformer t)
Draws all the pins.
|
void |
drawGhost(Graphics g,
IlvTransformer t,
Object orig,
Object dest,
Object linkOrClass,
boolean origin)
Draws the pins.
|
IlvGrapherPin |
getClosestConnectionPin(IlvPoint p,
Object orig,
Object dest,
Object linkOrClass,
boolean origin,
IlvTransformer t)
Returns the pin that is closest to point
p . |
IlvPoint |
getClosestConnectionPoint(IlvPoint p,
Object orig,
Object dest,
Object linkOrClass,
boolean origin,
IlvTransformer t)
Returns the connection point that is closest to the specified point.
|
IlvRect |
getGhostBoundingBox(IlvTransformer t)
Returns the bounding box of the ghost of the pins.
|
IlvGrapherPin |
getPin(IlvLinkImage link,
boolean origin)
Returns the pin where a link is attached (that is, the method
IlvGrapherPin.isConnected(IlvLinkImage, boolean) returns
true ), or null if none. |
Color |
getPinColor()
Returns the color of the pins.
|
Enumeration |
getPins()
Returns an enumeration of the pins.
|
int |
getPinSize()
Returns the size of the pin ghost.
|
int |
getPinType()
Returns the type of the pin ghost.
|
Color |
getPinXORColor()
Deprecated.
Beginning with Perforce JViews 5.0 the method
drawGhost(java.awt.Graphics, ilog.views.IlvTransformer, java.lang.Object, java.lang.Object, java.lang.Object, boolean) no longer
sets the XOR mode. The ghost of the pins is drawn in paint mode and erased
by invalidation of a region of the view (see getGhostBoundingBox(ilog.views.IlvTransformer) )
followed by a redraw of the invalid regions of the view. |
boolean |
isPersistent()
Indicates if the link connector must be saved to an IVL file.
|
void |
linkRemoved(IlvLinkImage link)
Detaches the pin from the links when a link is removed.
|
void |
read(IlvInputStream stream,
IlvLinkImage link,
boolean origin)
Reads from an
IlvOutputStream the IlvGrapherPin
to which a link is connected. |
void |
removePin(IlvGrapherPin pin)
Removes an
IlvGrapherPin . |
void |
setPinColor(Color color)
Changes the color of the pins.
|
void |
setPinSize(int size)
Changes the size of the pin ghosts.
|
void |
setPinType(int type)
Changes the type of the pin ghosts.
|
void |
setPinXORColor(Color color)
Deprecated.
Beginning with Perforce JViews 5.0 the method
drawGhost(java.awt.Graphics, ilog.views.IlvTransformer, java.lang.Object, java.lang.Object, java.lang.Object, boolean) no longer
sets the XOR mode. The ghost of the pins is drawn in paint mode and erased
by invalidation of a region of the view (see getGhostBoundingBox(ilog.views.IlvTransformer) )
followed by a redraw of the invalid regions of the view. Note that the XOR
color is no longer saved in IVL files. |
boolean |
supportsDrawGhost()
Overrides the default
supportsDrawGhost method and
always returns true . |
protected boolean |
useCache()
Returns
true because the pin link connector
uses the cache. |
void |
write(IlvOutputStream stream)
Writes the object to an
IlvOutputStream . |
void |
write(IlvOutputStream stream,
IlvLinkImage link,
boolean origin)
Writes to an
IlvOutputStream the IlvGrapherPin
to which a link is connected. |
protected boolean |
zoomable()
Returns
true if this link connector is zoomable. |
cleanCache, cleanCache, detach, detach, disconnectAllLinks, getCacheSize, getConnectionPoint, linkChanged, LinkChanged, LinkRemoved, setCacheSize, useCache
allowsConnectionPointMove, attach, attach, attach, Get, Get, GetAttached, GetAttached, getNode
public static final int IlvPinSquare
setPinType(int)
,
Constant Field Valuespublic static final int IlvPinDiamond
setPinType(int)
,
Constant Field Valuespublic static final int IlvPinCircle
setPinType(int)
,
Constant Field Valuespublic static final int IlvPinCross
setPinType(int)
,
Constant Field Valuespublic static final int IlvPinPlus
setPinType(int)
,
Constant Field Valuespublic static final int IlvPinFilledSquare
setPinType(int)
,
Constant Field Valuespublic static final int IlvPinFilledCircle
setPinType(int)
,
Constant Field Valuespublic static final int IlvPinFilledDiamond
setPinType(int)
,
Constant Field Valuespublic static final int IlvPinTriangle
setPinType(int)
,
Constant Field Valuespublic static final int IlvPinFilledTriangle
setPinType(int)
,
Constant Field Valuespublic IlvPinLinkConnector()
IlvPinLinkConnector
, with no pins.
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)
).
You must use the method addPin(ilog.views.linkconnector.IlvGrapherPin)
to add
pins to the IlvPinLinkConnector
.public IlvPinLinkConnector(IlvGraphic node)
IlvPinLinkConnector
attached to the node
node
, with no pins. You must use the method addPin(ilog.views.linkconnector.IlvGrapherPin)
to add pins to the IlvPinLinkConnector
.public IlvPinLinkConnector(IlvLinkImage link, boolean origin)
IlvPinLinkConnector
attached to the
origin or destination of the link link
, with no pins.
You must use the method addPin(ilog.views.linkconnector.IlvGrapherPin)
to add pins to the IlvPinLinkConnector
.
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 IlvPinLinkConnector(IlvInputStream stream) throws IlvReadFileException
IlvInputStream
.
Note that any subclass (except if it 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.read(ilog.views.io.IlvInputStream, ilog.views.IlvLinkImage, boolean)
,
write(ilog.views.io.IlvOutputStream)
,
isPersistent()
protected boolean useCache()
true
because the pin link connector
uses the cache.useCache
in class IlvCachingLinkConnector
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.IlvLinkConnector.isPersistent()
public void read(IlvInputStream stream, IlvLinkImage link, boolean origin) throws IlvReadFileException
IlvOutputStream
the IlvGrapherPin
to which a link is connected.
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
,
the connection pin of the origin of link
is read. Otherwise, the method reads the connection pin
of the destination of link
.IlvReadFileException
write(ilog.views.io.IlvOutputStream, ilog.views.IlvLinkImage, boolean)
public void write(IlvOutputStream stream, IlvLinkImage link, boolean origin) throws IOException
IlvOutputStream
the IlvGrapherPin
to which a link is connected.
If origin
is true
, the method saves the
pin to which the origin of link
is connected.
Otherwise, it saves the pin to which the destination of
link
is connected.
The method does nothing if link
is not connected to
any pin stored by this IlvPinLinkConnector
, or the
pin is not persistent (see IlvGrapherPin.isPersistent()
).
You must override this method if specific data is to be written.
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
to which the link connector is attached.
write
in class IlvLinkConnector
stream
- The output stream.link
- The link.origin
- If true
,
the connection pin of the origin of link
is written. Otherwise, the method writes the connection pin
of the destination of link
IOException
read(ilog.views.io.IlvInputStream, ilog.views.IlvLinkImage, boolean)
,
isPersistent()
public boolean isPersistent()
true
, the link connector
is saved; otherwise it is not saved.
The default implementation always returns true
.
Note that the link connector writes the pins stored by the link
connector only if they are persistent
(see IlvGrapherPin.isPersistent()
).
isPersistent
in class IlvLinkConnector
write(ilog.views.io.IlvOutputStream)
,
write(ilog.views.io.IlvOutputStream, ilog.views.IlvLinkImage, boolean)
public final Color getPinColor()
IlvGrapherPin.getColor()
to return a different color.public void setPinColor(Color color)
IlvGrapherPin.getColor()
to return a different color.setPinColor(java.awt.Color)
@Deprecated public final Color getPinXORColor()
drawGhost(java.awt.Graphics, ilog.views.IlvTransformer, java.lang.Object, java.lang.Object, java.lang.Object, boolean)
no longer
sets the XOR mode. The ghost of the pins is drawn in paint mode and erased
by invalidation of a region of the view (see getGhostBoundingBox(ilog.views.IlvTransformer)
)
followed by a redraw of the invalid regions of the view.@Deprecated public void setPinXORColor(Color color)
drawGhost(java.awt.Graphics, ilog.views.IlvTransformer, java.lang.Object, java.lang.Object, java.lang.Object, boolean)
no longer
sets the XOR mode. The ghost of the pins is drawn in paint mode and erased
by invalidation of a region of the view (see getGhostBoundingBox(ilog.views.IlvTransformer)
)
followed by a redraw of the invalid regions of the view. Note that the XOR
color is no longer saved in IVL files.public final void addPin(IlvGrapherPin pin)
IlvGrapherPin
.
If the pin was added to a different IlvPinLinkConnector
,
it is removed from it. The method does nothing if the pin was already
added to this link connector.
Note that adding a pin can change the bounding
box of the links incident to the node returned by the method
IlvLinkConnector.getNode()
. Therefore, the method
IlvManager.applyToObject(ilog.views.IlvGraphic, ilog.views.IlvApplyObject, java.lang.Object, boolean)
must be used for this node.
public final void removePin(IlvGrapherPin pin)
IlvGrapherPin
.
Note that removing a pin can change the bounding
box of the links attached to the pin. Therefore, the method
IlvManager.applyToObject(ilog.views.IlvGraphic, ilog.views.IlvApplyObject, java.lang.Object, boolean)
must be used for the node
returned by the method IlvLinkConnector.getNode()
.
public final Enumeration getPins()
IlvGrapherPin
.public void setPinType(int type)
IlvGrapherPin.getType()
to return a different type.
The type defines the way the ghost of the pins are drawn.
The default value is IlvPinFilledCircle
.
type
- The new type. Valid values are one of the
predefined types (IlvPinSquare
, IlvPinDiamond
,
and so forth). You can combine types (for example, IlvPinSquare
& IlvPinDiamond
) to create a more complex pin ghost.getPinType()
,
IlvPinSquare
,
IlvPinDiamond
,
IlvPinCircle
,
IlvPinCross
,
IlvPinPlus
,
IlvPinFilledSquare
,
IlvPinFilledCircle
,
IlvPinFilledDiamond
,
IlvPinTriangle
,
IlvPinFilledTriangle
public int getPinType()
IlvGrapherPin.getType()
to return a different type.
The type defines the way the ghost of the pins are drawn.
The default value is IlvPinFilledCircle
.
setPinType(int)
,
IlvGrapherPin.getType()
public void setPinSize(int size)
IlvGrapherPin.getSize()
to return a different value.
The default value is 4
.
A pin ghost is defined by its center point (see IlvGrapherPin.getPosition(ilog.views.IlvTransformer)
)
and its size.
A pin ghost is drawn in a square of size 2*size
located at (p.x-size, p.y-size)
, where p
is the center point.
getPinSize()
,
IlvGrapherPin.getSize()
public int getPinSize()
IlvGrapherPin.getSize()
to return a different value.
The default value is 4
.
setPinSize(int)
,
IlvGrapherPin.getSize()
public IlvPoint calcConnectionPoint(IlvLinkImage link, boolean origin, IlvTransformer t)
link
.
If the link is attached to a pin, it returns the position
of the pin; otherwise it returns the position of the closest pin.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.t
- The transformer that is used to draw the node.public IlvPoint getClosestConnectionPoint(IlvPoint p, Object orig, Object dest, Object linkOrClass, boolean origin, IlvTransformer t)
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.t
- The transformer used to draw the node.protected boolean zoomable()
true
if this link connector is zoomable.
It is zoomable if all contained pins are zoomable.zoomable
in class IlvLinkConnector
public IlvGrapherPin getClosestConnectionPin(IlvPoint p, Object orig, Object dest, Object linkOrClass, boolean origin, IlvTransformer t)
p
.p
- The starting point to search for the closest connection point.
This point is already transformed by transformer t
.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
- A link or a class of link.origin
- If true
, the closest pin for the origin
of the link origin is determined. Otherwise, the closest pin for
the destination of the link is found.t
- The transformer used to draw the node.public void connectLink(IlvLinkImage link, IlvGrapherPin pin, boolean origin)
IlvManager.applyToObject(ilog.views.IlvGraphic, ilog.views.IlvApplyObject, java.lang.Object, boolean)
method
to call this method.@Deprecated public void disConnectLink(IlvLinkImage link, boolean origin)
disconnectLink(IlvLinkImage, boolean)
instead.public void disconnectLink(IlvLinkImage link, boolean origin)
IlvManager.applyToObject(ilog.views.IlvGraphic, ilog.views.IlvApplyObject, java.lang.Object, boolean)
method
to call this method.disconnectLink
in class IlvCachingLinkConnector
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.IlvLinkConnector.connectLink(ilog.views.IlvLinkImage, ilog.views.IlvPoint, boolean, ilog.views.IlvTransformer)
public void connectLink(IlvLinkImage link, IlvPoint p, boolean origin, IlvTransformer t)
p
.
This may influences the bounding box of the link. If the link is already
added in another grapher, you must use the IlvManager.applyToObject(ilog.views.IlvGraphic, ilog.views.IlvApplyObject, java.lang.Object, boolean)
method
to call this method.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 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.IlvLinkConnector.allowsConnectionPointMove(ilog.views.IlvLinkImage, boolean)
public IlvGrapherPin getPin(IlvLinkImage link, boolean origin)
IlvGrapherPin.isConnected(IlvLinkImage, boolean)
returns
true
), or null
if none.public void linkRemoved(IlvLinkImage link)
linkRemoved
in class IlvCachingLinkConnector
protected void allLinksRemoved()
allLinksRemoved
in class IlvCachingLinkConnector
public void drawGhost(Graphics g, IlvTransformer t, Object orig, Object dest, Object linkOrClass, boolean origin)
This method is called when creating or editing a link.
It calls the method IlvGrapherPin.drawGhost(java.awt.Graphics, ilog.views.IlvTransformer)
of the pins
for which the method IlvGrapherPin.allow(java.lang.Object, java.lang.Object, java.lang.Object, boolean)
returns true
.
drawGhost
in class IlvLinkConnector
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 determinedIlvLinkConnector.supportsDrawGhost()
,
IlvLinkConnector.getGhostBoundingBox(ilog.views.IlvTransformer)
public void drawGhost(Graphics g, IlvTransformer t)
IlvGrapherPin.drawGhost(java.awt.Graphics, ilog.views.IlvTransformer)
of the pins.public IlvRect getGhostBoundingBox(IlvTransformer t)
The method iterates over the pins and computes their
bounding box using the methods IlvGrapherPin.getPosition(ilog.views.IlvTransformer)
and
IlvGrapherPin.getSize()
.
getGhostBoundingBox
in class IlvLinkConnector
t
- The transformer used to draw the pins.getPins()
,
supportsDrawGhost()
,
drawGhost(java.awt.Graphics, ilog.views.IlvTransformer, java.lang.Object, java.lang.Object, java.lang.Object, boolean)
,
IlvGrapherPin.drawGhost(java.awt.Graphics, ilog.views.IlvTransformer)
public boolean supportsDrawGhost()
supportsDrawGhost
method and
always returns true
.supportsDrawGhost
in class IlvLinkConnector
IlvLinkConnector.supportsDrawGhost()
© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.