Move components to an actual resource folder (that will remain in jar)
[Mograsim.git] / net.mograsim.logic.model.editor / src / net / mograsim / logic / model / editor / Editor.java
index 945490c..2cc13c1 100644 (file)
@@ -24,6 +24,7 @@ import net.mograsim.logic.model.model.ViewModelModifiable;
 import net.mograsim.logic.model.model.components.GUIComponent;
 import net.mograsim.logic.model.model.wires.GUIWire;
 import net.mograsim.logic.model.serializing.DeserializedSubmodelComponent;
+import net.mograsim.logic.model.serializing.IdentifierGetter;
 import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
 
 public final class Editor
@@ -175,7 +176,9 @@ public final class Editor
 
        public static String getIdentifier(GUIComponent c)
        {
-               return identifierPerComponent.get(c);
+               if (identifierPerComponent.containsKey(c))
+                       return identifierPerComponent.get(c);
+               return new IdentifierGetter().componentIDs.apply(c);
        }
 
        public void duplicate()
@@ -192,8 +195,8 @@ public final class Editor
                case OFF:
                        break;
                case ABSOLUTE:
-                       newP.x -= newP.x % snapX;
-                       newP.y -= newP.y % snapY;
+                       newP.x = (int) (newP.x / snapX + .5) * snapX;
+                       newP.y = (int) (newP.y / snapY + .5) * snapY;
                        break;
                default:
                        break;