Overide JgoBasicNode LayoutChildren()


I read the docuementation about this method, still confused about how to reimplement this method inorder to set the fixed width of the jgoBasic nodes. The example code in PersonNode did reimplement this method. But how can I set the drawable object of the node? Since JGoDrawable is an abstract class. I can create a Rectangle object?
(isInitializing()) return;
if (childchanged == null || childchanged == getLabel()) {
Rectangle rec = childchanged.getBoundingRect();
rec.setSize(50, 50);


I’m not sure what you want.
If you want to replace the background shape, a JGoDrawable, from a JGoEllipse to a JGoRectangle, you can either override createDrawable or just call setDrawable.
If you want just a fixed size shape even though the LabelSpot is JGoObject.Center, causing the shape to surround the JGoText label, set the AutoResize property to false. This causes JGoBasicNode.layoutChildren to change its behavior to make sure the JGoText label fits inside the drawable shape, rather than the other way around.


I want a jgoNode whose shape is a square, but with a fixed Width and flexible height. the width will automatically wrap all the label if the label is too long, if the label is short, the width of the rectangle is still the same as the node whose label is long.
I have done the following:
but the nodes whose label is too short is smaller in width than those nodes whose label got wrapped according the 100 pixels. How to make all the nodes have a fixed width rectangular.


Take a look at the Demo1.rectBasicNodeAction method in Demo1. This creates the purplish rectangular JGoBasicNode that you see at the bottom left of the automatically created stuff.
If you just set Resizable and AutoResize false and set the getDrawable()'s size to the dimension you want, isn’t this what you want?


Sorry, Maybe I did not explain my problem clearly enough. Let me try it again.
I want all the square nodes with fixed length. the Demo1.rectBasicNodeAction does create rectangular JGoBasicNodes, but If I change text lable, the length of the rectangular is growing. The feature I desire is that rectangular will wrap the length according to a fixed number, the length is fixed, but the height of the rectangular is growing because the long text label will be wrapped in multiple lines.


It works fine for me, but I may still be misunderstanding you.
I added the following lines to Demo1.rectBasicNodeAction after the call to setDrawable:
tnode.getDrawable().setSize(150, 150);