Tool to display Walter Giers' notebooks in either chronological or in random order
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

Notebook.pde 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. class Notebook {
  2. String notebookpath;
  3. String[] imagepaths;
  4. String dateText;
  5. int year;
  6. int id;
  7. Notebook(int id_, String notebookpath_, String[] imagepaths_) {
  8. id = id_;
  9. notebookpath = dataPath("") + "/Notizhefte/" + notebookpath_;
  10. imagepaths = Arrays.copyOfRange(imagepaths_, 1, imagepaths_.length-1);
  11. String[] separated = notebookpath_.split("-");
  12. dateText = (getMonth(int(separated[1])) + " " + separated[0]);
  13. year = int(separated[0]);
  14. }
  15. }
  16. String getMonth(int id) {
  17. switch(id) {
  18. case(1):
  19. return("January");
  20. case(2):
  21. return("February");
  22. case(3):
  23. return("March");
  24. case(4):
  25. return("April");
  26. case(5):
  27. return("May");
  28. case(6):
  29. return("June");
  30. case(7):
  31. return("July");
  32. case(8):
  33. return("August");
  34. case(9):
  35. return("September");
  36. case(10):
  37. return("October");
  38. case(11):
  39. return("November");
  40. case(12):
  41. return("December");
  42. default:
  43. return " ";
  44. }
  45. }
  46. void createNotebooks() {
  47. File datafolder = new File(dataPath("") + "/Notizhefte");
  48. String[] notebooknames = datafolder.list();
  49. notebooknames = sort(notebooknames);
  50. int notebookID = 0;
  51. for (int i = 0; i < notebooknames.length; i++) {
  52. File notebookfolder = new File(dataPath("") + "/Notizhefte/" + notebooknames[i]);
  53. if (notebookfolder.list() != null) {
  54. String[] imagenames = notebookfolder.list();
  55. List<String> strings = Arrays.asList(imagenames);
  56. Collections.sort(strings, new Comparator<String>() {
  57. public int compare(String o1, String o2) {
  58. return extractInt(o1) - extractInt(o2);
  59. }
  60. int extractInt(String s) {
  61. String num = s.replaceAll("\\D", "");
  62. return num.isEmpty() ? 0 : Integer.parseInt(num);
  63. }
  64. }
  65. );
  66. imagenames = strings.toArray(imagenames);
  67. notebooks.add(new Notebook(notebookID, notebooknames[i], imagenames));
  68. notebookID ++;
  69. }
  70. }
  71. }