Handlers on JGoLink


I am getting two handles on either side of the JGolink,which are reshapable.But I want those 2 handlers on the link.
If the link is straight line,I am getting handles on the JGoLink.But if I reshape it,then I am getting handles on either side of the JGoLink.
What method I have to use so that the handles are always on the JGoLink?



Is isCubic() true for your link?
What do you mean that you get handles (not handlers) “on either side of the JGoLink”?
Are you at all referring to the resize handles that are used to support relinking by the user?


Dear Mr. Walter,
Problem - 1:What I am looking for is these handles must sit on the curved line itself.
I mean by either side is " they are not sitting on the line" both the handles are on the opposite sides of the curved line.
Currently, For a straight line, the handles are sitting on the line, whereas in the case of curved line these handles are not on the line and they are coming somewhere else.
Problem - 2: There is a small gap between the curved line and the Arrow Head i want to remove this gap
On using setArrowHeads method and connecting them to an objects on the canvas with a curved line
Note: when the link is a straight line this gap is not present whereas when it is a curved line this is coming.

  1. For Cubic strokes, those handles that are not “on” the line are where the control points are for the Bezier curve. You will need to reimplement gainedSelection and handleResize to do what you want.
  2. I’m sorry, but I haven’t seen such behavior. Could you describe the kinds of ports you are connecting in such a case?


My 2nd problem was solved.
Problem: How can I make my 2 Handles(control points) sit always on the Bezier curve?
I have overridden gainedSelection() and handleResize() as follows:
protected void gainedSelection(JGoSelection selection)
if (getDataObject() instanceof Assign) {
if (isReshapable()) {

int nLastPoint = getLastPickPoint();
for (int i=getFirstPickPoint(); i <= nLastPoint; i++) {
Point pnt = getPoint(i);
if (pnt != null)
selection.createResizeHandle(this, pnt.x, pnt.y,NumReservedHandles + i, true);

public boolean isReshapable() { return myReshapable; }
public Rectangle handleResize(Graphics2D g, JGoView view,Rectangle prevRect, Point newPoint,int whichHandle,
int event,int minWidth, int minHeight)
if (whichHandle >= NumReservedHandles) {
setPoint(whichHandle - NumReservedHandles, newPoint);
} else {
return super.handleResize(g,view,prevRect,newPoint,whichHandle,even t,minWidth,minHeight);
// we return null so that the view doesn’t draw a bounding
// rectangle.
return null;
Is there any need to implement calculateStroke(),to get the desired behaviour?
what are the necessary changes needs to be done for my gainedSelection() and handleResize() methods,in order to get the desired behaviour?



No, you shouldn’t need to override calculateStroke, unless you really want it to compute a different path (set of points) for the stroke.
I don’t know exactly what you want to have, so I can’t say. This sounds non-trivial, although it depends on the details.


Hi Walter,
Here I am trying to paste the image ,so that you can better understand the situation.But I am unable to paste an image here.(paste is not working).
Atleast this window has not the facility to attach the document.
I have tried all the ways to attach the figure(as per my knowledge).It is asking URL,instead of Browse facility.
Please tell me the way to attach a file(existed in my system),so that u can have a better idea on the problem.


You have told “For Cubic strokes, those handles that are not “on” the line are where the control points are for the Bezier curve. You will need to reimplement gainedSelection and handleResize to do what you want.”
I have reimplemented the same 2 methods,which i had shown in the earlier post.Though i have reimplemented those methods,I am not getting the handles(control points) on the Bezier curve.
What may be the reason for this and whatmore to be added to these methods so that I will get handles on the Bezier curve.
I think U got the situation.


Sorry, but explaining how Bezier curves are implemented is too complicated to do in this forum. You can find a lot of information on the web about Bezier curves, though I’m not sure how easy that would be to use.


All my probs r solved.Thanks