Added getBounds() in BasicGUIComponent
authorDaniel Kirschten <daniel.kirschten@gmx.de>
Wed, 15 May 2019 09:48:24 +0000 (11:48 +0200)
committerDaniel Kirschten <daniel.kirschten@gmx.de>
Wed, 15 May 2019 09:48:24 +0000 (11:48 +0200)
LogicUI/src/era/mi/components/gui/BasicGUIComponent.java
LogicUI/src/era/mi/components/gui/GUIAndGate.java
LogicUI/src/era/mi/components/gui/GUIMerger.java
LogicUI/src/era/mi/components/gui/GUIMux.java
LogicUI/src/era/mi/components/gui/GUINotGate.java
LogicUI/src/era/mi/components/gui/GUISplitter.java

index f7e7d37..925fe4b 100644 (file)
@@ -3,6 +3,7 @@ package era.mi.components.gui;
 import era.mi.logic.wires.WireArray;
 import net.haspamelodica.swt.helper.gcs.GeneralGC;
 import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
+import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle;
 
 public interface BasicGUIComponent
 {
@@ -10,6 +11,11 @@ public interface BasicGUIComponent
         * Render this component to the given gc, at coordinates (0, 0).
         */
        public void render(GeneralGC gc);
+       /**
+        * Returns the bounds of this component.
+        * Used for calculating which component is clicked.
+        */
+       public Rectangle getBounds();
 
        //TODO this code will be replaced by code in BasicComponent.
        /**
index 92bc86e..93429e8 100644 (file)
@@ -10,6 +10,7 @@ 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 GUIAndGate extends AndGate implements BasicGUIComponent
 {
@@ -44,6 +45,11 @@ public class GUIAndGate extends AndGate implements BasicGUIComponent
                this.wireArrayConnectionPoints = Collections.unmodifiableList(wireArrayConnectionPointsModifiable);
        }
 
+       @Override
+       public Rectangle getBounds()
+       {
+               return new Rectangle(0, 0, 20, height);
+       }
        @Override
        public void render(GeneralGC gc)
        {
index 0f4f2da..69a47a2 100644 (file)
@@ -9,6 +9,7 @@ import era.mi.logic.components.Merger;
 import era.mi.logic.wires.WireArray;
 import net.haspamelodica.swt.helper.gcs.GeneralGC;
 import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
+import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle;
 
 public class GUIMerger extends Merger implements BasicGUIComponent
 {
@@ -41,6 +42,11 @@ public class GUIMerger extends Merger implements BasicGUIComponent
                this.wireArrayConnectionPoints = Collections.unmodifiableList(wireArrayConnectionPointsModifiable);
        }
 
+       @Override
+       public Rectangle getBounds()
+       {
+               return new Rectangle(0, 0, 20, height);
+       }
        @Override
        public void render(GeneralGC gc)
        {
index 42973ca..df61ca7 100644 (file)
@@ -9,6 +9,7 @@ import era.mi.logic.components.Mux;
 import era.mi.logic.wires.WireArray;
 import net.haspamelodica.swt.helper.gcs.GeneralGC;
 import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
+import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle;
 
 public class GUIMux extends Mux implements BasicGUIComponent
 {
@@ -45,6 +46,12 @@ public class GUIMux extends Mux implements BasicGUIComponent
                this.connectedWireArrays = Collections.unmodifiableList(connectedWireArraysModifiable);
                this.wireArrayConnectionPoints = Collections.unmodifiableList(wireArrayConnectionPointsModifiable);
        }
+
+       @Override
+       public Rectangle getBounds()
+       {
+               return new Rectangle(0, 0, 20, height + 20);
+       }
        @Override
        public void render(GeneralGC gc)
        {
index 4ab4c44..b428888 100644 (file)
@@ -9,6 +9,7 @@ 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 GUINotGate extends NotGate implements BasicGUIComponent
 {
@@ -34,6 +35,11 @@ public class GUINotGate extends NotGate implements BasicGUIComponent
                this.wireArrayConnectionPoints = Collections.unmodifiableList(wireArrayConnectionPointsModifiable);
        }
 
+       @Override
+       public Rectangle getBounds()
+       {
+               return new Rectangle(0, 0, 20, 10);
+       }
        @Override
        public void render(GeneralGC gc)
        {
index 67405bf..aab18cf 100644 (file)
@@ -9,6 +9,7 @@ import era.mi.logic.components.Splitter;
 import era.mi.logic.wires.WireArray;
 import net.haspamelodica.swt.helper.gcs.GeneralGC;
 import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
+import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle;
 
 public class GUISplitter extends Splitter implements BasicGUIComponent
 {
@@ -41,6 +42,11 @@ public class GUISplitter extends Splitter implements BasicGUIComponent
                this.wireArrayConnectionPoints = Collections.unmodifiableList(wireArrayConnectionPointsModifiable);
        }
 
+       @Override
+       public Rectangle getBounds()
+       {
+               return new Rectangle(0, 0, 20, height);
+       }
        @Override
        public void render(GeneralGC gc)
        {