- // 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;
+ double scaledX = (x - getPosX()) / submodelScale;
+ double scaledY = (y - getPosY()) / submodelScale;
+ for (GUIComponent component : submodel.getComponents())
+ if (component.getBounds().contains(scaledX, scaledY) && component.clicked(scaledX, scaledY))
+ return true;
+ return false;
+ }
+
+ /**
+ * @return {@link SubmodelComponentParams}, which describe this {@link SubmodelComponent}.
+ */
+ public SubmodelComponentParams calculateParams()
+ {
+ SubmodelComponentParams params = new SubmodelComponentParams();
+ params.type = SubmodelComponent.class.getSimpleName();
+ params.composition = calculateCompositionParams();
+
+ params.width = getWidth();
+ params.height = getHeight();
+
+ InterfacePinParams[] iPins = new InterfacePinParams[getPins().size()];
+ int i = 0;
+ for (Pin p : getPins().values())
+ {
+ 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;