import net.haspamelodica.swt.helper.gcs.GeneralGC;
import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle;
import net.mograsim.logic.ui.model.ViewModelModifiable;
+ import net.mograsim.logic.ui.model.Visitable;
import net.mograsim.logic.ui.model.wires.Pin;
/**
*
* @author Daniel Kirschten
*/
- public abstract class GUIComponent
+ public abstract class GUIComponent implements Visitable
{
/**
* The model this component is a part of.
private final Runnable redrawListenerForSubcomponents;
// Defines how the GUIComponent is referenced in SubmodelComponentParams
- protected Supplier<String> identifierDelegate = () -> "class:".concat(getClass().getCanonicalName());
+ protected Supplier<String> identifierDelegate = () -> getClass().getSimpleName();
// creation and destruction
import net.haspamelodica.swt.helper.swtobjectwrappers.Font;
import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle;
+ import net.mograsim.logic.ui.model.ModelVisitor;
import net.mograsim.logic.ui.model.ViewModelModifiable;
import net.mograsim.logic.ui.model.wires.MovablePin;
import net.mograsim.logic.ui.model.wires.Pin;
ret.type = SimpleRectangularSubmodelComponent.class.getSimpleName();
Map<String, Object> m = new TreeMap<>();
m.put(kLabel, label);
- m.put(kInCount, inputPinNames.size());
- m.put(kOutCount, outputPinNames.size());
+ m.put(kInCount, inputPinNames.toArray());
+ m.put(kOutCount, outputPinNames.toArray());
m.put(kLogicWidth, logicWidth);
ret.specialized = m;
return ret;
throw new UnsupportedOperationException(
"Can't set the size of a SimpleRectangularSubmodelComponent directly, call setInputPins / setOutputPins instead");
}
+
+ @Override
+ public void accept(ModelVisitor mv)
+ {
+ mv.visit(this);
+ }
}
public SubmodelComponentParams calculateParams()
{
SubmodelComponentParams params = new SubmodelComponentParams();
+ params.name = getIdentifier();
params.type = SubmodelComponent.class.getSimpleName();
params.composition = calculateCompositionParams();
InnerComponentParams inner = new InnerComponentParams();
comps[i] = inner;
inner.params = component.getInstantiationParameters();
- inner.pos = new Point(getPosX(), getPosY());
- inner.type = component.getIdentifier();
+ inner.pos = new Point(component.getPosX(), component.getPosY());
+ inner.name = component.getIdentifier();
i++;
}
params.subComps = comps;
return params;
}
+ public List<GUIComponent> getComponents()
+ {
+ return submodel.getComponents();
+ }
+
+ public List<GUIWire> getWires()
+ {
+ return submodel.getWires();
+ }
+
// operations no longer supported
@Override