Sprite as internal (in-jar resource) images

+1 vote
asked Jan 7, 2016 in Wanted features by anonymous
Now  we can define  external sprites (image from the filesystem) or internal sprites (textual representation).

Would it be possible to add sprites as  embedded resource in the plantuml jar ? If so it would be easier to distribute a self-contained application.

As an example, syntax could be something like

sprite foo1 jar:icons/archimate/business-process-16.png

Regards,

J.-M.

1 Answer

0 votes
answered Oct 11, 2016 by Serge Wenger Work (5,800 points)

Hello,

I see (http://plantuml.com/archimate) that sprite could be read from embedded png file:

sprite $aService jar:archimate/application-service

Is it possible to read them from a external jar file?

Thanks

commented Oct 12, 2016 by plantuml (134,650 points)
This is not documented yet, but you can have:
@startuml
sprite foo1 sprite1.png
Alice->Bob : hello <$foo1> there
@enduml

You have to import your sprite one by one.
If needed, we could implement a new command like:

importsprites some_file.zip

That would automatically import all readable images from "some_file.zip" as sprites.
commented Oct 13, 2016 by Serge Wenger Work (5,800 points)
Thanks for the command to load one by one.

With a zip (or a jar), I can create a library for me and my colleagues, but I'm not sure that a automatic load of all images is good for performance and there can be images with the same name in many zip file. It is why  I suggest to be able to load one by one from an archive file (zip, jar or what is better for you).

Thanks for this great project
commented Oct 13, 2016 by plantuml (134,650 points)
Ok, with last beta https://dl.dropboxusercontent.com/u/13064071/plantuml.jar

You can have:

@startuml
sprite foo1 some_file.jar~sprite1.png
Alice->Bob : hello <$foo1> there
@enduml

Where ~ delimits the file name (could be zip or jar) and the entry name in the zip/jar file.
This has not been highly tested...
commented Oct 13, 2016 by Serge Wenger Work (5,800 points)
Fantastic. It work as expected.
Very nice job
Thanks
commented Oct 24, 2016 by Serge Wenger Work (5,800 points)
When I print on big paper (A3 or bigger), I use SVG for the quality, but png sprites are pixelated (Openiconic are OK ("svg inside")). It would be nice if we can also have svg sprite like this:

@startuml
sprite foo1 some_file.zip~sprite1.svg
Alice->Bob : hello <$foo1> there
@enduml
commented Nov 3, 2016 by plantuml (134,650 points)
Good idea!

Last beta https://dl.dropboxusercontent.com/u/13064071/plantuml.jar support both syntax:

sprite foo1 some_file.zip~sprite1.svg
sprite foo2 sprite2.svg

Tell us if it's not working for you.
commented Nov 3, 2016 by Serge Wenger Work (5,800 points)
Hello,
It is working half: it is OK when I generate the output is svg, but not OK when the output is png.
OpenIconic is working on both png and svg
commented Nov 3, 2016 by plantuml (134,650 points)
Ok, here we have a real issue.
Transforming a SVG figure to bitmap is not simple. Luckily, OpenIconic SVG are really simple, so we made a tiny SVG interpretor that transforms those very simple SVG to bitmap when needed. This code will probably not work with your SVG.

So we have several options:

- either we use "batik" library to transform your SVG to PNG if needed
(batik.jar must be present when running PlantUML)

- either you can provide a PNG version of your icon, so that PlantUML uses it in case of bitmap export
(So, in your zip file, you have both .png and .svg sprites)

Which way sounds best to you ?
commented Nov 3, 2016 by Serge Wenger Work (5,800 points)
Hello,
I understand the problem.

For me do nothing and it work only with svg output (png output has not the image).

If I know the output type, I could use the preprocessor to select the right image extension

Thanks for your work.
...