1 package net.mograsim.logic.model.editor.handles;
3 import org.eclipse.swt.SWT;
4 import org.eclipse.swt.widgets.Display;
6 import net.haspamelodica.swt.helper.gcs.GeneralGC;
7 import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
8 import net.mograsim.logic.model.model.wires.Pin;
10 public class StaticPinHandle extends PinHandle
12 private final static int CIRCLE_DIAM = 2;
13 private final static int CIRCLE_RADIUS = 1;
14 private final Pin parent;
16 public StaticPinHandle(Pin parent)
20 setSize(CIRCLE_DIAM, CIRCLE_DIAM);
21 parent.addPinMovedListener((p) -> updatePos());
26 protected void render(GeneralGC gc)
28 gc.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GREEN));
29 gc.fillOval(getPosX(), getPosY(), CIRCLE_DIAM, CIRCLE_DIAM);
32 private void updatePos()
34 Point pos = parent.getPos();
35 moveTo(pos.x - CIRCLE_RADIUS, pos.y - CIRCLE_RADIUS);
39 public double getCenterX()
41 return getPosX() + CIRCLE_RADIUS;
45 public double getCenterY()
47 return getPosY() + CIRCLE_RADIUS;
51 public HandleType getType()
53 return HandleType.STATIC_PIN;