Adding a 'Note' on the bottom of an export

Started by JoCriSem, June 10, 2020, 09:42:41 AM

Previous topic - Next topic

JoCriSem

I am looking at a way to add a note on each export As Image.  Ideally that note would be below the lowest element in the view.
Is there a way to achieve this?

Currently I use a script that adds a static note, but if the model extends the coordinates I use, it doesn't look good.
(var note = view.createObject("note", 950, 700, 300, 70);)

Thanks.

Phil Beauvoir

#1
Have you tried something like iterating through all the elements in the view and finding the y-value of the bounds of each element (element's y value plus its height), getting the largest value, and then adding the note below that?
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

JoCriSem

Thanks Phil.  I haven't tried that yet.
How would I go about doing that exactly?

projetnumero9

Quote from: Phil Beauvoir on June 10, 2020, 10:06:08 AM
Have you tried something like iterating through all the elements in the view and getting the greatest y-value of its bounds (element's y value plus its height) and then adding the note below that?

I was thinking about suggesting that (and the gist https://gist.github.com/jbsarrodie/9784e2035d0e6599a8a7a890ba8c63cd would if necessary be a good start to iterate), but one would add : what about bendpoints? I have to admit I have difficulty wrapping my head around: https://github.com/archimatetool/archi-scripting-plugin/wiki/jArchi-Object#relativebendpoints

For example,
- x=0 and y=0 being the top left corner in the print screen attached,
- coordinate and size of my source being: {x: 150, width: 110, y: 190, height: 250}
- bendingpoint having the following value:  [{endY=-50, endX=-330, startY=-50, startX=-90}]
, how do I calculate the coordinate of my bendpoint? (I haven't thoroughly studied https://gist.github.com/jbsarrodie/3cfe6ae90b29696c55550ce3d4b3a577 yet)

Phil Beauvoir

#4
Quote from: JoCriSem on June 10, 2020, 10:17:55 AM
Thanks Phil.  I haven't tried that yet.
How would I go about doing that exactly?

This might help:


var view = selection.first();
var maxX = 0;
var maxY = 0;

$(view).children().filter("element").each(function(element) {
    var bounds = element.bounds;
   
    var x = bounds.x + bounds.width;
    if(x > maxX) {
        maxX = x;
    }

    var y = bounds.y + bounds.height;
    if(y > maxY) {
        maxY = y;
    }
});

var note = view.createObject("note", maxX + 10, maxY + 10, 300, 70)
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Phil Beauvoir

If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

projetnumero9


JoCriSem

Incorporated it in my script, applied a few tweaks on the positioning and it works super.

Many thanks.