Sub-object issues when resizing JGoNodes


Our current JGo application consists of homogenous nodes on a view and multiple links between them.

We’re trying to implement an algorithm where nodes within a certain radius of the center of the view are given a certain size (eg: ‘n’) and nodes that are further away are given progressively smaller sizes.

I finally worked out the best way to resize the nodes (node.setBoundingRect()) however i am having a couple of problems.

We have several sub-objects of our node including a JGoText object and a couple of JGoPort objects. These objects are added to the node via the addObjectAtTail() method and are then located using the setSpotLocation() method

Unfortunately when we call setBoundingRect() to change the size of these nodes, the location of some objects is not preserved. For example, with the text node that we add, we call;

text.setSpotLocation( JGoObject.Center, node, JGoObject.Bottom)

which means to anchor the text to the bottom of the node (as far as i understand)

When we then all setBoundingRect(), and increase the size of the node, the text seems to be in the same position as it was previously (which is now towards the center of the node) instead of shifting back down to the bottom of the node.

Is there a way that we can control this behaviour?

For bonus points, can you tell me if/how it will be possible to do rescaling while the user is dragging a node with the mouse? Eg: user drags node towards the center of the view. node should get bigger as we move it closer.


Take a look at

I don't have time right now to try to improve this, but it should give you some ideas about how to proceed.
It assumes the center area is given by the center of the document, but you could change that, perhaps as a property on your document.
It also assumes there are just three regions/sizes. Of course you could add more if you want. But initially I tried to make it continuous, based on the distance from the document center, and I found the dragging performance too slow as it was continuously trying to resize and relayout. Having discrete sizes greatly reduces the overhead during dragging, since most of the time a node isn't crossing a size region boundary.
Rescaling of text in nodes is problematic. I think it's fine in this implementation, but the more general way to do that doesn't work right. Maybe I forgot to set some JGoText property.

thanks Walter… you have definitely helped point me in the right direction.

I was wondering though… is it possible to make it so that the text length doesnt cause the node to resize? (just as a subclass of JGoNode - because we add (multiple) text objects to the node ourselves rather than using the JGoBasicNode superclass.

When i was testing your ShrinkingNode, when i would drag them the ellipse would turn into almost a vertical line due to the lenght of the text i believe…

On one hand, i don’t want the text to affect the rest of the node… but on the other hand i don’t want the text to wrap either.

Is this possible?