-
-
Notifications
You must be signed in to change notification settings - Fork 269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request for svg concept id in export/html report #821
Comments
Thanks for this. There's a lot going on here that needs to be unpacked. Using SVG digrams instead of PNG is certainly something that users have requested, as has being able to select connections. Then there's the additional functionality of showing paths between concepts and context menus. So, before getting into the technical code aspects, can we have a clear list of proposed features? |
I guess there are 3 features: extend the SVG export to provide the concept ids on diagram elements, modify the HTML report to use the SVG export, and enable graph analysis. The 3 features with more detail:
You're right, there is a lot to unpack. I'm sure I've glossed over things and may have missed others, but got the gist of it, I think. |
Thanks for the details. Do you have a fork of the Archi code on GitHub with your changes in that I could browse? |
I created a fork (oswalds/archi) with a branch svgId that I posted the exportSvg (#1) feature. My home internet failed today, so I’m uncertain when I’ll be able to get the html report part posted.
Sent from Yahoo Mail for iPhone
On Thursday, February 24, 2022, 02:09, Phil Beauvoir ***@***.***> wrote:
Thanks for the details.
Do you have a fork of the Archi code on GitHub with your changes in that I could browse?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
@oswalds I had a quick look at your branch: There should be a different way to get/set the IDs of Figures. The Figure classes should not have their Perhaps there is a better way to map concept IDs to figures? I think the IDs can be found at export time. |
IDs of objects can be collected at the point of SVG export from the main root figure:
Perhaps these could be collected in a lookup table and mapped to figures? |
I really don't like modifying these core classes to support a downstream plug-in. It makes maintenance harder and there is a hard coupling between the core graphics code and downstream SVG rendering. I think it's worth thinking about an alternate way to do this, or at least something more generic in the graphics classes. Setting the current ID temporarily seems a bit of a kludge. |
I see that there has been some accommodation for downstream SVG processing in quite a few classes (40+) where the line width is set to prevent SVG rendering "overspill."
The graphics classes are called from the core diagram figures and only receive geometric primitives to render. For the SVG export, the SVGGraphics2D classes render the geometric primitives in the same way the draw2d classes render the geometric primitives to the canvas. The only place where attributes can be added to the DOM is through the methods provided by the DOMGroupManager after the geometric primitive is rendered as an SVG element. To get model attributes (e.g., the concept-id) assigned to the geometric primitives, a bridge is required between the time when the rendering begins and when the element is added to the DOM. I implemented that bridge in the extended SVGGraphics2D class by introducing a new interface in the diagram figures package which the graphics classes can implement. The figure drawing methods then use the loose coupling of the interface to determine if it's possible to set the concept id into the graphics provider. So, the export svg project is dependent upon that interface in the editor project (not the other way around). I took some time to explore alternatives to figure out a more elegant solution, but I don't see another way to support the feature outside of writing a new SVG export engine, which would be a lot of work. In my opinion, the approach does leverage the generic capabilities of the SVGGraphics2D package with minimal maintenance impact (1 new interface, 6 class modifications with just a few lines of code) to the archimatetool diagram editor package. So, I guess it's a matter of value vs. effort. I think the value provided by adding the concept-id to the SVG DOM combined with the HTML report modifications is significant. Beyond the demonstration of the graph analysis, new views on the diagrams (like heat maps) are enabled when the SVG HTML report can access components in the diagrams and link them to other information sources (e.g., application catalog, project portfolio, system monitoring, etc.). I think this provides a new and powerful capability for Archi. |
This is a kludge: protected void paintFigure(Graphics graphics) {
if (graphics instanceof ISvgIdentifiable) {
IDiagramModelObject dmo = this.getDiagramModelObject();
String id = "";
try {
IDiagramModelArchimateObject dmao = (IDiagramModelArchimateObject)dmo;
id = dmao.getArchimateConcept().getId();
} catch (Exception e) {
id = "";
}
((ISvgIdentifiable)graphics).setId(id);
} There needs to be another way to set IDs. |
A comment that is copied and pasted several times to remind myself of one of the side effects (and which may actually no longer apply) is not "accommodation for downstream SVG processing" And when I find myself having to defend my code like this I think it's time for me to move on. Thank-you for your offer of contribution but unless there is a better way of mapping IDs I won't be spending any more time on this. |
To summarise the issue:
The problem is mapping the IDs to the elements which it seems can only be done when the Figures are painted here:
Ideally it would be good to do the mapping only in the SVG Export code without interfering with the core Archi diagram code. I think some more investigation should be done in case there is a way to do this. If it turns out that this is not possible, then we should consider a more generic approach to notifying when a paint event occurs to interested classes, a bit like SWT's Paint Listener. I've created a new branch,
This code is much more generic and is not concerned with IDs but rather generally notifying that a paint event is occurring for a given figure. As I said, I think we should continue to explore if it's possible to map IDs without resorting to this. |
I explored directly traversing the figure tree, painting each object below the layers (SVGFigure in my fork) but it would only work for top-level figures (with nested components getting a top-level id) and it isn't a viable approach. The nested figures would need to have their transformation tracked so they align spatially, and I don't know how the upper level figures could be painted without duplication of elements in the DOM. I'm doubtful that there is a way to map the IDs. I think your paintfigure-listener design is the solution. If you go with the paintfigure-listener, I think the connection id should be set in the setConceptId method of the custom DOMGroupManager, something like (works in my code, but may not be concise enough): else if (figure instanceof IDiagramConnectionFigure) { Also, I think there needs to be a way to distinguish between an archi-id that references a concept, and one that references a view (DiagramModelReferenceFigure) or something else (if there are others). Perhaps a convention of prefixing the archi-id attribute value with "view:" (which is what I had done), e.g., <rect ... archi-id="view:id-5e5009...">. |
I've pushed some more changes and refactored/rebased some branches:
|
I spent some time over the weekend to incorporate into my PoC of the HTML SVG Report the changes you made and it looks good to me. There are a few additions to the export.svg package I think are necessary to enable functionality in the HTML SVG Report.
It might be a good feature if these were also added as preferences set in the export dialog. |
(1) Not setting the (2) I don't understand what (3) There was a problem with some fonts not being displayed correctly so this was set to draw text as shapes - see #628 (comment) |
Sorry for the delay ...
|
I've refactored and rebased the
So you should be able to do something like:
|
Hi, Discovering this issue and going through it. Some remarks:
|
I haven't yet tested Phil's latest refactoring, but it looks like it wraps up the features needed (in my opinion) to address the 1st enhancement I outlined in my post on Feb21. |
@oswalds I think the way to proceed is for you to test the changes in |
circling back on this request. We've been using the ExtendedSVGExportProvider (from extended-svg branch) over the last year, upgrading with each release for our modifications to the html reporting (com.archimate.reports) and have not encountered any issues. |
This seems to have fallen by the wayside. I'll take a look at it. |
This feature request is to add the concept-id of diagram model elements to the svg export and generate an html report using the svg formatted diagrams.
The feature extends the functionality of the html_report, enabling more robust interaction with the diagram by leveraging the capabilities of svg. The image map interaction of the current html_report only allows selecting the rectangles associated with an element to display documentation/properties in a separate iframe and no extensibility of the html report. Adding the concept id to elements in the svg dom enables enhanced interaction with the diagram model elements within the browser environment. The svg representation of the diagram enables selecting any element or relationship, using the concept id to highlight the selected item, and enabling end-user extensions for interacting with the diagrams.
I have a working implementation that is shown in the attached videos and would be happy to submit a pull request for review.
The approach was to extend/modify a couple classes to enable adding an attribute of "archi-id" for elements added to the svg DOM managed by Batik and exported by the com.archimatetool.export.svg and ...svg.graphiti packages. A few classes in the ...editor.diagram packages also needed some modification to get the concept id for the "archi-id". The video archiId_exportSvg_20220218 shows the export and svg dom produced with the concept id as the attribute "archi-id" for elements and relationships. Text is exported as text nodes instead of paths and the viewbox is included to ensure an initial 1:1 scale.
The .../reports.html package is extended to add a maintSvg.stg and frameSvg.stg along with a new entry on the menu to generate either svg or imageMap format. The frameSvg.stg includes populating javascript objects with the nodes and edges of the diagram graph. The svg dom is exported with an onload script action to enable initialization of event listeners (for pan/zoom, pick highlights, etc.) and extensions that can use the concept ids to access graph elements. The second video (archiId_htmlReport_20220218) demonstrates the capabilities enabled with the svg support, including documentation/property views on relationships, image manipulation of panning/zooming, highlighting objects selected, and javascript extension to support tracing of graphs represented in the diagram.
archiSvgId_exportSvg_20220218.mp4
archiSvgId_htmlReport_20220218.mp4
(previously put earlier version of this feature request in issue #46)
The text was updated successfully, but these errors were encountered: