Skip to main content


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 14:26 Go to next message
Surya Kathayat is currently offline Surya KathayatFriend
Messages: 44
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 480 times)

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

Report message to a moderator

Re: Maintaing a list of BoxRelativeAnchors in a Shape [message #933065 is a reply to message #931788] Thu, 04 October 2012 17:45 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Hi Surja,

You would do that in the add method of your add connection feature. There you can navigate from your chopbox anchor or your shape to the right box relative anchor and set that as anchor for the new connection. This is possible for both source and target anchor.

Michael
Re: Maintaing a list of BoxRelativeAnchors in a Shape [message #933869 is a reply to message #933065] Fri, 05 October 2012 12:14 Go to previous messageGo to next message
Surya Kathayat is currently offline Surya KathayatFriend
Messages: 44
Registered: July 2012
Member
Thanks Michael.

Again, how to use/attach custom properties(for example assign Id to each BoxRelativeAnchor in a ContainerShape) to the anchors when creating them?
I don't find any useful information on this in Javadoc for BoxRelativeAnchor.

Best Regards
Surya
Re: Maintaing a list of BoxRelativeAnchors in a Shape [message #933888 is a reply to message #933869] Fri, 05 October 2012 12:35 Go to previous message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Hi Surya,

a BoxRelativeAnchor is also a PropertyContainer and has a list attribute properties. See http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.graphiti.doc%2Fresources%2Fdocu%2Fgfw%2Fuser-defined-properties.htm&cp=23_1_10 for details on user defined properties.

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


Current Time: Sat Apr 20 01:11:09 GMT 2024

Powered by FUDForum. Page generated in 0.03143 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top