Is there a way to examine/manipulate the elements of an SVGPath
? Since it is not derived from Path
(It is a direct subclass of Shape
), I can't get the PathElement
s via Path
's getElements
method.
(In essence, I'd like to use SVGPath
as an SVG path parser, instead of having to include Apache Batik or writing my own).
There is an easy way to convert
SVGPath
toPath
without any third party dependency, based precisely in their common superclassShape
's methodsubstract
. The result of a substract operation can be downcasted toPath
:So given a certain
SVGPath
, like one of the segments of the SVG logo:you can easily get the
Path
with all the differentPathElement
elements:and print the elements:
with the following result:
You can now manipulate the
Path
or any of its elements, but there is no easy way of getting a newSVGPath
back from thePath
.You can find a
ShapeConverter
utility in the JFXtras project. With it you can generate the SVGPath again: