X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=LogicUI%2Fsrc%2Fera%2Fmi%2Fgui%2Fcomponents%2FGUIManualSwitch.java;h=bcfa464b9efce00b9797895e1b2f332dd07ec3fa;hb=adb7d3662c194d94015851259cc67e6fd0575feb;hp=9d58cac9f23f57b4453f7d564ada00b4a2f9c84c;hpb=d3a382377768fdb1434d5baebf73c9413e61e46f;p=Mograsim.git diff --git a/LogicUI/src/era/mi/gui/components/GUIManualSwitch.java b/LogicUI/src/era/mi/gui/components/GUIManualSwitch.java index 9d58cac9..bcfa464b 100644 --- a/LogicUI/src/era/mi/gui/components/GUIManualSwitch.java +++ b/LogicUI/src/era/mi/gui/components/GUIManualSwitch.java @@ -1,72 +1,6 @@ package era.mi.gui.components; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import era.mi.logic.components.ManualSwitch; -import era.mi.logic.wires.WireArray; -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; - -public class GUIManualSwitch extends ManualSwitch implements BasicGUIComponent +public class GUIManualSwitch { - private final List connectedWireArrays; - private final List wireArrayConnectionPoints; - - public GUIManualSwitch(WireArray output) - { - super(output); - - List connectedWireArraysModifiable = new ArrayList<>(); - List wireArrayConnectionPointsModifiable = new ArrayList<>(); - - connectedWireArraysModifiable.add(output); - wireArrayConnectionPointsModifiable.add(new Point(20, 7.5)); - - this.connectedWireArrays = Collections.unmodifiableList(connectedWireArraysModifiable); - this.wireArrayConnectionPoints = Collections.unmodifiableList(wireArrayConnectionPointsModifiable); - } - - @Override - public Rectangle getBounds() - { - return new Rectangle(0, 0, 20, 15); - } - @Override - public void render(GeneralGC gc) - { - gc.drawRectangle(0, 0, 20, 15); - String label = isOn() ? "ON" : "OFF"; - Font oldFont = gc.getFont(); - Font labelFont = new Font(oldFont.getName(), 6, oldFont.getStyle()); - gc.setFont(labelFont); - Point textExtent = gc.textExtent(label); - gc.drawText(label, 10 - textExtent.x / 2, 7.5 - textExtent.y / 2, true); - gc.setFont(oldFont); - } - @Override - public boolean clicked(double x, double y) - { - toggle(); - return true; - } - @Override - public int getConnectedWireArraysCount() - { - return connectedWireArrays.size(); - } - @Override - public WireArray getConnectedWireArray(int connectionIndex) - { - return connectedWireArrays.get(connectionIndex); - } - @Override - public Point getWireArrayConnectionPoint(int connectionI) - { - return wireArrayConnectionPoints.get(connectionI); - } -} \ No newline at end of file +}