Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Support for svg shapes
Support for svg shapes [message #1821369] Wed, 12 February 2020 04:22 Go to next message
Denis Nikiforov is currently offline Denis NikiforovFriend
Messages: 343
Registered: August 2013
Senior Member
Hi

It seems that svg shapes aren't fully supported. Please see attached screenshot. There are 3 problems:

1) A node label is not centered vertically.
2) Border is scaled. I added vector-effect="non-scaling-stroke" but it doesn't help.
3) Also when I drag a node it's resized randomly.

Can you please help to fix it?

Here is the svg shape:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 50 30" preserveAspectRatio="none">
  <path d="M 5,0.5 h 40 l 4.5,14.5 -4.5,14.5 h -40 l -4.5,-15 Z"
    id="path"
    stroke="#000000"
    stroke-width="1"
    fill="#FFAFFF"
    vector-effect="non-scaling-stroke" />
</svg>
Re: Support for svg shapes [message #1821371 is a reply to message #1821369] Wed, 12 February 2020 06:34 Go to previous messageGo to next message
Denis Nikiforov is currently offline Denis NikiforovFriend
Messages: 343
Registered: August 2013
Senior Member
Sorry for spam. As always you spend hours to fix something. Then just ask an answer and the problem is auto-fixed.

Label vertical alignment is fixed by using org.eclipse.sirius.diagram.customBundledImageShape. See https://www.eclipse.org/forums/index.php/t/1102384/

Random node resizing could be related to odesign and svg files updating.

However I still have ugly scaled borders (please see the screenshot above). Can it be fixed somehow?
Re: Support for svg shapes [message #1821389 is a reply to message #1821371] Wed, 12 February 2020 10:25 Go to previous messageGo to next message
Steve Monnier is currently offline Steve MonnierFriend
Messages: 572
Registered: May 2011
Senior Member
Hello,

I am not sure about this issue because I am not an SVG expert, but I do not think that I tested this extension point with a SVG having the attributes "vector-effect" and "preserveAspectRatio". This might be the cause of your issue. I need to test to be sure.

Best regards,
Steve


Steve Monnier - Obeo Canada
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Support for svg shapes [message #1821390 is a reply to message #1821389] Wed, 12 February 2020 11:07 Go to previous messageGo to next message
Denis Nikiforov is currently offline Denis NikiforovFriend
Messages: 343
Registered: August 2013
Senior Member
Thanks for this and related answers! It seems that vector-effect is supported in SVG 1.2 or 2. And not supported in SVG 1.1. Here is a demonstration of the effect: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/vector-effect

Actually I don't need exactly this attribute. I need all the lines on the diagrams to have the same width. Please see the attache screenshot. Line widths depends on shape sizes.
Re: Support for svg shapes [message #1821551 is a reply to message #1821390] Fri, 14 February 2020 15:42 Go to previous messageGo to next message
Steve Monnier is currently offline Steve MonnierFriend
Messages: 572
Registered: May 2011
Senior Member
Hello,

I checked by adding your svg as a custom bundled image where I set the identifier and attribute for the border color and size. When I change the color and size in the VSM, I see it change on the diagram so the extension point is properly set. However, like you when I change the size of the diagram element, the border size change proportionally. What is strange is that if I open the image in an editor and zoom in, the border width also grows. As you have linked in your previous message I did not expect that with the attribute 'vector-effect="non-scaling-stroke"'. Do you have the same issue? For information, Sirius only changes the referenced attributes before displaying the SVG. At this point, I would tend to think that the issue comes from how the SVG file is specified but I am not entirely sure.

Best regards,
Steve


Steve Monnier - Obeo Canada
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Support for svg shapes [message #1821563 is a reply to message #1821551] Fri, 14 February 2020 19:58 Go to previous messageGo to next message
Denis Nikiforov is currently offline Denis NikiforovFriend
Messages: 343
Registered: August 2013
Senior Member
Hi

Here are svg images, which I created for my project https://github.com/AresEkb/epc/tree/master/epc.design/images

Stroke width scaling is a normal svg behaviour. I think it's ok for most of the applications. If one resizes an ordinary image, he expects that all parts of the image are scaled. However it's not desirable for a diagram editor.

I see two solutions:

1) Disable svg scaling and let Sirius to calculate coordinates for a main points of a figure and update them on figure resizing. For example, a Java service takes width and height of a node, calculates path's d attribute and updates the svg. I think it's a complicated solution.

2) I think, that for users a simpler approach is to update svg engine used by Sirius, so it will support vector-effect="non-scaling-stroke" It was added in SVG 1.2: https://www.w3.org/TR/SVGTiny12/painting.html#NonScalingStroke However I don't know what SVG engine Sirius uses...
Re: Support for svg shapes [message #1821609 is a reply to message #1821563] Mon, 17 February 2020 10:39 Go to previous message
Steve Monnier is currently offline Steve MonnierFriend
Messages: 572
Registered: May 2011
Senior Member
Hello,

We are using Apache Batik 1.6 to display SVG. It appears that this version only implements parts of the SVG 1.2 features [1]. I have not seen vector-effect="non-scaling-stroke" listed in the supported/unsupported features so I guess that this will be in the 1.7 or 2.0 version.

[1] https://xmlgraphics.apache.org/batik/faq.html#what-is-next


Steve Monnier - Obeo Canada
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Previous Topic:Decoration Tooltip not showing, error or bug ?
Next Topic:[IMPORTANT] The diagram is not saving
Goto Forum:
  


Current Time: Fri Mar 29 02:11:50 GMT 2024

Powered by FUDForum. Page generated in 0.04598 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top