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

Free Support Forum - aspose.com

Shape with "No Line"

Hello,

Thanks for the big support that you provide us through all the products.

I’m working now with Aspose diagram and I need to color the line of some shapes.
the code below works fine with most of the cases. but when the shape lineStyle is set to “No Line” the code doesn’t work.

in the attached file a simple example of shape where I can’t get to the line color.

License license = new License();
[//license.setLicense](https://license.setlicense/)(“C://Users//ark//Desktop//Visio Import//Aspose.Total.Java.lic.resj”);
license.setLicense(Licenses.class.getResourceAsStream("/Aspose.Total.Java.lic.resj"));
// The path to the documents directory.
String dataDir = “C://Users//ark//Desktop//Visio Import//Diagrams//”;
// Call the diagram constructor to load diagram
Diagram vdxDiagram = new Diagram(dataDir + “testCHD.vsd”);
for (Shape shape : (Iterable) vdxDiagram.getPages().get(0).getShapes()) {
if ((shape.getType() == TypeValue.GROUP) && (shape.getShapes().getCount() > 0)) {
for (Shape subShape : (Iterable) shape.getShapes()) {
if (shape.getType() != TypeValue.UNDEFINED) {
System.out.println(“ID :” + subShape.getID() + " " + TestGroup.getName(subShape));
System.out.println(“Master :” + subShape.getMaster().getName());
subShape.getLine().getLineColor().setValue(“FF0000”);
subShape.getLine().getLineWeight().setValue(0.03);
}
}
} else {
System.out.println(“ID :” + shape.getID() + " " + RandomTest.getName(shape));
}
}
ImageSaveOptions imgOpts = null;
imgOpts = new ImageSaveOptions(SaveFileFormat.PNG);
imgOpts.setPageIndex(0);
Page page = vdxDiagram.getPages().get(0);
//String urlRead = AnalysisRenderingToolbox.getGenerationFolderRead(root.currentEnvironment().getContext(), root, imgurl);
vdxDiagram.save(dataDir + “groupColor.png”, imgOpts);

Hi Achraf,


Thank you for contacting us and using Aspose.Diagram APIs.
abc:
when the shape lineStyle is set to “No Line” the code doesn’t work.
Did you mean the “Dash Type” value selection is set to the “None” (as shown in the attached screenshot: LineStyle.png)? Please confirm us about the line style property. If it is so, then Aspose.Diagram APIs behavior looks perfect to me. If the line is not being visible, then its color and weight will also not be visible in the resulting PNG file. However, in the code, you can set line pattern property to set the line style. Please let us know about your thoughts.

We’re looking forward to help you.

When I select the shape and I go to the line properties as shown in the attached file. The line property is set to “No Line”. In that case how I can set the line Weight and Color.

Hi Achraf,


Thank you for clarifying this scenario. This option hides the shape’s line. Please set line pattern property of the shape. It will properly display shape’s line along with weight and color. Please modify your sample code as follows:

[Java]
if (shape.getType() != TypeValue.UNDEFINED)
{
System.out.println(“ID :” + subShape.getID());//+ " " + TestGroup.getName(subShape));
System.out.println(“Master :” + subShape.getMaster().getName());
subShape.getLine().getLineColor().setValue(“FF0000”);
subShape.getLine().getLineWeight().setValue(0.03);
subShape.getLine().getLinePattern().setValue(1);
}

We hope, this helps.

Yes It works :slight_smile:

Thanks Imrane.