LocalMode.java 1.7 KB

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