Author Topic: Coordinates of connectors  (Read 9462 times)

KristoferG

  • EA Novice
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
Coordinates of connectors
« on: January 29, 2015, 05:50:22 pm »
Hi!

We need a more customized website than what we can get with the built-in html generator. One of the features we need/want are clickable connectors (to show the connector information).

So I have been looking at the DiagramLinks class, and the two attributes Geometry and Path, and Path gives me the coordinates of the bends.

In Geometry there is SX, SY, EX and EY, which seems to give the position of the connector on the connected DiagramObject, related to that DiagramObject's center position.

At first it seemed that SX and SY gave me the position on the source object, but that is not always true. Sometimes when I reposition the connector and think that SX should be changed, it instead changes EX.

Is there any explanation somewhere to how I cand find the coordinates of each connector on a diagram, so I can build a html map area based on it?

Or, if it is easier, to get the position of the name of the connector, to make the name clickable.

/Kristofer

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Coordinates of connectors
« Reply #1 on: January 29, 2015, 06:16:37 pm »
The best chance to find some kind of documentation about this are books of Thomas Kilian

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Coordinates of connectors
« Reply #2 on: January 29, 2015, 08:57:00 pm »
I guess Geert is right ;) If you don't find what you need you're free to ask and I'll do my best.

q.

KristoferG

  • EA Novice
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
Re: Coordinates of connectors
« Reply #3 on: January 30, 2015, 01:44:45 am »
Hi again!

I had a look in Inside Enterprise Architect and there is a lot of great information that i will need now and in the future, and some other things that I got confirmed. Great to have something to read instead of guessing and testing.

But I am still confused of the connector coordinates.

The following scenario is probable the reason for my confusion.

If I move the connector position at the start object to another edge of the start object, sx and sy changes (expected). But the values of sx/sy does not necessarily correlate to the graphical position I see in EA or in a saved image.

If I after this move the start object  1 pixel, sx/sy stays the same (expected since I do not change the position of the connector on the object), but the graphical representation of the connector start position is moved (not expected since i only moved the object).

Now sx/sy correlate to the actual graphical position of the connector.

So my conclusion is that I cannot only use sx/sy (and probably the same for ex/ey) to be sure of the position. It works sometimes, and is sometimes broken, and there has to be something else somewhere that is also involved. But what?

It seems that EA knows the connector position all the time (since you can click on it in the GUI), even after closing the application and making sure nothing is cached somewhere. So the information is there somewhere...


/Kristofer

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Coordinates of connectors
« Reply #4 on: January 30, 2015, 01:58:36 am »
Just as an extra information: if you modify a drawing this is not directly reflected in the database/API but only after you save it. Might that explain the confusion (before trying to understand your post in detail ;))

q.

KristoferG

  • EA Novice
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
Re: Coordinates of connectors
« Reply #5 on: January 30, 2015, 02:08:48 am »
This is where i save and then check the database (we are using Oracle as repository, and I use SQL in EA to check the database):

- After I move the connector to another edge (i can see that the EDGE value is changed).

- After I move the object (i see no change to sx/sy nor EDGE in the database).

/Kristofer


qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Coordinates of connectors
« Reply #6 on: January 30, 2015, 07:42:07 am »
I guess I know what you mean. EA draws connectors automatically. This is shown by SX=0;SY=0;EX=0;EY=0;. So if you move client or supplier these coordinates don't change. Once you move the connector these coordinates will change to the position [highlight]relative to the connected element[/highlight]. There is some relation between EDGE and where you moved the connector. But I don't think it makes sense to take care since the SXY/EXY coordinates tell that already.

q.
« Last Edit: January 30, 2015, 09:47:19 am by qwerty »

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8083
  • Karma: +118/-20
    • View Profile
Re: Coordinates of connectors
« Reply #7 on: January 30, 2015, 09:25:13 am »
From memory, sx/sy are relative to the object in some way. So just moving the object won't change those values.
« Last Edit: January 30, 2015, 09:25:24 am by simonm »

KristoferG

  • EA Novice
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
Re: Coordinates of connectors
« Reply #8 on: January 30, 2015, 06:27:52 pm »
Sorry for the lenghty post, put i wanted to include images and what i observe in the database.

This is a simple scenario where you notice that sx is not reliable to use, and ex is somehow involved, but at the same time not...

