cancel
Showing results for 
Search instead for 
Did you mean: 

How to retrieve name for a sequenceFlow in generated diagram

aurelienpel
Champ in-the-making
Champ in-the-making
Hello !

I am creating a model with Activiti Explorer, and between 2 tasks, I give a name to the sequenceFlow. I can see it when I am in my model workspace, and also when I export it in my bpmn20.xml but when I retrieve the diagram of the process instance with a call to REST API, the name disappear in my generated diagram. Maybe I forgot to specify an option before exporting the file, or even when I call it. What did I forget to precise ? Could you help me please ?

Thanks a lot !

Aurelien
9 REPLIES 9

jbarrez
Star Contributor
Star Contributor
No, the name is not supported in the png diagram viewer (yet).

aurelienpel
Champ in-the-making
Champ in-the-making
Could you tell me when it will be done please, because I really need it…

Meanwhile, I am editing the source code, and especially :
activiti-image-generator\src\main\java\org\activiti\image\impl\DefaultProcessDiagramCanvas.java       
and
activiti-image-generator\src\main\java\org\activiti\image\impl\DefaultProcessDiagramGenerator.java

I think it is in a drawSequenceFlow method that you can modify to retrieve the sequenceFlow name, but I'm not sure on how to do it, can you help me please ?

Thanks

Aurelien

jbarrez
Star Contributor
Star Contributor
I can't give you a date, cause it's not something which we currently have prioritised (to be honest, the javascript renderer is more important).

I like it that you searched where to fix it, and indeed it's there. In theory, it should only be one Java2D call that draws text on the canvas. But Java2D really sucks when it comes to text - font-sizes and all that.

That being said, what should be changed is that this method

  public void drawSequenceflow(int[] xPoints, int[] yPoints, boolean conditional, boolean isDefault, boolean highLighted, double scaleFactor)

takes in a String name.

Which should be easy, it's in the SequenceFlow object.

aurelienpel
Champ in-the-making
Champ in-the-making
What I did is below :

As suggested, I added the String name from SequenceFlow Object as parameter in a second method :

Activiti-activiti-5.16.3\modules\activiti-image-generator\src\main\java\org\activiti\image\impl\DefaultProcessDiagramCanvas.java :
<java>
public void drawSequenceflow(String name, int[] xPoints, int[] yPoints, boolean conditional, boolean isDefault, boolean highLighted, double scaleFactor) {
   LOGGER.info("drawSequenceflow");
   LOGGER.info("name : {}", name);
   drawConnection(xPoints, yPoints, conditional, isDefault, "sequenceFlow", AssociationDirection.ONE, highLighted, scaleFactor);
  
   for (int i=1; i<xPoints.length; i++) {
       Integer sourceX = xPoints;
       Integer sourceY = yPoints;
       g.drawString(name, sourceX, sourceY);
   }
  }
</java>

Activiti-activiti-5.16.3\modules\activiti-image-generator\src\main\java\org\activiti\image\impl\DefaultProcessDiagramGenerator.java :

<java>
processDiagramCanvas.drawSequenceflow(sequenceFlow.getName(), xPoints, yPoints, drawConditionalIndicator, isDefault, highLighted, scaleFactor);
</java>

However, I can see in the logs that the name is always null, but when I create a workflow with Activiti Explorer and then I export it, I can see the name of the sequenceFlow.

Maybe I make a mistake, but I don't know where…

aurelienpel
Champ in-the-making
Champ in-the-making
My bad sorry, I made a mistake, finally I can have all the names for the different sequenceFlows, and now I understand what you were meaning when you said that Java2D sucks about graphics. For example, every time I add a docker to an edge the name appears, so I have several times the name on the same edge, or half of it because out.. need to fix it..
Thanks anyway for the indications !

Aurelien

jbarrez
Star Contributor
Star Contributor
Indeed … and it differs from platform to platform too! And from JDK to JDK (they ship with different fonts).
But the main problem is that there is no way to know how big a bit of text is, given a certain font and fontsize …. which is crucial here (something which for example the IOS SDK does perfect! But that doesnt help us)

aurelienpel
Champ in-the-making
Champ in-the-making
Finally I found how to do it (I needed to be patient at the beginning..), and if you want at the end of the week I will be able to do a pull request about this subject, but I don't know if it's possible and if so, how to do it..

Regards

Aurelien

jbarrez
Star Contributor
Star Contributor
A pull request is always great!

Making a pull request is easy: after loggin in into github, you go to https://github.com/Activiti/Activiti.
There, you press 'fork'. This creates a personal fork of the activiti code. You clone it locally, do your changes, commit and push the code.
Then, go to the github page for your personal fork, and the UI will show you now a button to send us the pull request.

if you need more help, do let us know!

jbarrez
Star Contributor
Star Contributor
I wanted to do this for a long time now, but your post finally pushed me: http://www.jorambarrez.be/blog/2014/11/05/how-to-create-an-activiti-pull-request/