Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Anchors(Locating anchors properly)
Anchors [message #1062891] Tue, 11 June 2013 09:23 Go to next message
John Cole is currently offline John ColeFriend
Messages: 66
Registered: June 2013
Member
Hello everyone,

I am working on my new Graphiti diagram and actually got some problems with the location of anchors.

I used the code in the Graphiti tutorial, where a anchor on the middle right side is located. This is the code:

		// create an box relative anchor at middle-right
		final BoxRelativeAnchor boxAnchorLeft = peCreateService
				.createBoxRelativeAnchor(containerShape);
		boxAnchorLeft.setRelativeWidth(1.0);
		boxAnchorLeft.setRelativeHeight(0.5);
		// anchor references visible rectangle instead of invisible rectangle
		boxAnchorLeft.setReferencedGraphicsAlgorithm(roundedRectangle);
		// assign a graphics algorithm for the box relative anchor
		Rectangle rectangleLeft = gaService.createRectangle(boxAnchorLeft);
		rectangleLeft.setFilled(true);
		gaService.setLocationAndSize(rectangleLeft, -2 * edge, edge, 2 * edge, 2 * edge);
		rectangleLeft.setForeground(manageColor(CLASS_FOREGROUND));
		rectangleLeft.setBackground(manageColor(CLASS_BACKGROUND));
		// call the layout feature
		layoutPictogramElement(containerShape);


Now I want to move that anchor to the middle left side.
I tried to experiment with the parameters in setLocationAndSize(), setRelativeWidth() and setRelativeHeight() but unfortunately I do not get reasonable results.

I do not understand the way the methods work and depend on each other. Editing the third parameter in setLocationAndSize() (the y coordinate) moves the anchor on the y axis but the effects on chaging the second parameter (the x coordinate) seems not logical to me. A bigger number moves the anchor to the left and if I resize the EClass the anchor is not docked to the left edge (like the right anchor in the Graphiti tutorial).

Could someone explain how they work and how I can create two anchors, one docking at the middle-right and on on the middle-left side? Also two other anchors at the middle-top and middle-bottom.

I'm grateful for any help!
Re: Anchors [message #1064075 is a reply to message #1062891] Mon, 17 June 2013 13:46 Go to previous message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
John,

depending on the structure of a diagram, this might become rather tricky. In
general every graphics algorithm is located relative to its next active
parent shape (or rather the shape's graphics algorithm), which again is
located relative to its parent...

Did you see
http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.graphiti.doc%2Fresources%2Fdocu%2Fgfw%2Fanchors.htm&cp=30_1_3_8_1
? It provides an introduction to the specific anchors in Graphiti.

Michael
Previous Topic:decorating visual representation of business objects with icons provided from outside of the editor
Next Topic:Insert image as shape
Goto Forum:
  


Current Time: Fri Apr 26 12:10:31 GMT 2024

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

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

Back to the top