IndexTranslator.java 1023 B

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