Skip to content
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] view images exporting as vector graphics #77

Closed
WatchTh1 opened this issue Jul 9, 2020 · 28 comments
Closed

[feature request] view images exporting as vector graphics #77

WatchTh1 opened this issue Jul 9, 2020 · 28 comments

Comments

@WatchTh1
Copy link

WatchTh1 commented Jul 9, 2020

Could you plan a jArchi method to render views as a vector graphics format format with jArchi script ? Would be very usefull to have such an option to export LARGE images.
Currently there is only renderviewasbase64 method available.

@WatchTh1
Copy link
Author

WatchTh1 commented Jul 9, 2020

With current realization maybe would be simple enough to do it with Plotly JS library

@Phillipus
Copy link
Member

Phillipus commented Jul 9, 2020

We already have a SVG exporter plug-in but it needs some refactoring so that it can be used by jArchi. The SVG data will have to be returned in a re-usable format - perhaps the SVG DOM Element could be returned as a String. Then this could be saved as a file, or converted into another format consumed by JS.

This will have to be added to the "to do" list.

@bozoh
Copy link

bozoh commented Jul 9, 2020

Try d3.js its a very powerful js graphic framework , i think it could be converted in SVG

@Phillipus
Copy link
Member

Phillipus commented Jul 9, 2020

Try d3.js its a very powerful js graphic framework , i think it could be converted in SVG

To convert Archi diagrams to SVG requires special code.

See https://github.com/archimatetool/archi/tree/master/com.archimatetool.export.svg/src/com/archimatetool/export/svg

If/when the SVG export is implemented in jArchi, the likely format will be a String of the SVG DOM Element.

@WatchTh1
Copy link
Author

WatchTh1 commented Jul 10, 2020

Would like to see this at the roadmap )

We already have a SVG exporter plug

@Phillipus , I could not find how to make SVG export happen in Archi GUI itself for 4.7 or 4.7.1 beta. Is it currently available as a feature

@Phillipus
Copy link
Member

@WatchTh1

Choose "SVG Image" from the "Export as Image" dialog.

https://www.archimatetool.com/downloads/Archi%20User%20Guide.pdf

page 45

@WatchTh1
Copy link
Author

WatchTh1 commented Jul 10, 2020

@Phillipus , found. Could you provide some advice how to use vector fonts in generated images ? Seems like now it uses rasters with a specific resolutoin and zooming in results in low quality text, like this one:
image

And seems like also objects are generated somehow in raster manner ,

@jbsarrodie
Copy link
Member

And seems like also objects are generated somehow in raster manner ,

It seems you didn't use SVG format. Are you sure you selected it from the list ?

@WatchTh1
Copy link
Author

WatchTh1 commented Jul 11, 2020

And seems like also objects are generated somehow in raster manner ,

It seems you didn't use SVG format. Are you sure you selected it from the list ?

Pretty sure. I've been wondering as well about it.

  1. "Export view as an image..."
  2. Select "SVG Image" from dropdown.
  3. Press OK

File is saved as SVG. I can even open it as SVG XML. And it contains XML.

@jbsarrodie
Copy link
Member

jbsarrodie commented Jul 11, 2020

In this case which software did you use to open the SVG? Can you try in a browser like chrome if not already done?

@WatchTh1
Copy link
Author

In this case which software did you use to open the SVG? Can you try in a browser like chrome if not already done?

XNView.
Chrome on Linux can not scale SVG image. Just checked out.
Zoom in and zoom out just don't change a thing. Firefox is more friendly, but doesn't seem like it can zoom up to 500+%.
I'll try to import SVGs into Confluence page and see how image will be rendered with zooming view and exported documents.

@jbsarrodie
Copy link
Member

I'm pretty sure xnview create a raster image when loading the svg, which should explain your issue.

Chrome can zoom, but you first have to export from archi without setting the bounding box.

@WatchTh1
Copy link
Author

WatchTh1 commented Jul 11, 2020

I'm pretty sure xnview create a raster image when loading the svg, which should explain your issue.

Yeah seems like this is the issue. But second thought is How can i build up SVG images for 60+ views in model while updating a project documentation based on model in a collaboration tool like Confluence ?

Currently we have continous integration toolchain to support documentation update. Using SVG (or other vector format) images would greatly improve documentation readaility.

Toolchain is currently generates HTML report referenced by pages. But it only makes things to use PNG images.

@Phillipus
Copy link
Member

I've refactored the SVG code in Archi to support this for Archi 4.9, and added a method in jArchi.

It would then be possible to do the following in a similar pattern to saving to other formats:

var svgString = $.model.renderViewAsSVG(theView);
$.fs.writeFile("MyView.svg", svgString);

Depends on Archi 4.9.

