|
||||||||||
| PREV CLASS Documentation homepage. NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectilog.views.IlvGraphic
ilog.views.IlvLinkImage
ilog.views.graphic.IlvPolylineLinkImage
ilog.views.graphic.linkpolicy.IlvPolicyAwareLinkImage
ilog.views.graphic.linkpolicy.IlvCrossingAwareLinkImage
public class IlvCrossingAwareLinkImage
An 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.
The most methods are just the standard methods of polyline links. The interesting methods of this class are:
setCrossingGraphic(ilog.views.IlvGraphic)
setLayerOfCrossingGraphic(int)
setGap(float)
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.
| Constructor Summary | |
|---|---|
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. |
|
| Method Summary | |
|---|---|
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)
Returns the bounding rectangle of the crossing graphic that belongs to this link. |
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,
float lineWidth,
int lineJoin,
int endCap,
float[] lineStyle,
IlvTransformer t,
boolean pointsTransformed)
Draws a polyline that is part of the link. |
protected float |
getBackArrowSize(float 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. |
float |
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,
float x,
float y,
IlvTransformer t)
Inserts a point at a specified index. |
protected void |
invalidateBoundingBoxCache()
Invalidate the bounding box cache of the link. |
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(float dist,
float gap,
float lineWidth,
IlvTransformer t)
Returns whether to merge two subsequent crossings. |
void |
movePoint(int index,
float x,
float 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(float 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(float lineWidth)
Changes the line width of the object. |
void |
setMaximumLineWidth(float maximumLineWidth)
Changes the maximum line width of the link. |
void |
setOriented(boolean oriented)
Sets the link as oriented or nonoriented. |
void |
write(IlvOutputStream stream)
Writes the object to an IlvOutputStream. |
| Methods inherited from class ilog.views.graphic.linkpolicy.IlvPolicyAwareLinkImage |
|---|
getLinkPoints, getLinkShapePolicy, getPointAt, setLinkShapePolicy |
| Methods inherited from class ilog.views.graphic.IlvPolylineLinkImage |
|---|
allowsPointInsertion, allowsPointRemoval, getPointsCardinal |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
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.| Method Detail |
|---|
public IlvGraphic copy()
copy in class IlvPolicyAwareLinkImageIlvGraphic instance.IlvGraphicpublic void setCrossingEnabled(boolean flag)
isCrossingEnabled()public boolean isCrossingEnabled()
true if crossings are shown on the link.
public void setGap(float gap)
getGap()public final float getGap()
setGap(float)public void setGapZoomable(boolean zoomable)
The option is enabled by default.
isGapZoomable()public final boolean isGapZoomable()
true if the gap of the link crossings is zoomable.
setGapZoomable(boolean)public void setCrossingGraphic(IlvGraphic g)
IlvGraphic that can draw
all the crossing points of this link. It must implement the
IlvCrossingGraphic interface.
This operation does not change the shape of this link, but it changes
bounds of the crossing graphic. It is recommended to set a crossing
graphic only when the crossing graphic is outside any grapher.
If the crossing graphic is already inside a grapher,
you need to encapsulate the operation into applyToObject
for the crossing graphic (that is, not for the link).
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.
When the crossing graphic becomes active due to crossings, it is
automatically inserted into an appropriate grapher into the specified
layer.
The layer number should be above the layer that contains the links.
If the layer number is -1, an appropriate layer is
automatically calculated.
This operation does not change the shape of this link, but it changes
bounds of the crossing graphic. It is recommended to set a crossing
graphic only when the crossing graphic is outside any grapher.
If the crossing graphic is already inside a grapher,
you need to encapsulate the operation into applyToObject
for the crossing graphic (that is, not for the link).
getCrossingGraphic()public final IlvGraphic getCrossingGraphic()
setCrossingGraphic(ilog.views.IlvGraphic)public void setLayerOfCrossingGraphic(int layerNumber)
-1, an appropriate layer is
automatically calculated.
getLayerOfCrossingGraphic(),
setCrossingGraphic(IlvGraphic, int)public final int getLayerOfCrossingGraphic()
-1 if the layer is automatically calculated.
setLayerOfCrossingGraphic(int)public void setGraphicBag(IlvGraphicBag bag)
setGraphicBag in class IlvPolicyAwareLinkImagebag - The graphic bag.IlvGraphicpublic 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 IlvPersistentObjectwrite in class IlvPolicyAwareLinkImagestream - 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 IlvLinkImagedst - The destination Graphics.t - The transformation used to draw the object.IlvGraphic.boundingBox(ilog.views.IlvTransformer),
IlvGraphic.zoomable(),
IlvGraphicprotected 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.
backArrowBBox(ilog.views.IlvPoint, ilog.views.IlvPoint, ilog.views.IlvTransformer)
protected void drawPolyline(Graphics dst,
IlvPoint[] pts,
int length,
float 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(float dist,
float gap,
float 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)public IlvRect boundingBoxCrossingGraphic(IlvTransformer t)
boundingBox method
to this method if necessary.
t - The transformer used to draw the link.IlvAbstractCrossingGraphic.boundingBox(ilog.views.IlvTransformer)
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 IlvPolyPointsInterfaceboundingBox in class IlvLinkImaget - The transformer used to draw the object.IlvGraphic.draw(java.awt.Graphics, ilog.views.IlvTransformer),
IlvGraphic.zoomable(),
IlvGraphicpublic 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 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.
arrowBBox in class IlvLinkImageIlvLinkImage.drawArrow(java.awt.Graphics, ilog.views.IlvPoint, ilog.views.IlvPoint, ilog.views.IlvTransformer)
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.
drawBackArrow(java.awt.Graphics, ilog.views.IlvPoint, ilog.views.IlvPoint, ilog.views.IlvTransformer)
protected float getBackArrowSize(float 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 IlvLinkImage.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 IlvLinkImagep - 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,
float x,
float y,
IlvTransformer t)
insertPoint in interface IlvPolyPointsInterfaceinsertPoint in class IlvPolicyAwareLinkImageindex - 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 IlvPolyPointsInterfaceremovePoint in class IlvPolicyAwareLinkImageindex - The index of the point to be removed.t - The transformer used to draw the polypoint.
public void movePoint(int index,
float x,
float 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 IlvPolyPointsInterfacemovePoint in class IlvPolicyAwareLinkImageindex - 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 IlvPolicyAwareLinkImagepoints - 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 IlvLinkImageIlvLinkImage.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(float lineWidth)
setLineWidth in class IlvLinkImagelineWidth - The new line width.IlvLinkImage.getLineWidth()public void setMaximumLineWidth(float maximumLineWidth)
setMaximumLineWidth in class IlvLinkImagemaximumLineWidth - The maximum line width, or 0 to indicate no limit.IlvLinkImage.getMaximumLineWidth()public void setEndCap(int endCap)
setEndCap in class IlvLinkImageendCap - The new decoration style. The values
are defined in the class IlvStroke.
The default value is CAP_SQUARE.IlvStrokepublic void setLineJoin(int lineJoin)
setLineJoin in class IlvLinkImagelineJoin - The new decoration style. The values are defined
in the class IlvStroke.
The default value is JOIN_MITER.IlvStrokepublic void applyTransform(IlvTransformer t)
t to the
intermediate points of the link, if any.
applyTransform in class IlvPolicyAwareLinkImaget - The transformer to be applied.IlvGraphic
|
||||||||||
| PREV CLASS Documentation homepage. NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||