Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How to position a link between the center borders (Read 3296 times)
Zaplobe
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 4
Joined: May 4th, 2009
How to position a link between the center borders
May 4th, 2009 at 12:38pm
Print Post  
Hello,

I want to position the links between each of the nodes to be from the border of a node at its middle to the middle of the border of the next node. I tried different things but cant get it. Now, the links go from the corner of a node the corner of the next node. I just want the links to be at the middle of the borders instead of at the corners. How can i achieve this?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to position a link between the center bord
Reply #1 - May 4th, 2009 at 2:24pm
Print Post  
Hi,

Try calling DiagramNode.setAnchorPattern(AnchorPattern.fromId("Decision2In2Out")) for each node.

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


I love YaBB 1G - SP1!

Posts: 4
Joined: May 4th, 2009
Re: How to position a link between the center bord
Reply #2 - May 4th, 2009 at 3:36pm
Print Post  
hi,

still its not working..

heres are parts of the code:

diagram1 = new
com.mindfusion.diagramming.Diagram();

diagramView2 = new DiagramView(diagram1);

diagram1.setAdjustmentHandlesSize(3.0F);

diagram1.setAutoResize(7);

diagram1.setBackBrush(new SolidBrush(new Color((int)0, (int)102, (int)153)));

diagram1.setDefaultShape(recShape);

diagram1.setFont(new java.awt.Font("Times New Roman", 0, 12)); // NOI18N

diagram1.setLinkBaseShapeSize(2.5F);

diagram1.setLinkCascadeOrientation(com.mindfusion.diagramming.jlayout.Orientati
on.Vertical);

diagram1.setLinkHeadShape(ArrowHead.Arrow);

diagram1.setLinkSegments((short)2);

diagram1.setLinkStyle(com.mindfusion.diagramming.LinkStyle.Cascading);

diagram1.setLinksSnapToBorders(true);

diagram1.setMeasureUnit(GraphicsUnit.Point);

diagram1.setRecursiveExpand(true);

diagram1.setRouteLinks(true);

diagram1.setShadowOffsetX(2.0F);

diagram1.setShadowOffsetY(2.5F);

diagram1.setShapeBrush(new SolidBrush(new Color((int)128, (int)192, (int)128)));

diagram1.setTablePen(new Pen());

diagramView2.setBehavior(Behavior.Modify);

private void performLayout()

{


TreeLayout tl = new TreeLayout();



tl.setRoot(null);


tl.setType(TreeLayoutType.Centered);


tl.setDirection(com.mindfusion.diagramming.jlayout.TreeLayoutDirection.TopToBott
om);


tl.setLevelDistance(50);


tl.setNodeDistance(15);


tl.setKeepRootPosition(true);


tl.setReversedLinks(false);


tl.setLinkStyle(TreeLayoutLinkType.Straight);



tl.arrange(diagram1);

}

int height = 0;

private void buildTree()
{

// create a box that will be a root in our hierarchy

ShapeNode root = diagram1.getFactory().createShapeNode(0,0,100,50,recShape);

root.setText("root");
DiagramNode root1 = root;
root1.setAnchorPattern(AnchorPattern.fromId("Decision2In2Out"));
height = 50;

ShapeNode Node1 = diagram1.getFactory().createShapeNode(50,50,105,50,recShape);
Node1.setText("Node1");
Node1.setAnchorPattern(AnchorPattern.fromId("Decision2In2Out"));

DiagramLink arrow = diagram1.getFactory().createDiagramLink(root1, Node1);
arrow.setSegmentCount(2);



arrow.setStyle(com.mindfusion.diagramming.LinkStyle.Cascading);
arrow.setSnapToNodeBorder(true);

ShapeNode Node2 = diagram1.getFactory().createShapeNode(100,100,105,50,recShape);
Node2.setText("Node2");
Node2.setAnchorPattern(AnchorPattern.fromId("Decision2In2Out"));

arrow = diagram1.getFactory().createDiagramLink(Node1, Node2);



arrow.setSegmentCount(2);



arrow.setStyle(com.mindfusion.diagramming.LinkStyle.Cascading);
arrow.setSnapToNodeBorder(true);

performLayout();


diagram1.resizeToFitItems(40);
}

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to position a link between the center bord
Reply #3 - May 5th, 2009 at 2:45pm
Print Post  
What does the performLayout() method do? If it applies some of the built-in layout algorithms, try setting the Anchoring property of the respective layout class.
  
Back to top
 
IP Logged
 
Zaplobe
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 4
Joined: May 4th, 2009
Re: How to position a link between the center bord
Reply #4 - May 5th, 2009 at 10:18pm
Print Post  
the performLayout() medthod makes a new treeLayout() then uses some of the methods inside this Layout. I've tried to use the setAnchor method of this layout but it didnt work i even tried to input to the method diffrent nubmers but still not working. How should i use it? And I also noticed something: when i call the setAnchorPattern(AnchorPattern.fromId("Decision2In2Out")); for a node and not for the next node, The arrow will start at the corner of the node and point to the middle of the border of the next node. If i called it for that next node but not for the previous one the opposite happens, The arrow starts at the middle of the border of the previous node and will point to the corner of the next node. Else, it starts from the corner of the previous node and ends the corner of the next node.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to position a link between the center bord
Reply #5 - May 6th, 2009 at 8:26am
Print Post  
Pass either Anchoring.Keep or Anchoring.Reassign to TreeLayout.setAnchoring; the former if you explicitly set the anchor points and want to keep them, the latter to let TreeLayout choose some anchor points. Depending on the tree direction, you might have to define custom AnchorPattern objects, e.g. none of the predefined ones will do for right-to-left direction.

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


I love YaBB 1G - SP1!

Posts: 4
Joined: May 4th, 2009
Re: How to position a link between the center bord
Reply #6 - May 6th, 2009 at 6:30pm
Print Post  
Hi,

I defined diffrent Anchor pattrens for the nodes. the Anchor points that were used represented the middle of the borders of each of the nodes. Then I set the anchor patterns of the arrows to the ones i defined, and it worked. The setAnchoring method of the tree layout seems to make no difference but i choosed to keep it while passing to it Anchoring.keep just for convenience.

Thanks for helping me out.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint