IndexTranslator.java 975 B

12345678910111213141516171819202122232425262728
  1. package holeg.ui.controller;
  2. import holeg.interfaces.LocalMode;
  3. import holeg.ui.model.Model;
  4. public class IndexTranslator {
  5. public static int STANDARD_GRAPH_ACCURACY = 100;
  6. public static Model model;
  7. /**
  8. * Determines the index of the internal value array
  9. * of an element that should be used, since elements only save 100 values,
  10. * but iterations and local period can be anything between 1 and 100000.
  11. *
  12. * @param m the corresponding model.
  13. * @param e the element for which the calculation should be made.
  14. * @param timeStep the iteration for which the calculation should be made.
  15. * @return
  16. */
  17. public static int getEffectiveIndex(LocalMode e, int timeStep){
  18. if(e.isUsingLocalPeriod()) {
  19. return timeStep % e.getLocalPeriod()* 100 /e.getLocalPeriod();
  20. }
  21. else {
  22. return timeStep * 100 / (model == null?STANDARD_GRAPH_ACCURACY:model.getMaxIterations());
  23. }
  24. }
  25. }