瀏覽代碼

Fixed HolonElement indexing not working without a model.

Even though this situation exclusively occurs in the tests.
Ludwig Tietze 6 年之前
父節點
當前提交
20e96789dd
共有 1 個文件被更改,包括 3 次插入5 次删除
  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){