X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=LogicUI%2Fsrc%2Fera%2Fmi%2Fgui%2Fcomponents%2FGUIAndGate.java;fp=LogicUI%2Fsrc%2Fera%2Fmi%2Fgui%2Fcomponents%2FGUIAndGate.java;h=0000000000000000000000000000000000000000;hb=4d29cabdc45d68b5e5f210266dc4fbc5560dbcdd;hp=c76d65a0260afa4cfabb64a042bd5ef9eec1def8;hpb=34fbe2b9bd5bdf6eda0506d9bf00c8840c6cc28a;p=Mograsim.git diff --git a/LogicUI/src/era/mi/gui/components/GUIAndGate.java b/LogicUI/src/era/mi/gui/components/GUIAndGate.java deleted file mode 100644 index c76d65a0..00000000 --- a/LogicUI/src/era/mi/gui/components/GUIAndGate.java +++ /dev/null @@ -1,85 +0,0 @@ -package era.mi.gui.components; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import era.mi.logic.components.gates.AndGate; -import era.mi.logic.timeline.Timeline; -import era.mi.logic.wires.Wire.ReadEnd; -import era.mi.logic.wires.Wire.ReadWriteEnd; -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 GUIAndGate extends AndGate implements BasicGUIComponent -{ - private static final String LABEL = "&"; - - private final int inputCount; - private final double height; - private final List connectedWireEnds; - private final List wireEndConnectionPoints; - - public GUIAndGate(Timeline timeline, int processTime, ReadWriteEnd out, ReadEnd... in) - { - super(timeline, processTime, out, in); - - List connectedWireEndsModifiable = new ArrayList<>(); - List wireEndConnectionPointsModifiable = new ArrayList<>(); - - this.inputCount = in.length; - this.height = inputCount * 10; - - { - connectedWireEndsModifiable.addAll(Arrays.asList(in)); - double inputHeight = 5; - for (int i = 0; i < inputCount; i++, inputHeight += 10) - wireEndConnectionPointsModifiable.add(new Point(0, inputHeight)); - } - - connectedWireEndsModifiable.add(out); - wireEndConnectionPointsModifiable.add(new Point(20, height / 2)); - - this.connectedWireEnds = Collections.unmodifiableList(connectedWireEndsModifiable); - this.wireEndConnectionPoints = Collections.unmodifiableList(wireEndConnectionPointsModifiable); - } - - @Override - public Rectangle getBounds() - { - return new Rectangle(0, 0, 20, height); - } - - @Override - public void render(GeneralGC gc) - { - gc.drawRectangle(0, 0, 20, height); - Font oldFont = gc.getFont(); - Font labelFont = new Font(oldFont.getName(), 5, oldFont.getStyle()); - gc.setFont(labelFont); - Point textExtent = gc.textExtent(LABEL); - gc.drawText(LABEL, 10 - textExtent.x / 2, (height - textExtent.y) / 2, true); - gc.setFont(oldFont); - } - - @Override - public int getConnectedWireEndsCount() - { - return connectedWireEnds.size(); - } - - @Override - public ReadEnd getConnectedWireEnd(int connectionIndex) - { - return connectedWireEnds.get(connectionIndex); - } - - @Override - public Point getWireEndConnectionPoint(int connectionI) - { - return wireEndConnectionPoints.get(connectionI); - } -} \ No newline at end of file