Changed interface of GUIComponent.getPins()
authorDaniel Kirschten <daniel.kirschten@gmx.de>
Sat, 22 Jun 2019 08:43:15 +0000 (10:43 +0200)
committerDaniel Kirschten <daniel.kirschten@gmx.de>
Sat, 22 Jun 2019 08:43:15 +0000 (10:43 +0200)
net.mograsim.logic.ui/src/net/mograsim/logic/ui/LogicUIRenderer.java
net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/GUIComponent.java
net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/SubmodelComponent.java
net.mograsim.logic.ui/src/net/mograsim/logic/ui/modeladapter/ViewLogicModelAdapter.java

index 29bf613..7858a70 100644 (file)
@@ -45,7 +45,7 @@ public class LogicUIRenderer
                        if (DRAW_PINS)
                        {
                                gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_DARK_CYAN));
-                               for (Pin p : component.getPins())
+                               for (Pin p : component.getPins().values())
                                {
                                        Point pos = p.getPos();
                                        gc.fillOval(pos.x - 1, pos.y - 1, 2, 2);
index 472798f..a586616 100644 (file)
@@ -1,7 +1,6 @@
 package net.mograsim.logic.ui.model.components;
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
@@ -33,9 +32,9 @@ public abstract class GUIComponent
         */
        private final Map<String, Pin> pinsByName;
        /**
-        * An unmodifiable view of {@link #pinsByName}<code>.</code>{@link Map#values() values()}.
+        * An unmodifiable view of {@link #pinsByName}.
         */
-       protected final Collection<Pin> pinsUnmodifiable;
+       protected final Map<String, Pin> pinsUnmodifiable;
 
        private final List<Consumer<? super GUIComponent>> componentMovedListeners;
        private final List<Consumer<? super Pin>> pinAddedListeners;
@@ -53,7 +52,7 @@ public abstract class GUIComponent
                this.model = model;
                this.bounds = new Rectangle(0, 0, 0, 0);
                this.pinsByName = new HashMap<>();
-               this.pinsUnmodifiable = Collections.unmodifiableCollection(pinsByName.values());
+               this.pinsUnmodifiable = Collections.unmodifiableMap(pinsByName);
 
                this.componentMovedListeners = new ArrayList<>();
                this.pinAddedListeners = new ArrayList<>();
@@ -119,7 +118,7 @@ public abstract class GUIComponent
         * 
         * @author Daniel Kirschten
         */
-       public Collection<Pin> getPins()
+       public Map<String, Pin> getPins()
        {
                return pinsUnmodifiable;
        }
index 8febda8..6aad07f 100644 (file)
@@ -224,7 +224,7 @@ public abstract class SubmodelComponent extends GUIComponent
 
                InterfacePinParams[] iPins = new InterfacePinParams[getPins().size()];
                int i = 0;
-               for (Pin p : getPins())
+               for (Pin p : getPins().values())
                {
                        InterfacePinParams iPinParams = new InterfacePinParams();
                        iPins[i] = iPinParams;
index 3cbc150..5503dc4 100644 (file)
@@ -85,7 +85,7 @@ public class ViewLogicModelAdapter
 
        private static Set<Pin> getAllPins(ViewModel viewModel)
        {
-               return viewModel.getComponents().stream().flatMap(component -> component.getPins().stream()).collect(Collectors.toSet());
+               return viewModel.getComponents().stream().flatMap(component -> component.getPins().values().stream()).collect(Collectors.toSet());
        }
 
        private static Map<Pin, Wire> convertWires(Set<Pin> allPins, List<GUIWire> wires, Map<Pin, Wire> externalWires,