Step 1: I drag two existing classes onto the diagram and save. In database I have:
Code: [Select]
DiagramID;ConnectorID;Geometry;Style;Hidden;Path;Instance_ID;
80;8;EDGE=1;$LLB=CX=18:CY=13:OX=0:OY=0:HDN=0:BLD=0:ITA=0:UND=0:CLR=-1:ALN=0:DIR=0:ROT=0;LLT=;LMT=CX=54:CY=13:OX=0:OY=0:HDN=0:BLD=0:ITA=0:UND=0:CLR=-1:ALN=0:DIR=0:ROT=0;LMB=;LRT=;LRB=CX=6:CY=13:OX=0:OY=0:HDN=0:BLD=0:ITA=0:UND=0:CLR=-1:ALN=0:DIR=0:ROT=0;IRHS=;ILHS=;;Mode=3;EOID=5C7A0CBE;SOID=104C56E5;Color=-1;LWidth=0;;False; ;31;


Step 2: I change line style to "Orthogonal rounded" and save
Code: [Select]
DiagramID;ConnectorID;Geometry;Style;Hidden;Path;Instance_ID;
80;8;EDGE=1;SX=0;SY=0;$LLB=CX=18:CY=13:OX=0:OY=0:HDN=0:BLD=0:ITA=0:UND=0:CLR=-1:ALN=0:DIR=0:ROT=0;LLT=;LMT=CX=54:CY=13:OX=0:OY=0:HDN=0:BLD=0:ITA=0:UND=0:CLR=-1:ALN=0:DIR=0:ROT=0;LMB=;LRT=;LRB=CX=6:CY=13:OX=0:OY=0:HDN=0:BLD=0:ITA=0:UND=0:CLR=-1:ALN=0:DIR=0:ROT=0;IRHS=;ILHS=;;Mode=3;EOID=5C7A0CBE;SOID=104C56E5;Color=-1;LWidth=0;TREE=OR;;False; ;31;


Step 3: I move the connector (dragging on the vertical line) and save
Code: [Select]
DiagramID;ConnectorID;Geometry;Style;Hidden;Path;Instance_ID;
80;8;EDGE=1;SX=-64;SY=28;EX=-1;EY=0;$LLB=CX=18:CY=13:OX=0:OY=0:HDN=0:BLD=0:ITA=0:UND=0:CLR=-1:ALN=0:DIR=0:ROT=0;LLT=;LMT=CX=54:CY=13:OX=0:OY=0:HDN=0:BLD=0:ITA=0:UND=0:CLR=-1:ALN=0:DIR=0:ROT=0;LMB=;LRT=;LRB=CX=6:CY=13:OX=0:OY=0:HDN=0:BLD=0:ITA=0:UND=0:CLR=-1:ALN=0:DIR=0:ROT=0;IRHS=;ILHS=;;Mode=3;EOID=5C7A0CBE;SOID=104C56E5;Color=-1;LWidth=0;TREE=OR;;False;352:-251;;31;


Step 4: I move the connector again, but this time dragging on the horizontal line, and save
Code: [Select]
DiagramID;ConnectorID;Geometry;Style;Hidden;Path;Instance_ID;
80;8;EDGE=1;SX=-64;SY=28;EX=-44;EY=-5;$LLB=CX=18:CY=13:OX=0:OY=0:HDN=0:BLD=0:ITA=0:UND=0:CLR=-1:ALN=0:DIR=0:ROT=0;LLT=;LMT=CX=54:CY=13:OX=0:OY=0:HDN=0:BLD=0:ITA=0:UND=0:CLR=-1:ALN=0:DIR=0:ROT=0;LMB=;LRT=;LRB=CX=6:CY=13:OX=0:OY=0:HDN=0:BLD=0:ITA=0:UND=0:CLR=-1:ALN=0:DIR=0:ROT=0;IRHS=;ILHS=;;Mode=3;EOID=5C7A0CBE;SOID=104C56E5;Color=-1;LWidth=0;TREE=OR;;False;309:-256;;31;


Step 5: I move the source object 1 pixel to the right and save
Code: [Select]
DiagramID;ConnectorID;Geometry;Style;Hidden;Path;Instance_ID;
80;8;EDGE=1;SX=-64;SY=28;EX=-44;EY=-5;$LLB=CX=18:CY=13:OX=0:OY=0:HDN=0:BLD=0:ITA=0:UND=0:CLR=-1:ALN=0:DIR=0:ROT=0;LLT=;LMT=CX=54:CY=13:OX=0:OY=0:HDN=0:BLD=0:ITA=0:UND=0:CLR=-1:ALN=0:DIR=0:ROT=0;LMB=;LRT=;LRB=CX=6:CY=13:OX=0:OY=0:HDN=0:BLD=0:ITA=0:UND=0:CLR=-1:ALN=0:DIR=0:ROT=0;IRHS=;ILHS=;;Mode=3;EOID=5C7A0CBE;SOID=104C56E5;Color=-1;LWidth=0;TREE=OR;;False;335:-256;;31;


