Move the parts with group while resizing to samller dimension

Currently when I add a part inside a group, while resizing the group I am able to remove the part outside the group but the binding with group is still in place, but I want that the part should move with the group if it is getting resized to a smaller dimension. How can we do that?

Maybe rather than moving the part you should limit the group so it can’t resize such that it won’t contain its members. A basic example of that is here, and a more complicated example can be seen in the Swimlanes sample.

I used the resizing example and it is working fine for rectangular groups but I also have polygonal groups and there are two things there one is resizing and other is reshaping. How to achieve it in that scenario as resizing will also not work because that will consider the outside rect and not the actual polygonal shape and what should be done for reshaping as that doesn’t have the “computeMinSize”.

During resizing or reshaping, at each step (i.e. mouse move) you will need to recompute whether any group members would no longer still be within the polygon. If that is the case, do not make that resize or reshape.

But we need that resize and reshape.
How can we compute the bounds of a polygon which will result in polygon area rather than a rect bound.

Sorry, I misunderstood your requirements. But what should happen to those members as they are moved to fit within a shrinking group? Should they overlap each other or should they be resized too? If you do not resize them then as the group gets small, member nodes will stick out beyond your polygon.

Take a look at this sample: https://gojs.net/extras/resizingGroups.html

Actually, it might be better to change the scale of member nodes, rather than resizing them.

no resizing should stopped or canceled in such scenario like it is happening in https://gojs.net/extras/groupResizing.html
For polygon it should be same right now if you will draw a polygon and place a node inside it.

Did you try the sample I just suggested?

but in this sample the nodes placed inside are also getting resized that is not desired result. It should happen like in swim lanes or resizing groups but that is not working for polygon’s

Consider this example if blue line is adornment for resizing and black line in group outline.
image

On resizing the result is something like this.
image

this time it is going outside.

But you just said: “no resizing should stopped or canceled”. Now I do not understand what you want.

Well, we have given you several possibilities, so you can choose what you want to implement.

Ah, OK, examples always help. But what result do you want instead? Either you should prevent resizing or you need to move and resize the member nodes. And what should happen when the group is resized to be bigger again?

I think I am not able give good example.
It should stop like in group resixing but should also work with polygons like in above provided images the node is stopped but with respect to outer rectangle and not the real polygon.
on getting bigger it should stay in the same place which is getting handled.

If you do not want to move or resize/rescale any member nodes, then this quote still seems like the best advice.

So I will have to calculate the polygon bounds on every mouse up.
Is there any inbuilt bounds calculator that gives bounds of polygon on the basis of the points?
and what will be the way to get all the points of that polygon on mouse up because at mouse up I will only get current point from “lastInput.documentPoint”

Presumably your Group has a Shape in it that is the polygon. Its Shape.geometry is what you want. Its points are in local coordinates, but you can shift them by the shape’s getDocumentPoint(go.Spot.TopLeft)

So I will have to add the geometry points with this point getDocumentPoint(go.Spot.TopLeft)?
and will it give exact points while I am resizing or reshaping it or after that is done, if so which event or function I should override?

It’s probably more efficient to shift the member node’s actualBounds.copy() by the document position of the shape.

I suppose overriding ResizingTool.computeResize would be best. ResizingTool.computeMinSize and computeMaxSize might be useful if there are some easily computed limits that you can determine ahead of time.

This is for normal rectangle resize what about the following queries

Do you define your groups’s shape’s geometry by constructing a Path Geometry? And are you expecting the geometry to scale uniformly as the shape changes size? If so, you might want to scale each member node’s copy of its actualBounds before deciding if the rectangle is fully within the geometry.

Alas, deciding whether a rectangle is fully within an arbitrary geometry is not a predicate that GoJS provides in its API. You will have to implement that yourself.