import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
import net.mograsim.logic.model.model.ViewModel;
import net.mograsim.logic.model.model.ViewModelModifiable;
import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
import net.mograsim.logic.model.model.ViewModel;
import net.mograsim.logic.model.model.ViewModelModifiable;
import net.mograsim.logic.model.serializing.ViewModelParams.ComponentParams;
import net.mograsim.logic.model.serializing.ViewModelParams.WireParams;
import net.mograsim.logic.model.serializing.ViewModelParams.WireParams.PinParams;
import net.mograsim.logic.model.serializing.ViewModelParams.ComponentParams;
import net.mograsim.logic.model.serializing.ViewModelParams.WireParams;
import net.mograsim.logic.model.serializing.ViewModelParams.WireParams.PinParams;
- public static void serialize(ViewModel model, IdentifierGetter idGetter, String targetPath) throws IOException
+ public static void serialize(ViewModel model, IdentifyParams idParams, String targetPath) throws IOException
- Map<String, GUIComponent> componentsByName = model.getComponentsByName();
- GUIComponent[] components = new GUIComponent[params.components.length];
+ Map<String, ModelComponent> componentsByName = model.getComponentsByName();
+ ModelComponent[] components = new ModelComponent[params.components.length];
- components[i] = IndirectGUIComponentCreator.createComponent(model, compParams.id, compParams.params, compParams.name);
+ components[i] = IndirectModelComponentCreator.createComponent(model, compParams.id, compParams.params, compParams.name);
components[i].moveTo(compParams.pos.x, compParams.pos.y);
}
for (int i = 0; i < params.wires.length; i++)
{
WireParams wire = params.wires[i];
components[i].moveTo(compParams.pos.x, compParams.pos.y);
}
for (int i = 0; i < params.wires.length; i++)
{
WireParams wire = params.wires[i];
- new GUIWire(model, wire.name, componentsByName.get(wire.pin1.compName).getPin(wire.pin1.pinName),
+ new ModelWire(model, wire.name, componentsByName.get(wire.pin1.compName).getPin(wire.pin1.pinName),
* {@link DeserializedSubmodelComponent#paramsForSerializingOverride paramsForSerializingOverride} are written.<br>
* If this case doesn't apply (e.g. if the component is not a <code>SubmodelComponent</code>; or it is a <code>SubmodelComponent</code>,
* but hasn't been deserialized; or it has no {@link DeserializedSubmodelComponent#idForSerializingOverride idForSerializingOverride}
* {@link DeserializedSubmodelComponent#paramsForSerializingOverride paramsForSerializingOverride} are written.<br>
* If this case doesn't apply (e.g. if the component is not a <code>SubmodelComponent</code>; or it is a <code>SubmodelComponent</code>,
* but hasn't been deserialized; or it has no {@link DeserializedSubmodelComponent#idForSerializingOverride idForSerializingOverride}
components.remove(SubmodelComponent.SUBMODEL_INTERFACE_NAME);
Set<ComponentParams> componentsParams = new HashSet<>();
components.remove(SubmodelComponent.SUBMODEL_INTERFACE_NAME);
Set<ComponentParams> componentsParams = new HashSet<>();
- compParams.id = idGetter.componentIDs.apply(component);
- compParams.params = component.getParamsForSerializing(idGetter);
+ compParams.id = component.getIDForSerializing(idParams);
+ compParams.params = component.getParamsForSerializingJSON(idParams);
}
compParams.name = component.name;
}
modelParams.components = componentsParams.toArray(ComponentParams[]::new);
Arrays.sort(modelParams.components, Comparator.comparing(c -> c.name));
}
compParams.name = component.name;
}
modelParams.components = componentsParams.toArray(ComponentParams[]::new);
Arrays.sort(modelParams.components, Comparator.comparing(c -> c.name));