From a02758ecd4e6baad2cd0aa7e74ec618b5fec277b Mon Sep 17 00:00:00 2001
From: Andrew Lalis
Date: Sun, 8 May 2022 01:37:25 +0200
Subject: [PATCH] Added proper connection management.
---
railsignal-app/src/components/RailSystem.vue | 2 +-
.../src/components/railsystem/canvasUtils.js | 16 ++++
.../railsystem/component/ComponentView.vue | 8 +-
.../component/PathNodeComponentView.vue | 48 ++++++++++
.../src/components/railsystem/drawing.js | 87 +++++++++++++++++++
.../src/components/railsystem/mapRenderer.js | 68 +++------------
railsignal-app/src/stores/railSystemsStore.js | 54 +++++++++++-
.../model/component/PathNode.java | 7 +-
.../rest/dto/PathNodeUpdatePayload.java | 11 ++-
.../service/ComponentService.java | 22 ++++-
10 files changed, 248 insertions(+), 75 deletions(-)
create mode 100644 railsignal-app/src/components/railsystem/canvasUtils.js
create mode 100644 railsignal-app/src/components/railsystem/drawing.js
diff --git a/railsignal-app/src/components/RailSystem.vue b/railsignal-app/src/components/RailSystem.vue
index 079b94e..11a5da4 100644
--- a/railsignal-app/src/components/RailSystem.vue
+++ b/railsignal-app/src/components/RailSystem.vue
@@ -2,7 +2,7 @@
{{railSystem.name}}
-
+
diff --git a/railsignal-app/src/components/railsystem/canvasUtils.js b/railsignal-app/src/components/railsystem/canvasUtils.js
new file mode 100644
index 0000000..726b394
--- /dev/null
+++ b/railsignal-app/src/components/railsystem/canvasUtils.js
@@ -0,0 +1,16 @@
+export function roundedRect(ctx, x, y, w, h, r) {
+ if (w < 2 * r) r = w / 2;
+ if (h < 2 * r) r = h / 2;
+ ctx.beginPath();
+ ctx.moveTo(x+r, y);
+ ctx.arcTo(x+w, y, x+w, y+h, r);
+ ctx.arcTo(x+w, y+h, x, y+h, r);
+ ctx.arcTo(x, y+h, x, y, r);
+ ctx.arcTo(x, y, x+w, y, r);
+ ctx.closePath();
+}
+
+export function circle(ctx, x, y, r) {
+ ctx.beginPath();
+ ctx.arc(x, y, r, 0, Math.PI * 2);
+}
\ No newline at end of file
diff --git a/railsignal-app/src/components/railsystem/component/ComponentView.vue b/railsignal-app/src/components/railsystem/component/ComponentView.vue
index 5332df1..d6fc2ed 100644
--- a/railsignal-app/src/components/railsystem/component/ComponentView.vue
+++ b/railsignal-app/src/components/railsystem/component/ComponentView.vue
@@ -15,16 +15,16 @@
-
+