I am trying to implement a left to right tree (single root node) with JGoTextNode and JGoLabeledLinks. I want the graph view to have a fixed width and height. The tree needs to dynamically shrink the size of the nodes to fit the fixed size of the view. It works fine with a certain node size. However, when I reduce the node size, the tree graph is not rendered properly. Do you have any suggestions?

The easiest thing is to create the diagram and then rescale the view so that it fits. Call GoView.RescaleToFit.

Hi Walter,

I did not see rescaleToFit API in JGoView. Where is this rescaleToFit API?
Sorry, I didn't recognize you were talking about JGo. I have moved this topic from the GoDiagram forum to this forum.
You're right -- that method isn't defined on JGoView. Here's one definition:
public void rescaleToFit() {
Dimension dispSize = getCanvas().getSize();
Rectangle docbounds = getDocument().computeBounds();
double newscale = 1;
if (docbounds.width > 0 && docbounds.height > 0)
newscale = Math.min((dispSize.width / (double)docbounds.width), (dispSize.height / (double)docbounds.height));
if (newscale > 1)
newscale = 1;
setViewPosition(docbounds.x, docbounds.y);
This need not be a method on JGoView of course. You can easily parameterize it to take a JGoView as an argument.

I have a JPanel panelA which contains a JGoView. I have another JPanel

panelB which will contain panelA. I am trying to have the JGoView
canvas color the same as the background color of panelB. I made panelA
and JGoView opaque but I still see the white color on the JGoView canvas.
Any suggestions?

If you called JGoView.setBackground and that didn’t have any effect, is that because you had set JGoDocument.setPaperColor to be non-null?

Actually, what I want is JGoView to be opaque. This way, the canvas/view color will be the same as the background of its container. How do I do this? I tried setting setOpaque(true) on the JGoView but I still see a white

color on the canvas. Any suggestions?

JGoView is always opaque. Did you try calling JGoView.setBackground or JGoDocument.setPaperColor?