closed Generate activity diagram in java

0 votes
asked Jun 5, 2013 in Bug by anarcky (120 points)
closed Jun 5, 2013 by anarcky

Hi!

Fisrt of all, thanks for your great work!

 

I'm working on a J2EE application and I fell the need to display a list of actions as a picture to my users. The most elegant way I found is to use PlantUML Activity diagrams. 

I used the code sample here : http://plantuml.sourceforge.net/api.html to generate a SVG picture.

My code works great with the sample diagram ("Bob -> Alice : hello\n").

But i need an activity diagram. I tried with the old activity diagrams and it seems that i would need to install Graphiz on my server and I don't want to do that.

So I tried to use the new beta Activity diagrams but I can't get any SVG. I just have a "sintax error?" message (my syntax is correct, if I debug my code and copy my generated string, I can see my diagram in the Eclipse plugin).

I also tried to generate the diagram with the javascript libraries and the same error occurs.

I'm kind of stuck there. Maybe the feature is not yet implemented.

If somone has any informations, i'm very interesed :)

Thanks!

 

P.S.: sorry for my english :D

 

Edit : I just realized that i was not using the right version of the jar... Everything works just fine!

closed with the note: works fine, i'm just a bit dumb...

1 Answer

0 votes
answered Jun 5, 2013 by plantuml (294,960 points)

First, you are right: if you do not install GraphViz, only Sequence Diagram and Activity Diagram (Beta) will work.

Both are working with SVG generation, so my guess is that you are using a too old version of PlantUML.
Probably your Eclipse Plugin uses a version of PlantUML, and your running server uses another version.

The following code is working fine with last version:

    public static void main(String[] args) throws IOException {
        String source = "@startuml\n";
        source += "start\n";
        source += ":foo;\n";
        source += "@enduml\n";

        SourceStringReader reader = new SourceStringReader(source);
        final ByteArrayOutputStream os = new ByteArrayOutputStream();
        // Write the first image to "os"
        String desc = reader.generateImage(os, new FileFormatOption(FileFormat.SVG));
        os.close();

        // The XML is stored into svg
        final String svg = new String(os.toByteArray());

        System.err.println(svg);
    }


To doublecheck your running PlantUML version, just try this:
    
    public static void main(String[] args) throws IOException {
        String source = "@startuml\n";
        source += "version\n";
        source += "@enduml\n";

        SourceStringReader reader = new SourceStringReader(source);
        final ByteArrayOutputStream os = new ByteArrayOutputStream();
        // Write the first image to "os"
        String desc = reader.generateImage(os, new FileFormatOption(FileFormat.SVG));
        os.close();

        // The XML is stored into svg
        final String svg = new String(os.toByteArray());

        System.err.println(svg);
    }

    
Copy/paste the printed SVG string in some file, open it with a SVG reader, and tell us the result.

Hopes it helps.
 

...