Document size fits the frame


#1

Hi,
Suppose the frame of a JGoView for display a JGoDocument is 500 in height and 500 in width. I can open jgodocuments in this frame. some document has only 3 linked nodes, some has a lot nodes. I want the document to be viewed fills the exact size of the frame. The large documents will be shrinked to the frame, the small document will be enlarged according to the size of the frame.
I know that there is a method called setScale in the jgoview, how to utilize the ratio of the frame size and document size to accomplish the task? I also check the zoomIn and out methods in the LayoutDemo, still have not got any clue to do this task. Please give me any sugguestions, thanks a lot.
Li


#2

Well, actually what I want to do is in the JGoOverview Frame to display the document according to the JGoOverview frame which is a dialog pop up.
Thanks again.
Li


#3

Look at the zoomToFit method in ProcessView.java of the Processor example.


#4

thanks a lot. now the jgodocument size is rescheduled according to the size of the dialog. I have encountered another problem. on the overview panel, there is a square for user to move around. I set the size of this square is 25% of the dialog area. But if I move the jgoView’s scroll bar, the overview square size is doubled automatically?
myOverview.getOverviewRect().setSize(myOverviewDialog.getWid th()/3, myOverviewDialog.getHeight()/3);
how can fix the size of the overview square?


#5

The size of the OverviewRectangle should depend only on the size of the observed view relative to the size of that view’s document. It should have no relationship to the size of the overview component.
Perhaps the document is larger than you want it to be?


#6

I don’t understand what you mean: the document is larger than I want it to be.
The OverviewRectangle is automatically calculated when I call overview.setObserved(myView)?
I do see the rectangular size was temporilly changed by myOverview.getOverviewRect().setSize(40, 40) ,
void jMenuItem_OverView_actionPerformed(ActionEvent e){
setStatus("");
WorkflowView view = (WorkflowView)jTabbedPane1.getSelectedComponent();
myOverview = new JGoOverview();
myOverview.setObserved(view);
if(myOverviewDialog == null){
myOverviewDialog = new JDialog(view.getFrame(), “Overview”, false);
}


myOverviewDialog.getContentPane().setLayout(new BorderLayout());
myOverviewDialog.getContentPane().add(myOverview, BorderLayout.CENTER);
myOverviewDialog.setSize(400,400);
myOverview.getOverviewRect().setSize(40,40);
Dimension overDim = myOverview.getSize();

double newscale = 1;
if (!view.getDoc().isEmpty()){
Rectangle docbounds = new Rectangle(view.getDoc().computeBounds());
// include the (0, 0) point
if (docbounds.x > 0) {
docbounds.width += docbounds.x;
docbounds.x = 0;
}
if (docbounds.y > 0) {
docbounds.height += docbounds.y;
docbounds.y = 0;
}
newscale = Math.min((myOverviewDialog.getWidth()/(double)docbounds.width),
(myOverviewDialog.getHeight()/(double)docbounds.height));
}
//newscale *= myOverview.getScale();
System.out.println(" newscale is : "+ newscale);

if (newscale > 1)
newscale = 1;
myOverview.setScale(newscale);
myOverview.setViewPosition(0, 0);
myOverviewDialog.pack();
myOverviewDialog.show();
setStatus(“Overview the workflow”);
}


#7

I’m just saying that JGoOverview.updateRectFromView() is called frequently, and it sets the bounding rectangle of the OverviewRect to match the observed view’s extent in the document.
Trying to set the size of the OverviewRect is futile until you change the behavior of updateRectFromView. Are you just trying to change the scale of the observed view?


#8

I have changed the scale of the observed view calling the setScale method. What I want to do is to reset the rectangle in the overOview, it seem quite big on the overView dialog frame comparing to the size of the oberved document.
Thank you for your explanation. I got what you mean about the size of overview Rectangle.
The overview rectangle is set by JGoOverview.updateRectFromView() according to the size of the observed view’s extent in the document. So if I change the scale of the observed view, the OverviewRec would be updated by JGoOverview.updateRectFromView(). Or in another word: If I changed the observed view’s extent in the document, the rectangle could be updated accordingly too.
How to do that? I check the example code, it simple passed the JGoview to JGoOver to observe. It did not call setSize method, such as JGoview.setSize, etc.
Li


#9

The OverviewRect should get updated automatically.
If you run the Demo1 sample, and you zoom in and out of the main view, while the Overview window is visible, don’t you see the OverviewRect automatically changing size?