PraktikumHolonsAdapter.java 1.5 KB

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