Notice that from step 3 (i have moved the connector for the first time), sx and sy stayes the same, although graphically, the connector is positioned at three different locations relative to the source object. I would have expected sx to be changed.

Any idea how i could figure out the start coordinates in the above scenario? I am stunned.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Coordinates of connectors
« Reply #9 on: January 30, 2015, 08:55:48 pm »
Oh yeeees. I'm stunned too. First off you should send a bug report (and just link to this thread).


I'll try digging into this miracle but right now I have absolutely no idea :-?

q.

KristoferG

  • EA Novice
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
Re: Coordinates of connectors
« Reply #10 on: January 30, 2015, 09:38:02 pm »
I have filed a bug report now.

/Kristofer

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Coordinates of connectors
« Reply #11 on: January 31, 2015, 07:20:18 am »
I found out more: there is a Path column which is getting set once you move one of the elements. It looks like (in the case of orthogonal) EA renders a bend at he position reflected in this coordinate. You can set additional manual bends which are then sent (semi-colon separated) to that list in Path. Conclusion: when you move an element EA generates a manual bend at the position you seen on the diagram. EAUI as usual? Well, we're diving in the deep dark of EA's inner guts. Not always fun ::)

q.

KristoferG

  • EA Novice
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
Re: Coordinates of connectors
« Reply #12 on: February 01, 2015, 05:28:22 am »
Yes, that's true, the Path gives the coordinate's of the bends. And you just gave me an idea.

If Path is empty, it is is a straight line, and sx/sy should be reliable to use, from what I have seen so far in my testing.

If Path is not empty, the first coordinate will be the first bend, and since we use orthogonal connectors, either the x coordinate or the y coordinate is the same where the connector attaches to the object.

So all I need to figure out is where the connected object is, related to this bend (it will be either to the right, left, above or below).

I hope this will work for us. Time will tell when I put this into code next week.

*crossing fingers*

/Kristofer

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Coordinates of connectors
« Reply #13 on: March 03, 2015, 08:58:09 pm »
For those stumbling onto this issue, I had a very similar problem.
I needed order connectors based on their vertical position in a diagram.

In order to do this I needed to know the vertical starting position of the diagramlink.

Here the code (vbscript) that worked for me.
Code: [Select]
'In order to get the height of the starting point we have to get the top position of the starting diagram object
'Then substract add half of the height of the object, and then add the SY value of the geometry
function getStartingHeight(connector, diagramLink, diagram)
      'get the SY value
      dim SY
      SY = 0
      dim SYStart
      dim SYEnd
      SYStart = Instr(diagramLink.Geometry, "SY=")
      if SYStart > 0 then
            SYStart = SYStart + len("SY=")
            SYEnd = Instr(SYStart, diagramLink.Geometry, ";")
            SY = CInt(Mid(diagramLink.Geometry,SYStart, SYEnd - SYStart))
            Session.Output "SY: " & SY
      end if
      'get the Y position of the middle of the starting object
      dim diagramObject as EA.DiagramObject
      set diagramObject = getDiagramObjectForElementID(connector.ClientID,diagram)
      dim doY
      doY = 0
      if not diagramObject is nothing then
            doY = CInt(diagramObject.top + (diagramObject.bottom - diagramObject.top)/2)
      end if
      getStartingHeight = SY + doY
end function

function getDiagramObjectForElementID(elementID, diagram)
      set getDiagramObjectForElementID = nothing
      dim diagramObject as EA.DiagramObject
      for each diagramObject in diagram.DiagramObjects
            if diagramObject.ElementID = elementID then
                  set getDiagramObjectForElementID = diagramObject
                  exit for
            end if
      next
end function

Geert

KristoferG

  • EA Novice
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
Re: Coordinates of connectors
« Reply #14 on: April 09, 2015, 10:57:51 pm »
Hmm, I am still trying to figure out how this works. It seems that when the connector style is custom, sx/sy and ex/ey is correct. But when the line is orthogonal (rounded if that makes any difference), sx/sy and ex/ey is not correct.

I cannot really make any sense of this. In one case I have been playing around with (for a few hours), either sx or ex was correct and it depended on the direction of the connector. Or put in other words, the offset from the center was correct for one of the elements, but the value was either in sx or ex, and I cannot find any way to know which one to look at. Or perhaps this is just a red herring. Frustrating however.

Anyone knows if they have been working in this area in EA 12 so I should update to EA 12 (currently using EA 11) and keep trying to figure out how this works?

/Kristofer

Edit: In the above I mean a straight line with the style set to orthogonal.
« Last Edit: April 09, 2015, 11:04:11 pm by K831214 »