Explorar o código

Fixed HolonElement indexing not working without a model.

Even though this situation exclusively occurs in the tests.
Ludwig Tietze %!s(int64=6) %!d(string=hai) anos
pai
achega
20e96789dd
Modificáronse 1 ficheiros con 3 adicións e 5 borrados
  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){