I have to save an javafx.scene.shape.Path
object to xml using JAXB.
In my adapter class I'm using (Path).toString
to marshal it.
The string I get looks like :
"Path[elements=[MoveTo[x=25.0, y=25.0], LineTo[x=125.0, y=25.0]], fill=null, fillRule=NON_ZERO, stroke=0x000000ff, strokeWidth=1.0]"
I need then to find a way to reverse it from String
to Path
and I'm looking for an elegant solution to do this (or any better idea to marshal/unmarshal!)
public class PathAdapter extends XmlAdapter<String, Path> {
@Override
public Path unmarshal(String v) throws Exception {
Path output = new Path();
/* Here I have to rebuild my Path with its PathElements from a string */
return output;
}
@Override
public String marshal(Path p) throws Exception {
return p.toString();
}
}
User contributions licensed under CC BY-SA 3.0