Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Autosize Doc to items (Read 2065 times)
tronied
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 17
Joined: May 7th, 2008
Autosize Doc to items
Apr 2nd, 2009 at 4:28pm
Print Post  
Is it possible to autosize the jdiagram document to the size of the flowchart? I know there is a FlowChart.setAutoSizeDoc(AutoSize.AllDirections), but it doesn't shrink back once an object has been dragged. I don't mind if there isn't a feature to automatically shrink back to the correct size when dragging, but I am having trouble with a fit doc to chart button i'm trying to make. So far I have:

Code
Select All
        Rectangle2D rect = csiFlowChart.getDocBounds();
        csiFlowChart.setAutoSizeDoc(AutoSize.None);
        BoxList oBoxes = csiFlowChart.getBoxes();
        double dRight = 0.0;
        double dBottom = 0.0;
        for (Box oBox : oBoxes) {
            if (oBox.getBounds().getX() + oBox.getBounds().getWidth() > dRight) {
                dRight = oBox.getBounds().getX() + oBox.getBounds().getWidth();
            }
            if (oBox.getBounds().getY() + oBox.getBounds().getHeight() > dBottom) {
                dBottom = oBox.getBounds().getY() + oBox.getBounds().getHeight();
            }
        }
        rect.setRect(rect.getX(), rect.getY(), dRight + 5, dBottom + 5);
        csiFlowChart.setDocBounds(rect);
        csiFlowChart.setAutoScroll(true);
        csiFlowChart.setAutoSizeDoc(AutoSize.AllDirections); 



The above seems to shrink the document to half the size of the chart for some reason.

The reason I am asking is that sometimes mistakenly, a box is dragged well outside the area of the flowchart, and with no way of shrinking the document back down, it remains huge leading to scrollbars being constantly visible with nothing off-screen.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Autosize Doc to items
Reply #1 - Apr 2nd, 2009 at 5:14pm
Print Post  
setRect() expects width and height arguments, not right and bottom. Anyway there's the Diagram.resizeToFitItems() method, which might be called fitDocToObjects in the older version you are using.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
tronied
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 17
Joined: May 7th, 2008
Re: Autosize Doc to items
Reply #2 - Apr 3rd, 2009 at 8:04am
Print Post  
Ah, thats where I was going wrong then. I should have added the positive X and Y rect values to the right and bottom (width and height basically) to get it working. The start X and Y positions of the rect were something like -36.0f, -55.0f, so to get the correct width and height that would make sense.

Anyway, no need now with the resizeDocToItems() functions. Thanks Smiley
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint