X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=LogicUI%2Fsrc%2Fera%2Fmi%2Fgui%2Fwires%2FGUIWire.java;fp=LogicUI%2Fsrc%2Fera%2Fmi%2Fgui%2Fwires%2FGUIWire.java;h=e711acb9e8d7616325a175dd7a577ec154d3b782;hb=873c7cd58e0a035e68b5af352260da9f4d667c96;hp=cae2cfd7e08afea744cd897156ad5547a13a5531;hpb=340eb95b6ab64f2c1a784d1dc36002537b1cbd15;p=Mograsim.git diff --git a/LogicUI/src/era/mi/gui/wires/GUIWire.java b/LogicUI/src/era/mi/gui/wires/GUIWire.java index cae2cfd7..e711acb9 100644 --- a/LogicUI/src/era/mi/gui/wires/GUIWire.java +++ b/LogicUI/src/era/mi/gui/wires/GUIWire.java @@ -13,19 +13,20 @@ import net.haspamelodica.swt.helper.swtobjectwrappers.Point; public class GUIWire { - private final WireArray wa; - private final double[] path; + private final WireArray wa; + private final double[] path; - public GUIWire(Runnable redraw, BasicGUIComponent component1, int component1ConnectionIndex, Point component1Pos, BasicGUIComponent component2, int component2ConnectionIndex, Point component2Pos, Point... path) + public GUIWire(Runnable redraw, BasicGUIComponent component1, int component1ConnectionIndex, Point component1Pos, + BasicGUIComponent component2, int component2ConnectionIndex, Point component2Pos, Point... path) { this.wa = component1.getConnectedWireArray(component1ConnectionIndex); - if(!Objects.equals(wa, component2.getConnectedWireArray(component2ConnectionIndex))) + if (!Objects.equals(wa, component2.getConnectedWireArray(component2ConnectionIndex))) throw new IllegalArgumentException("Given connection points are not connected!"); this.path = new double[path.length * 2 + 4]; Point component1ConnectionPoint = component1.getWireArrayConnectionPoint(component1ConnectionIndex); this.path[0] = component1Pos.x + component1ConnectionPoint.x; this.path[1] = component1Pos.y + component1ConnectionPoint.y; - for(int srcI = 0, dstI = 2; srcI < path.length; srcI ++, dstI += 2) + for (int srcI = 0, dstI = 2; srcI < path.length; srcI++, dstI += 2) { this.path[dstI + 0] = path[srcI].x; this.path[dstI + 1] = path[srcI].y; @@ -40,7 +41,7 @@ public class GUIWire public void render(GeneralGC gc) { Color oldFG = gc.getForeground(); - if(wa.length == 1) + if (wa.length == 1) gc.setForeground(gc.getDevice().getSystemColor(getSWTColorConstantForBit(wa.getValue()))); gc.drawPolyline(path); gc.setForeground(oldFG); @@ -48,19 +49,19 @@ public class GUIWire public static int getSWTColorConstantForBit(Bit bit) { - switch(bit) + switch (bit) { - case ONE: - return SWT.COLOR_GREEN; - case ZERO: - return SWT.COLOR_BLUE; - case Z: - return SWT.COLOR_BLACK; - case U: - case X: - return SWT.COLOR_RED; - default: - throw new IllegalArgumentException("Unknown enum constant: " + bit); + case ONE: + return SWT.COLOR_GREEN; + case ZERO: + return SWT.COLOR_BLUE; + case Z: + return SWT.COLOR_BLACK; + case U: + case X: + return SWT.COLOR_RED; + default: + throw new IllegalArgumentException("Unknown enum constant: " + bit); } } } \ No newline at end of file