We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Diagram - Set Subshape Text from Master

Hi All,


I am working with Aspose Diagram for Java.

I have a master shape (stencil attached) that represents an enhanced version of the classic flow chart decision.

I have added a rectangle to the upper-right that would allow me to number each with an ID number. This and the base shape are grouped and the group has the text formatted.

I can set the text just fine as that is the “outer-most” shape, but I’m having issues trying to locate the inner shape.

Ultimately I just need to set the text on the correct inner shape immediately after but I’ve cycled through several attempts at iterating the Shapes collection for the master and I’m just no finding it.

I can identify that the shape is in an inner iteration:

for (Shape s : (Iterable) shape.getShapes()) {
for (Shape in : (Iterable) s.getShapes()) {
String text = in.getText().getValue().getText();
if (in.getID() == 18l){
String tText = in.getText().getValue().getText();
System.out.println(“Crumb”);
}
in.getText().getValue().add(new Txt(Long.toString(in.getID())));
System.out.println(“Crumb”);
}
s.getText().getValue().add(new Txt(Long.toString(s.getID())));
System.out.println(“Crumb”);
}

In my diagram, when this shape is dropped, the correct subshape gets the ID value of 18, so I can prove that I’ve found the right place to set the text manually, and do that in the above, but that’s obviously not what I’m after.

I just want to be able to identify then set the correct sub-shape’s text - the master should have default text in that sub-shape of “id” but my variable tText is always null.

Thanks in advance for any pointers.

Not sure if this is the “correct” way of doing this but by ensuring that the Master has a value in that shape of “id” I can effectively find this by doing a text comparison.


[Java]
for (Shape s : (Iterable) shape.getShapes()) {
for (Shape in : (Iterable) s.getShapes()) {
if(in.getMasterShape().getText().getValue().getText().contains(“id”)){
in.getText().getValue().add(new Txt(Integer.toString(ni.getNodeId())));
}
}
}
[/Java]

Is there a better way to do this?

Thanks.

Hi Fili,


Thank you for contacting support. Please provide complete details of the use case. When you placed a shape of the stencil to a diagram, in which format you saved Visio diagram? Please also provide a zip archive of your source diagram and complete sample code in this forum thread. We’ll investigate and reply you appropriately.

I am currently saving the output file in PDF, though I’d prefer to be using VSDX - that’s throwing an error when I try to open the generated VSDX - if you change the output format in the attached code and open the file in Visio 2013, you should see an “error (271) Some parts are missing” type error.


For this one though, I put together a simple project that emulates the problem, attached. The project also contains the stencil in the root. I did not include my license file.

The use case:

I have a complex Master shape with multiple groups and sub-shapes. I need to find the correct sub-shape (yellow rectangle; Master shape text “id”) and update the Master text with an Id value which comes from elsewhere in the program.

I figured this one out as I made the shape and have working knowledge of the layers/groups involved, but I have other complex shapes provided from elsewhere that I don’t have knowledge of or control over the shape’s layer structure and will similarly need to find sub-shapes and set values.

I was considering writing a recursive helper method to handle this but I wanted to validate if there is a better or more efficient way to handle the case already in the API?

Much appreciated!

All relative to that same stencil, my questions/issues are:


  1. Confirm best method of locating sub-shape
  2. Saving to VSDX produces error
  3. Glue to a connector to a specific connection point instead of just (TOP, etc)
That last one just came up as I’m now trying to connect to the True or False.

Thanks again.

Hi Fili,

Thank you for contacting support. In short, you are placing a group shape in the diagram and iterating through all the sub shapes to find out a shape having the text “id” and setting the new text. To accomplish this task, please refer to the following help topic: Find and Replace the Text of a Shape. In another help topic, it is extracting the plain text of the whole diagram page by using recursive approach. Since, you can use this approach to deal with an N level of the sub shapes.

fili.tine:
Saving to VSDX produces error

We managed to replicate the error message said. We’ve logged this problem under ticket id DIAGRAMJAVA-50276 in our bug tracking system. Your post has also been linked to this ticket. We’ll keep you informed regarding any available updates. We’re sorry for the inconvenience caused.

fili.tine:
Glue to a connector to a specific connection point instead of just (TOP, etc)

Please note, ConnectionPointPlace enum offers top, bottom, right, left and center points to connect shapes. Please refer to the following help topic: Add and Connect Visio Shapes

Please let us know in case of any ambiguity or questions.

Thanks for the prompt response - I appreciate it.


Just one followup - is there anything in your backlog in regards to gluing to specific connection point as opposed to the general top/bottom/left/right/center?

Thanks again.

Hi Fili,

Thank you for the inquiry. Please note, you can also glue shapes by passing their connection indexes. Please refer to the following two help topics: Glue Visio Shapes Together with Connection Point and Glue Shapes Inside the Container

We hope, this helps. Please let us know in case of any confusion or questions.

Hi Fili,

Thank you for being patient. We have a good news for you that the issue id DIAGRAMJAVA-50276 has now been resolved. If there is no issue in the QA phase, then this fix will be included in the next version of Aspose.Diagram for Java 6.0.0. We'll inform you via this forum thread as soon as the new release is published.

The issues you have found earlier (filed as DIAGRAMJAVA-50276) have been fixed in Aspose.Diagram for Java 6.0.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.