Welcome to yEd Q&A!
Here you can ask questions and receive answers from other members of the community and yEd developers. And you can tell us your most wanted feature requests.

Categories

Keep internal positions the same when an element is untouched

0 votes
To improve element alignment and save space, we cut all decimal places from a graphML file from all x,y,width and height attributes. However as soon as we load this file in yEd, it will for example change all occurrences of `x=5.0` to `x=4.9998989889798798732948729384734` with an absurd number of decimal places. This happens even if the element is never moved. Please keep positions of unmoved elements the same and it would also be nice if the decimal places would be limited to a reasonable amount.
in Feature Requests by
That seems strange. When I create a diagram with a single node at x=5.0 and y=5.0, save that diagram in GraphML format, open the GraphML file, modify the diagram in a way that does not affect the existing node, and save the modified diagram once more, the coordinates of the original node are still x=5.0 and y=5.0 in the new GraphML file.

Values like x=4.9998989889798798732948729384734 occur due to rounding errors. While rounding errors cannot be prevented, these only occur if an actual calculation is performed. Simply loading a file will not do that.

Are you maybe doing more than just loading the file?

By the way, x=4.9998989889798798732948729384734 is a bit too precise for a textual representation of a double-precision floating point number. (It is not possible to store that much precision in a 52-bit mantissa.)
Thank you for the swift reply and sorry for being imprecise, please let me clarify:

1. I am not doing anything with the graph, just loading and saving.
2. However on further investigation, the problem only occurs within the "NodeLabel" element, not with the Node position itself.
3. The number given was an example from my head not from the real file, I should have clarified that. The real output contains for example "63.825775146484375".

Apparently I cannot attach files here, so I will just copy one of the nodes:

```
    <node id="n0">
      <data key="d6">
        <y:ShapeNode>
          <y:Geometry height="30.0" width="195.0" x="725.0" y="220.0"/>
          <y:Fill hasColor="false" transparent="false"/>
          <y:BorderStyle color="#000000" raised="false" type="line" width="1.0"/>
          <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="16.0" horizontalTextPosition="center" iconTextGap="4" modelName="custom" textColor="#000000" verticalTextPosition="bottom" visible="true" width="67.0" x="63.0" y="6.0">Certification<y:LabelModel>
              <y:SmartNodeLabelModel distance="4.0"/>
            </y:LabelModel>
            <y:ModelParameter>
              <y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/>
            </y:ModelParameter>
          </y:NodeLabel>
          <y:Shape type="roundrectangle"/>
        </y:ShapeNode>
      </data>
    </node>
```

After saving:

```
    <node id="n0">
      <data key="d6">
        <y:ShapeNode>
          <y:Geometry height="30.0" width="195.0" x="725.0" y="220.0"/>
          <y:Fill hasColor="false" transparent="false"/>
          <y:BorderStyle color="#000000" raised="false" type="line" width="1.0"/>
          <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="16.000083923339844" horizontalTextPosition="center" iconTextGap="4" modelName="custom" textColor="#000000" verticalTextPosition="bottom" visible="true" width="67.34844970703125" x="63.825775146484375" y="6.999958038330078">Certification<y:LabelModel>
              <y:SmartNodeLabelModel distance="4.0"/>
            </y:LabelModel>
            <y:ModelParameter>
              <y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/>
            </y:ModelParameter>
          </y:NodeLabel>
          <y:Shape type="roundrectangle"/>
        </y:ShapeNode>
      </data>
    </node>
```

Thank you very much for the clarifications.

yEd does not use the x, y, width, and height attributes from the <y:NodeLabel> and <y:EdgeLabel> GraphML elements at all. The sole reason for these attributes is to allow software other than yFiles (the programming library upon which yEd is built) to get the position and size of the label from the GraphML file.

yEd's/yFiles' graph model does not store positions for labels, but uses parameterized algorithms to calculate the positions of labels from the geometry of the labels' owner node or edge and those parameters whenever the position is needed. (A label's "Placement" setting determines which algorithm is used.)

The same is true for label sizes. (For node labels, the "Size" settings determines the algorithm. For edge labels, yEd always uses "Fit Content".)

Unfortunately, yEd does not offer a way to not write a label's position and size to GraphML.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.
Legal Disclosure | Privacy Policy
...