import net.haspamelodica.swt.helper.gcs.TranslatedGC;
import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle;
import net.mograsim.logic.model.LogicUIRenderer;
-import net.mograsim.logic.model.model.ViewModel;
-import net.mograsim.logic.model.model.ViewModelModifiable;
+import net.mograsim.logic.model.model.LogicModel;
+import net.mograsim.logic.model.model.LogicModelModifiable;
import net.mograsim.logic.model.model.components.ModelComponent;
import net.mograsim.logic.model.model.wires.MovablePin;
import net.mograsim.logic.model.model.wires.Pin;
/**
* A modifiable view of {@link #submodel}.
*/
- protected final ViewModelModifiable submodelModifiable;
+ protected final LogicModelModifiable submodelModifiable;
/**
* The model this {@link SubmodelComponent} consists of.
*/
- public final ViewModel submodel;
+ public final LogicModel submodel;
/**
* The list of all submodel interface pins of this {@link SubmodelComponent} on the submodel side.
*/
// creation and destruction
- public SubmodelComponent(ViewModelModifiable model, String name)
+ public SubmodelComponent(LogicModelModifiable model, String name)
{
- super(model, name);
- this.submodelModifiable = new ViewModelModifiable();
+ this(model, name, true);
+ }
+
+ protected SubmodelComponent(LogicModelModifiable model, String name, boolean callInit)
+ {
+ super(model, name, false);
+ this.submodelModifiable = new LogicModelModifiable();
this.submodel = submodelModifiable;
this.submodelPins = new HashMap<>();
this.submodelMovablePinsUnmodifiable = Collections.unmodifiableMap(submodelPins);
this.supermodelPins = new HashMap<>();
this.supermodelMovablePinsUnmodifiable = Collections.unmodifiableMap(supermodelPins);
this.supermodelUnmovablePinsUnmodifiable = Collections.unmodifiableMap(supermodelPins);
- this.submodelInterface = new SubmodelInterface(submodelModifiable, SUBMODEL_INTERFACE_NAME);
+ this.submodelInterface = new SubmodelInterface(submodelModifiable);
this.submodelScale = 1;
this.maxVisibleRegionFillRatioForAlpha0 = 0.8;
model.removeRedrawHandlerChangedListener(redrawHandlerChangedListener);
});
submodelModifiable.setRedrawHandler(model.getRedrawHandler());
+
+ if (callInit)
+ init();
}
// pins
default:
throw new IllegalArgumentException("Unknown enum constant: " + supermodelPin.usage);
}
- MovablePin submodelPin = new MovablePin(submodelInterface, name, supermodelPin.logicWidth, submodelPinUsage,
+ MovablePin submodelPin = new MovablePin(submodelModifiable, submodelInterface, name, supermodelPin.logicWidth, submodelPinUsage,
supermodelPin.getRelX() / submodelScale, supermodelPin.getRelY() / submodelScale);
submodelPin.addPinMovedListener(p ->
// serializing
+ /**
+ * {@link SubmodelComponent}'s implementation of {@link ModelComponent#getIDForSerializing(IdentifyParams)} returns "submodel". It is
+ * recommended to override this behaviour.
+ *
+ * @see ModelComponent#getIDForSerializing(IdentifyParams)
+ * @see ModelComponent#getParamsForSerializing(IdentifyParams)
+ */
@Override
public String getIDForSerializing(IdentifyParams idParams)
{
return "submodel";// TODO what ID?
}
+ /**
+ * {@link SubmodelComponent}'s implementation of {@link ModelComponent#getParamsForSerializing(IdentifyParams)} returns an instance of
+ * {@link SubmodelComponentParams}. It is recommended to override this behaviour.
+ *
+ * @see ModelComponent#getIDForSerializing(IdentifyParams)
+ * @see ModelComponent#getParamsForSerializing(IdentifyParams)
+ */
@Override
- public SubmodelComponentParams getParamsForSerializing(IdentifyParams idParams)
+ public Object getParamsForSerializing(IdentifyParams idParams)
{
return SubmodelComponentSerializer.serialize(this, idParams);
}