- /**
- * @param path This value is used when the new SubmodelComponent is an inner component to a different SubmodelComponent, which is being
- * saved to a file; Then, the new SubmodelComponent is referenced by its given path within the file.
- */
- public static SubmodelComponent create(ViewModelModifiable model, SubComponentParams params, String path)
+ // May return null
+ private static SimpleRectangularSubmodelComponent createRectComponent(ViewModelModifiable model, SubmodelComponentParams params)
+ {
+ try
+ {
+ Map<String, Object> m = params.specialized;
+ SimpleRectangularSubmodelComponent rect = new SimpleRectangularSubmodelComponent(model,
+ ((Number) m.get(SimpleRectangularSubmodelComponent.kLogicWidth)).intValue(),
+ (String) m.get(SimpleRectangularSubmodelComponent.kLabel));
+ rect.setSubmodelScale(params.composition.innerScale);
+ rect.setSize(params.width, params.height);
+ rect.setInputCount(((Number) m.get(SimpleRectangularSubmodelComponent.kInCount)).intValue());
+ rect.setOutputCount(((Number) m.get(SimpleRectangularSubmodelComponent.kOutCount)).intValue());
+ return rect;
+ }
+ catch (ClassCastException | NullPointerException e)
+ {
+ System.err.println("Failed to specialize component!");
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ private static SubmodelComponent createSubmodelComponent(ViewModelModifiable model, SubmodelComponentParams params)