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 1.8KB

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