| | | | Browse by category |
Article ID: 2247
Last updated: 29 May, 2018
Question
How to draw a bi-directional link?
Answer
Since JViews 6.0, IlvEnhancedPolylineLinkImage
supports bi-directional link display, that is, it can show two arrow heads.
Alternatively, you can override the draw method in IlvLinkImage
to draw the additional arrow.
IlvBidirectionalLink.java
import java.awt.Graphics; import ilog.views.IlvGraphic; import ilog.views.IlvLinkImage; import ilog.views.IlvPoint; import ilog.views.IlvRect; import ilog.views.IlvTransformer; /** * Simple IlvLinkImage subclass to include the drawing of a second * arrow. */ public class IlvBidirectionalLink extends IlvLinkImage { public IlvBidirectionalLink(IlvGraphic from, IlvGraphic to) { super(from,to,true); } /** * Draws a link with two arrows on each end. */ public void draw(Graphics dst, IlvTransformer t) { // Draw common link. super.draw(dst, t); // Add another arrow. IlvPoint[] points = getLinkPoints(t); IlvPoint from = points[0]; IlvPoint to = points[1]; dst.setColor(getForeground()); drawArrow(dst, to, from, t); } /** * Adds the bbox of the additional arrow to the original * */ public IlvRect boundingBox (IlvTransformer t) { IlvRect rect = super.boundingBox(t); IlvPoint[] points = getLinkPoints(t); IlvPoint from = points[0]; IlvPoint to = points[1]; IlvRect secondArrowBBox = this.arrowBBox(to, from, t); rect.add(secondArrowBBox); return rect; } }
This article was:
Helpful |
Not helpful
Report an issue
Article ID: 2247
Last updated: 29 May, 2018
Revision: 3
Views: 764
Posted: 03 Mar, 2011 by
Dean J.
Updated: 29 May, 2018 by
Gargani A.
Attached files
Also listed in
Others in this category
Powered by KBPublisher (Knowledge base software)