public class IlvCrossingAwareLinkImage extends IlvPolicyAwareLinkImage
IlvCrossingAwareLinkImage
is
a link between two nodes of a grapher with several bend points, that is
is aware of link crossings. It allows to display the link crossings
in different styles.
The link crossings get automatically updated if you install a link shape
policy of type IlvCrossingLinkShapePolicy
.
setCrossingGraphic(ilog.views.IlvGraphic)
setLayerOfCrossingGraphic(int)
setGap(double)
setGapZoomable(boolean)
setCrossingEnabled(boolean)
hasCrossings(ilog.views.IlvTransformer)
IlvCrossingLinkShapePolicy policy = new IlvCrossingLinkShapePolicy(); // the policy can be shared among links, but each link needs its own // tunnel crossing object IlvCrossingAwareLinkImage link1 = new IlvCrossingAwareLinkImage(node1, node2, true, null); link1.setCrossingGraphic(new IlvTunnelCrossings(link1)); link1.setLinkShapePolicy(policy); IlvCrossingAwareLinkImage link2 = new IlvCrossingAwareLinkImage(node3, node4, true, null); link2.setCrossingGraphic(new IlvTunnelCrossings(link2)); link2.setLinkShapePolicy(policy); ... // insert the links into the grapher only AFTER installing the policy grapher.addLink(link1, redraw); grapher.addLink(link2, redraw); ...If you want to install the crossing link shape policy and the orthogonal link shape policy together at the same link, this is easily possible:
IlvOrthogonalLinkShapePolicy policy = new IlvOrthogonalLinkShapePolicy(); policy.setChildPolicy(new IlvCrossingLinkShapePolicy()); IlvCrossingAwareLinkImage link = new IlvCrossingAwareLinkImage(node1, node2, true, null); link.setCrossingGraphic(new IlvTunnelCrossings(link)); link.setLinkShapePolicy(policy); ... // insert the links into the grapher only AFTER installing the policy grapher.addLink(link, redraw); ...The class is designed to work for nested graphs, if the views are attached to the topmost grapher. If any view is attached to a subgrapher, it may show crossings between a link in the subgrapher and a link of any ancestor grapher that is not visible in this view. System property IlvCrossingAwareLinkImage.optimize.cache (boolean, default=true) can disable the scrolling performance improvement for links with crossing
Constructor and Description |
---|
IlvCrossingAwareLinkImage(IlvCrossingAwareLinkImage source)
Creates and initializes a new
IlvCrossingAwareLinkImage by
copying an existing one. |
IlvCrossingAwareLinkImage(IlvGraphic from,
IlvGraphic to,
boolean backoriented,
boolean oriented,
IlvPoint[] points)
Creates and initializes a new
IlvCrossingAwareLinkImage . |
IlvCrossingAwareLinkImage(IlvGraphic from,
IlvGraphic to,
boolean oriented,
IlvPoint[] points)
Creates and initializes a new
IlvCrossingAwareLinkImage . |
IlvCrossingAwareLinkImage(IlvInputStream stream)
Reads the object from an
IlvInputStream . |
Modifier and Type | Method and Description |
---|---|
void |
applyTransform(IlvTransformer t)
Applies a transformation to the shape of the link.
|
protected IlvRect |
arrowBBox(IlvPoint from,
IlvPoint to,
IlvTransformer t)
Computes the bounding rectangle of the
arrow when the link is oriented.
|
protected IlvRect |
backArrowBBox(IlvPoint from,
IlvPoint to,
IlvTransformer t)
Computes the bounding rectangle of the
backward arrow when the link is backward oriented.
|
IlvRect |
boundingBox(IlvTransformer t)
Returns the bounding rectangle of the object.
|
protected boolean |
boundingBoxCacheContains(IlvTransformer t)
Checks whether the input transformer is cached in the bounding box cache.
|
IlvRect |
boundingBoxCrossingGraphic(IlvTransformer t)
Deprecated.
Since JViews 8.5, this method is no longer needed.
|
protected IlvRect |
calcBoundingBox(IlvTransformer t)
Calculate the bounding rectangle of the link.
|
boolean |
contains(IlvPoint p,
IlvPoint tp,
IlvTransformer t)
Tests if a point lies within the outline of the link.
|
boolean |
containsAtCrossingGraphic(IlvPoint p,
IlvPoint tp,
IlvTransformer t)
Tests if a point lies within the outline of the crossing graphic
that belongs to this link.
|
IlvGraphic |
copy()
Copies the object.
|
void |
draw(Graphics dst,
IlvTransformer t)
Draws the link.
|
protected void |
drawBackArrow(Graphics dst,
IlvPoint from,
IlvPoint to,
IlvTransformer t)
Draws the arrow of the link if the link is backward oriented.
|
void |
drawCrossingGraphic(Graphics dst,
IlvTransformer t)
Draws the crossing graphic that belongs to this link.
|
protected void |
drawPolyline(Graphics dst,
IlvPoint[] pts,
int length,
double lineWidth,
int lineJoin,
int endCap,
float[] lineStyle,
IlvTransformer t,
boolean pointsTransformed)
Draws a polyline that is part of the link.
|
protected double |
getBackArrowSize(double lineWidth,
IlvTransformer t)
Returns the size of the backward arrow for the corresponding
IlvTransformer and lineWidth . |
int |
getBoundingBoxCacheSize()
Returns the size of the bounding box cache.
|
IlvGraphic |
getCrossingGraphic()
Returns the graphic object that draws the crossings.
|
IlvCrossingLinkShapePolicy |
getCrossingPolicy()
Returns the crossing link shape policy that controls this link.
|
protected IlvPoint[] |
getDrawingLinkPoints(IlvTransformer t)
Returns the link points used to draw the polyline of the link.
|
double |
getGap()
Returns the gap width of the link crossings.
|
int |
getLayerOfCrossingGraphic()
Returns the default layer of the graphic object that draws the crossings.
|
protected Shape |
getSimpleShape(IlvPoint[] points,
IlvTransformer t)
Returns the shape of the link, according to the given intermediate
points.
|
protected Shape |
getStrokeShape(IlvPoint[] points,
IlvTransformer t)
Returns the stroke shape of the link.
|
boolean |
hasCrossings(IlvTransformer t)
Returns
true if the link has crossings that cut the link
into subparts. |
void |
insertPoint(int index,
double x,
double y,
IlvTransformer t)
Inserts a point at a specified index.
|
protected void |
invalidateBBoxCache()
Invalidate the bounding box cache of the link.
|
protected void |
invalidateBoundingBoxCache()
Deprecated.
Use #invalidateBBoxCache()
|
boolean |
isBackOriented()
Returns
true if the link is backward oriented,
and false otherwise. |
boolean |
isCrossingEnabled()
Returns
true if crossings are shown on the link. |
boolean |
isGapZoomable()
Returns
true if the gap of the link crossings is zoomable. |
protected boolean |
mergeCrossings(double dist,
double gap,
double lineWidth,
IlvTransformer t)
Returns whether to merge two subsequent crossings.
|
void |
movePoint(int index,
double x,
double y,
IlvTransformer t)
Changes the position of a point.
|
void |
removePoint(int index,
IlvTransformer t)
Removes the point at a specified index.
|
void |
setBackOriented(boolean oriented)
Sets whether the link is backward oriented.
|
void |
setBoundingBoxCacheSize(int size)
Sets the size of the bounding box cache.
|
void |
setCrossingEnabled(boolean flag)
Sets whether crossings are shown on the link.
|
void |
setCrossingGraphic(IlvGraphic g)
Sets the graphic object that draws the crossings.
|
void |
setCrossingGraphic(IlvGraphic g,
int layerNumber)
Sets the graphic object that draws the crossings.
|
void |
setEndCap(int endCap)
Changes the decoration applied at the end of the polyline.
|
void |
setGap(double gap)
Sets the gap width of the link crossings.
|
void |
setGapZoomable(boolean zoomable)
Sets whether the gap of the link crossings is zoomable.
|
void |
setGraphicBag(IlvGraphicBag bag)
Changes the bag that contains the object.
|
void |
setIntermediateLinkPoints(IlvPoint[] points,
int index,
int length)
Changes the intermediate points that define the link.
|
void |
setLayerOfCrossingGraphic(int layerNumber)
Sets the default layer of the graphic object that draws the crossings.
|
void |
setLineJoin(int lineJoin)
Changes the decoration applied when two segments are joined.
|
void |
setLineWidth(double lineWidth)
Changes the line width of the object.
|
void |
setMaximumLineWidth(double maximumLineWidth)
Changes the maximum line width of the link.
|
void |
setOriented(boolean oriented)
Sets the link as oriented or nonoriented.
|
protected static boolean |
shouldOptimizeCache()
do we want to optimize crossing rendering on translation ?
|
void |
write(IlvOutputStream stream)
Writes the object to an
IlvOutputStream . |
boolean |
zoomable()
Returns
true if the object is zoomable; otherwise it
returns false . |
getLinkPoints, getLinkShapePolicy, getPointAt, setLinkShapePolicy
allowsPointInsertion, allowsPointRemoval, getPointsCardinal
allowsPointMove, 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, isSpline, makeSelection, pointsInBBox, setForeground, setFrom, setLineStyle, setLinkPoints, setTo
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, 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, setInApplyToObject, setMovable, setName, setNamedProperty, setNameImpl, setObjectInteractor, setPopupMenu, setPopupMenuName, setProperty, setSelectable, setStrokeOn, setToolTipBaseTextDirection, setToolTipText, setVisible, setZOrderIndex, toString, translate, updateNeedsViewNotification, usesBidiMarkers, viewAddedOrRemoved
public IlvCrossingAwareLinkImage(IlvGraphic from, IlvGraphic to, boolean oriented, IlvPoint[] points)
IlvCrossingAwareLinkImage
.
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 polylink.public IlvCrossingAwareLinkImage(IlvGraphic from, IlvGraphic to, boolean backoriented, boolean oriented, IlvPoint[] points)
IlvCrossingAwareLinkImage
.
from
- The origin object.to
- The destination object.backoriented
- Specifies whether an arrow is drawn at the start of
the link or not.oriented
- Specifies whether an arrow is drawn at the end of the
link or not.points
- The intermediate points of the polylink.public IlvCrossingAwareLinkImage(IlvCrossingAwareLinkImage source)
IlvCrossingAwareLinkImage
by
copying an existing one.
source
- The copied object.public IlvCrossingAwareLinkImage(IlvInputStream stream) throws IlvReadFileException
IlvInputStream
.
stream
- The input stream.IlvReadFileException
- if the format is not correct.protected static boolean shouldOptimizeCache()
public IlvGraphic copy()
copy
in class IlvPolicyAwareLinkImage
IlvGraphic
instance.IlvGraphic
public void setCrossingEnabled(boolean flag)
isCrossingEnabled()
public boolean isCrossingEnabled()
true
if crossings are shown on the link.public void setGap(double gap)
getGap()
public final double getGap()
setGap(double)
public void setGapZoomable(boolean zoomable)
isGapZoomable()
public final boolean isGapZoomable()
true
if the gap of the link crossings is zoomable.
setGapZoomable(boolean)
public boolean zoomable()
true
if the object is zoomable; otherwise it
returns false
.
The object is zoomable if the gap is zoomable.zoomable
in class IlvLinkImage
isGapZoomable()
public void setCrossingGraphic(IlvGraphic g)
IlvGraphic
that can draw
all the crossing points of this link. It must implement the
IlvCrossingGraphic
interface.
applyToObject
for the crossing graphic.
getCrossingGraphic()
public void setCrossingGraphic(IlvGraphic g, int layerNumber)
IlvGraphic
that can draw
all the crossing points of this link. It must implement the
IlvCrossingGraphic
interface.
-1
, an appropriate layer is
automatically calculated.
applyToObject
for the crossing graphic.
getCrossingGraphic()
public final IlvGraphic getCrossingGraphic()
public void setLayerOfCrossingGraphic(int layerNumber)
-1
, an appropriate layer is
automatically calculated.
public final int getLayerOfCrossingGraphic()
-1
if the layer is automatically calculated.
setLayerOfCrossingGraphic(int)
public void setGraphicBag(IlvGraphicBag bag)
setGraphicBag
in class IlvPolicyAwareLinkImage
bag
- The graphic bag.IlvGraphic
public IlvCrossingLinkShapePolicy getCrossingPolicy()
public void write(IlvOutputStream stream) throws IOException
IlvOutputStream
.
You should not call this
method directly; instead, you should use the write
methods of the manager.
write
in interface IlvPersistentObject
write
in class IlvPolicyAwareLinkImage
stream
- The output stream.IOException
- thrown when an exception occurs during
the write operation for this object.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
protected IlvPoint[] getDrawingLinkPoints(IlvTransformer t)
IlvPolicyAwareLinkImage.getLinkPoints(ilog.views.IlvTransformer)
as the line must be shortened
to draw the end arrows correctly.t
- The transformer to draw the link.public final boolean hasCrossings(IlvTransformer t)
true
if the link has crossings that cut the link
into subparts. If nonzoomable links exist, then the link may have
crossings in one transformer but no crossings in another transformer.
t
- The transformer to draw the link.protected Shape getStrokeShape(IlvPoint[] points, IlvTransformer t)
points
- The transformed link points.t
- The transformer to draw the link.protected Shape getSimpleShape(IlvPoint[] points, IlvTransformer t)
points
- The transformed link points.t
- The transformer to draw the link.protected void drawBackArrow(Graphics dst, IlvPoint from, IlvPoint to, IlvTransformer t)
from
and to
. The head of
the arrow is on point to
.
Note that the points are already transformed by the transformer.protected void drawPolyline(Graphics dst, IlvPoint[] pts, int length, double lineWidth, int lineJoin, int endCap, float[] lineStyle, IlvTransformer t, boolean pointsTransformed)
dst
- The destination Graphics
.pts
- The control points of the polyline.length
- The number of significant points in pts
.lineWidth
- The width of the pen used to draw the polyline.lineJoin
- The 'line join' style used to draw the polyline.
The valid values are defined in the interface IlvStroke
.endCap
- The 'end cap' style used to draw the polyline.
The valid values are defined in the interface IlvStroke
.lineStyle
- The array representing the dashing pattern.t
- The transformer used to draw the polyline.pointsTransformed
- true if the points are transformed by the
transformer, false otherwise.hasCrossings(ilog.views.IlvTransformer)
protected boolean mergeCrossings(double dist, double gap, double lineWidth, IlvTransformer t)
dist
- The distance between this crossing and the next crossing.gap
- The desired gap for the crossing.lineWidth
- The line width of the other link that crosses this link.t
- The transformer to draw the link;public void drawCrossingGraphic(Graphics dst, IlvTransformer t)
draw
method
to this method if necessary.
dst
- The destination Graphics.t
- The transformation used to draw the link.IlvAbstractCrossingGraphic.draw(java.awt.Graphics, ilog.views.IlvTransformer)
@Deprecated public IlvRect boundingBoxCrossingGraphic(IlvTransformer t)
public boolean containsAtCrossingGraphic(IlvPoint p, IlvPoint tp, IlvTransformer t)
contains
method
to this method if necessary.
p
- The point to be tested in the coordinate system of the link.tp
- The point p
transformed by the transformer
t
.t
- The transformation that was applied to the link object when it
was drawn.IlvAbstractCrossingGraphic.contains(ilog.views.IlvPoint, ilog.views.IlvPoint, ilog.views.IlvTransformer)
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 void setBoundingBoxCacheSize(int size)
public int getBoundingBoxCacheSize()
protected IlvRect calcBoundingBox(IlvTransformer t)
boundingBox(ilog.views.IlvTransformer)
when the bounding box for the input
transformer is not internally cached.protected boolean boundingBoxCacheContains(IlvTransformer t)
protected void invalidateBBoxCache()
invalidateBBoxCache
in class IlvGraphic
@Deprecated protected void invalidateBoundingBoxCache()
protected IlvRect arrowBBox(IlvPoint from, IlvPoint to, IlvTransformer t)
from
and to
. The head of
the arrow is on point to
.
Note that the points are already transformed by the transformer.protected IlvRect backArrowBBox(IlvPoint from, IlvPoint to, IlvTransformer t)
from
and to
. The head of
the arrow is on point to
.
Note that the points are already transformed by the transformer.protected double getBackArrowSize(double lineWidth, IlvTransformer t)
IlvTransformer
and lineWidth
.
By redefining this method the subclass can change the size of the arrow
which by default is proportional to the link line width and the transformer
zoom factor.
If this method returns a size that is not anymore proportional to the
transformer zoom factor, this may change the zoomability of this object and
the zoomable()
method may also have to return something different.lineWidth
- the actual line width used to drawn the object
in manager coordinates.t
- the transformer used to draw the object.IlvLinkImage.getLineWidth()
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 used to draw the link.true
if the point lies inside this graphic object.IlvGraphic
public void insertPoint(int index, double x, double y, IlvTransformer t)
insertPoint
in interface IlvPolyPointsInterface
insertPoint
in class IlvPolicyAwareLinkImage
index
- The index at which the new point will be inserted.x
- The x coordinate of the new point (in manager coordinates).y
- The y coordinate of the new point (in manager coordinates).t
- The transformer used to draw the polypoint.public void removePoint(int index, IlvTransformer t)
removePoint
in interface IlvPolyPointsInterface
removePoint
in class IlvPolicyAwareLinkImage
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 last point,
this 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 IlvPolicyAwareLinkImage
index
- The index of the point to be moved.x
- The new x coordinate (in manager coordinates).y
- The new y coordinate (in manager 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 setIntermediateLinkPoints(IlvPoint[] points, int index, int length)
length
points in the 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 IlvPolicyAwareLinkImage
points
- An array of points.index
- The index of the point that 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 void setOriented(boolean oriented)
setOriented
in class IlvLinkImage
IlvLinkImage.isOriented()
public void setBackOriented(boolean oriented)
isBackOriented()
public boolean isBackOriented()
true
if the link is backward oriented,
and false
otherwise.
A backward oriented link has an arrow drawn at the origin.setBackOriented(boolean)
public void setLineWidth(double lineWidth)
setLineWidth
in class IlvLinkImage
lineWidth
- The new line width.IlvLinkImage.getLineWidth()
public void setMaximumLineWidth(double maximumLineWidth)
setMaximumLineWidth
in class IlvLinkImage
maximumLineWidth
- The maximum line width, or 0 to indicate no limit.IlvLinkImage.getMaximumLineWidth()
public void setEndCap(int endCap)
setEndCap
in class IlvLinkImage
endCap
- The new decoration style. The values
are defined in the class IlvStroke
.
The default value is CAP_SQUARE
.IlvStroke
public void setLineJoin(int lineJoin)
setLineJoin
in class IlvLinkImage
lineJoin
- The new decoration style. The values are defined
in the class IlvStroke
.
The default value is JOIN_MITER
.IlvStroke
public void applyTransform(IlvTransformer t)
t
to the
intermediate points of the link, if any.applyTransform
in class IlvPolicyAwareLinkImage
t
- The transformer to be applied.IlvGraphic
© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.