Book a Demo

Author Topic: Make EA update the label size after changing it in the database  (Read 4764 times)

Sebastian Mense

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
I implemented a functionality that enables us to resize labels which
allows us to change the amount of rows a label will have. This is part
of our layouting algorithm.

If I was to set the label width to 0, EA would make the label use the
maximum amount of rows it can do. Setting the label size to a really big number
would make it single-line.

What I need to know now is when EA actually does this correction change
(Basically what EA does too when you resize a label by hand to fit the text).
The next ste in layouting would be placing the label relative to a port, but
without the proper width this will not work.

What I am doing now is:

1. Read label from the database
2. Change the width of the label (in the database)
3. Reload the diagram
4. Reading the label again from the database
5. Change the label position (dependant on width)

Reloading the diagram doesn't seem to work. I only get
the not yet corrected width from the database.

How can I make EA execute this?

Best Regards
Sebastian

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Make EA update the label size after changing it in the database
« Reply #1 on: June 01, 2017, 09:28:41 pm »
You're probably bound to trial and error here. EA does not offer access to rendering details. Working with diagrams is more tricky even since EA caches information. You might need to insert diagram save operations and see if that helps.

q.

Sebastian Mense

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Make EA update the label size after changing it in the database
« Reply #2 on: June 02, 2017, 07:40:25 pm »
Thanks for the help!

I tried a bit further and found a solution:

1.
Either
IDualRepository.RefreshOpenDiagrams();
or
.Update() all elements whose labels should be updated.
2. Reload the diagram
3. Save the diagram

I'm not entirely sure why it works like this but I hope this can help someone with a similar problem.

Sebastian

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Make EA update the label size after changing it in the database
« Reply #3 on: June 02, 2017, 08:10:18 pm »
Sometimes you just have to poke in the guts to extract the appendix :-)

q.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Make EA update the label size after changing it in the database
« Reply #4 on: June 06, 2017, 09:29:04 am »
AFAIK, EA, when it reports vertex sizing will report the last saved size on disk, NOT the size on the screen.  That's why you have to save the diagram.

HTH,
Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!