LocalMode.java 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package holeg.interfaces;
  2. public interface LocalMode {
  3. int STANDARD_GRAPH_ACCURACY=100;
  4. class Period {
  5. public Period(Period other) {
  6. this.type = other.type;
  7. this.interval = other.interval;
  8. }
  9. public enum PeriodType{
  10. Local, Global
  11. }
  12. private final PeriodType type;
  13. private int interval;
  14. public Period(int interval){
  15. this.interval = interval;
  16. type = PeriodType.Local;
  17. }
  18. public Period(){
  19. type = PeriodType.Global;
  20. };
  21. /**
  22. * Sets the local period of the element.
  23. * If the simulation has 100 steps and the local period is 50,
  24. * then there will be two full cycles during the simulation.
  25. * @param interval The local period for this element.
  26. */
  27. public void setInterval(int interval){
  28. this.interval = interval;
  29. }
  30. /**
  31. * Used to query the local period of an element.
  32. * @return The local period of this element.
  33. * This should return the set local period,
  34. * which may be anything, even if the component is set to be "stretching",
  35. * that is,
  36. * acting as if the local period was the same
  37. * as the number of total iterations for this simulation.
  38. */
  39. public int getInterval(){
  40. if (type == PeriodType.Local) {
  41. return interval;
  42. }
  43. return STANDARD_GRAPH_ACCURACY;
  44. }
  45. public Period.PeriodType getType() {
  46. return type;
  47. }
  48. }
  49. Period getPeriod();
  50. /**
  51. * Determine if it should use his own LocalPeriod or use the global Period over the entire simulation.
  52. * Local Period is opposed to repeated once the period is over.
  53. */
  54. void setPeriod(Period period);
  55. }