Can you explain how the coordinates of X and Y are used when creating different objects that are appended to the same node group. How does one get control of where objects are rendered?
The behavior at first seems inconsistent as there is a mix of physical and logical relationships between coordinates for the group and objects (child diagram nodes). Also, depending on the order you place nodes into a group, the nodes are rendered at different locations.
Except for the very first node added to a node group, the other nodes are not rendered where one expects. I used to the following code to illustrate:
I used the following code:
Group g = new Group();
Rectangle r1 = new Rectangle(10, 20, 50, 50);
Rectangle r2 = new Rectangle(5, 10, 50, 50);
TextNode t1 = new TextNode(“My Text Box”);
PointF pf = new PointF(30, 50);
Size = new Size(200, 15);
- - -
If I create in code and place three nodes into a group (two rectangles and one text node), that are then placed on the diagram I get the following:
1. The first rectangle (x, y) coordinates are relative to the physical model. So, if x = 10 and Y = 20 the rectangle will be rendered with the upper left corner at (10, 20) on the physical model.
2. The second rectangle (x, y) coordinates are relative to the first node (or the boundary created by the first node). So, if x = 5 and Y = 10, the rectangle is rendered with the upper left corner at (15, 30) on the physical model (a positive increase down and to the right of the first rectangle; not up and to the left as I expected.)
(At this point it seems a bit odd, but understandable. The first node sets the relative boundary for all other objects.)
3. The third object (a text node) coordinates are perplexing and seems to have a negative offset relative to the first (or last) node (x, y) coordinates.
So if, x = 30 and Y = 50 then the text node is rendered with the upper left corner at (-20, -30) on the physical model. However, this is not always the case. It seems where a text node is rendered may be based an offset to the (x, y) coordinates of the pervious node added to the node collection.
At no time did I change any rotation properties (or any other properties except the x, y coordinates during object creation).
- - -
I expected that the (x, y) coordinates of an node (be it a rectangle or text node) are relative to an imaginary set of fix/static points in the container (in this case the node group). And, the container sets the physical location in the model.
I can work around the differences in the meaning of (x, y) coordinates between the first and second nodes. However, I need to be able to pin the upper left corner of the text node to a specific (x, y) coordinates relative to the group. When I set the text node’s PontF to (30, 50), I expect the upper left corner to be at (30, 50). So, if I place the group at (100, 100) the upper left corner of the text node will be at (130, 150) on the physical model.
I also expect that regardless of the order objects are placed into the group, the objects will always be rendered in the same place (although z ordered differently). Using the code example above, changing appending order results in very differnt renderings.