Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Maintaing a list of BoxRelativeAnchors in a Shape
Maintaing a list of BoxRelativeAnchors in a Shape [message #931788] Wed, 03 October 2012 10:26 Go to previous message
Surya Kathayat is currently offline Surya Kathayat
Messages: 30
Registered: July 2012
Member
Hi,

I am trying to have incoming links to end at the middle of top line of a node(e.g. rectangle) and all outgoing links to start at the middle of the buttom line of a graphical node. See in the figure, incoming links should end on A and outgoing links on B.

index.php/fa/11705/0/

How this could be done? I though of using BoxRelativeAnchors. I created two box relative anchors and added to the pictorial element of a graphical node, as below.

But I am not sure how can I set proper anchors at the start and end of a connection in the add method of add link feature i.e. in connection.setStart(??); connection.setEnd(??); ??.



@Override
public PictogramElement add(IAddContext context) {
...
...
		final BoxRelativeAnchor boxAnchorIn = peCreateService.createBoxRelativeAnchor(containerShape);
		boxAnchorIn.setRelativeWidth(0.5);
		boxAnchorIn.setRelativeHeight(0.0); 
		boxAnchorIn.setReferencedGraphicsAlgorithm(roundedRectangle);
	      final Rectangle rectangle = gaService.createRectangle(boxAnchorIn);      
	      rectangle.setForeground(manageColor(IdmColors.TASK_BORDER_COLOR));
	      rectangle.setBackground(manageColor(IdmColors.TASK_FILL_COLOR));
	      rectangle.setLineWidth(2);
	      gaService.setLocationAndSize(rectangle, 0, 0, 5, 5);

		
		final BoxRelativeAnchor boxAnchorOut = peCreateService.createBoxRelativeAnchor(containerShape);
		boxAnchorOut.setRelativeWidth(0.5);
		boxAnchorOut.setRelativeHeight(1.0);  
		boxAnchorOut.setReferencedGraphicsAlgorithm(roundedRectangle);
	      final Rectangle rectangleOut = gaService.createRectangle(boxAnchorOut);      
	      rectangleOut.setForeground(manageColor(IdmColors.TASK_BORDER_COLOR));
	      rectangleOut.setBackground(manageColor(IdmColors.TASK_FILL_COLOR));
	      rectangleOut.setLineWidth(2);
	      gaService.setLocationAndSize(rectangleOut, -5, -5, 5, 5);
...
...
}
  • Attachment: anchors.gif
    (Size: 5.54KB, Downloaded 114 times)

[Updated on: Wed, 03 October 2012 11:29]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Previous Topic:Setting BoxRelativeAnchor at the source of ConnectionContext does work!!
Next Topic:Graphiti framework and decorators
Goto Forum:
  


Current Time: Sat May 25 13:46:43 EDT 2013

Powered by FUDForum. Page generated in 0.05632 seconds