Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How to position a diagram so that a particular node is in the center (Read 1918 times)
jlj30
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 183
Joined: Sep 4th, 2011
How to position a diagram so that a particular node is in the center
Dec 31st, 2012 at 4:57pm
Print Post  
Hi,

I have a diagram which is rendered using the Java applet and has an Overview control placed in the upper left corner.
The diagram will almost always be bigger than the physical screen and will have scroll bars.

When the diagram is initially displayed, I would like the root node (I'm using TreeLayout) to be centered vertically and horizontally.  See the attached screenshot for an example of what I would like to do - Incident Management is the node in question.

Any suggestions on an approach?

Thanks in advance and Happy New Year (if it's not already 2013 where you are).

Jim

  

NetDiagram_-_centering_process_name_on_mind_map.png (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to position a diagram so that a particular node is in the center
Reply #1 - Jan 2nd, 2013 at 8:02am
Print Post  
Hi,

Try calling bringIntoView from the AppletStarted handler:

Code
Select All
function onAppletStarted()
{
	var diagram = <%= diagramView.AppletElement %>.getDiagram();
	var view = <%= diagramView.AppletElement %>.getDiagramView();

	var root = diagram.getNodes().get(0);
	view.bringIntoView(root);
} 



bringIntoView will center on the specified node if it isn't already shown in the current viewport, so it should work for the root shown in your screenshot. If the node is initially visible, bringIntoView does nothing and wouldn't center on your root if the diagram was smaller. In such case you could first scroll to a position where the root is off-screen, before calling bringIntoView.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint