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.2KB

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