X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.ui%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fui%2Fmodel%2Fcomponents%2FGUICustomComponentCreator.java;h=0f6fc1bc4dd5f3f534e4d80c05fa0a4ece241950;hb=ae74a6a022756a4cc7ee5b453ad7a68e13832788;hp=c1503978c6c0cd7c4c5a65e5127e9fdb996de6d3;hpb=82cc1d386820c179be331790fa3c1fae22bada76;p=Mograsim.git diff --git a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/GUICustomComponentCreator.java b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/GUICustomComponentCreator.java index c1503978..0f6fc1bc 100644 --- a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/GUICustomComponentCreator.java +++ b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/GUICustomComponentCreator.java @@ -6,11 +6,10 @@ import java.lang.reflect.InvocationTargetException; import java.util.Map; import net.mograsim.logic.ui.model.ViewModelModifiable; -import net.mograsim.logic.ui.model.components.params.ComponentCompositionParams; -import net.mograsim.logic.ui.model.components.params.ComponentCompositionParams.InnerComponentParams; -import net.mograsim.logic.ui.model.components.params.SubmodelComponentParams; -import net.mograsim.logic.ui.model.components.params.SubmodelComponentParams.InnerWireParams; -import net.mograsim.logic.ui.model.components.params.SubmodelComponentParams.InterfacePinParams; +import net.mograsim.logic.ui.model.components.SubmodelComponentParams.ComponentCompositionParams.InnerComponentParams; +import net.mograsim.logic.ui.model.components.SubmodelComponentParams.ComponentCompositionParams; +import net.mograsim.logic.ui.model.components.SubmodelComponentParams.InnerWireParams; +import net.mograsim.logic.ui.model.components.SubmodelComponentParams.InterfacePinParams; import net.mograsim.logic.ui.model.wires.GUIWire; /** @@ -21,8 +20,9 @@ public final class GUICustomComponentCreator private static final String rectC = SimpleRectangularSubmodelComponent.class.getSimpleName(); /** - * Creates a {@link SubmodelComponent} from the {@link SubmodelComponentParams}, specified at the given path. The returned SubmodelComponent - * can also be e.g. a {@link SimpleRectangularSubmodelComponent}, depending on what the {@link SubmodelComponentParams} describe. + * Creates a {@link SubmodelComponent} from the {@link SubmodelComponentParams}, specified at the given path. The returned + * SubmodelComponent can also be e.g. a {@link SimpleRectangularSubmodelComponent}, depending on what the + * {@link SubmodelComponentParams} describe. * * @param path The path of the file describing the {@link SubmodelComponentParams}, which define the new {@link SubmodelComponent} * @return A new SubmodelComponent, as described in the file located at the given path @@ -44,8 +44,8 @@ public final class GUICustomComponentCreator } /** - * Creates a {@link SubmodelComponent} from the specified {@link SubmodelComponentParams}. The returned SubmodelComponent can also be e.g. a - * {@link SimpleRectangularSubmodelComponent}, depending on what the {@link SubmodelComponentParams} describe. + * Creates a {@link SubmodelComponent} from the specified {@link SubmodelComponentParams}. The returned SubmodelComponent can also be + * e.g. a {@link SimpleRectangularSubmodelComponent}, depending on what the {@link SubmodelComponentParams} describe. * * @param params The parameters describing the {@link SubmodelComponent} * @param path This value is used when the new {@link SubmodelComponent} is an inner component to a different SubmodelComponent, which @@ -80,8 +80,20 @@ public final class GUICustomComponentCreator (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()); + + // TODO names + int inputCount = ((Number) m.get(SimpleRectangularSubmodelComponent.kInCount)).intValue(); + String[] inputNames = new String[inputCount]; + for (int i = 0; i < inputCount; i++) + inputNames[i] = "Input pin #" + i; + rect.setInputPins(inputNames); + + int outputCount = ((Number) m.get(SimpleRectangularSubmodelComponent.kOutCount)).intValue(); + String[] outputPins = new String[outputCount]; + for (int i = 0; i < outputCount; i++) + outputPins[i] = "Output pin #" + i; + rect.setOutputPins(outputPins); + return rect; } catch (ClassCastException | NullPointerException e) @@ -100,7 +112,7 @@ public final class GUICustomComponentCreator comp.setSize(params.width, params.height); for (InterfacePinParams iPinParams : params.interfacePins) { - comp.addSubmodelInterface(iPinParams.logicWidth, iPinParams.location.x, iPinParams.location.y); + comp.addSubmodelInterface(iPinParams.name, iPinParams.logicWidth, iPinParams.location.x, iPinParams.location.y); } return comp; }