Archi Forum

Discussion Boards => jArchi => Topic started by: Manj75 on August 23, 2021, 15:19:04 PM

Title: Archimate concept/element/diagram object size and position query in jArchi
Post by: Manj75 on August 23, 2021, 15:19:04 PM
Is it possible to return the position and size of a object in jArchi as I've not been able to find a method on the Wiki.  All you can do is specify position and size when creating, i.e. x, y, width, height.

There should be something like:

var object = selection.filter(selector)

console.log("object position is x: " + object.posx + " y:" + object.posy + ", size is width: " + object.width + " height:" + object.height)

OR return in JSON object

var objectProperties = selection.filter(selector)
objectProperties.x_position
objectPropeties.y_position
objectProperties.width
objectProperties.height

Returns:

{
   x_position:<number>
   y_position:<number>
   width: <number>
   height: <number>
}


If this is already possible then please can you show me, otherwise this would be really useful to add support - let me know if I should raise a feature issue.
Title: Re: Archimate concept/element/diagram object size and position query in jArchi
Post by: projetnumero9 on August 23, 2021, 16:11:49 PM
If I understood properly your usecase, you could achieve it with:

// 
// Get Coordinates 
// 
// Quick and dirty coordinates and graphical object dimensions, extraction 
// 
 
// # Main 
// Clear the console for any new message which may occur 
console.show(); 
console.clear(); 
 
//  - for each selected objects, 
selection.each(function(selectedElement) { 
    //    - Print to the console their coordinates, width and height 
    console.log(selectedElement.name, ": ",selectedElement.bounds); 
}); 


Going one step further would then be: selectedElement.bounds.x, etc.
Title: Re: Archimate concept/element/diagram object size and position query in jArchi
Post by: Manj75 on August 23, 2021, 16:30:21 PM
Perfecto  :) :)

Exactly what I was after - having seen your code I re-read the wiki and found .bounds with description of 'Get/set the bounds...', but the snippet code only shows for setting object to bounds, hence why I missed it.

The Wiki guide can do with more detail and examples for all permutation of usage consistently stating the Getter and Setter variant and return value/object.  I know this is open for all to edit and I'll try to work through, but have been hesitant as I don't want to mess it up.  Phil/JB is there an edit->review process for the Wiki or are all edits issued and made public?

Btw - thank you projetnumero9
Title: Re: Archimate concept/element/diagram object size and position query in jArchi
Post by: Phil Beauvoir on August 24, 2021, 09:16:37 AM
Quote from: Manj75 on August 23, 2021, 16:30:21 PM
The Wiki guide can do with more detail and examples for all permutation of usage consistently stating the Getter and Setter variant and return value/object.  I know this is open for all to edit and I'll try to work through, but have been hesitant as I don't want to mess it up.  Phil/JB is there an edit->review process for the Wiki or are all edits issued and made public?

Opening an issue on GH would work.

I've added a getter example of bounds to the wiki.