Trying to understand the coordinate system used for objects on a view.

Started by murraygc, February 15, 2018, 02:10:23 AM

Previous topic - Next topic

murraygc

I'm trying to use a model stored through the database plugin, and re-create a view with an image, followed by the appropriate hotspots to link down to. Ie, I'm not using the supplied HTML report capability directly.

I found an interesting problem, and described it more thoroughly in this post: https://github.com/archi-contribs/database-plugin/issues/30#issuecomment-365719413

When I export the model using the database plugin, I get the tables of models, views in the model, and objects in the views, including the location information about objects on the view.

When I export the model using the Jasper HTML plug in, that information gets converted to HTML, and images get created, as well as the image map locations for the objects on the HTML view. However, the locations in the HTML view are offset from the ones in the database.

The images that get exported also seem to be cropped in some way, so that the view objects don't show up in the same map location as when I look at it through Archi. It's like some image whitespace gets cropped (left and top maybe?) when the image screenshot is created.

What's interesting is that the HTML Jasper report seems to be able to adjust for that shift, but the database details do not.

The Diagram in Archi.png file attached shows the diagram in the Archi view mode.

The Diagram in Jasper HTML.png file attached shows that same diagram in the HTML report mode. Notice that much of the whitespace in the view has been removed, and the image starts much closer to the top left of the HTML view.

The Jasper HTML report creates the following locations for the clickable objects, and these click properly:

<area shape="rect" coords="10,10,130,65" href="../views/846bccbc-4ca2-43a0-b73a-c1872cf32d38.html"  target="view">
<area shape="rect" coords="10,94,130,149" href="../views/fbab4b24-67f8-4616-bed5-2a0e334bfbac.html"  target="view">
<area shape="rect" coords="10,214,130,269" href="../views/18a30867-b4e3-48cd-80da-10d0a4083640.html"  target="view">

However, this coordinates from the database for the same clickable objects are (in the following, only critical area shape information left in so more easy to match to above example):

<area shape="rect" coords="214,58,396,175"    title="846bccbc-4ca2-43a0-b73a-c1872cf32d38"/>
<area shape="rect" coords="214,142,396,259"  title=" fbab4b24-67f8-4616-bed5-2a0e334bfbac"/>
<area shape="rect" coords="214,262,396,379"  title="18a30867-b4e3-48cd-80da-10d0a4083640"/>

I suspect that the database mechanism is providing the coordinates of the objects on the Archi view, not against the exported screenshot dimensions.

So, after a very long winded explanation, is there some other offset information associated with a view that can be exported to the database information, to allow the object mapping to be created correctly?

It seems like the database plugin exports all the information it can find, so then my question is, what does the Jasper report do differently to allow the image map for the objects to be created correctly?

Hervé

Hi,

The HTML export calculates the x,y coordinates of the top left element of the diagram and use them as an offset to shift the diagram to the top left corner.
            // Get and store the bounds of the top-left element in the figure to act as overall x,y offset
            Rectangle bounds = geoImage.getBounds();
            bounds.performScale(ImageFactory.getDeviceZoom() / 100); // Account for device zoom level
            diagramBoundsMap.put(dm, bounds);


The database plugin creates an image of the diagram (with a margin of 10 pixels around) but does not shift the elements to the top left corner.
ImageLoader saver = new ImageLoader();
Image image = DiagramUtils.createImage(view, scale, margin);
saver.data = new ImageData[] { image.getImageData() };
saver.save(writeOut, SWT.IMAGE_PNG);


Best regards
Hervé

Phil Beauvoir

As Hervé says. There is also a 10 pixel border around each diagram.
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

murraygc

Can the same type of calculated offsets the HTML export does be saved in the database tables as well? I understand the original values are there for recreating the map as is on Archi. It would really help what I'm doing. Perhaps as additional information on the objects?

murraygc

Just to explain why it would help me to have the image scaled coordinates:

I've built a web app prototype in C#, ASP .NET that uses the Archi data from the database to display, and combines the Archi information with the ability to add PlantUML syntax diagrams to an Archi View.

What does the user get:
1) An ability to choose a specific model version, as well as see the history of changes between model versions (soon to be detailed changes, for now, just history table).
2) An ability to click down between views based on the image map data.
3) An ability to see all views any particular object is part of. (really good for answering that question "As an X, what processes do I take part in?"
4) Links in Documentation fields (views and objects) are linkify'd.
5) PlantUML diagrams (you can have multiple) that are contained in the Documentation text of a view are extracted and displayed as tab'd image views behind the main view image
6) The Archi search treeview like functionality is available to help users rapidly navigate a large model treeview.

Right now, I use a tooltip to hover over the objects in the Archi view, so at least people know they are clicking in the right area. I've also made it an operational step to move the diagrams to closer to the top left of the Archi view. That makes the objects closer, but it doesn't account for the inherent scaling.

I'm also using the github collaboration to basically form two levels of checkin. The first is a select group of process owners who can modify the navigation map / processes involved. The second level is a more restricted set of people who can publish changes into the SQL database. Since the staff read from the SQL database, we can make multiple iteration baselines and confirm it before publishing it for real for wider use.

Anyway, about to start showing the prototype to more people in my org. Everyone I've shown it to so far thinks it's pretty cool. A few more bells and whistles to add, but getting there.

Hervé

Hi,

Sorry for this late answer, I've been on vacation for few days.

I believe it shouldn't be a big piece of work to add an option to choose between saving the views screenshots as they are or to shift them to the top left corner. I'll add it to my todo list  :D

Best regards
Hervé

murraygc

You, as always, are a gentleman and a scholar, Hervé.

It's kind of cool, seeing people excited about being able to use processes :-).