Adornment position for LinkReshapingTool

Hi!
I’m creating a Tool for reshaping a link and I need to create a handle and position it based on the document position.
Right now, the way it’s placing is not based on the document coordinates.

I’m using adornment.position = midPoint.

 const adornment = new go.Adornment()
  adornment.type = go.Panel.Link
  const h = this.makeHandle(pathshape, 0)
  this.setReshapingBehavior(h, go.LinkReshapingTool.All)
  h.cursor = 'move'
  adornment.add(h)
  adornment.location = midPoint
  adornment.isGeometryPositioned = true
  adornment.category = this.name
  adornment.adornedObject = pathshape
  return adornment

How can solve this?

Thanks!

The elements of a Link Panel Adornment are arranged according to the rules for labels on links – using the properties like segmentIndex, segmentOrientation, alignment, et al. So setting the position will have no effect.

What is it that you want to achieve? Did you want to put a handle at a particular (relative) point along the link? If so, set its properties as described at GoJS Link Labels -- Northwoods Software.

If I can’t place it based on the document position then I have to get the relative. Is there an easy solution to transform the position I have (in document coordinates) to a position relative to the link?

Well, the literal answer is GraphObject.getLocalPoint: GraphObject | GoJS API

But I’m concerned that that is not going to help you. Links normally get their bounds based on the positions of the connected ports, which is quite different from what you want. Do you really need this object to be in the visual tree of a Link?

What I’m trying to do is create a handle to reshape the form of the link, so I need to show that handle once I select the link.
I just need to define a point between the start and end, and compute the line based on this middle point.


I’m only missing this part where I set the handle in this previously defined middle point. This middle point is defined on a stored schema not previously created with gojs

So you were starting from the CurvedLinkReshapingTool extension?
You could still try setting your handle’s alignment. Assume the handle does not have a segmentIndex (so it’s goes to the midPoint) or segmentOffset, and set the alignment to be a Spot with Spot.offsetX and Spot.offsetY that is the difference between the desired point in document coordinates and the Link.midPoint.