PraktikumHolonsAdapter.java 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package tests;
  2. import java.util.ArrayList;
  3. import static java.lang.Math.*;
  4. import classes.Category;
  5. import classes.AbstractCanvasObject;
  6. import classes.HolonElement;
  7. import classes.HolonObject;
  8. import classes.IdCounter;
  9. import classes.IdCounter.CounterType;
  10. /**
  11. * This Class Generates Stuff for the Tests.
  12. *
  13. * @author Gruppe14
  14. */
  15. public class PraktikumHolonsAdapter {
  16. /**
  17. * Generate Sequence of Categories from A - ZZZ.
  18. * @param arr ArrayList of Categories
  19. */
  20. public void generateCategories(ArrayList<Category> arr) {
  21. for (int i = 1; i < 18279; i++) {
  22. arr.add(new Category(generate(i)));
  23. }
  24. }
  25. /**
  26. * Generate Sequence of Objects from A - ZZZ.
  27. * @param arr ArrayList of Categories
  28. */
  29. public void generateObjects(ArrayList<AbstractCanvasObject> arr) {
  30. for (int i = 1; i < 18279; i++) {
  31. arr.add(new HolonObject(generate(i)));
  32. }
  33. }
  34. /**
  35. * Generate Sequence of Elements from A - ZZZ.
  36. * @param arr ArrayList of Categories
  37. */
  38. public void generateElements(ArrayList<HolonElement> arr) {
  39. for (int i = 1; i < 18279; i++) {
  40. arr.add(new HolonElement(null, generate(i), 1, 10, IdCounter.nextId(CounterType.Element)));
  41. }
  42. }
  43. /**
  44. * Generate Alphabetical Sequences.
  45. * @param n Generator
  46. * @return A generated Alphabetical Sequence
  47. */
  48. public String generate(int n) {
  49. char[] buf = new char[(int) floor(log(25 * (n + 1)) / log(26))];
  50. for (int i = buf.length - 1; i >= 0; i--) {
  51. n--;
  52. buf[i] = (char) ('A' + n % 26);
  53. n /= 26;
  54. }
  55. return new String(buf);
  56. }
  57. }