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

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. buttons[2].display();
  52. buttons[3].display();
  53. buttons[4].display();
  54. buttons[5].display();
  55. buttons[6].display();
  56. buttons[7].display();
  57. rectMode(CENTER);
  58. textAlign(CENTER);
  59. textSize(textSize);
  60. } else {
  61. save(savePNGpath);
  62. exporting = false;
  63. }
  64. /**
  65. * Pull "wire" out of in/outlet before creating a link (see mouseReleased in ui)
  66. */
  67. if (dragLink) {
  68. stroke(darkMode? 255:0);
  69. strokeWeight(2);
  70. if (dragOriginLet == -1) {
  71. line(nodes[dragOriginId].inletCenter.x, nodes[dragOriginId].inletCenter.y, mouseX, mouseY);
  72. } else if (dragOriginLet == 1) {
  73. line(nodes[dragOriginId].outletCenter.x, nodes[dragOriginId].outletCenter.y, mouseX, mouseY);
  74. }
  75. }
  76. }
  77. void deleteAll() {
  78. for (int i = 0; i < nodeCount; i++) {
  79. //nodes[i].deleted = true;
  80. i_selectedNode = i;
  81. deleteSelectedNode();
  82. }
  83. nodeCount = 0;
  84. for (int i = 0; i < linkCount; i++) {
  85. links[i].active = false;
  86. }
  87. linkCount = 0;
  88. }