@flexarts
Copy link

Hi Phillipus,
Thanks for your hard work. I saw your changes to support this API in jArchi are added to a branch "svg-view" in 196a81c. When do you plan to make it available in the master branch? May i get a test release of this branch for testing with Archi Beta (4.9)?

Btw, I am planning to use this feature when a user publishes a Change via the "coArchi" Plugin to the git Repo. Is there some way of "event hook" for "before commit" or "after push" to hook into this workflow with a jArchi script?

Thanks in advance!

BR Dominic

@Phillipus
Copy link
Member

Hi Phillipus,
Thanks for your hard work. I saw your changes to support this API in jArchi are added to a branch "svg-view" in 196a81c. When do you plan to make it available in the master branch? May i get a test release of this branch for testing with Archi Beta (4.9)?

We are working on Archi 4.9 aiming for a release over the coming weeks. Once this has been released and any bugs fixed, we will then add new features to jArchi for specializations, and include the SVG support. There won't be any new releases of jArchi until all of the pre-requisites are completed.

Btw, I am planning to use this feature when a user publishes a Change via the "coArchi" Plugin to the git Repo. Is there some way of "event hook" for "before commit" or "after push" to hook into this workflow with a jArchi script?

No, jArchi is not linked to coArchi. We might consider this for coArchi 2.

Regards,

Phil

@flexarts
Copy link

flexarts commented Aug 29, 2021

Hi Phil,

