Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic overview does not sychronize with a diagram changes (Read 6553 times)
Jan Meyer
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 23
Joined: Feb 26th, 2012
overview does not sychronize with a diagram changes
Aug 23rd, 2012 at 7:38am
Print Post  
When running the following test program and draw shapes the overview will not update. Pressing the UPDATE-Button has not effect, too. Only after clicking on the overview component it will update with the current content of the diagram view.

Only if the "
Code (Java)
Select All
overview.setDiagramView(diagramView); 

" statement is placed at the end of the constructor the overview is connected with the diagram view properly. But that's not helpful if your diagram view is handling more the one diagram.

So my questions are:

* What went wrong?

* What should be inside the actionPerformed() statement

Regards,
Jan


Code (Java)
Select All
public class TestOverview extends JFrame {
	private static final long serialVersionUID = 1L;
	final DiagramView diagramView = new DiagramView();
	final Overview overview = new Overview();
	final Diagram diagram = new Diagram();;


	public TestOverview() {
		setSize(new Dimension(600, 400));
		JScrollPane scrollPane = new JScrollPane(diagramView);
		overview.setPreferredSize(new Dimension(200, 80));
		overview.setDiagramView(diagramView);
		diagramView.setDiagram(diagram);

		DiagramNode mainNode1 = diagram.getFactory().createShapeNode(10, 10, 20, 20);
		JButton btnUpdate = new JButton("UPDATE") {
			public void actionPerformed(ActionEvent e) {
				TestOverview.this.overview.repaint(); // no effect
				TestOverview.this.overview.validate();// no effect
				TestOverview.this.overview.update();// no effect
				TestOverview.this.overview.setDiagramView(null);        //
				TestOverview.this.overview.setDiagramView(diagramView); // no effect
				TestOverview.this.overview.doLayout();// no effect
				TestOverview.this.diagramView.repaint();// no effect

				TestOverview.this.diagramView.validate();// no effect
				TestOverview.this.diagram.repaint(); // no effect
				TestOverview.this.diagram.notifyAll(); // no effect

				TestOverview.this.overview.requestFocus(); // no effect
				TestOverview.this.overview.setFocusable(true); // no effect

				TestOverview.this.overview.setBackgroundColor(Color.white); // no effect
				TestOverview.this.overview.update();// no effect
			}
		};

		this.overview.setBackground(Color.WHITE);
		getContentPane().add(scrollPane, BorderLayout.CENTER);
		getContentPane().add(overview, BorderLayout.EAST);
		getContentPane().add(btnUpdate, BorderLayout.SOUTH);

		/***********************************************************************
		overview.setDiagramView(diagramView); ** this would work
 		***********************************************************************/
	}

	public static void main(String[] args) {
		TestOverview window = new TestOverview();
		window.setVisible(true);

	}

}
 

  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: overview does not sychronize with a diagram changes
Reply #1 - Aug 23rd, 2012 at 8:27am
Print Post  
PrintPreview shows only a snapshot of the diagram. You can recreate it by calling the PrintPreview.createPrintPreview() method.

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


I Love MindFusion!

Posts: 23
Joined: Feb 26th, 2012
Re: overview does not sychronize with a diagram changes
Reply #2 - Aug 23rd, 2012 at 8:50am
Print Post  
I am sorry, but can't see the relation between the com.mindfusion.diagramming.PrintPreview and com.mindfusion.diagramming.Overview class.

[quote]The Overview control provides a scaled-down view of Diagram contents and allows scrolling and zooming the diagram with the mouse. [end quote]

Testprogram demonstrates the problem quite clearly. Just draw a shape and you will recognize that overview will get updated until you perform a mouse click on that overview.

Regards,
Jan

  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: overview does not sychronize with a diagram changes
Reply #3 - Aug 23rd, 2012 at 10:21am
Print Post  
Overview.setDiagramView connects an event listener to the Diagram.repaint event and the Overview updates automatically when the diagram raises it. If you are changing view's diagram dynamically, you will have to call setDiagramView again to attach handlers to the new diagram, even if it's the same view shown in Overview.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint