Hi,

\n

I have some issue when serializing graph with edges routed manually by the user, the "points array" or abs are not saved in the xml file.

\n

I use a class for edge called Line that extend mxCell

\n
public class Line extends mxCell{\n\nprivate String Type;\npublic Line() {\n    //this("",new mxGeometry(0, 0, 100, 100),"endArrow=none;strokeWidth=2;", "");\n    this("",new mxGeometry(0, 0, 100, 100),"H_GROUNDLINE");\n\n}\npublic Line(Object value, mxGeometry geometry, String style) {\n    setValue(value);\n\n    setGeometry(geometry);\n    setStyle(style);\n    setEdge(true);\n    Type = style;\n\n}\n\n @Override\npublic String toString() {\n    return Type;\n}\n
\n

}

\n

I registered the codec like this:

\n
mxCodecRegistry.register(new mxCellCodec(new Line(),\n              null, new String[] { "parent", "source", "target" }, null));\n
\n

when i save the graph, it gives me this xml code:

\n
<Line id="15" parent="1" source="6" target="11" />\n
\n

but I would something like in the original graph editor example with the geometry data and where points array appears:

\n
<mxCell edge="1" id="4" parent="1" source="2" target="3"\nvalue="">\n  <mxGeometry as="geometry" height="100.0" relative="1"\n  width="100.0">\n    <mxPoint as="sourcePoint" x="410.0" y="330.0" />\n    <mxPoint as="targetPoint" x="410.0" y="700.0" />\n    <Array as="points">\n      <mxPoint x="170.0" y="530.0" />\n    </Array>\n  </mxGeometry>\n</mxCell>\n
\n

I tied to add "geometry" in

\n
new String[] { "parent", "source", "target" },\n
\n

but no changes.

\n

Any suggestions?

\n

Thanks for help and for your time.

asked 30 Jan, 01:13

Abu%20Ubeyd's gravatar image

Abu Ubeyd
111
accept rate: 0%


The properties of the object created with an empty constructor are considered default values and are not written out. Try changing the default geometry of the instances or set codec.setEncodeDefaults(false).

link

answered 30 Jan, 22:04

Gaudenz's gravatar image

Gaudenz ♦♦
7.4k15
accept rate: 31%

It seems that the problem come from the call inside the empty constructor to the constructor with "constant" value so it is not needed to write out this CONSTANT. It does make sense.

\n

With the following empty constructor, it fixed the problem but I have an issue with old xml that not contains geometry for edges, so it does not appear when displaying the graph

\n
public Line() {\n    this("",null ,"");\n
\n

}

\n

I think a solution is to cross through the model after loading the xml and to add geometry object to such edges that do not have.

\n

A better idea?

link

answered 03 Feb, 07:20

Abu%20Ubeyd's gravatar image

Abu Ubeyd
111
accept rate: 0%

Probably the easiest solution. Alternatively you could implement mxCellCodec.afterDecode.

link

answered 03 Feb, 07:50

Gaudenz's gravatar image

Gaudenz ♦♦
7.4k15
accept rate: 31%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×123
×41
×12

Asked: 30 Jan, 01:13

Seen: 195 times

Last updated: 03 Feb, 07:50

powered by BitNami OSQA