Sync git svn branch with SVN repository r33406.
[simantics/platform.git] / bundles / org.simantics.trend / src / org / simantics / trend / impl / TrendNode.java
index 1d19e2f1775c1df298d31fa864a02ac3c1be4242..dba76ccad2afdc13565cdc1412a62ab20a358883 100644 (file)
@@ -60,7 +60,6 @@ import org.simantics.utils.format.ValueFormat;
 \r
 import gnu.trove.map.TObjectIntMap;\r
 import gnu.trove.map.hash.TObjectIntHashMap;\r
-import gnu.trove.procedure.TIntProcedure;\r
 import gnu.trove.procedure.TObjectProcedure;\r
 \r
 public class TrendNode extends G2DParentNode implements TrendLayout {\r
@@ -276,7 +275,6 @@ public class TrendNode extends G2DParentNode implements TrendLayout {
 \r
                TObjectIntMap<String> newItemMap = itemIndexMap(newSpec.items);\r
                TObjectIntMap<String> currentItemMap = itemIndexMap(spec.items);\r
-               TObjectIntMap<String> addedItemMap = subtract(newItemMap, currentItemMap);\r
                TObjectIntMap<String> removedItemMap = subtract(currentItemMap, newItemMap);\r
                Map<String, VertRuler> existingRulers = new HashMap<>();\r
                if (this.spec.axisMode == YAxisMode.MultiAxis) {\r
@@ -347,6 +345,9 @@ public class TrendNode extends G2DParentNode implements TrendLayout {
                                for (int i=0; i<analogItems.size(); i++)\r
                                        vertRulers.add( addNode(VertRuler.class) );\r
                        } else {\r
+                               // Remove rulers of the items that were removed\r
+                               // and add new rulers to have enough of them for\r
+                               // each separate analog signal.\r
                                removedItemMap.forEachKey(new TObjectProcedure<String>() {\r
                                        @Override\r
                                        public boolean execute(String id) {\r
@@ -358,13 +359,10 @@ public class TrendNode extends G2DParentNode implements TrendLayout {
                                                return true;\r
                                        }\r
                                });\r
-                               addedItemMap.forEachValue(new TIntProcedure() {\r
-                                       @Override\r
-                                       public boolean execute(int index) {\r
-                                               vertRulers.add( index, addNode(VertRuler.class) );\r
-                                               return true;\r
-                                       }\r
-                               });\r
+                               for (int i = vertRulers.size(); i < analogItems.size(); ++i) {\r
+                                       VertRuler ruler = addNode(VertRuler.class);\r
+                                       vertRulers.add(ruler);\r
+                               }\r
                        }\r
 \r
                        for (int i = 0; i < analogItems.size(); i++) {\r