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.

buttons.pde 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. int buttonCount = 6;
  2. int i_buttonId;
  3. void initButtons() {
  4. buttons[0] = new Button(10, 10, "Add Node");
  5. buttons[1] = new Button(104, 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[0] = new Button(10, 10, "Node Hinzufügen");
  11. buttons[1] = new Button(155, 10, "Löschen");
  12. buttons[2] = new Button(10, 50, "Farben umkehren");
  13. buttons[3] = new Button(10, 90, "Speichern");
  14. buttons[4] = new Button(10, 130, "Öffnen");
  15. buttons[5] = new Button(10, 170, "Bild Exportieren");*/
  16. }
  17. void buttonFunctions(int functionID) {
  18. switch (functionID) {
  19. case(0):
  20. addNode(int(random(50, width-50)), int(random(30, height-150)), "");
  21. i_selectedNode = nodeCount-1;
  22. break;
  23. case(1):
  24. deleteSelectedNode();
  25. break;
  26. case(2):
  27. darkMode = !darkMode;
  28. break;
  29. case(3):
  30. saveCSV(dataPath("save.csv"));
  31. selectOutput("Where to save .csv file to?", "saveCSVFile");
  32. break;
  33. case(4):
  34. selectInput("Select csv File", "loadCSVFile");
  35. break;
  36. case(5):
  37. selectOutput("Where to export .png image file to?", "savePNGFile");
  38. break;
  39. default:
  40. break;
  41. }
  42. }
  43. Button buttons[] = new Button[buttonCount];
  44. class Button {
  45. int id, x, y, w, h;
  46. String label;
  47. boolean hover() {
  48. return (mouseX > x && mouseX < x+w && mouseY > y && mouseY < y+h) ? true : false;
  49. }
  50. void click() {
  51. buttonFunctions(id);
  52. }
  53. Button(int x_, int y_, String label_) {
  54. id = i_buttonId;
  55. i_buttonId++;
  56. x = x_;
  57. y = y_ ;
  58. label = label_;
  59. w = int(textWidth(label))+18;
  60. h = 32;
  61. }
  62. void display() {
  63. stroke(0);
  64. strokeWeight(1);
  65. fill(255, 127);
  66. rect(x, y, w, h, 4);
  67. fill(0);
  68. text(label, x+9, y+h/2+5);
  69. }
  70. }