How to set the thickness of the "No Symbol" shape programmatically

I have produced a diagram with nodes (i.e. shapes) and connectors. So far all is perfect. The problem I have is that I cannot figure out how to make the “No Symbol” (the shape that is a circle with a line between it) shape have a narrow border. the circle and line are quite fat, and
shape.getLine().getLineWeight().setValue(0.01); // Thin line
does NOT work.

In Visio, I can change the thickness of the border, but that is too late. Any help would be appreciated.

@richardcromer

Cause

It appears that you are attempting to set the thickness of the “No Symbol” shape in your diagram, but the method you are using to adjust the line weight is not producing the expected results. This issue may arise from the specific properties of the “No Symbol” shape, which may require a different approach to modify its line attributes.

Solution

To successfully adjust the thickness of the “No Symbol” shape, you need to ensure you are accessing the correct line properties. The line attributes for shapes in Aspose.Diagram can be set using the Line property of the Shape class. Here’s how to do it:

  1. Access the shape you want to modify.
  2. Use the Line property to set the line weight.

Code

Here’s a code snippet that demonstrates how to set the line weight for the “No Symbol” shape:

// Load the diagram
Diagram diagram = new Diagram("path/to/your/diagram.vsdx");

// Access the specific shape by its ID or name
Shape noSymbolShape = diagram.getPages().get(0).getShapes().getShape(1); // Adjust the index as needed

// Set the line weight
noSymbolShape.getLine().getLineWeight().setValue(0.01); // Set to desired thickness

// Save the modified diagram
diagram.save("path/to/your/modified_diagram.vsdx", SaveFileFormat.VSDX);

Make sure to replace the shape index with the correct one for your “No Symbol” shape.

Next Steps

  1. Test the code snippet above in your environment.
  2. Adjust the line weight value as needed to achieve the desired thickness.
  3. If the changes are still not reflected, check if the shape inherits any properties from a master shape that might override your settings.

If you have any further questions or need additional assistance, please feel free to ask!

Asposer,
That is exactly what I did and it does not work. In my debugger, I have verified that I am dealing with the correct shape (the “No Symbol” shape), and as I mentioned in the original question, I used:

shape.getLine().getLineWeight().setValue(0.01); - Where shape is the No Symbol shape.
FYI- the above line DOES work for all other basic shapes, but it does not work for the “No Symbol” shape. Could it be that the “No Symbol” shape requires a different strategy (as you eluded to), in your initial reply?

@richardcromer
Thanks for your inquiry.
Please try this sample code to set linepattern:

 shape.getLine().getLinePattern().setValue(1);

If you still experience the same issue, then please provide us the template file with the “No Symbol” shape to reproduce the issue. We will check your issue soon.

Philip,
First of all, thank you for creating such an awesome product. With it, I have been able to create some very interesting diagrams programmatically (through Java).

As for our current issue, regrettably, the suggestion of using: shape.getLine().getLinePattern().setValue(1); Did NOT work.

The reason I believe this must require a different approach is because, in Visio, changing the thickness of the “No Symbol” shape is done differently (by selecting a small red circle on the inner border and actually moving it toward the outer-edge) than the other basic shapes that I use (e.g. Circle, Rectangle, etc.)

BasicShapes.zip (98.1 KB)

Aspose_Diagram_Example.zip (27.9 KB)

FYI: The version of the library in use is aspose-diagram-23.8.jar

@richardcromer
Thanks for the template file.
After an initial testing, I am able to reproduce the issue as you mentioned by using your template file.We will evaluate your issue further.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): DIAGRAMJAVA-51266

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

The issues you have found earlier (filed as DIAGRAMJAVA-51266) have been fixed in this update. This message was posted using Bugs notification tool by philip.zhou

@richardcromer
Please try this sample code to set control of shape and refresh shape’s data:

       Page page = diagram.getPages().get(0);
       Shape shape = page.getShapes().getShape(3);
       
      Control control = (Control)shape.getMasterShape().getControls().get(0).deepClone();  
      control.getX().getUfe().setF("BOUND(Width*0.15,0,FALSE,0,Width*0.3)"); //set formula of the control or set  it's value
      shape.getControls().add(control);
      //shape.getControls().get(0).getX().setValue(0.36); //or set value
       shape.refreshData();

Thanks.