X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=plugins%2Fnet.mograsim.logic.model.editor%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fmodel%2Feditor%2Fhandles%2FStaticPinHandle.java;fp=plugins%2Fnet.mograsim.logic.model.editor%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fmodel%2Feditor%2Fhandles%2FStaticPinHandle.java;h=0f4a1524ff8835d2dd657f162d88005388b92df0;hb=7d05144c25daa53e60fc9ed9fd503546a86567f8;hp=0000000000000000000000000000000000000000;hpb=8bed58cd47f4e53a0a83e066d38864aa6875502f;p=Mograsim.git diff --git a/plugins/net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/handles/StaticPinHandle.java b/plugins/net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/handles/StaticPinHandle.java new file mode 100644 index 00000000..0f4a1524 --- /dev/null +++ b/plugins/net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/handles/StaticPinHandle.java @@ -0,0 +1,61 @@ +package net.mograsim.logic.model.editor.handles; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Display; + +import net.haspamelodica.swt.helper.gcs.GeneralGC; +import net.haspamelodica.swt.helper.swtobjectwrappers.Point; +import net.mograsim.logic.model.model.wires.Pin; + +public class StaticPinHandle extends PinHandle +{ + private final static int CIRCLE_DIAM = 2; + private final static int CIRCLE_RADIUS = 1; + private final Pin parent; + + public StaticPinHandle(Pin parent) + { + super(1); + this.parent = parent; + setSize(CIRCLE_DIAM, CIRCLE_DIAM); + parent.addPinMovedListener((p) -> updatePos()); + updatePos(); + } + + @Override + protected void render(GeneralGC gc) + { + gc.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GREEN)); + gc.fillOval(getPosX(), getPosY(), CIRCLE_DIAM, CIRCLE_DIAM); + } + + private void updatePos() + { + Point pos = parent.getPos(); + moveTo(pos.x - CIRCLE_RADIUS, pos.y - CIRCLE_RADIUS); + } + + @Override + public double getCenterX() + { + return getPosX() + CIRCLE_RADIUS; + } + + @Override + public double getCenterY() + { + return getPosY() + CIRCLE_RADIUS; + } + + @Override + public HandleType getType() + { + return HandleType.STATIC_PIN; + } + + @Override + public Pin getPin() + { + return parent; + } +} \ No newline at end of file