Browse Source

Fixed HolonElement indexing not working without a model.

Even though this situation exclusively occurs in the tests.
Ludwig Tietze 6 years ago
parent
commit
20e96789dd
1 changed files with 3 additions and 5 deletions
  1. 3 5
      src/ui/view/UnitGraph.java

+ 3 - 5
src/ui/view/UnitGraph.java

@@ -875,14 +875,12 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
     static int lv=0;
     
     public static int getEffectiveIndex(Model m, IGraphedElement e, int timeStep){
-    	int o;
-    	if(e.isStretching())o= timeStep*100/m.getIterations();
-    	else o= timeStep%e.getLocalPeriod()*100/e.getLocalPeriod();
-    	return o;//TODO
+    	if(e.isStretching())return timeStep*100/(m==null?100:m.getIterations());
+    	else return timeStep%e.getLocalPeriod()*100/e.getLocalPeriod();
     }
     
     public static int getEffectiveIndex(IGraphedElement e, int timeStep){
-    	return getEffectiveIndex(SingletonControl.getInstance().getControl().getModel(),e,timeStep);
+    	return getEffectiveIndex(SingletonControl.getInstance().getControl()==null?null:SingletonControl.getInstance().getControl().getModel(),e,timeStep);
     }
     
     public static int getEffectiveIndex(IGraphedElement e){