Can JGoTreeAutoLayout center the resulting tree?

Hello All,

Does anyone know if the JGoTreeAutoLayout can be configured to layout it’s tree within the center of the JGoDocument?

I am only able to get me nodes to layout and appear in the top, left hand position of my JGoDocument, but not in the center.

Here is my Use Case:

  • My document has a size of 1000 x 1000 pixels.
  • After performLayout, my tree appears in the top, left hand corner of the document and has a size of 600 x 600 pixels.
  • I would like the complete tree to appear within the center of the document and have a 200 pixel margin surrounding it.
Is this do-able?

I have read the JGoTreeAutoLayout API… my apologies if I missed something.

Thanks

Greg

Just me again,

Using layout.setArrangementOrigin(new Point(500,500)) almost satisfies my requirement, however this method only defines the top, left hand corner of the tree, not it’s center. Using my Use Case, this command will position my tree with a margin of top 500, left 500, right -100, bottom -100.

Any suggestions would be great!

You could make your autolayout a 2 step process. First, let the autolayout algorithm perform the layout. Second, calculate the offset required to move the entire tree to the location you want. Then iterate through all the nodes on the diagram and set a new location by adding the offset to the current node location.