renew-js / renew-lib

Core component of renew-js for displaying and modifying drawings
Other
0 stars 0 forks source link

Exported drawings are not aligned correclty #146

Closed tim-kilian closed 5 years ago

tim-kilian commented 5 years ago

Describe the bug

When you try to import a pnml in renew it does not look like in renew-js.

To Reproduce

Steps to reproduce the behavior:

  1. Draw a place, transition and a vertical / horizontal connection
  2. Export it as pnml
  3. Import to renew
  4. See error

Expected behavior

It should look the same

Screenshots

grafik

tim-kilian commented 5 years ago

Also take a look at the line width and size, that does not match.

tim-kilian commented 5 years ago

Overlapping both images results in: grafik Seems like there is something wrong with the place

tim-kilian commented 5 years ago

Exported drawing:

<pnml xmlns="http://www.pnml.org/version-2009/grammar/pnml">
  <net xmlns="" id="net_1563094823731" type="http://www.pnml.org/version-2009/grammar/pnml">
    <place id="1">
      <graphics>
        <position x="297" y="317"/>
        <dimension x="40" y="40"/>
      </graphics>
    </place>
    <transition id="2">
      <graphics>
        <position x="470" y="321"/>
        <dimension x="48" y="32"/>
      </graphics>
    </transition>
    <place id="3">
      <graphics>
        <position x="474" y="425"/>
        <dimension x="40" y="40"/>
      </graphics>
    </place>
    <transition id="4">
      <graphics>
        <position x="293" y="429"/>
        <dimension x="48" y="32"/>
      </graphics>
    </transition>
    <arc id="5" source="1" target="2">
      <graphics/>
    </arc>
    <arc id="6" source="2" target="3">
      <graphics/>
    </arc>
    <arc id="7" source="3" target="4">
      <graphics/>
    </arc>
    <arc id="8" source="4" target="1">
      <graphics/>
    </arc>
  </net>
</pnml>

The same file from renew exported:

<pnml xmlns="RefNet">
  <net id="netId1563095092211" type="RefNet">
    <place id="1">
      <label>
        <graphics>
          <offset x="0" y="0"/>
        </graphics>
        <text></text>
      </label>
      <graphics>
        <position x="297" y="317"/>
        <dimension x="40" y="40"/>
        <fill color="rgb(112,219,147)"/>
        <line color="rgb(0,0,0)"/>
      </graphics>
    </place>
    <place id="3">
      <label>
        <graphics>
          <offset x="0" y="0"/>
        </graphics>
        <text></text>
      </label>
      <graphics>
        <position x="474" y="425"/>
        <dimension x="40" y="40"/>
        <fill color="rgb(112,219,147)"/>
        <line color="rgb(0,0,0)"/>
      </graphics>
    </place>
    <transition id="2">
      <label>
        <graphics>
          <offset x="0" y="0"/>
        </graphics>
        <text></text>
      </label>
      <graphics>
        <position x="470" y="321"/>
        <dimension x="48" y="32"/>
        <fill color="rgb(112,219,147)"/>
        <line color="rgb(0,0,0)"/>
      </graphics>
    </transition>
    <transition id="4">
      <label>
        <graphics>
          <offset x="0" y="0"/>
        </graphics>
        <text></text>
      </label>
      <graphics>
        <position x="293" y="429"/>
        <dimension x="48" y="32"/>
        <fill color="rgb(112,219,147)"/>
        <line color="rgb(0,0,0)"/>
      </graphics>
    </transition>
    <arc id="5" source="1" target="2">
      <label>
        <graphics>
          <offset x="0" y="0"/>
        </graphics>
        <text></text>
      </label>
      <type>
        <text>ordinary</text>
      </type>
      <graphics>
        <line color="rgb(0,0,0)" style="solid"/>
      </graphics>
    </arc>
    <arc id="6" source="2" target="3">
      <label>
        <graphics>
          <offset x="0" y="0"/>
        </graphics>
        <text></text>
      </label>
      <type>
        <text>ordinary</text>
      </type>
      <graphics>
        <line color="rgb(0,0,0)" style="solid"/>
      </graphics>
    </arc>
    <arc id="7" source="3" target="4">
      <label>
        <graphics>
          <offset x="0" y="0"/>
        </graphics>
        <text></text>
      </label>
      <type>
        <text>ordinary</text>
      </type>
      <graphics>
        <line color="rgb(0,0,0)" style="solid"/>
      </graphics>
    </arc>
    <arc id="8" source="4" target="1">
      <label>
        <graphics>
          <offset x="0" y="0"/>
        </graphics>
        <text></text>
      </label>
      <type>
        <text>ordinary</text>
      </type>
      <graphics>
        <line color="rgb(0,0,0)" style="solid"/>
      </graphics>
    </arc>
    <name>
      <text>untitled</text>
    </name>
  </net>
</pnml>
tim-kilian commented 5 years ago

From the source Code of renew:

    Point location = getLocation();
    Point bottomRight = getGraphic().getDimension();

    if (bottomRight == null) {
        bottomRight = new Point(20, 20);
    }

    moveObject(location.x - (bottomRight.x / 2), location.y - (bottomRight.y / 2));
tim-kilian commented 5 years ago

This moveObject is doing wrong. That shouldn't be there.

tim-kilian commented 5 years ago

The PNML specification shows that the coordinated of the objects are ineed at the center position, not in the top left corner. They call it bendpoints.

http://www.petrinets.info/docs/ISO-IEC15909-2.WD.V0.9.0.pdf

tim-kilian commented 5 years ago

Future tracked by renew-js/renew-formalism-pt#18