import org.eclipse.swt.widgets.Display;
import net.haspamelodica.swt.helper.gcs.GeneralGC;
+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.model.editor.Editor;
import net.mograsim.logic.model.editor.Editor.ComponentInfo;
-import net.mograsim.logic.model.model.ViewModelModifiable;
-import net.mograsim.logic.model.model.components.GUIComponent;
+import net.mograsim.logic.model.model.LogicModelModifiable;
+import net.mograsim.logic.model.model.components.ModelComponent;
import net.mograsim.logic.model.serializing.IdentifyParams;
public class ComponentHandle extends Handle
{
- private final ViewModelModifiable model;
- public final GUIComponent parent;
+ private final LogicModelModifiable model;
+ public final ModelComponent parent;
private final static double POS_OFFSET = 2.0d;
private final static double LENGTH_OFFSET = POS_OFFSET * 2;
boolean selected = false;
- public ComponentHandle(ViewModelModifiable model, GUIComponent parent)
+ public ComponentHandle(LogicModelModifiable model, ModelComponent parent)
{
super(4);
this.model = model;
bounds.width += LENGTH_OFFSET;
bounds.height += LENGTH_OFFSET;
gc.drawRectangle(bounds);
+ Font oldFont = gc.getFont();
+ gc.setFont(new Font(oldFont.getName(), 5, oldFont.getStyle()));
+ gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));
+ gc.drawText(parent.getName(), bounds.x, bounds.y, true);
+ gc.setFont(oldFont);
}
}
@Override
public Optional<ComponentInfo> reqCopy(Point refPoint)
{
- return Optional.of(new ComponentInfo(parent.getPosX() - refPoint.x, parent.getPosY() - refPoint.y, Editor.getIdentifier(parent),
- parent.getParamsForSerializingJSON(new IdentifyParams())));
+ IdentifyParams idParams = new IdentifyParams();
+ return Optional.of(new ComponentInfo(parent.getPosX() - refPoint.x, parent.getPosY() - refPoint.y,
+ parent.getIDForSerializing(idParams), parent.getParamsForSerializingJSON(idParams)));
}
@Override