Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Anchor points (Read 4529 times)
jagdipa
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 52
Joined: Jun 23rd, 2011
Anchor points
Jul 22nd, 2011 at 2:32pm
Print Post  
What is the easiest method of getting all the incoming links to go into a node from the top middle, and all the outgoing links go out from a node from the bottom middle?

I have been messing with the setAnchorPoint(), but have been unsuccessful so far.
  
Back to top
 
IP Logged
 
Iva
Junior Member
**
Offline


MindFusion support

Posts: 55
Joined: Aug 6th, 2005
Re: Anchor points
Reply #1 - Jul 24th, 2011 at 4:19pm
Print Post  
There's a predefined anchorPattern that places the links exactly how you want them. Here is the code that assigns the pattern to a node on the client side:

Code
Select All
var scriptHelper = applet.getScriptHelper();
var pattern = scriptHelper.anchorPatternFromId("TopInBottomOut");
node.setAnchorPattern(pattern); 


I hope this helps.
  
Back to top
 
IP Logged
 
jagdipa
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 52
Joined: Jun 23rd, 2011
Re: Anchor points
Reply #2 - Jul 25th, 2011 at 8:45am
Print Post  
Hi Stoyo,

I have tried this, and it doesnt seem to work. I thought this was because I am setting the layout to flowchart afterwards, but removing this didnt help. I have also tried all the options for Diagram-RoutingOptions-Anchoring with no success. Can you help?

Here is my code:

<ndiag:DiagramView
                           ID="DiagramView1"
                           runat="server"
                           ClientSideMode="JavaApplet"
                           Height="600px"
                           Width="100%"
                           JarLocation="JDiagram.jar"
                           AllowInplaceEdit="true"
                           Behavior="Modify"
                           Diagram-RoutingOptions-Anchoring="Reassign"
                           Diagram-AllowSelfLoops="false"
                           Diagram-AllowSplitLinks="false"
                           Diagram-AllowUnanchoredLinks="false"
                           Diagram-AllowUnconnectedLinks="false"
                           Diagram-AutoResize="AllDirections"
                           AppletStartedScript="onAppletStarted"
                           NodeCreatedScript="onNodeCreated"
                           DelKeyAction="DeleteSelectedItems">
                           <Diagram LinkHeadShape="Triangle" AlignToGrid="False" AllowLinksRepeat="False"
                               BackBrush="s:#FFE3E3E3" DefaultShape="Rectangle" LinkBrush="s:#FFABABAB"
                               LinkSegments="2" LinkStyle="Cascading" />
                   </ndiag:DiagramView>











<script type="text/javascript">

       var applet;
       var diagram;
       var script;


       function initialiseVariables()
       {
           applet = <%= DiagramView1.AppletElement %>;
           diagram = applet.getDiagram();
           script = applet.getScriptHelper();
       }

       function onAppletStarted() {
           initialiseVariables();
       }
      

       function onNodeCreated(sender, args)
       {
           initialiseVariables();
           var node = args.getNode();

       var r = node.getBounds();
       var point = script.createPointF(
       r.getX() + r.getWidth() / 2,
       r.getY() + r.getHeight() / 2);

       var nodes = diagram.getNodesAt(point);

       if (nodes.size() < 2) {
               diagram.getNodes().remove(args.getNode());
           }  else {
       diagram.getFactory().createDiagramLink(nodes.get(1), args.getNode());

               //Set the numbering
               var link = node.getIncomingLinks().get(0);
               var parentNode = link.getOrigin();
               var siblingsCount = parentNode.getOutgoingLinks().size();
               //Already added this link, so dont increment the siblingsCount
               node.setTag(parentNode.getTag() + '.' + (parseInt(siblingsCount)));
              
               //Set the ID for the shape
               var shapeId = diagram.getTag();
               node.setId(shapeId);
               diagram.setTag(parseInt(shapeId) + 1);

               //Set the anchoring
               var pattern = script.anchorPatternFromId("TopInBottomOut");
               node.setAnchorPattern(pattern);

               redrawLayout(diagram);

           }
       }


       function redrawLayout()
       {
           var diag = applet.getDiagramView().getDiagram();
           var tl = applet.getScriptHelper().createFlowchartLayout();
           tl.arrange(diag);
       }
   


</script>
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Anchor points
Reply #3 - Jul 25th, 2011 at 9:56am
Print Post  
Try setting the Anchoring on the layout object (rather than on the RoutingOptions).

Code
Select All
function redrawLayout()
{
      var diag = applet.getDiagramView().getDiagram();
      var tl = applet.getScriptHelper().createFlowchartLayout();
      tl.setAnchoring(2); // 2 = Reassign
      tl.arrange(diag);
} 


Regards,
Meppy
  
Back to top
 
IP Logged
 
jagdipa
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 52
Joined: Jun 23rd, 2011
Re: Anchor points
Reply #4 - Jul 25th, 2011 at 2:09pm
Print Post  
Hi Meppy,

That hasnt work. Is there anything else I am missing?
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Anchor points
Reply #5 - Jul 25th, 2011 at 2:52pm
Print Post  
It turns out that the Flowchart layout ignores link anchoring. I suspect this is by design since this layout is very strict about the positioning of the links. Applying anchoring at the end of the layout will have peculiar results. To see the effect, you can run the following code after the layout has executed in order to apply anchoring to the links manually:

Code
Select All
for (var i = 0; i < diagram.getLinks().size(); i++)
{
	var link = diagram.getLinks().get(i);
	link.setOriginAnchor(-1);
	link.setOriginAnchor(1);
	link.setDestinationAnchor(-1);
	link.setDestinationAnchor(0);
} 


Regards,
Meppy
  
Back to top
 
IP Logged
 
jagdipa
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 52
Joined: Jun 23rd, 2011
Re: Anchor points
Reply #6 - Jul 26th, 2011 at 8:19am
Print Post  
Is there any other diagram type I can use to get the image to look like this:

http://imageshack.us/photo/my-images/263/teaqg.jpg/
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Anchor points
Reply #7 - Jul 26th, 2011 at 8:59am
Print Post  
You can get near identical results using TreeLayout, but in this case you have to guarantee that the structure being arranged is a tree.

If this is not the case, you can probably still use FlowchartLayout with addition post-processing of links to ensure that they meet your criteria.

Regards,
Meppy
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint