Simple editor to create custom node network graphs aka ontologies
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

gui.pde 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. int buttonCount = 8;
  2. int i_buttonId;
  3. boolean menuOpen = true;
  4. int[] menuButtons = {2, 3, 4, 5, 6};
  5. void menu() {
  6. menuOpen = !menuOpen;
  7. for (int i = 0; i < menuButtons.length; i++) {
  8. buttons[menuButtons[i]].active = menuOpen;
  9. }
  10. }
  11. void initButtons() {
  12. buttons[0] = new Button(72, 10, "Add Node");
  13. buttons[1] = new Button(164, 10, "Delete Node");
  14. buttons[2] = new Button(10, 50, "Dark/Bright Mode");
  15. buttons[3] = new Button(10, 90, "Save");
  16. buttons[4] = new Button(10, 130, "Open");
  17. buttons[5] = new Button(10, 170, "Export Image");
  18. buttons[6] = new Button(10, 210, "Empty Workspace");
  19. buttons[7] = new Button(10, 10, "Menu");
  20. menu();
  21. /* buttons[0] = new Button(10, 10, "Node Hinzufügen");
  22. buttons[1] = new Button(155, 10, "Löschen");
  23. buttons[2] = new Button(10, 50, "Farben umkehren");
  24. buttons[3] = new Button(10, 90, "Speichern");
  25. buttons[4] = new Button(10, 130, "Öffnen");
  26. buttons[5] = new Button(10, 170, "Bild Exportieren");
  27. buttons[6] = new Button(10, 210, "Arbeitsfläche leeren");
  28. buttons[7] = new Button(10, 210, "Menü");*/
  29. }
  30. void buttonFunctions(int functionID) {
  31. switch (functionID) {
  32. case(0):
  33. addNode(int(random(50, width-50)), int(random(30, height-150)), "");
  34. i_selectedNode = nodeCount-1;
  35. break;
  36. case(1):
  37. deleteSelectedNode();
  38. break;
  39. case(2):
  40. darkMode = !darkMode;
  41. break;
  42. case(3):
  43. saveCSV(dataPath("save.csv"));
  44. selectOutput("Where to save .csv file to?", "saveCSVFile");
  45. break;
  46. case(4):
  47. selectInput("Select csv File", "loadCSVFile");
  48. break;
  49. case(5):
  50. selectOutput("Where to export .png image file to?", "savePNGFile");
  51. break;
  52. case(6):
  53. deleteAll();
  54. break;
  55. case(7):
  56. menu();
  57. break;
  58. default:
  59. break;
  60. }
  61. }
  62. Button buttons[] = new Button[buttonCount];
  63. class Button {
  64. int id, x, y, w, h;
  65. String label;
  66. boolean active;
  67. boolean hover() {
  68. return (active) ? ((mouseX > x && mouseX < x+w && mouseY > y && mouseY < y+h) ? true : false) : false;
  69. }
  70. void click() {
  71. buttonFunctions(id);
  72. }
  73. Button(int x_, int y_, String label_) {
  74. id = i_buttonId;
  75. i_buttonId++;
  76. x = x_;
  77. y = y_ ;
  78. label = label_;
  79. w = int(textWidth(label))+18;
  80. h = 32;
  81. active = true;
  82. }
  83. void display() {
  84. if (active) {
  85. stroke(0);
  86. strokeWeight(1);
  87. fill(255, 127);
  88. rect(x, y, w, h, 4);
  89. fill(0);
  90. text(label, x+9, y+h/2+5);
  91. }
  92. }
  93. }