IndexTranslator.java 997 B

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