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

Free Support Forum - aspose.com

Working with layers

Hi,


I need an explanation on how to work with layers in Aspose.Diagram for Java.
Current documentation<span style=“font-size:11.0pt;font-family:“Calibri”,“sans-serif”;
mso-ascii-theme-font:minor-latin;mso-fareast-font-family:Calibri;mso-fareast-theme-font:
minor-latin;mso-hansi-theme-font:minor-latin;mso-bidi-font-family:Arial;
mso-bidi-theme-font:minor-bidi;mso-ansi-language:EN-US;mso-fareast-language:
EN-US;mso-bidi-language:HE”> is not clear. I don’t understand what is supported and what isn’t.

1. Is it possible to create a new layer in a diagram ?
2. Is it possible to add a shape to a layer ?
3. Is it possible to get a list of existing layers in a diagram ?
4. How can I use the LayerCollection class ? This class does not have a constructor and I don’t see any way to get this collection from a Page/Diagram.

Note that I already saw the code example “Configuring Shape Objects with Layers”. This example did not answer my questions above.

Your help will be very appreciated, please also add code examples.

Thanks !
Tamir.

Hi Tamir,


Thank you for contacting support.
tamirl1:
Is it possible to add a shape to a layer ?
Yes, it is possible. We can retrieve a shape class object from the Diagram class. The LayerMem property of the shape class holds indexes of the layer. We can update indexes of the layer to add, remove shape from the existing list of layer by indexes. The Diagram class presents Visio document. We hope, this helps. Sample code: Configure Shape Objects with Layers in Visio

In reference of other two questions, there is no way to add a new layer or get a list of existing layers. We have logged two feature requests as follows:

DIAGRAMNET-50607 - Add support to include a new Layer in the Visio diagram
DIAGRAMNET-50608 - Add support to get a list of existing layers from the Visio diagram

Your post has also been linked to these issues. We’ll keep you informed regarding any available updates. We’re sorry for the inconvenience caused.

Hi Imran !


Thank you very much for your help.

Meanwhile I did some more digging into this forum and I found some answers. From what I found, it looks like it is possible to add layers to a page, which is good for me.

I found this thread here:

With the following example:

Page page = dia.getPages().getPage(“PageTemplate”);

Layer layObj = new Layer();
layObj.getName().setValue(“Lay1”);
layObj.getVisible().setValue(BOOL.TRUE);
page.getPageSheet().getLayers().add(layObj);

long shapeId = page.addShape(3.0, 3.0, 0.36, 0.36, “Shape1”);
Shape shape = page.getShapes().getShape(shapeId);
shape.getLayerMem().getLayerMember().setValue(Integer.toString(layObj.getIX()));

I checked it and it seem to work fine.

Thanks !
Tamir.

Hi Tamir,

We’re sorry for the inconvenience caused. We have added two help topics in reference of above feature operations as follows: Add a new Layer in the Visio Diagram, Retrieve All Layers from the Visio Diagram

Note: The logged ticket ids DIAGRAMNET-50607 and DIAGRAMNET-50608 have been closed.

Thanks Imarn !