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.

ontology.pde 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. Node nodes[] = new Node[1000];
  2. Link links[] = new Link[6000];
  3. int textSize = 14;
  4. boolean darkMode = true;
  5. void setup() {
  6. size(800, 600);
  7. surface.setResizable(true);
  8. //frame.setResizable(true);
  9. textSize(textSize);
  10. initButtons();
  11. /**
  12. * When saving, a copy of the save-file is stored locally which is opened when starting the program
  13. */
  14. try {
  15. loadCSV(dataPath("save.csv"));
  16. }
  17. catch(Exception e) {
  18. println("No File found, starting blank");
  19. }
  20. }
  21. void draw() {
  22. background(darkMode? 0 : 255);
  23. /**
  24. * Update and display links
  25. */
  26. for (int i = 0; i < linkCount; i++) {
  27. if (links[i].active) {
  28. links[i].update();
  29. links[i].display();
  30. }
  31. }
  32. /**
  33. * Update and display nodes
  34. */
  35. for (int i = 0; i < nodeCount; i++) {
  36. if (!nodes[i].deleted) {
  37. nodes[i].update();
  38. nodes[i].display();
  39. }
  40. }
  41. /**
  42. * Update and display ui, hide via exporting-flag for easy image-saving
  43. * Not all buttons always show, that's why this isn't in a loop
  44. */
  45. if (!exporting) {
  46. textSize(14);
  47. rectMode(CORNER);
  48. textAlign(CORNER);
  49. buttons[0].display();
  50. if (i_selectedNode != -1) buttons[1].display();
  51. if (menuOpen) {
  52. buttons[2].display();
  53. buttons[3].display();
  54. buttons[4].display();
  55. buttons[5].display();
  56. buttons[6].display();
  57. }
  58. buttons[7].display();
  59. rectMode(CENTER);
  60. textAlign(CENTER);
  61. textSize(textSize);
  62. } else {
  63. save(savePNGpath);
  64. exporting = false;
  65. }
  66. /**
  67. * Pull "wire" out of in/outlet before creating a link (see mouseReleased in ui)
  68. */
  69. if (dragLink) {
  70. stroke(darkMode? 255:0);
  71. strokeWeight(2);
  72. if (dragOriginLet == -1) {
  73. line(nodes[dragOriginId].inletCenter.x, nodes[dragOriginId].inletCenter.y, mouseX, mouseY);
  74. } else if (dragOriginLet == 1) {
  75. line(nodes[dragOriginId].outletCenter.x, nodes[dragOriginId].outletCenter.y, mouseX, mouseY);
  76. }
  77. }
  78. }
  79. void deleteAll() {
  80. for (int i = 0; i < nodeCount; i++) {
  81. //nodes[i].deleted = true;
  82. i_selectedNode = i;
  83. deleteSelectedNode();
  84. }
  85. nodeCount = 0;
  86. for (int i = 0; i < linkCount; i++) {
  87. links[i].active = false;
  88. }
  89. linkCount = 0;
  90. }