+ // TODO
+ double scaledX = (x - getBounds().x) / submodelScale;
+ double scaledY = (y - getBounds().y) / submodelScale;
+ double roundedScaledX = Math.round(scaledX / 5 * 2) * 5 / 2.;
+ double roundedScaledY = Math.round(scaledY / 5 * 2) * 5 / 2.;
+ System.out.println(scaledX + "|" + scaledY + ", rounded " + roundedScaledX + "|" + roundedScaledY);
+ return true;
+ }
+
+ /**
+ * @return {@link SubmodelComponentParams}, which describe this {@link SubmodelComponent}.
+ */
+ public SubmodelComponentParams calculateParams()
+ {
+ SubmodelComponentParams params = new SubmodelComponentParams();
+ params.type = SubmodelComponent.class.getSimpleName();
+ params.composition = calculateCompositionParams();
+
+ Rectangle bounds = getBounds();
+ params.width = bounds.width;
+ params.height = bounds.height;
+
+ InterfacePinParams[] iPins = new InterfacePinParams[getPins().size()];
+ int i = 0;
+ for (Pin p : getPins())
+ {
+ InterfacePinParams iPinParams = new InterfacePinParams();
+ iPins[i] = iPinParams;
+ iPinParams.location = p.getRelPos();
+ iPinParams.name = p.name;
+ iPinParams.logicWidth = p.logicWidth;
+ i++;
+ }
+ params.interfacePins = iPins;
+ return params;
+ }
+
+ protected ComponentCompositionParams calculateCompositionParams()
+ {
+ ComponentCompositionParams params = new ComponentCompositionParams();
+ params.innerScale = getSubmodelScale();
+
+ List<GUIComponent> compList = submodelModifiable.getComponents();
+ Iterator<GUIComponent> componentIt = compList.iterator();
+ componentIt.next(); // Skip inner SubmodelInterface
+ InnerComponentParams[] comps = new InnerComponentParams[compList.size() - 1];
+ int i = 0;
+ while (componentIt.hasNext())