public abstract class IlvGrapherPin extends Object implements Serializable, IlvPersistentObject
IlvLinkImage
).
The pins are managed by the class IlvPinLinkConnector
.
This class is an abstract class. To specify the position of the pin,
you must implement the method getPosition(ilog.views.IlvTransformer)
.
Constructor and Description |
---|
IlvGrapherPin(IlvInputStream stream)
Reads the object from an
IlvInputStream . |
IlvGrapherPin(IlvPinLinkConnector connector)
Creates a new pin and adds it to the pin link connector.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
allow(Object oClass,
Object dClass,
Object linkOrClass,
boolean origin)
Returns a boolean value that allows or inhibits a link on this pin.
|
boolean |
allowsMove()
Returns
true if the location of the pin can be
changed using the method setPosition(ilog.views.IlvPoint, ilog.views.IlvTransformer) , and returns
false otherwise. |
protected void |
drawGhost(Graphics g,
IlvTransformer t)
Draws the grapher pin during editing.
|
Color |
getColor()
Returns the color of the pin ghost.
|
IlvGraphic |
getNode()
Returns the node corresponding to the pin, that is, the node
returned by the method
IlvLinkConnector.getNode() called
on the IlvPinLinkConnector that manages this pin. |
IlvPinLinkConnector |
getPinLinkConnector()
Returns the
IlvPinLinkConnector which manages this
pin, or null if the pin has been removed. |
abstract IlvPoint |
getPosition(IlvTransformer t)
Returns the position of the pin.
|
int |
getSize()
Returns the size of the pin ghost.
|
int |
getType()
Returns the type of the pin ghost.
|
boolean |
isConnected(IlvLinkImage link,
boolean origin)
Returns
true if link is connected to this pin,
and false otherwise. |
boolean |
isPersistent()
Indicates whether the grapher pin must be saved to an IVL file.
|
void |
setPosition(IlvPoint p,
IlvTransformer t)
Sets the position of the pin.
|
void |
write(IlvOutputStream stream)
Writes the object to an
IlvOutputStream . |
protected boolean |
zoomable()
Returns
true if the pin is zoomable;
otherwise it returns false . |
public IlvGrapherPin(IlvPinLinkConnector connector)
connector
- The link connector where the pin is added.public IlvGrapherPin(IlvInputStream stream) throws IlvReadFileException
IlvInputStream
.
The default implementation of the method does nothing.
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.write(ilog.views.io.IlvOutputStream)
,
isPersistent()
public void write(IlvOutputStream stream) throws IOException
IlvOutputStream
.
The default implementation of the method does nothing.
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
stream
- The output stream.IOException
- thrown when an exception occurs during
the write operation for this object.public boolean isPersistent()
true
, the grapher pin
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)
public IlvPinLinkConnector getPinLinkConnector()
IlvPinLinkConnector
which manages this
pin, or null
if the pin has been removed.public final boolean isConnected(IlvLinkImage link, boolean origin)
true
if link
is connected to this pin,
and false
otherwise.link
- The link image.origin
- If the value is true
, checks whether the
link is connected by the origin point.
If the value is false
, checks whether the link is
connected by the destination point.public int getType()
IlvPinLinkConnector
or a combination of these values.
The default implementation returns the pin ghost type of
the IlvPinLinkConnector
to which this pin is
connected.
You can override this method if you need a different type
for the pins of the same IlvPinLinkConnector
.
IlvPinLinkConnector.getPinType()
public int getSize()
IlvPinLinkConnector
to which this pin is
connected.
You can override this method if you need a different size
for pins of the same IlvPinLinkConnector
.
A pin ghost is defined by its center point (see 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.
IlvPinLinkConnector.getPinSize()
public Color getColor()
IlvPinLinkConnector
to which this pin is
connected.
You can override this method if you need a different color
for pins of the same IlvPinLinkConnector
.IlvPinLinkConnector.getPinColor()
public final IlvGraphic getNode()
IlvLinkConnector.getNode()
called
on the IlvPinLinkConnector
that manages this pin.
The method returns null
for a pin that has been
removed from its IlvPinLinkConnector
.protected boolean allow(Object oClass, Object dClass, Object linkOrClass, boolean origin)
true
.oClass
- The class of the origin object,
or the origin object itself.dClass
- The class of the destination object,
or the destination object itself.linkOrClass
- The class of the link object.origin
- If the value is true
, checks if a
link starting at this pin is allowed.
If the value is false
, checks if a link ending at
this pin is allowed.public void setPosition(IlvPoint p, IlvTransformer t)
The default implementation of the method does nothing. Subclasses
of IlvGrapherPin
that support the change of the
location of the pin using this method must provide an overridden
implementation. Also, such subclasses must override the method
allowsMove()
to return true
.
Note that changing the position of 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 getNode()
.
p
- The point where the pin must be located. The point
must be transformed by transformer t
.t
- The transformer that is used to draw the node associated with the
pin link connector.getPosition(ilog.views.IlvTransformer)
,
allowsMove()
public abstract IlvPoint getPosition(IlvTransformer t)
Note that the bounding box of the links connected to a pin
depends on the position of the pin. Therefore, once a pin
has been added to an IlvPinLinkConnector
attached
to a node or a link inside an IlvGrapher
, the position of the
pin should be changed only using the method IlvManager.applyToObject(ilog.views.IlvGraphic, ilog.views.IlvApplyObject, java.lang.Object, boolean)
.
t
- The transformer used to draw the node.setPosition(ilog.views.IlvPoint, ilog.views.IlvTransformer)
public boolean allowsMove()
true
if the location of the pin can be
changed using the method setPosition(ilog.views.IlvPoint, ilog.views.IlvTransformer)
, and returns
false
otherwise.
The default implementation always returns false
.
Subclasses that support the change of the location of the pin
using the method setPosition(ilog.views.IlvPoint, ilog.views.IlvTransformer)
must provide an overridden
implementation of setPosition(ilog.views.IlvPoint, ilog.views.IlvTransformer)
and must override
allowsMove()
to return true
.
protected boolean zoomable()
true
if the pin is zoomable;
otherwise it returns false
.
A grapher pin is zoomable if calling the getPosition
member function with a transformer gives the same result as calling it
with a null
(identity) transformer and then applying the
transformer to the result.
The default implementation returns true
.
Note that an instance of a grapher pin must return the same value during its lifetime.
protected void drawGhost(Graphics g, IlvTransformer t)
g
- The destination graphics (already in XOR mode when
called by interactors that need this mode).t
- The transformer used to draw the node.© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.