Thanks for your update to your envisioned roadmap.
I found another issue (#34) which closely describes what i am trying to archive (but I want to use SVGs instead of PNGs):

I would have a publication use case for this feature. I have a model with 19 views. I commonly publish the models to pdf for distribution. I use the File/Export/View as Image function to produce the PDFs. Executing this 19 times for each publication cycle takes a bit of time that I'd like to automate.

I'm told that jarchi can already programmatically manipulate and save views as PNGs. But I am left with the manual task of printing to PDF - so no real time savings or accuracy improvements there.

Just a thought for you. Thanks

Is there any way to "easily" achieve to execute either:

  • jArchi Scripts from UI Actions (e.g. coArchi Commit Action)
    or
  • coArchi actions from jArchi Scripts

Thanks in advance
Dominic

@Phillipus
Copy link
Member

Is there any way to "easily" achieve to execute either:

* jArchi Scripts from UI Actions (e.g. coArchi Commit Action)
  or

* coArchi actions from jArchi Scripts

Hi Dominic,

jArchi scripts cannot be triggered by other actions, but a script file can be run from the ACLI (https://github.com/archimatetool/archi/wiki/Archi-Command-Line-Interface).

coArchi does have a couple of ACLI commands that could probably be called indirectly from a jArchi script, but there's no more interaction than that.

Phil

@dwinkler-oebb
Copy link

Hi Phil,

I built the jArchi plugin from the svg-view branch and used it on Mac OS together with Archi Beta 4.9 and both functions $.model.renderViewAsSVGString(o, true) and $.model.renderViewToSVGFile(o, svgpath, true) worked without a problem.

When I switch to windows OS and use the same plugin jar's I used on Mac OS, the following error happens:
Script Error: java.lang.NullPointerException.
What can be the cause of the problem?
Where can I view the trace log of jArchi problems? In /.metadata/.log no error is listed.

Thanks in advance,
Dominic

@flexarts
Copy link

flexarts commented Sep 7, 2021

I built the jArchi plugin from the svg-view branch and used it on Mac OS together with Archi Beta 4.9 and both functions $.model.renderViewAsSVGString(o, true) and $.model.renderViewToSVGFile(o, svgpath, true) worked without a problem.

Just to add to my last comment, it only works when i run Archi 4.9 (master branch) in Eclipse from source together with the jarchi plugin from the svg-view branch.
But when I use the built JAR files (from the setup) and try to run it in Archi Beta (4.9.) downloaded from https://www.archimatetool.com/beta/ it fails to execute on MacOS or Windows. The same error Script Error: java.lang.NullPointerException occurs.

Maybe an outdated dependency in the Beta builds?

@flexarts
Copy link

flexarts commented Sep 7, 2021

Btw...

Since i am trying to provide a "publish to PNG/SVG" automation when a model author wants a commit changes via coArchi, i forked both plugins (https://github.com/flexarts/archi-modelrepository-plugin and https://github.com/flexarts/archi-scripting-plugin) and combined the two for my workflow via a "command" execution pre-commit vom coArchi -> jArchi.

for coArchi:
flexarts/archi-modelrepository-plugin@5863879

for jArchi:
flexarts@8977ef1

Kind regards,
Dominic

@Phillipus
Copy link
Member

@flexarts Dominic, the svg-view branch has changed, and so has the API function name.

@flexarts
Copy link

flexarts commented Sep 7, 2021

Hi Phil,
Thanks i saw now the method is called $.model.renderViewToSVG.
But also this method does not work in "standalone" mode using the Archi Beta builds :-(.
Thanks

@flexarts
Copy link

flexarts commented Sep 7, 2021

Hi Phil,
I used the jarchi funtion renderViewToSVG and the following error (stacktrace included) did appear:

Script Error: java.lang.NullPointerException
java.lang.NullPointerException
	at com.archimatetool.editor.diagram.figures.elements.GroupingFigure.drawFigure(GroupingFigure.java:131)
	at com.archimatetool.editor.diagram.figures.AbstractContainerFigure.paintFigure(AbstractContainerFigure.java:97)
	at org.eclipse.draw2d.Figure.paint(Figure.java:1191)
	at org.eclipse.draw2d.Figure.paintChildren(Figure.java:1243)
	at org.eclipse.draw2d.Figure.paintClientArea(Figure.java:1282)
	at org.eclipse.draw2d.Figure.paint(Figure.java:1193)
	at org.eclipse.draw2d.Figure.paintChildren(Figure.java:1243)
	at org.eclipse.draw2d.Figure.paintClientArea(Figure.java:1278)
	at org.eclipse.draw2d.Figure.paint(Figure.java:1193)
	at org.eclipse.draw2d.Figure.paintChildren(Figure.java:1243)
	at org.eclipse.draw2d.Figure.paintClientArea(Figure.java:1278)
	at org.eclipse.draw2d.Figure.paint(Figure.java:1193)
	at com.archimatetool.export.svg.AbstractExportProvider.initialiseGraphics(AbstractExportProvider.java:57)
	at com.archimatetool.export.svg.SVGExportProvider.createElementForView(SVGExportProvider.java:117)
	at com.archimatetool.export.svg.SVGExportProvider.export(SVGExportProvider.java:76)
	at com.archimatetool.script.dom.model.Model.renderViewToSVG(Model.java:230)
	at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$29$454A$ExportSVG_ajs$cu1$restOf.L:20(/Applications/Archi_Beta.app/Contents/MacOS/scripts/ExportSVG.ajs:42)
	at jdk.nashorn.javaadapters.java_util_function_Consumer.accept(Unknown Source)
	at java.base/java.util.ArrayList.forEach(Unknown Source)
	at com.archimatetool.script.dom.model.EObjectProxyCollection.each(EObjectProxyCollection.java:359)
	at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$20$ExportSVG_ajs$cu1$restOf.:program(/Applications/Archi_Beta.app/Contents/MacOS/scripts/ExportSVG.ajs:20)
	at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(Unknown Source)
	at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptFunction.invoke(Unknown Source)
	at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptRuntime.apply(Unknown Source)
	at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.Context.evaluateSource(Unknown Source)
	at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.Context.load(Unknown Source)
	at jdk.scripting.nashorn/jdk.nashorn.internal.objects.Global.load(Unknown Source)
	at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$15$\^eval\_/0x00000008009d9440.:program(<eval>:1)
	at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(Unknown Source)
	at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptFunction.invoke(Unknown Source)
	at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptRuntime.apply(Unknown Source)
	at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(Unknown Source)
	at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(Unknown Source)
	at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(Unknown Source)
	at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.eval(Unknown Source)
	at java.scripting/javax.script.AbstractScriptEngine.eval(Unknown Source)
	at com.archimatetool.script.JSProvider.run(JSProvider.java:48)
	at com.archimatetool.script.RunArchiScript.run(RunArchiScript.java:69)
	at com.archimatetool.script.views.scripts.RunScriptAction.run(RunScriptAction.java:41)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:474)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:580)
	at org.eclipse.jface.action.ActionContributionItem.lambda$5(ActionContributionItem.java:453)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4524)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1522)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1545)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1530)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1324)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4310)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3883)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1150)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1041)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
	at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:644)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:551)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:156)
	at com.archimatetool.editor.Application.start(Application.java:81)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:401)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1467)

@Phillipus
Copy link
Member

@flexarts Thanks for that stacktrace. I'm getting that here, as well. Investigating...

@Phillipus
Copy link
Member

...bug found...a fix and a deeper investigation of the cause incoming...

@flexarts
Copy link

flexarts commented Sep 7, 2021

...bug found...a fix and a deeper investigation of the cause incoming...

Thanks a lot Phil... I began to think my system setup was the problem...

@Phillipus
Copy link
Member

Phillipus commented Sep 7, 2021

...bug found...a fix and a deeper investigation of the cause incoming...

...cause found, fix is done but will upload it tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants