public class IlvSplineLinkImage extends IlvLinkImage
IlvSplineLinkImage
represents the connection between two nodes
in a grapher
; the link is displayed as a series
of spline curves that trace the link points. For more information about
specialized link graphic objects, see
IlvLinkImage.
The default values for an IlvSplineLinkImage
instance are as
follows:
Color.black
0
IlvStroke.CAP_SQUARE
The following code example shows how to use an
IlvSplineLinkImage
in a simple Java application:
IlvGraphic node1, node2; IlvGrapher grapher = new IlvGrapher(); IlvSplineLinkImage link; // Create new ellipse node and add it to the grapher. node1 = new IlvEllipse(new IlvRect(30, 10, 50, 50), true, false); grapher.addNode(node1, false); // Add a new rectangular node to the grapher. node2 = new IlvRectangle(new IlvRect(220, 90, 50, 50), false, true); grapher.addNode(node2, 2, true); // Add points IlvPoint[] points = new IlvPoint[5]; points[0] = new IlvPoint(40, 40); points[1] = new IlvPoint(50, 20); points[2] = new IlvPoint(90, 40); points[3] = new IlvPoint(70, 70); points[4] = new IlvPoint(90, 90); // Link the two nodes and add the link to a grapher. link = new IlvSplineLinkImage(node1, node2, true, points); link.setSmoothness(0.5); link.setForeground(Color.green); grapher.addLink(link, true);
The following image shows the graphic object created in the code example:
IlvSplineLinkImage
is a custom graphic object, that is, a
subclass of IlvGraphic
. Graphic objects are controlled using an
IlvManager
instance and displayed using one or more
IlvManagerView
instances in a Java Swing application. For
information about generic features for graphic objects, see
IlvGraphic.
IlvPoint
,
IlvManager
,
IlvManagerView
,
Serialized FormConstructor and Description |
---|
IlvSplineLinkImage(IlvGraphic from,
IlvGraphic to,
boolean oriented,
IlvPoint[] points)
Creates and initializes a new
IlvSplineLinkImage . |
IlvSplineLinkImage(IlvInputStream stream)
Reads the object from an
IlvInputStream . |
IlvSplineLinkImage(IlvSplineLinkImage source)
Creates and initializes a new
IlvSplineLinkImage by copying an
existing one. |
Modifier and Type | Method and Description |
---|---|
boolean |
allowsPointInsertion()
Returns
true if point insertion is allowed, and
false otherwise. |
boolean |
allowsPointRemoval()
Returns
true if point removal is allowed, and
false otherwise. |
void |
applyTransform(IlvTransformer t)
Applies a transformation to the shape of the object.
|
IlvRect |
boundingBox(IlvTransformer t)
Returns the bounding rectangle of the object.
|
boolean |
contains(IlvPoint p,
IlvPoint tp,
IlvTransformer t)
Tests if a point lies within the outline of the link.
|
IlvGraphic |
copy()
Copies the object.
|
void |
draw(Graphics dst,
IlvTransformer t)
Draws the object.
|
IlvPoint[] |
getLinkPoints(IlvTransformer t)
Returns the points that define the link.
|
IlvPoint |
getPointAt(int index,
IlvTransformer t)
Returns the point at the specified index.
|
int |
getPointsCardinal()
Returns the number of points.
|
double |
getSmoothness()
Returns the smoothness of the spline.
|
void |
insertPoint(int index,
double x,
double y,
IlvTransformer t)
Inserts a point at a specified index.
|
boolean |
isSpline()
Returns
true if the link has spline routing functionality. |
IlvSelection |
makeSelection()
Creates the selection object for this class.
|
void |
movePoint(int index,
double x,
double y,
IlvTransformer t)
Changes the position of a point.
|
boolean |
pointsInBBox()
Returns
false since the points defining the spline are not in
the bounding box of the object. |
void |
removePoint(int index,
IlvTransformer t)
Removes the point at the specified index.
|
void |
setIntermediateLinkPoints(IlvPoint[] points,
int index,
int length)
Changes the intermediate points that define the link.
|
void |
setSmoothness(double smoothness)
Sets the smoothness of the spline.
|
void |
write(IlvOutputStream stream)
Writes the object to an
IlvOutputStream . |
allowsPointMove, arrowBBox, arrowContains, drawArrow, finalize, getArrowSize, getConnectionPoints, getConnectionReferencePoint, getEndCap, getForeground, getFrom, getFromBoundingBox, getFromTransformer, getLineJoin, getLineStyle, getLineWidth, getLineWidth, getLinkConnectorConnectionPoint, getLinkPoints, getLocalTransformerOf, getMaximumLineWidth, getOpposite, getTo, getToBoundingBox, getToTransformer, getVisibleFrom, getVisibleTo, isOriented, isPersistent, setEndCap, setForeground, setFrom, setLineJoin, setLineStyle, setLineWidth, setLinkPoints, setMaximumLineWidth, setOriented, setTo, zoomable
addActionListener, addNamedPropertyListener, allViewsRemoved, baseTextDirectionChanged, blinkingStateOn, boundingBox, callDraw, componentOrientationChanged, getAndAssociateObjectInteractor, getBaseTextDirection, getBlinkingAction, getBlinkingObjectOwner, getBlinkingOffPeriod, getBlinkingOnPeriod, getCenter, getComponentOrientation, getDefaultInteractor, getGraphicBag, GetGraphicObject, getIntersectionWithOutline, getLocale, getName, getNamedProperty, getObjectInteractor, getPopupMenu, getPopupMenu, getPopupMenuName, getProperty, getResolvedBaseTextDirection, getToolTipBaseTextDirection, getToolTipText, getToolTipText, getTopLevelGraphicBag, getTransferData, getTransferDataFlavors, getULocale, getZOrderIndex, hasProperty, inside, intersects, invalidateBBoxCache, invalidateBidiCache, isBaseTextDirectionSensitive, isComponentOrientationSensitive, isDataFlavorSupported, isEditable, isInApplyToObject, isLocaleSensitive, isMovable, isSelectable, isVisible, localeChanged, move, move, moveResize, needsViewNotification, notifyObjectInteractorToManager, processActionEvent, reDraw, registerBlinkingResource, removeActionListener, removeNamedProperty, removeNamedPropertyListener, removeProperty, replaceProperty, resize, rotate, scale, setBackground, setBaseTextDirection, setBaseTextDirectionDuringConstruction, setBlinkingAction, setBlinkingOffPeriod, setBlinkingOnPeriod, setEditable, setFillOn, setGraphicBag, setInApplyToObject, setMovable, setName, setNamedProperty, setNameImpl, setObjectInteractor, setPopupMenu, setPopupMenuName, setProperty, setSelectable, setStrokeOn, setToolTipBaseTextDirection, setToolTipText, setVisible, setZOrderIndex, toString, translate, updateNeedsViewNotification, usesBidiMarkers, viewAddedOrRemoved
public IlvSplineLinkImage(IlvGraphic from, IlvGraphic to, boolean oriented, IlvPoint[] points)
IlvSplineLinkImage
.from
- the origin object.to
- the destination object.oriented
- specifies whether an arrow is drawn at the end of the link, or
not.points
- the intermediate points of the spline.public IlvSplineLinkImage(IlvSplineLinkImage source)
IlvSplineLinkImage
by copying an
existing one.source
- the copied object.public IlvSplineLinkImage(IlvInputStream stream) throws IlvReadFileException
IlvInputStream
.stream
- the input stream.IlvReadFileException
- if the format is not correct.public IlvGraphic copy()
copy
in class IlvLinkImage
IlvGraphic
public int getPointsCardinal()
getPointsCardinal
in interface IlvPolyPointsInterface
getPointsCardinal
in class IlvLinkImage
public IlvPoint[] getLinkPoints(IlvTransformer t)
getLinkPoints
in class IlvLinkImage
public void setIntermediateLinkPoints(IlvPoint[] points, int index, int length)
length
points in points
array beginning at the
index
point and will use them for a new intermediate points
array. If the array is null
or the length parameter is 0,
intermediate points are removed.setIntermediateLinkPoints
in class IlvLinkImage
points
- An array of points.index
- The index of the point which will be the first intermediate point.length
- The number of intermediate points taken in the points array.IlvApplyObject
,
IlvManager.applyToObject(ilog.views.IlvGraphic, ilog.views.IlvApplyObject, java.lang.Object, boolean)
public IlvPoint getPointAt(int index, IlvTransformer t)
getPointAt
in interface IlvPolyPointsInterface
getPointAt
in class IlvLinkImage
index
- The index of the point.t
- The transformer through which the object is drawn.public boolean allowsPointInsertion()
true
if point insertion is allowed, and
false
otherwise. The default implementation returns
true
.allowsPointInsertion
in interface IlvPolyPointsInterface
allowsPointInsertion
in class IlvLinkImage
true
if the insertion of intermediate points is
allowed and false
otherwise.IlvLinkImage.insertPoint(int, double, double, ilog.views.IlvTransformer)
public boolean allowsPointRemoval()
true
if point removal is allowed, and
false
otherwise.allowsPointRemoval
in interface IlvPolyPointsInterface
allowsPointRemoval
in class IlvLinkImage
true
if the removal of intermediate points is
allowed and false
otherwise.IlvLinkImage.removePoint(int, ilog.views.IlvTransformer)
public void insertPoint(int index, double x, double y, IlvTransformer t)
insertPoint
in interface IlvPolyPointsInterface
insertPoint
in class IlvLinkImage
index
- The index at which the new point will be inserted.x
- The x coordinate of the new point (in manager's coordinates).y
- The y coordinate of the new point (in manager's coordinates).t
- The transformer used to draw the link.public void removePoint(int index, IlvTransformer t)
removePoint
in interface IlvPolyPointsInterface
removePoint
in class IlvLinkImage
index
- The index of the point to be removed.t
- The transformer used to draw the polypoint.public void movePoint(int index, double x, double y, IlvTransformer t)
index
is the index of the
first or the last point, the method calls the movePoint
method
of the superclass. Otherwise, the method simply moves the point to the new
coordinates.movePoint
in interface IlvPolyPointsInterface
movePoint
in class IlvLinkImage
index
- The index of the point to be moved.x
- The new x coordinate of the point (in manager's coordinates).y
- The new y coordinate of the point (in manager's coordinates).t
- the transformer through which the object is drawn.IlvApplyObject
,
IlvManager.applyToObject(ilog.views.IlvGraphic, ilog.views.IlvApplyObject, java.lang.Object, boolean)
public void applyTransform(IlvTransformer t)
applyTransform
in class IlvLinkImage
t
- The transformer to be applied.IlvGraphic
public boolean pointsInBBox()
false
since the points defining the spline are not in
the bounding box of the object.pointsInBBox
in interface IlvPolyPointsInterface
pointsInBBox
in class IlvLinkImage
public IlvRect boundingBox(IlvTransformer t)
boundingBox
in interface IlvPolyPointsInterface
boundingBox
in class IlvLinkImage
t
- The transformer used to draw the object.IlvGraphic.draw(java.awt.Graphics, ilog.views.IlvTransformer)
,
IlvGraphic.zoomable()
,
IlvGraphic
public boolean contains(IlvPoint p, IlvPoint tp, IlvTransformer t)
contains
in class IlvLinkImage
p
- The point to be tested.tp
- The point p transformed by the transformer t.t
- The transformation that was applied to the object when it was
drawn.true
if the point lies inside this graphic object.IlvGraphic
public void draw(Graphics dst, IlvTransformer t)
draw
in class IlvLinkImage
dst
- The destination Graphics.t
- The transformation used to draw the object.IlvGraphic.callDraw(Graphics,IlvTransformer)
,
IlvGraphic.boundingBox(IlvTransformer)
,
IlvGraphic.zoomable()
,
IlvGraphic
public void write(IlvOutputStream stream) throws IOException
IlvOutputStream
. Note that even if
this is a public method, you should not call it directly, you should use
the write
methods of the manager.write
in interface IlvPersistentObject
write
in class IlvLinkImage
stream
- The output stream.IOException
- thrown when an exception occurs during
the write operation for this object.public void setSmoothness(double smoothness)
IlvGraphicUtil.AUTO_SMOOTHNESS
can be set to use an
algorithm that automatically detects an appropriate smoothness for each
bend.
IlvGraphicUtil.COMPATIBLE_SMOOTHNESS
. With
this value, a spline looks exactly as in JViews 3.0, that is, the spline
with more than two bends (4 control points) will not look smooth.
IlvApplyObject
passed to
IlvManager.applyToObject(ilog.views.IlvGraphic, ilog.views.IlvApplyObject, java.lang.Object, boolean)
.
smoothness
- The smoothness.getSmoothness()
public double getSmoothness()
setSmoothness(double)
public boolean isSpline()
true
if the link has spline routing functionality.
This implementation always returns true
.isSpline
in class IlvLinkImage
public IlvSelection makeSelection()
IlvSplineLinkSelection
.makeSelection
in class IlvLinkImage
IlvSplineLinkSelection
© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.