From fece3da438a217ab6ddedbf09c962a54123447e8 Mon Sep 17 00:00:00 2001 From: barsdeveloper Date: Mon, 4 Oct 2021 00:32:22 +0200 Subject: [PATCH] Large mouse events refactoring and cleanup --- js/UEBlueprint.js | 47 ++- js/UEBlueprintDrag.js | 66 ---- js/UEBlueprintDragScroll.js | 40 -- js/UEBlueprintDraggableObject.js | 6 +- js/UEBlueprintObject.js | 4 +- js/UEBlueprintSelect.js | 60 --- js/input/UDrag.js | 38 ++ js/input/UDragScroll.js | 18 + js/input/UMouseClickDrag.js | 94 +++++ js/input/UMouseWheel.js | 47 +++ js/input/USelect.js | 38 ++ js/input/UZoom.js | 9 + js/{ => selection}/FastSelectionModel.js | 60 +-- js/{ => selection}/OrderedIndexArray.js | 10 - js/{ => selection}/SimpleSelectionModel.js | 0 ueblueprint.html | 3 +- ueblueprint.js | 419 ++++++++++++--------- 17 files changed, 545 insertions(+), 414 deletions(-) delete mode 100644 js/UEBlueprintDrag.js delete mode 100644 js/UEBlueprintDragScroll.js delete mode 100644 js/UEBlueprintSelect.js create mode 100644 js/input/UDrag.js create mode 100644 js/input/UDragScroll.js create mode 100644 js/input/UMouseClickDrag.js create mode 100644 js/input/UMouseWheel.js create mode 100644 js/input/USelect.js create mode 100644 js/input/UZoom.js rename js/{ => selection}/FastSelectionModel.js (79%) rename js/{ => selection}/OrderedIndexArray.js (94%) rename js/{ => selection}/SimpleSelectionModel.js (100%) diff --git a/js/UEBlueprint.js b/js/UEBlueprint.js index 3ccd455..f394dee 100644 --- a/js/UEBlueprint.js +++ b/js/UEBlueprint.js @@ -1,11 +1,12 @@ -import Utility from "./Utility.js" -import UEBlueprintDragScroll from "./UEBlueprintDragScroll.js" -import UEBlueprintSelect from "./UEBlueprintSelect.js" -import FastSelectionModel from "./FastSelectionModel.js" -import SimpleSelectionModel from "./SimpleSelectionModel.js" +import Utility from "./Utility" +import UDragScroll from "./input/UDragScroll" +import USelect from "./input/USelect" +import UZoom from "./input/UZoom" +import FastSelectionModel from "./selection/FastSelectionModel" +import SimpleSelectionModel from "./selection/SimpleSelectionModel" /** - * @typedef {import("./UEBlueprintObject.js").default} UEBlueprintObject + * @typedef {import("./UEBlueprintObject").default} UEBlueprintObject */ export default class UEBlueprint extends HTMLElement { @@ -37,7 +38,7 @@ export default class UEBlueprint extends HTMLElement { } static getElement(template) { - let div = document.createElement('div'); + let div = document.createElement('div') div.innerHTML = template return div.firstElementChild } @@ -61,8 +62,6 @@ export default class UEBlueprint extends HTMLElement { this.selectorElement = null /** @type {HTMLElement} */ this.nodesContainerElement = null - /** @type {IntersectionObserver} */ - this.selectorObserver = null this.dragObject = null this.selectObject = null /** @type {Array} */ @@ -107,28 +106,19 @@ export default class UEBlueprint extends HTMLElement { this.nodesContainerElement = this.querySelector('[data-nodes]') this.insertChildren() - this.selectorObserver = new IntersectionObserver( - (entries, observer) => { - entries.map(entry => { - /** @type {import("./UEBlueprintObject.js").default;}" */ - let target = entry.target - target.setSelected(entry.isIntersecting) - }) - }, { - threshold: [0.01], - root: this.selectorElement - }) - this.nodes.forEach(element => this.selectorObserver.observe(element)) - - this.dragObject = new UEBlueprintDragScroll(this, { + this.dragObject = new UDragScroll(this.getGridDOMElement(), this, { 'clickButton': 2, 'stepSize': 1, 'exitDragAnyButton': false }) - this.selectObject = new UEBlueprintSelect(this, { + this.zoomObject = new UZoom(this.getGridDOMElement(), this, { + looseTarget: true + }) + + this.selectObject = new USelect(this.getGridDOMElement(), this, { 'clickButton': 0, - 'exitSelectAnyButton': true + 'exitAnyButton': true }) } @@ -356,6 +346,13 @@ export default class UEBlueprint extends HTMLElement { this.selectionModel.selectTo(finalPosition) } + /** + * Unselect all nodes + */ + unselectAll() { + this.nodes.forEach(node => this.nodeSelectToggleFunction(node, false)) + } + /** * * @param {...UEBlueprintObject} blueprintNodes diff --git a/js/UEBlueprintDrag.js b/js/UEBlueprintDrag.js deleted file mode 100644 index 348b351..0000000 --- a/js/UEBlueprintDrag.js +++ /dev/null @@ -1,66 +0,0 @@ -export default class UEBlueprintDrag { - constructor(blueprintNode, options) { - this.blueprintNode = blueprintNode; - this.mousePosition = [0, 0]; - this.stepSize = options?.stepSize - this.clickButton = options?.clickButton ?? 0 - this.exitDragAnyButton = options?.exitDragAnyButton ?? true - let self = this; - this.mouseDownHandler = function (e) { - switch (e.button) { - case self.clickButton: - self.clicked(e.clientX, e.clientY) - break; - default: - if (!self.exitDragAnyButton) { - self.mouseUpHandler(e) - } - break; - } - }; - this.mouseMoveHandler = function (e) { - let mousePosition = self.snapToGrid(e.clientX, e.clientY) - const d = [mousePosition[0] - self.mousePosition[0], mousePosition[1] - self.mousePosition[1]] - - if (d[0] == 0 && d[1] == 0) { - return; - } - - self.blueprintNode.addLocation(d) - - // Reassign the position of mouse - self.mousePosition = mousePosition - }; - this.mouseUpHandler = function (e) { - if (!self.exitDragAnyButton || e.button == self.clickButton) { - // Remove the handlers of `mousemove` and `mouseup` - document.removeEventListener('mousemove', self.mouseMoveHandler) - document.removeEventListener('mouseup', self.mouseUpHandler) - } - }; - this.blueprintNode.addEventListener('mousedown', this.mouseDownHandler) - this.blueprintNode.addEventListener('contextmenu', e => e.preventDefault()) - } - - unlistenDOMElement() { - this.blueprintNode.removeEventListener('mousedown', this.mouseDownHandler) - } - - snapToGrid(posX, posY) { - return [ - this.stepSize * Math.round(posX / this.stepSize), - this.stepSize * Math.round(posY / this.stepSize) - ] - } - - clicked(x, y) { - if (!this.stepSize) { - this.stepSize = parseInt(getComputedStyle(this.blueprintNode).getPropertyValue('--ueb-grid-snap')) - } - // Get the current mouse position - this.mousePosition = this.snapToGrid(x, y) - // Attach the listeners to `document` - document.addEventListener('mousemove', this.mouseMoveHandler) - document.addEventListener('mouseup', this.mouseUpHandler) - } -} \ No newline at end of file diff --git a/js/UEBlueprintDragScroll.js b/js/UEBlueprintDragScroll.js deleted file mode 100644 index 4a6d03c..0000000 --- a/js/UEBlueprintDragScroll.js +++ /dev/null @@ -1,40 +0,0 @@ -import UEBlueprintDrag from "./UEBlueprintDrag.js" - -export default class UEBlueprintDragScroll extends UEBlueprintDrag { - constructor(scrolledEntity, options) { - super(scrolledEntity, options) - this.minZoom = options?.minZoom ?? -12 - let self = this - - this.mouseMoveHandler = function (e) { - let mousePosition = self.snapToGrid(e.clientX, e.clientY) - - // How far the mouse has been moved - const dx = mousePosition[0] - self.mousePosition[0] - const dy = mousePosition[1] - self.mousePosition[1] - - self.blueprintNode.scrollDelta([-dx, -dy]) - - // Reassign the position of mouse - self.mousePosition = mousePosition - } - - this.mouseWheelHandler = function (e) { - e.preventDefault() - let zoomLevel = self.blueprintNode.getZoom() - zoomLevel -= Math.sign(e.deltaY) - let scaleCorrection = 1 / self.blueprintNode.getScale() - const targetOffset = e.target.getBoundingClientRect() - const currentTargetOffset = e.currentTarget.getBoundingClientRect() - let offset = [ - e.offsetX + targetOffset.x * scaleCorrection - currentTargetOffset.x * scaleCorrection, - e.offsetY + targetOffset.y * scaleCorrection - currentTargetOffset.y * scaleCorrection - ] - self.blueprintNode.setZoom(zoomLevel, offset) - } - - this.blueprintNode.getGridDOMElement().addEventListener('wheel', this.mouseWheelHandler, false) - this.blueprintNode.getGridDOMElement().parentElement.addEventListener('wheel', e => e.preventDefault()) - } - -} \ No newline at end of file diff --git a/js/UEBlueprintDraggableObject.js b/js/UEBlueprintDraggableObject.js index be25242..0ce3b48 100644 --- a/js/UEBlueprintDraggableObject.js +++ b/js/UEBlueprintDraggableObject.js @@ -1,4 +1,4 @@ -import UEBlueprintDrag from "./UEBlueprintDrag.js" +import UDrag from "./input/UDrag" export default class UEBlueprintDraggableObject extends HTMLElement { @@ -9,7 +9,9 @@ export default class UEBlueprintDraggableObject extends HTMLElement { } connectedCallback() { - this.dragObject = new UEBlueprintDrag(this) + this.dragObject = new UDrag(this, null, { + looseTarget: true + }) } disconnectedCallback() { diff --git a/js/UEBlueprintObject.js b/js/UEBlueprintObject.js index 5ad1bea..21afa93 100644 --- a/js/UEBlueprintObject.js +++ b/js/UEBlueprintObject.js @@ -1,4 +1,4 @@ -import UEBlueprintDraggableObject from "./UEBlueprintDraggableObject.js" +import UEBlueprintDraggableObject from "./UEBlueprintDraggableObject" export default class UEBlueprintObject extends UEBlueprintDraggableObject { static classInputs = [/* @@ -86,7 +86,7 @@ export default class UEBlueprintObject extends UEBlueprintDraggableObject { this.style.setProperty('--ueb-position-x', this.location[0]) this.style.setProperty('--ueb-position-y', this.location[1]) - let aDiv = document.createElement('div'); + let aDiv = document.createElement('div') aDiv.innerHTML = this.render() this.appendChild(aDiv.firstElementChild) } diff --git a/js/UEBlueprintSelect.js b/js/UEBlueprintSelect.js deleted file mode 100644 index 1b2a555..0000000 --- a/js/UEBlueprintSelect.js +++ /dev/null @@ -1,60 +0,0 @@ -export default class UEBlueprintSelect { - constructor(blueprintNode, options) { - /** @type {import("./UEBlueprint.js").default;}" */ - this.blueprintNode = blueprintNode; - this.mousePosition = [0, 0]; - this.clickButton = options?.clickButton ?? 0 - this.exitSelectAnyButton = options?.exitSelectAnyButton ?? true - let self = this - - this.mouseDownHandler = function (e) { - switch (e.button) { - case self.clickButton: - self.clicked([e.offsetX, e.offsetY]) - break - default: - if (!self.exitSelectAnyButton) { - self.mouseUpHandler(e) - } - break - } - } - - this.mouseMoveHandler = function (e) { - e.preventDefault() - let scaleCorrection = 1 / self.blueprintNode.getScale() - const targetOffset = e.target.getBoundingClientRect() - const currentTargetOffset = e.currentTarget.getBoundingClientRect() - let offset = [ - e.offsetX + targetOffset.x * scaleCorrection - currentTargetOffset.x * scaleCorrection, - e.offsetY + targetOffset.y * scaleCorrection - currentTargetOffset.y * scaleCorrection - ] - self.blueprintNode.doSelecting(offset) - } - - this.mouseUpHandler = function (e) { - if (!self.exitSelectAnyButton || e.button == self.clickButton) { - // Remove the handlers of `mousemove` and `mouseup` - self.blueprintNode.getGridDOMElement().removeEventListener('mousemove', self.mouseMoveHandler) - self.blueprintNode.finishSelecting() - document.removeEventListener('mouseup', self.mouseUpHandler) - } - } - - let gridElement = this.blueprintNode.getGridDOMElement() - gridElement.addEventListener('mousedown', this.mouseDownHandler) - gridElement.addEventListener('contextmenu', e => e.preventDefault()) - } - - unlistenDOMElement() { - this.blueprintNode.removeEventListener('mousedown', this.mouseDownHandler) - } - - clicked(position) { - // Attach the listeners to `document` - this.blueprintNode.getGridDOMElement().addEventListener('mousemove', this.mouseMoveHandler) - document.addEventListener('mouseup', this.mouseUpHandler) - // Start selecting - this.blueprintNode.startSelecting(position) - } -} \ No newline at end of file diff --git a/js/input/UDrag.js b/js/input/UDrag.js new file mode 100644 index 0000000..4de87f4 --- /dev/null +++ b/js/input/UDrag.js @@ -0,0 +1,38 @@ +import UMouseClickDrag from "./UMouseClickDrag" + +export default class UDrag extends UMouseClickDrag { + constructor(target, blueprint, options) { + super(target, blueprint, options) + this.stepSize = options?.stepSize + this.mousePosition = [0, 0] + } + + snapToGrid(posX, posY) { + return [ + this.stepSize * Math.round(posX / this.stepSize), + this.stepSize * Math.round(posY / this.stepSize) + ] + } + + startDrag(e) { + if (!this.stepSize) { + this.stepSize = parseInt(getComputedStyle(this.target).getPropertyValue('--ueb-grid-snap')) + } + // Get the current mouse position + this.mousePosition = this.snapToGrid(e.clientX, e.clientY) + } + + dragTo(e) { + let mousePosition = this.snapToGrid(e.clientX, e.clientY) + const d = [mousePosition[0] - this.mousePosition[0], mousePosition[1] - this.mousePosition[1]] + + if (d[0] == 0 && d[1] == 0) { + return + } + + this.target.addLocation(d) + + // Reassign the position of mouse + this.mousePosition = mousePosition + } +} \ No newline at end of file diff --git a/js/input/UDragScroll.js b/js/input/UDragScroll.js new file mode 100644 index 0000000..6c079a0 --- /dev/null +++ b/js/input/UDragScroll.js @@ -0,0 +1,18 @@ +import UDrag from "./UDrag" + +export default class UDragScroll extends UDrag { + + dragTo(e) { + const mousePosition = this.snapToGrid(e.clientX, e.clientY) + + // How far the mouse has been moved + const dx = mousePosition[0] - this.mousePosition[0] + const dy = mousePosition[1] - this.mousePosition[1] + + this.blueprint.scrollDelta([-dx, -dy]) + + // Reassign the position of mouse + this.mousePosition = mousePosition + } + +} \ No newline at end of file diff --git a/js/input/UMouseClickDrag.js b/js/input/UMouseClickDrag.js new file mode 100644 index 0000000..80b2e9c --- /dev/null +++ b/js/input/UMouseClickDrag.js @@ -0,0 +1,94 @@ +/** + * This class manages the ui gesture of mouse click and drag. Tha actual operations are implemented by the subclasses. + */ +export default class UMouseClickDrag { + constructor(target, blueprint, options) { + this.target = target + /** @type {import("../UEBlueprint").default}" */ + this.blueprint = blueprint + this.clickButton = options?.clickButton ?? 0 + this.exitAnyButton = options?.exitAnyButton ?? true + this.looseTarget = options?.looseTarget ?? false + this.started = false + this.clickedPosition = [0, 0] + let movementSpace = this.blueprint?.getGridDOMElement() ?? document + let self = this + + this.mouseDownHandler = function (e) { + switch (e.button) { + case self.clickButton: + // Either doesn't matter or consider the click only when clicking on the parent, not descandants + if (self.looseTarget || e.target == e.currentTarget) { + self.started = false + // Attach the listeners + movementSpace.addEventListener('mousemove', self.mouseStartedMovingHandler) + document.addEventListener('mouseup', self.mouseUpHandler) + self.clickedPosition = [e.offsetX, e.offsetY] + self.clicked(e) + } + break + default: + if (!self.exitAnyButton) { + self.mouseUpHandler(e) + } + break + } + } + + this.mouseStartedMovingHandler = function (e) { + e.preventDefault() + + // Delegate from now on to self.mouseMoveHandler + movementSpace.removeEventListener('mousemove', self.mouseStartedMovingHandler) + movementSpace.addEventListener('mousemove', self.mouseMoveHandler) + + // Do actual actions + self.startDrag(e) + self.started = true + } + + this.mouseMoveHandler = function (e) { + e.preventDefault() + self.dragTo(e) + } + + this.mouseUpHandler = function (e) { + if (!self.exitAnyButton || e.button == self.clickButton) { + // Remove the handlers of `mousemove` and `mouseup` + movementSpace.removeEventListener('mousemove', self.mouseStartedMovingHandler) + movementSpace.removeEventListener('mousemove', self.mouseMoveHandler) + document.removeEventListener('mouseup', self.mouseUpHandler) + self.endDrag(e) + } + } + + this.target.addEventListener('mousedown', this.mouseDownHandler) + if (this.clickButton == 2) { + this.target.addEventListener('contextmenu', this.preventDefault) + } + } + + preventDefault(e) { + e.preventDefault() + } + + unlistenDOMElement() { + this.target.removeEventListener('mousedown', this.mouseDownHandler) + if (this.clickButton == 2) { + this.target.removeEventListener('contextmenu', this.preventDefault) + } + } + + /* Subclasses will override the following methods */ + clicked(e) { + } + + startDrag(e) { + } + + dragTo(e) { + } + + endDrag(e) { + } +} \ No newline at end of file diff --git a/js/input/UMouseWheel.js b/js/input/UMouseWheel.js new file mode 100644 index 0000000..be664b3 --- /dev/null +++ b/js/input/UMouseWheel.js @@ -0,0 +1,47 @@ +export default class UMouseWheel { + + /** + * + * @param {HTMLElement} target + * @param {import("../UEBlueprint").default} blueprint + * @param {Object} options + */ + constructor(target, blueprint, options) { + this.target = target + this.blueprint = blueprint + this.looseTarget = options?.looseTarget ?? true + this.movementSpace = this.blueprint?.getGridDOMElement() ?? document + let self = this + + this.mouseWheelHandler = function (e) { + e.preventDefault() + if (!self.looseTarget && e.target != e.currentTarget) { + return + } + let scaleCorrection = 1 / self.blueprint.getScale() + let offset = [e.offsetX, e.offsetY] + if (self.looseTarget) { + /* + * Compensating for having used the mouse wheel over a descendant of the target (the element listened for the 'wheel' event). + * We are interested to get the location relative to the listened target, not the exact target that caused the event. + */ + const targetOffset = e.target.getBoundingClientRect() + const currentTargetOffset = e.currentTarget.getBoundingClientRect() + offset = [ + offset[0] + targetOffset.x * scaleCorrection - currentTargetOffset.x * scaleCorrection, + offset[1] + targetOffset.y * scaleCorrection - currentTargetOffset.y * scaleCorrection + ] + } + self.wheel(Math.sign(e.deltaY), offset) + } + + this.movementSpace.addEventListener('wheel', this.mouseWheelHandler, false) + // Prevent movement space from being scrolled + this.movementSpace.parentElement?.addEventListener('wheel', e => e.preventDefault()) + } + + /* Subclasses will override the following method */ + wheel(location, variation) { + + } +} \ No newline at end of file diff --git a/js/input/USelect.js b/js/input/USelect.js new file mode 100644 index 0000000..d6854d3 --- /dev/null +++ b/js/input/USelect.js @@ -0,0 +1,38 @@ +import UMouseClickDrag from "./UMouseClickDrag" + +export default class USelect extends UMouseClickDrag { + + constructor(target, blueprint, options) { + super(target, blueprint, options) + + this.blueprint = blueprint // blueprint is needed + this.stepSize = options?.stepSize + this.mousePosition = [0, 0] + } + + clicked(e) { + } + + startDrag(e) { + this.blueprint.startSelecting(this.clickedPosition) + } + + dragTo(e) { + let scaleCorrection = 1 / this.blueprint.getScale() + const targetOffset = e.target.getBoundingClientRect() + const currentTargetOffset = e.currentTarget.getBoundingClientRect() + let offset = [ + e.offsetX + targetOffset.x * scaleCorrection - currentTargetOffset.x * scaleCorrection, + e.offsetY + targetOffset.y * scaleCorrection - currentTargetOffset.y * scaleCorrection + ] + this.blueprint.doSelecting(offset) + } + + endDrag(e) { + if (this.started) { + this.blueprint.finishSelecting() + } else { + this.blueprint.unselectAll() + } + } +} \ No newline at end of file diff --git a/js/input/UZoom.js b/js/input/UZoom.js new file mode 100644 index 0000000..13474ea --- /dev/null +++ b/js/input/UZoom.js @@ -0,0 +1,9 @@ +import UMouseWheel from "./UMouseWheel"; + +export default class UZoom extends UMouseWheel { + wheel(variation, location) { + let zoomLevel = this.blueprint.getZoom() + zoomLevel -= variation + this.blueprint.setZoom(zoomLevel, location) + } +} \ No newline at end of file diff --git a/js/FastSelectionModel.js b/js/selection/FastSelectionModel.js similarity index 79% rename from js/FastSelectionModel.js rename to js/selection/FastSelectionModel.js index 99b0dec..0153886 100644 --- a/js/FastSelectionModel.js +++ b/js/selection/FastSelectionModel.js @@ -1,4 +1,4 @@ -import OrderedIndexArray from "./OrderedIndexArray.js" +import OrderedIndexArray from "./OrderedIndexArray" export default class FastSelectionModel { @@ -20,16 +20,16 @@ export default class FastSelectionModel { * @param {number[]} initialPosition Coordinates of the starting point of selection [primaryAxisValue, secondaryAxisValue]. * @param {Rectangle[]} rectangles Rectangles that can be selected by this object. * @param {(rect: Rectangle) => BoundariesInfo} boundariesFunc A function that, given a rectangle, it provides the boundaries of such rectangle. - * @param {(rect: Rectangle, selected: bool) => void} selectToggleFunction A function that selects or deselects individual rectangles. + * @param {(rect: Rectangle, selected: bool) => void} selectFunc A function that selects or deselects individual rectangles. */ - constructor(initialPosition, rectangles, boundariesFunc, selectToggleFunction) { + constructor(initialPosition, rectangles, boundariesFunc, selectFunc) { this.initialPosition = initialPosition this.finalPosition = initialPosition /** @type Metadata[] */ this.metadata = new Array(rectangles.length) this.primaryOrder = new OrderedIndexArray((element) => this.metadata[element].primaryBoundary) this.secondaryOrder = new OrderedIndexArray((element) => this.metadata[element].secondaryBoundary) - this.selectToggleFunction = selectToggleFunction + this.selectFunc = selectFunc this.rectangles = rectangles this.primaryOrder.reserve(this.rectangles.length) this.secondaryOrder.reserve(this.rectangles.length) @@ -42,7 +42,7 @@ export default class FastSelectionModel { onSecondaryAxis: false } this.metadata[index] = rectangleMetadata - selectToggleFunction(rect, false) // Initially deselected (Eventually) + selectFunc(rect, false) // Initially deselected (Eventually) const rectangleBoundaries = boundariesFunc(rect) // Secondary axis first because it may be inserted in this.secondaryOrder during the primary axis check @@ -65,7 +65,7 @@ export default class FastSelectionModel { if (rectangleBoundaries.secondarySup < this.initialPosition[1] || this.initialPosition[1] < rectangleBoundaries.secondaryInf) { this.secondaryOrder.insert(index) } else { - selectToggleFunction(rect, true) + selectFunc(rect, true) } } }) @@ -78,22 +78,22 @@ export default class FastSelectionModel { this.boundaries = { // Primary axis negative expanding primaryN: { - 'value': this.primaryOrder.getPrevValue(), - 'index': this.primaryOrder.getPrev() + v: this.primaryOrder.getPrevValue(), + i: this.primaryOrder.getPrev() }, primaryP: { - 'value': this.primaryOrder.getNextValue(), - 'index': this.primaryOrder.getNext() + v: this.primaryOrder.getNextValue(), + i: this.primaryOrder.getNext() }, // Secondary axis negative expanding secondaryN: { - 'value': this.secondaryOrder.getPrevValue(), - 'index': this.secondaryOrder.getPrev() + v: this.secondaryOrder.getPrevValue(), + i: this.secondaryOrder.getPrev() }, // Secondary axis positive expanding secondaryP: { - 'value': this.secondaryOrder.getNextValue(), - 'index': this.secondaryOrder.getNext() + v: this.secondaryOrder.getNextValue(), + i: this.secondaryOrder.getNext() } } } @@ -105,7 +105,7 @@ export default class FastSelectionModel { ] const primaryBoundaryCrossed = (index, added) => { if (this.metadata[index].onSecondaryAxis) { - this.selectToggleFunction(this.rectangles[index], added) + this.selectFunc(this.rectangles[index], added) } else { if (added) { this.secondaryOrder.insert(index, finalPosition[1]) @@ -117,10 +117,10 @@ export default class FastSelectionModel { && Math.sign(secondaryBoundary - this.initialPosition[1]) == direction[1] ) { // Secondary axis is already satisfied then - this.selectToggleFunction(this.rectangles[index], true) + this.selectFunc(this.rectangles[index], true) } } else { - this.selectToggleFunction(this.rectangles[index], false) + this.selectFunc(this.rectangles[index], false) this.secondaryOrder.remove(index) } } @@ -128,35 +128,35 @@ export default class FastSelectionModel { this.selectTo(finalPosition) } - if (finalPosition[0] < this.boundaries.primaryN.value) { + if (finalPosition[0] < this.boundaries.primaryN.v) { --this.primaryOrder.currentPosition primaryBoundaryCrossed( - this.boundaries.primaryN.index, - this.initialPosition[0] > this.boundaries.primaryN.value && finalPosition[0] < this.initialPosition[0]) - } else if (finalPosition[0] > this.boundaries.primaryP.value) { + this.boundaries.primaryN.i, + this.initialPosition[0] > this.boundaries.primaryN.v && finalPosition[0] < this.initialPosition[0]) + } else if (finalPosition[0] > this.boundaries.primaryP.v) { ++this.primaryOrder.currentPosition primaryBoundaryCrossed( - this.boundaries.primaryP.index, - this.initialPosition[0] < this.boundaries.primaryP.value && this.initialPosition[0] < finalPosition[0]) + this.boundaries.primaryP.i, + this.initialPosition[0] < this.boundaries.primaryP.v && this.initialPosition[0] < finalPosition[0]) } const secondaryBoundaryCrossed = (index, added) => { - this.selectToggleFunction(this.rectangles[index], added) + this.selectFunc(this.rectangles[index], added) this.computeBoundaries(finalPosition) this.selectTo(finalPosition) } - if (finalPosition[1] < this.boundaries.secondaryN.value) { + if (finalPosition[1] < this.boundaries.secondaryN.v) { --this.secondaryOrder.currentPosition secondaryBoundaryCrossed( - this.boundaries.secondaryN.index, - this.initialPosition[1] > this.boundaries.secondaryN.value && finalPosition[1] < this.initialPosition[1]); - } else if (finalPosition[1] > this.boundaries.secondaryP.value) { + this.boundaries.secondaryN.i, + this.initialPosition[1] > this.boundaries.secondaryN.v && finalPosition[1] < this.initialPosition[1]) + } else if (finalPosition[1] > this.boundaries.secondaryP.v) { ++this.secondaryOrder.currentPosition secondaryBoundaryCrossed( - this.boundaries.secondaryP.index, - this.initialPosition[1] < this.boundaries.secondaryP.value && this.initialPosition[1] < finalPosition[1]); + this.boundaries.secondaryP.i, + this.initialPosition[1] < this.boundaries.secondaryP.v && this.initialPosition[1] < finalPosition[1]) } this.finalPosition = finalPosition } diff --git a/js/OrderedIndexArray.js b/js/selection/OrderedIndexArray.js similarity index 94% rename from js/OrderedIndexArray.js rename to js/selection/OrderedIndexArray.js index 51d3f3b..62e5f92 100644 --- a/js/OrderedIndexArray.js +++ b/js/selection/OrderedIndexArray.js @@ -64,13 +64,6 @@ export default class OrderedIndexArray { * @returns {number} The position into occupied by value into the array. */ insert(element, comparisonValue = null) { - let i = 0; - for (i = 0; i < this.length; ++i) { - if (element == this.array[i]) { - console.log("error"); - break; - } - } let position = this.getPosition(this.comparisonValueSupplier(element)) if ( position < this.currentPosition @@ -87,9 +80,6 @@ export default class OrderedIndexArray { this.shiftRight(position) this.array[position] = element ++this.length - if (this.length > this.array.length) { - console.log("error2") - } return position } diff --git a/js/SimpleSelectionModel.js b/js/selection/SimpleSelectionModel.js similarity index 100% rename from js/SimpleSelectionModel.js rename to js/selection/SimpleSelectionModel.js diff --git a/ueblueprint.html b/ueblueprint.html index 3eb9aa7..eaaa57c 100644 --- a/ueblueprint.html +++ b/ueblueprint.html @@ -17,7 +17,8 @@ import { UEBlueprint, UEBlueprintObject } from "./ueblueprint.js" let blueprint = new UEBlueprint() - let node0 = new UEBlueprintObject(); node0.setLocation([1056, 124]); let node1 = new UEBlueprintObject(); node1.setLocation([873, 281]); let node2 = new UEBlueprintObject(); node2.setLocation([743, 385]); let node3 = new UEBlueprintObject(); node3.setLocation([525, 290]); let node4 = new UEBlueprintObject(); node4.setLocation([548, 235]); let node5 = new UEBlueprintObject(); node5.setLocation([872, 177]); let node6 = new UEBlueprintObject(); node6.setLocation([961, 279]); let node7 = new UEBlueprintObject(); node7.setLocation([1060, 323]); let node8 = new UEBlueprintObject(); node8.setLocation([987, 3]); let node9 = new UEBlueprintObject(); node9.setLocation([798, -36]); let node10 = new UEBlueprintObject(); node10.setLocation([751, 158]); let node11 = new UEBlueprintObject(); node11.setLocation([832, 194]); let node12 = new UEBlueprintObject(); node12.setLocation([526, 179]); let node13 = new UEBlueprintObject(); node13.setLocation([689, 225]); let node14 = new UEBlueprintObject(); node14.setLocation([1452, 291]); let node15 = new UEBlueprintObject(); node15.setLocation([745, 176]); let node16 = new UEBlueprintObject(); node16.setLocation([603, 289]); let node17 = new UEBlueprintObject(); node17.setLocation([987, 191]); let node18 = new UEBlueprintObject(); node18.setLocation([885, 61]); let node19 = new UEBlueprintObject(); node19.setLocation([725, 150]); let node20 = new UEBlueprintObject(); node20.setLocation([636, 77]); let node21 = new UEBlueprintObject(); node21.setLocation([350, -2]); let node22 = new UEBlueprintObject(); node22.setLocation([999, 273]); let node23 = new UEBlueprintObject(); node23.setLocation([773, 102]); let node24 = new UEBlueprintObject(); node24.setLocation([727, 181]); let node25 = new UEBlueprintObject(); node25.setLocation([683, 213]); let node26 = new UEBlueprintObject(); node26.setLocation([1000, 159]); let node27 = new UEBlueprintObject(); node27.setLocation([869, 156]); let node28 = new UEBlueprintObject(); node28.setLocation([887, 99]); let node29 = new UEBlueprintObject(); node29.setLocation([1088, 243]); let node30 = new UEBlueprintObject(); node30.setLocation([946, 311]); let node31 = new UEBlueprintObject(); node31.setLocation([810, 203]); let node32 = new UEBlueprintObject(); node32.setLocation([869, 65]); let node33 = new UEBlueprintObject(); node33.setLocation([882, 123]); let node34 = new UEBlueprintObject(); node34.setLocation([708, 288]); let node35 = new UEBlueprintObject(); node35.setLocation([756, 182]); let node36 = new UEBlueprintObject(); node36.setLocation([608, 129]); let node37 = new UEBlueprintObject(); node37.setLocation([709, 319]); let node38 = new UEBlueprintObject(); node38.setLocation([970, 250]); let node39 = new UEBlueprintObject(); node39.setLocation([998, 221]); let node40 = new UEBlueprintObject(); node40.setLocation([583, 89]); let node41 = new UEBlueprintObject(); node41.setLocation([398, 293]); let node42 = new UEBlueprintObject(); node42.setLocation([852, 238]); let node43 = new UEBlueprintObject(); node43.setLocation([1140, 210]); let node44 = new UEBlueprintObject(); node44.setLocation([903, 150]); let node45 = new UEBlueprintObject(); node45.setLocation([652, 109]); let node46 = new UEBlueprintObject(); node46.setLocation([831, 128]); let node47 = new UEBlueprintObject(); node47.setLocation([855, 13]); let node48 = new UEBlueprintObject(); node48.setLocation([579, 177]); let node49 = new UEBlueprintObject(); node49.setLocation([427, 375]); let node50 = new UEBlueprintObject(); node50.setLocation([1124, 200]); let node51 = new UEBlueprintObject(); node51.setLocation([849, 162]); let node52 = new UEBlueprintObject(); node52.setLocation([735, 292]); let node53 = new UEBlueprintObject(); node53.setLocation([576, 92]); let node54 = new UEBlueprintObject(); node54.setLocation([653, 253]); let node55 = new UEBlueprintObject(); node55.setLocation([912, 206]); let node56 = new UEBlueprintObject(); node56.setLocation([786, 330]); let node57 = new UEBlueprintObject(); node57.setLocation([673, 236]); let node58 = new UEBlueprintObject(); node58.setLocation([876, 189]); let node59 = new UEBlueprintObject(); node59.setLocation([588, 220]); let node60 = new UEBlueprintObject(); node60.setLocation([747, 150]); let node61 = new UEBlueprintObject(); node61.setLocation([633, 253]); let node62 = new UEBlueprintObject(); node62.setLocation([731, 223]); let node63 = new UEBlueprintObject(); node63.setLocation([1046, 23]); let node64 = new UEBlueprintObject(); node64.setLocation([930, 294]); let node65 = new UEBlueprintObject(); node65.setLocation([659, 61]); let node66 = new UEBlueprintObject(); node66.setLocation([951, 175]); let node67 = new UEBlueprintObject(); node67.setLocation([638, 220]); let node68 = new UEBlueprintObject(); node68.setLocation([1000, 54]); let node69 = new UEBlueprintObject(); node69.setLocation([972, 190]); let node70 = new UEBlueprintObject(); node70.setLocation([490, 287]); let node71 = new UEBlueprintObject(); node71.setLocation([759, 172]); let node72 = new UEBlueprintObject(); node72.setLocation([1046, 363]); let node73 = new UEBlueprintObject(); node73.setLocation([1121, 208]); let node74 = new UEBlueprintObject(); node74.setLocation([884, 299]); let node75 = new UEBlueprintObject(); node75.setLocation([442, 166]); let node76 = new UEBlueprintObject(); node76.setLocation([1053, 239]); let node77 = new UEBlueprintObject(); node77.setLocation([782, 213]); let node78 = new UEBlueprintObject(); node78.setLocation([866, 198]); let node79 = new UEBlueprintObject(); node79.setLocation([841, 261]); let node80 = new UEBlueprintObject(); node80.setLocation([925, 147]); let node81 = new UEBlueprintObject(); node81.setLocation([462, 258]); let node82 = new UEBlueprintObject(); node82.setLocation([792, 207]); let node83 = new UEBlueprintObject(); node83.setLocation([880, 204]); let node84 = new UEBlueprintObject(); node84.setLocation([830, 180]); let node85 = new UEBlueprintObject(); node85.setLocation([488, 228]); let node86 = new UEBlueprintObject(); node86.setLocation([574, 169]); let node87 = new UEBlueprintObject(); node87.setLocation([805, 80]); let node88 = new UEBlueprintObject(); node88.setLocation([842, 273]); let node89 = new UEBlueprintObject(); node89.setLocation([1271, 141]); let node90 = new UEBlueprintObject(); node90.setLocation([654, 69]); let node91 = new UEBlueprintObject(); node91.setLocation([943, 134]); let node92 = new UEBlueprintObject(); node92.setLocation([654, 268]); let node93 = new UEBlueprintObject(); node93.setLocation([1024, 199]); let node94 = new UEBlueprintObject(); node94.setLocation([895, 374]); let node95 = new UEBlueprintObject(); node95.setLocation([1052, 118]); let node96 = new UEBlueprintObject(); node96.setLocation([827, 130]); let node97 = new UEBlueprintObject(); node97.setLocation([740, 205]); let node98 = new UEBlueprintObject(); node98.setLocation([715, 49]); let node99 = new UEBlueprintObject(); node99.setLocation([650, 173]); let node100 = new UEBlueprintObject(); node100.setLocation([645, 143]); let node101 = new UEBlueprintObject(); node101.setLocation([725, 174]); let node102 = new UEBlueprintObject(); node102.setLocation([612, 166]); let node103 = new UEBlueprintObject(); node103.setLocation([869, 273]); let node104 = new UEBlueprintObject(); node104.setLocation([604, 352]); let node105 = new UEBlueprintObject(); node105.setLocation([983, 134]); let node106 = new UEBlueprintObject(); node106.setLocation([1018, 10]); let node107 = new UEBlueprintObject(); node107.setLocation([562, 330]); let node108 = new UEBlueprintObject(); node108.setLocation([645, 107]); let node109 = new UEBlueprintObject(); node109.setLocation([773, 71]); let node110 = new UEBlueprintObject(); node110.setLocation([947, 154]); let node111 = new UEBlueprintObject(); node111.setLocation([1062, 240]); let node112 = new UEBlueprintObject(); node112.setLocation([713, 220]); let node113 = new UEBlueprintObject(); node113.setLocation([940, 104]); let node114 = new UEBlueprintObject(); node114.setLocation([956, 21]); let node115 = new UEBlueprintObject(); node115.setLocation([563, 263]); let node116 = new UEBlueprintObject(); node116.setLocation([803, 290]); let node117 = new UEBlueprintObject(); node117.setLocation([967, 45]); let node118 = new UEBlueprintObject(); node118.setLocation([812, 126]); let node119 = new UEBlueprintObject(); node119.setLocation([816, 267]); let node120 = new UEBlueprintObject(); node120.setLocation([1187, 368]); let node121 = new UEBlueprintObject(); node121.setLocation([488, 99]); let node122 = new UEBlueprintObject(); node122.setLocation([519, 187]); let node123 = new UEBlueprintObject(); node123.setLocation([1034, 316]); let node124 = new UEBlueprintObject(); node124.setLocation([704, 124]); let node125 = new UEBlueprintObject(); node125.setLocation([887, 216]); let node126 = new UEBlueprintObject(); node126.setLocation([883, 377]); let node127 = new UEBlueprintObject(); node127.setLocation([722, -35]); let node128 = new UEBlueprintObject(); node128.setLocation([536, 188]); let node129 = new UEBlueprintObject(); node129.setLocation([786, 200]); let node130 = new UEBlueprintObject(); node130.setLocation([1122, 169]); let node131 = new UEBlueprintObject(); node131.setLocation([688, 320]); let node132 = new UEBlueprintObject(); node132.setLocation([752, 45]); let node133 = new UEBlueprintObject(); node133.setLocation([820, 217]); let node134 = new UEBlueprintObject(); node134.setLocation([464, 165]); let node135 = new UEBlueprintObject(); node135.setLocation([563, 122]); let node136 = new UEBlueprintObject(); node136.setLocation([829, 198]); let node137 = new UEBlueprintObject(); node137.setLocation([693, 350]); let node138 = new UEBlueprintObject(); node138.setLocation([761, 286]); let node139 = new UEBlueprintObject(); node139.setLocation([1216, 140]); let node140 = new UEBlueprintObject(); node140.setLocation([1034, 174]); let node141 = new UEBlueprintObject(); node141.setLocation([732, 172]); let node142 = new UEBlueprintObject(); node142.setLocation([553, 110]); let node143 = new UEBlueprintObject(); node143.setLocation([939, 69]); let node144 = new UEBlueprintObject(); node144.setLocation([794, 114]); let node145 = new UEBlueprintObject(); node145.setLocation([949, 166]); let node146 = new UEBlueprintObject(); node146.setLocation([776, 461]); let node147 = new UEBlueprintObject(); node147.setLocation([1112, 177]); let node148 = new UEBlueprintObject(); node148.setLocation([858, 208]); let node149 = new UEBlueprintObject(); node149.setLocation([926, 240]); let node150 = new UEBlueprintObject(); node150.setLocation([877, 181]); let node151 = new UEBlueprintObject(); node151.setLocation([879, 69]); let node152 = new UEBlueprintObject(); node152.setLocation([1196, 296]); let node153 = new UEBlueprintObject(); node153.setLocation([1032, -14]); let node154 = new UEBlueprintObject(); node154.setLocation([533, 187]); let node155 = new UEBlueprintObject(); node155.setLocation([851, 157]); let node156 = new UEBlueprintObject(); node156.setLocation([1166, 203]); let node157 = new UEBlueprintObject(); node157.setLocation([583, 104]); let node158 = new UEBlueprintObject(); node158.setLocation([577, 239]); let node159 = new UEBlueprintObject(); node159.setLocation([704, 307]); let node160 = new UEBlueprintObject(); node160.setLocation([1015, 133]); let node161 = new UEBlueprintObject(); node161.setLocation([1109, 42]); let node162 = new UEBlueprintObject(); node162.setLocation([555, 214]); let node163 = new UEBlueprintObject(); node163.setLocation([867, 182]); let node164 = new UEBlueprintObject(); node164.setLocation([646, 198]); let node165 = new UEBlueprintObject(); node165.setLocation([1004, 211]); let node166 = new UEBlueprintObject(); node166.setLocation([1137, 220]); let node167 = new UEBlueprintObject(); node167.setLocation([617, 229]); let node168 = new UEBlueprintObject(); node168.setLocation([983, 220]); let node169 = new UEBlueprintObject(); node169.setLocation([1074, 195]); let node170 = new UEBlueprintObject(); node170.setLocation([655, 158]); let node171 = new UEBlueprintObject(); node171.setLocation([752, 107]); let node172 = new UEBlueprintObject(); node172.setLocation([650, 77]); let node173 = new UEBlueprintObject(); node173.setLocation([623, 88]); let node174 = new UEBlueprintObject(); node174.setLocation([713, 237]); let node175 = new UEBlueprintObject(); node175.setLocation([884, 263]); let node176 = new UEBlueprintObject(); node176.setLocation([771, 264]); let node177 = new UEBlueprintObject(); node177.setLocation([521, 193]); let node178 = new UEBlueprintObject(); node178.setLocation([853, 229]); let node179 = new UEBlueprintObject(); node179.setLocation([662, 311]); let node180 = new UEBlueprintObject(); node180.setLocation([556, 61]); let node181 = new UEBlueprintObject(); node181.setLocation([812, 196]); let node182 = new UEBlueprintObject(); node182.setLocation([917, 255]); let node183 = new UEBlueprintObject(); node183.setLocation([930, 254]); let node184 = new UEBlueprintObject(); node184.setLocation([639, -35]); let node185 = new UEBlueprintObject(); node185.setLocation([573, 78]); let node186 = new UEBlueprintObject(); node186.setLocation([902, 238]); let node187 = new UEBlueprintObject(); node187.setLocation([787, 286]); let node188 = new UEBlueprintObject(); node188.setLocation([754, 125]); let node189 = new UEBlueprintObject(); node189.setLocation([1072, 350]); let node190 = new UEBlueprintObject(); node190.setLocation([782, 152]); let node191 = new UEBlueprintObject(); node191.setLocation([673, -17]); let node192 = new UEBlueprintObject(); node192.setLocation([694, 238]); let node193 = new UEBlueprintObject(); node193.setLocation([649, 170]); let node194 = new UEBlueprintObject(); node194.setLocation([656, 197]); let node195 = new UEBlueprintObject(); node195.setLocation([389, 129]); let node196 = new UEBlueprintObject(); node196.setLocation([650, 256]); let node197 = new UEBlueprintObject(); node197.setLocation([701, 266]); let node198 = new UEBlueprintObject(); node198.setLocation([864, 245]); let node199 = new UEBlueprintObject(); node199.setLocation([819, 213]); let node200 = new UEBlueprintObject(); node200.setLocation([832, 170]); let node201 = new UEBlueprintObject(); node201.setLocation([691, 159]); let node202 = new UEBlueprintObject(); node202.setLocation([854, 58]); let node203 = new UEBlueprintObject(); node203.setLocation([804, 300]); let node204 = new UEBlueprintObject(); node204.setLocation([690, 177]); let node205 = new UEBlueprintObject(); node205.setLocation([719, 356]); let node206 = new UEBlueprintObject(); node206.setLocation([795, 328]); let node207 = new UEBlueprintObject(); node207.setLocation([742, 259]); let node208 = new UEBlueprintObject(); node208.setLocation([847, 181]); let node209 = new UEBlueprintObject(); node209.setLocation([872, 348]); let node210 = new UEBlueprintObject(); node210.setLocation([837, 15]); let node211 = new UEBlueprintObject(); node211.setLocation([636, 129]); let node212 = new UEBlueprintObject(); node212.setLocation([988, 41]); let node213 = new UEBlueprintObject(); node213.setLocation([817, 139]); let node214 = new UEBlueprintObject(); node214.setLocation([1246, 322]); let node215 = new UEBlueprintObject(); node215.setLocation([626, 88]); let node216 = new UEBlueprintObject(); node216.setLocation([753, 176]); let node217 = new UEBlueprintObject(); node217.setLocation([589, 204]); let node218 = new UEBlueprintObject(); node218.setLocation([701, 134]); let node219 = new UEBlueprintObject(); node219.setLocation([912, 195]); let node220 = new UEBlueprintObject(); node220.setLocation([920, 95]); let node221 = new UEBlueprintObject(); node221.setLocation([574, 88]); let node222 = new UEBlueprintObject(); node222.setLocation([1294, -70]); let node223 = new UEBlueprintObject(); node223.setLocation([813, 100]); let node224 = new UEBlueprintObject(); node224.setLocation([792, 248]); let node225 = new UEBlueprintObject(); node225.setLocation([974, 174]); let node226 = new UEBlueprintObject(); node226.setLocation([735, 252]); let node227 = new UEBlueprintObject(); node227.setLocation([960, 53]); let node228 = new UEBlueprintObject(); node228.setLocation([531, 108]); let node229 = new UEBlueprintObject(); node229.setLocation([582, 101]); let node230 = new UEBlueprintObject(); node230.setLocation([725, 62]); let node231 = new UEBlueprintObject(); node231.setLocation([649, 377]); let node232 = new UEBlueprintObject(); node232.setLocation([798, 110]); let node233 = new UEBlueprintObject(); node233.setLocation([891, 264]); let node234 = new UEBlueprintObject(); node234.setLocation([991, 296]); let node235 = new UEBlueprintObject(); node235.setLocation([566, 329]); let node236 = new UEBlueprintObject(); node236.setLocation([879, 307]); let node237 = new UEBlueprintObject(); node237.setLocation([895, 142]); let node238 = new UEBlueprintObject(); node238.setLocation([795, 56]); let node239 = new UEBlueprintObject(); node239.setLocation([888, 155]); let node240 = new UEBlueprintObject(); node240.setLocation([660, 78]); let node241 = new UEBlueprintObject(); node241.setLocation([430, 142]); let node242 = new UEBlueprintObject(); node242.setLocation([695, 222]); let node243 = new UEBlueprintObject(); node243.setLocation([579, 126]); let node244 = new UEBlueprintObject(); node244.setLocation([763, 178]); let node245 = new UEBlueprintObject(); node245.setLocation([675, 96]); let node246 = new UEBlueprintObject(); node246.setLocation([650, 299]); let node247 = new UEBlueprintObject(); node247.setLocation([610, 239]); let node248 = new UEBlueprintObject(); node248.setLocation([971, 196]); let node249 = new UEBlueprintObject(); node249.setLocation([864, 276]); let node250 = new UEBlueprintObject(); node250.setLocation([448, 21]); let node251 = new UEBlueprintObject(); node251.setLocation([1303, 423]); let node252 = new UEBlueprintObject(); node252.setLocation([924, 158]); let node253 = new UEBlueprintObject(); node253.setLocation([955, 42]); let node254 = new UEBlueprintObject(); node254.setLocation([867, 122]); let node255 = new UEBlueprintObject(); node255.setLocation([1232, 293]); let node256 = new UEBlueprintObject(); node256.setLocation([519, 359]); let node257 = new UEBlueprintObject(); node257.setLocation([840, 249]); let node258 = new UEBlueprintObject(); node258.setLocation([611, -34]); let node259 = new UEBlueprintObject(); node259.setLocation([1069, -37]); let node260 = new UEBlueprintObject(); node260.setLocation([774, 5]); let node261 = new UEBlueprintObject(); node261.setLocation([738, 300]); let node262 = new UEBlueprintObject(); node262.setLocation([685, 180]); let node263 = new UEBlueprintObject(); node263.setLocation([976, 73]); let node264 = new UEBlueprintObject(); node264.setLocation([642, 178]); let node265 = new UEBlueprintObject(); node265.setLocation([686, 238]); let node266 = new UEBlueprintObject(); node266.setLocation([629, 100]); let node267 = new UEBlueprintObject(); node267.setLocation([1058, 262]); let node268 = new UEBlueprintObject(); node268.setLocation([865, 193]); let node269 = new UEBlueprintObject(); node269.setLocation([868, 177]); let node270 = new UEBlueprintObject(); node270.setLocation([987, 11]); let node271 = new UEBlueprintObject(); node271.setLocation([1141, 128]); let node272 = new UEBlueprintObject(); node272.setLocation([574, 235]); let node273 = new UEBlueprintObject(); node273.setLocation([927, 253]); let node274 = new UEBlueprintObject(); node274.setLocation([775, 33]); let node275 = new UEBlueprintObject(); node275.setLocation([392, 202]); let node276 = new UEBlueprintObject(); node276.setLocation([1141, 73]); let node277 = new UEBlueprintObject(); node277.setLocation([749, 87]); let node278 = new UEBlueprintObject(); node278.setLocation([835, 195]); let node279 = new UEBlueprintObject(); node279.setLocation([1080, 225]); let node280 = new UEBlueprintObject(); node280.setLocation([1114, 182]); let node281 = new UEBlueprintObject(); node281.setLocation([927, 220]); let node282 = new UEBlueprintObject(); node282.setLocation([555, 251]); let node283 = new UEBlueprintObject(); node283.setLocation([576, 173]); let node284 = new UEBlueprintObject(); node284.setLocation([1011, 190]); let node285 = new UEBlueprintObject(); node285.setLocation([781, 251]); let node286 = new UEBlueprintObject(); node286.setLocation([1210, 298]); let node287 = new UEBlueprintObject(); node287.setLocation([624, 233]); let node288 = new UEBlueprintObject(); node288.setLocation([895, 112]); let node289 = new UEBlueprintObject(); node289.setLocation([541, 267]); let node290 = new UEBlueprintObject(); node290.setLocation([938, 267]); let node291 = new UEBlueprintObject(); node291.setLocation([872, 350]); let node292 = new UEBlueprintObject(); node292.setLocation([650, 292]); let node293 = new UEBlueprintObject(); node293.setLocation([936, 141]); let node294 = new UEBlueprintObject(); node294.setLocation([929, 64]); let node295 = new UEBlueprintObject(); node295.setLocation([842, 396]); let node296 = new UEBlueprintObject(); node296.setLocation([1207, 250]); let node297 = new UEBlueprintObject(); node297.setLocation([819, 152]); let node298 = new UEBlueprintObject(); node298.setLocation([510, 324]); let node299 = new UEBlueprintObject(); node299.setLocation([708, -111]); let node300 = new UEBlueprintObject(); node300.setLocation([802, 306]); let node301 = new UEBlueprintObject(); node301.setLocation([802, 314]); let node302 = new UEBlueprintObject(); node302.setLocation([655, 129]); let node303 = new UEBlueprintObject(); node303.setLocation([516, 244]); let node304 = new UEBlueprintObject(); node304.setLocation([921, 216]); let node305 = new UEBlueprintObject(); node305.setLocation([820, 18]); let node306 = new UEBlueprintObject(); node306.setLocation([807, 61]); let node307 = new UEBlueprintObject(); node307.setLocation([819, 208]); let node308 = new UEBlueprintObject(); node308.setLocation([1056, 111]); let node309 = new UEBlueprintObject(); node309.setLocation([662, 146]); let node310 = new UEBlueprintObject(); node310.setLocation([666, 309]); let node311 = new UEBlueprintObject(); node311.setLocation([662, 157]); let node312 = new UEBlueprintObject(); node312.setLocation([504, 186]); let node313 = new UEBlueprintObject(); node313.setLocation([919, 173]); let node314 = new UEBlueprintObject(); node314.setLocation([642, 323]); let node315 = new UEBlueprintObject(); node315.setLocation([1054, 211]); let node316 = new UEBlueprintObject(); node316.setLocation([696, 222]); let node317 = new UEBlueprintObject(); node317.setLocation([748, 222]); let node318 = new UEBlueprintObject(); node318.setLocation([754, 305]); let node319 = new UEBlueprintObject(); node319.setLocation([904, 355]); let node320 = new UEBlueprintObject(); node320.setLocation([833, 271]); let node321 = new UEBlueprintObject(); node321.setLocation([751, 20]); let node322 = new UEBlueprintObject(); node322.setLocation([808, 137]); let node323 = new UEBlueprintObject(); node323.setLocation([570, 172]); let node324 = new UEBlueprintObject(); node324.setLocation([934, 114]); let node325 = new UEBlueprintObject(); node325.setLocation([1048, 286]); let node326 = new UEBlueprintObject(); node326.setLocation([643, 369]); let node327 = new UEBlueprintObject(); node327.setLocation([892, 254]); let node328 = new UEBlueprintObject(); node328.setLocation([501, 184]); let node329 = new UEBlueprintObject(); node329.setLocation([756, 293]); let node330 = new UEBlueprintObject(); node330.setLocation([897, 236]); let node331 = new UEBlueprintObject(); node331.setLocation([862, 408]); let node332 = new UEBlueprintObject(); node332.setLocation([1033, 161]); let node333 = new UEBlueprintObject(); node333.setLocation([546, 42]); let node334 = new UEBlueprintObject(); node334.setLocation([942, 230]); let node335 = new UEBlueprintObject(); node335.setLocation([784, 167]); let node336 = new UEBlueprintObject(); node336.setLocation([1003, 521]); let node337 = new UEBlueprintObject(); node337.setLocation([922, 187]); let node338 = new UEBlueprintObject(); node338.setLocation([827, 262]); let node339 = new UEBlueprintObject(); node339.setLocation([1118, 245]); let node340 = new UEBlueprintObject(); node340.setLocation([592, 206]); let node341 = new UEBlueprintObject(); node341.setLocation([1006, 240]); let node342 = new UEBlueprintObject(); node342.setLocation([856, 210]); let node343 = new UEBlueprintObject(); node343.setLocation([819, 203]); let node344 = new UEBlueprintObject(); node344.setLocation([725, 291]); let node345 = new UEBlueprintObject(); node345.setLocation([750, 330]); let node346 = new UEBlueprintObject(); node346.setLocation([1030, 103]); let node347 = new UEBlueprintObject(); node347.setLocation([871, 393]); let node348 = new UEBlueprintObject(); node348.setLocation([547, 289]); let node349 = new UEBlueprintObject(); node349.setLocation([921, 91]); let node350 = new UEBlueprintObject(); node350.setLocation([968, 298]); let node351 = new UEBlueprintObject(); node351.setLocation([706, 276]); let node352 = new UEBlueprintObject(); node352.setLocation([793, 194]); let node353 = new UEBlueprintObject(); node353.setLocation([833, 341]); let node354 = new UEBlueprintObject(); node354.setLocation([951, 112]); let node355 = new UEBlueprintObject(); node355.setLocation([697, 214]); let node356 = new UEBlueprintObject(); node356.setLocation([617, 35]); let node357 = new UEBlueprintObject(); node357.setLocation([585, 185]); let node358 = new UEBlueprintObject(); node358.setLocation([888, 175]); let node359 = new UEBlueprintObject(); node359.setLocation([861, 198]); let node360 = new UEBlueprintObject(); node360.setLocation([809, 98]); let node361 = new UEBlueprintObject(); node361.setLocation([616, 261]); let node362 = new UEBlueprintObject(); node362.setLocation([780, 189]); let node363 = new UEBlueprintObject(); node363.setLocation([1133, 314]); let node364 = new UEBlueprintObject(); node364.setLocation([626, 317]); let node365 = new UEBlueprintObject(); node365.setLocation([771, 158]); let node366 = new UEBlueprintObject(); node366.setLocation([839, 195]); let node367 = new UEBlueprintObject(); node367.setLocation([725, -51]); let node368 = new UEBlueprintObject(); node368.setLocation([513, 278]); let node369 = new UEBlueprintObject(); node369.setLocation([775, 135]); let node370 = new UEBlueprintObject(); node370.setLocation([1093, 104]); let node371 = new UEBlueprintObject(); node371.setLocation([1027, 222]); let node372 = new UEBlueprintObject(); node372.setLocation([1013, 254]); let node373 = new UEBlueprintObject(); node373.setLocation([885, 262]); let node374 = new UEBlueprintObject(); node374.setLocation([859, 12]); let node375 = new UEBlueprintObject(); node375.setLocation([747, 99]); let node376 = new UEBlueprintObject(); node376.setLocation([1029, 303]); let node377 = new UEBlueprintObject(); node377.setLocation([826, 102]); let node378 = new UEBlueprintObject(); node378.setLocation([833, 237]); let node379 = new UEBlueprintObject(); node379.setLocation([908, 166]); let node380 = new UEBlueprintObject(); node380.setLocation([904, 252]); let node381 = new UEBlueprintObject(); node381.setLocation([1027, 185]); let node382 = new UEBlueprintObject(); node382.setLocation([740, 211]); let node383 = new UEBlueprintObject(); node383.setLocation([802, 291]); let node384 = new UEBlueprintObject(); node384.setLocation([1083, 234]); let node385 = new UEBlueprintObject(); node385.setLocation([853, 163]); let node386 = new UEBlueprintObject(); node386.setLocation([514, 146]); let node387 = new UEBlueprintObject(); node387.setLocation([774, 169]); let node388 = new UEBlueprintObject(); node388.setLocation([805, 237]); let node389 = new UEBlueprintObject(); node389.setLocation([706, 182]); let node390 = new UEBlueprintObject(); node390.setLocation([820, 183]); let node391 = new UEBlueprintObject(); node391.setLocation([1126, 252]); let node392 = new UEBlueprintObject(); node392.setLocation([726, 67]); let node393 = new UEBlueprintObject(); node393.setLocation([849, 180]); let node394 = new UEBlueprintObject(); node394.setLocation([1033, 170]); let node395 = new UEBlueprintObject(); node395.setLocation([501, 208]); let node396 = new UEBlueprintObject(); node396.setLocation([962, 324]); let node397 = new UEBlueprintObject(); node397.setLocation([1038, 240]); let node398 = new UEBlueprintObject(); node398.setLocation([1081, 149]); let node399 = new UEBlueprintObject(); node399.setLocation([1009, 85]); let node400 = new UEBlueprintObject(); node400.setLocation([823, -30]); let node401 = new UEBlueprintObject(); node401.setLocation([637, 215]); let node402 = new UEBlueprintObject(); node402.setLocation([1120, 216]); let node403 = new UEBlueprintObject(); node403.setLocation([658, 113]); let node404 = new UEBlueprintObject(); node404.setLocation([589, 133]); let node405 = new UEBlueprintObject(); node405.setLocation([706, 87]); let node406 = new UEBlueprintObject(); node406.setLocation([831, 307]); let node407 = new UEBlueprintObject(); node407.setLocation([786, -36]); let node408 = new UEBlueprintObject(); node408.setLocation([615, 311]); let node409 = new UEBlueprintObject(); node409.setLocation([655, 127]); let node410 = new UEBlueprintObject(); node410.setLocation([809, 346]); let node411 = new UEBlueprintObject(); node411.setLocation([965, 281]); let node412 = new UEBlueprintObject(); node412.setLocation([518, 167]); let node413 = new UEBlueprintObject(); node413.setLocation([605, 273]); let node414 = new UEBlueprintObject(); node414.setLocation([680, 232]); let node415 = new UEBlueprintObject(); node415.setLocation([813, 235]); let node416 = new UEBlueprintObject(); node416.setLocation([679, 117]); let node417 = new UEBlueprintObject(); node417.setLocation([980, 119]); let node418 = new UEBlueprintObject(); node418.setLocation([827, 134]); let node419 = new UEBlueprintObject(); node419.setLocation([764, 255]); let node420 = new UEBlueprintObject(); node420.setLocation([988, 306]); let node421 = new UEBlueprintObject(); node421.setLocation([606, 35]); let node422 = new UEBlueprintObject(); node422.setLocation([1023, 258]); let node423 = new UEBlueprintObject(); node423.setLocation([894, 276]); let node424 = new UEBlueprintObject(); node424.setLocation([379, 286]); let node425 = new UEBlueprintObject(); node425.setLocation([586, 296]); let node426 = new UEBlueprintObject(); node426.setLocation([896, 339]); let node427 = new UEBlueprintObject(); node427.setLocation([558, 180]); let node428 = new UEBlueprintObject(); node428.setLocation([686, 75]); let node429 = new UEBlueprintObject(); node429.setLocation([779, 233]); let node430 = new UEBlueprintObject(); node430.setLocation([701, 326]); let node431 = new UEBlueprintObject(); node431.setLocation([763, 210]); let node432 = new UEBlueprintObject(); node432.setLocation([987, 184]); let node433 = new UEBlueprintObject(); node433.setLocation([711, 199]); let node434 = new UEBlueprintObject(); node434.setLocation([947, 183]); let node435 = new UEBlueprintObject(); node435.setLocation([783, 169]); let node436 = new UEBlueprintObject(); node436.setLocation([1103, 104]); let node437 = new UEBlueprintObject(); node437.setLocation([869, 272]); let node438 = new UEBlueprintObject(); node438.setLocation([865, 214]); let node439 = new UEBlueprintObject(); node439.setLocation([570, 240]); let node440 = new UEBlueprintObject(); node440.setLocation([761, 285]); let node441 = new UEBlueprintObject(); node441.setLocation([660, 124]); let node442 = new UEBlueprintObject(); node442.setLocation([796, 159]); let node443 = new UEBlueprintObject(); node443.setLocation([1003, 357]); let node444 = new UEBlueprintObject(); node444.setLocation([669, 76]); let node445 = new UEBlueprintObject(); node445.setLocation([785, 85]); let node446 = new UEBlueprintObject(); node446.setLocation([956, 176]); let node447 = new UEBlueprintObject(); node447.setLocation([1145, 305]); let node448 = new UEBlueprintObject(); node448.setLocation([275, 93]); let node449 = new UEBlueprintObject(); node449.setLocation([804, 62]); let node450 = new UEBlueprintObject(); node450.setLocation([738, 433]); let node451 = new UEBlueprintObject(); node451.setLocation([644, 297]); let node452 = new UEBlueprintObject(); node452.setLocation([855, 163]); let node453 = new UEBlueprintObject(); node453.setLocation([826, 363]); let node454 = new UEBlueprintObject(); node454.setLocation([933, 277]); let node455 = new UEBlueprintObject(); node455.setLocation([607, 338]); let node456 = new UEBlueprintObject(); node456.setLocation([961, 82]); let node457 = new UEBlueprintObject(); node457.setLocation([822, 21]); let node458 = new UEBlueprintObject(); node458.setLocation([861, 119]); let node459 = new UEBlueprintObject(); node459.setLocation([625, 88]); let node460 = new UEBlueprintObject(); node460.setLocation([619, 213]); let node461 = new UEBlueprintObject(); node461.setLocation([509, 172]); let node462 = new UEBlueprintObject(); node462.setLocation([749, 256]); let node463 = new UEBlueprintObject(); node463.setLocation([645, 108]); let node464 = new UEBlueprintObject(); node464.setLocation([930, 248]); let node465 = new UEBlueprintObject(); node465.setLocation([842, 271]); let node466 = new UEBlueprintObject(); node466.setLocation([400, 154]); let node467 = new UEBlueprintObject(); node467.setLocation([782, 287]); let node468 = new UEBlueprintObject(); node468.setLocation([542, 231]); let node469 = new UEBlueprintObject(); node469.setLocation([831, 225]); let node470 = new UEBlueprintObject(); node470.setLocation([921, 11]); let node471 = new UEBlueprintObject(); node471.setLocation([860, 394]); let node472 = new UEBlueprintObject(); node472.setLocation([661, 188]); let node473 = new UEBlueprintObject(); node473.setLocation([724, 170]); let node474 = new UEBlueprintObject(); node474.setLocation([1140, 221]); let node475 = new UEBlueprintObject(); node475.setLocation([1338, 108]); let node476 = new UEBlueprintObject(); node476.setLocation([457, 98]); let node477 = new UEBlueprintObject(); node477.setLocation([1071, 203]); let node478 = new UEBlueprintObject(); node478.setLocation([856, 289]); let node479 = new UEBlueprintObject(); node479.setLocation([529, 214]); let node480 = new UEBlueprintObject(); node480.setLocation([718, 43]); let node481 = new UEBlueprintObject(); node481.setLocation([902, 208]); let node482 = new UEBlueprintObject(); node482.setLocation([962, 162]); let node483 = new UEBlueprintObject(); node483.setLocation([637, 344]); let node484 = new UEBlueprintObject(); node484.setLocation([984, 146]); let node485 = new UEBlueprintObject(); node485.setLocation([839, 162]); let node486 = new UEBlueprintObject(); node486.setLocation([646, 80]); let node487 = new UEBlueprintObject(); node487.setLocation([670, 290]); let node488 = new UEBlueprintObject(); node488.setLocation([929, 77]); let node489 = new UEBlueprintObject(); node489.setLocation([835, 163]); let node490 = new UEBlueprintObject(); node490.setLocation([497, 260]); let node491 = new UEBlueprintObject(); node491.setLocation([1038, 195]); let node492 = new UEBlueprintObject(); node492.setLocation([523, 259]); let node493 = new UEBlueprintObject(); node493.setLocation([529, 153]); let node494 = new UEBlueprintObject(); node494.setLocation([953, 33]); let node495 = new UEBlueprintObject(); node495.setLocation([777, 112]); let node496 = new UEBlueprintObject(); node496.setLocation([713, 43]); let node497 = new UEBlueprintObject(); node497.setLocation([906, 346]); let node498 = new UEBlueprintObject(); node498.setLocation([842, 243]); let node499 = new UEBlueprintObject(); node499.setLocation([660, 269]); let node500 = new UEBlueprintObject(); node500.setLocation([929, 236]); let node501 = new UEBlueprintObject(); node501.setLocation([876, 261]); let node502 = new UEBlueprintObject(); node502.setLocation([659, 268]); let node503 = new UEBlueprintObject(); node503.setLocation([470, 116]); let node504 = new UEBlueprintObject(); node504.setLocation([518, 125]); let node505 = new UEBlueprintObject(); node505.setLocation([636, 256]); let node506 = new UEBlueprintObject(); node506.setLocation([325, 345]); let node507 = new UEBlueprintObject(); node507.setLocation([1088, 152]); let node508 = new UEBlueprintObject(); node508.setLocation([906, 86]); let node509 = new UEBlueprintObject(); node509.setLocation([616, 89]); let node510 = new UEBlueprintObject(); node510.setLocation([667, 352]); let node511 = new UEBlueprintObject(); node511.setLocation([531, 168]); let node512 = new UEBlueprintObject(); node512.setLocation([784, -59]); let node513 = new UEBlueprintObject(); node513.setLocation([618, 177]); let node514 = new UEBlueprintObject(); node514.setLocation([895, 281]); let node515 = new UEBlueprintObject(); node515.setLocation([1091, 386]); let node516 = new UEBlueprintObject(); node516.setLocation([871, 283]); let node517 = new UEBlueprintObject(); node517.setLocation([696, 297]); let node518 = new UEBlueprintObject(); node518.setLocation([1163, 108]); let node519 = new UEBlueprintObject(); node519.setLocation([1022, 203]); let node520 = new UEBlueprintObject(); node520.setLocation([1023, 306]); let node521 = new UEBlueprintObject(); node521.setLocation([845, 212]); let node522 = new UEBlueprintObject(); node522.setLocation([876, 248]); let node523 = new UEBlueprintObject(); node523.setLocation([872, 87]); let node524 = new UEBlueprintObject(); node524.setLocation([786, 392]); let node525 = new UEBlueprintObject(); node525.setLocation([825, 151]); let node526 = new UEBlueprintObject(); node526.setLocation([731, 225]); let node527 = new UEBlueprintObject(); node527.setLocation([587, 275]); let node528 = new UEBlueprintObject(); node528.setLocation([630, 262]); let node529 = new UEBlueprintObject(); node529.setLocation([807, 280]); let node530 = new UEBlueprintObject(); node530.setLocation([568, 253]); let node531 = new UEBlueprintObject(); node531.setLocation([1222, 104]); let node532 = new UEBlueprintObject(); node532.setLocation([693, 371]); let node533 = new UEBlueprintObject(); node533.setLocation([582, 315]); let node534 = new UEBlueprintObject(); node534.setLocation([598, 204]); let node535 = new UEBlueprintObject(); node535.setLocation([994, 326]); let node536 = new UEBlueprintObject(); node536.setLocation([726, 150]); let node537 = new UEBlueprintObject(); node537.setLocation([725, 76]); let node538 = new UEBlueprintObject(); node538.setLocation([588, 161]); let node539 = new UEBlueprintObject(); node539.setLocation([749, 259]); let node540 = new UEBlueprintObject(); node540.setLocation([721, 286]); let node541 = new UEBlueprintObject(); node541.setLocation([792, 224]); let node542 = new UEBlueprintObject(); node542.setLocation([804, 278]); let node543 = new UEBlueprintObject(); node543.setLocation([643, 315]); let node544 = new UEBlueprintObject(); node544.setLocation([577, 9]); let node545 = new UEBlueprintObject(); node545.setLocation([614, 286]); let node546 = new UEBlueprintObject(); node546.setLocation([912, 118]); let node547 = new UEBlueprintObject(); node547.setLocation([1012, 249]); let node548 = new UEBlueprintObject(); node548.setLocation([608, 230]); let node549 = new UEBlueprintObject(); node549.setLocation([793, 229]); let node550 = new UEBlueprintObject(); node550.setLocation([718, 120]); let node551 = new UEBlueprintObject(); node551.setLocation([740, 178]); let node552 = new UEBlueprintObject(); node552.setLocation([770, 115]); let node553 = new UEBlueprintObject(); node553.setLocation([1267, 142]); let node554 = new UEBlueprintObject(); node554.setLocation([744, 144]); let node555 = new UEBlueprintObject(); node555.setLocation([585, 243]); let node556 = new UEBlueprintObject(); node556.setLocation([654, 241]); let node557 = new UEBlueprintObject(); node557.setLocation([540, 269]); let node558 = new UEBlueprintObject(); node558.setLocation([997, 154]); let node559 = new UEBlueprintObject(); node559.setLocation([784, 155]); let node560 = new UEBlueprintObject(); node560.setLocation([1056, 322]); let node561 = new UEBlueprintObject(); node561.setLocation([362, 221]); let node562 = new UEBlueprintObject(); node562.setLocation([786, 178]); let node563 = new UEBlueprintObject(); node563.setLocation([977, 251]); let node564 = new UEBlueprintObject(); node564.setLocation([891, 190]); let node565 = new UEBlueprintObject(); node565.setLocation([515, 109]); let node566 = new UEBlueprintObject(); node566.setLocation([875, 255]); let node567 = new UEBlueprintObject(); node567.setLocation([808, 149]); let node568 = new UEBlueprintObject(); node568.setLocation([804, 11]); let node569 = new UEBlueprintObject(); node569.setLocation([959, 321]); let node570 = new UEBlueprintObject(); node570.setLocation([607, 78]); let node571 = new UEBlueprintObject(); node571.setLocation([1099, 254]); let node572 = new UEBlueprintObject(); node572.setLocation([919, 126]); let node573 = new UEBlueprintObject(); node573.setLocation([936, 125]); let node574 = new UEBlueprintObject(); node574.setLocation([761, 235]); let node575 = new UEBlueprintObject(); node575.setLocation([803, 209]); let node576 = new UEBlueprintObject(); node576.setLocation([1059, -21]); let node577 = new UEBlueprintObject(); node577.setLocation([881, 129]); let node578 = new UEBlueprintObject(); node578.setLocation([612, 128]); let node579 = new UEBlueprintObject(); node579.setLocation([844, 127]); let node580 = new UEBlueprintObject(); node580.setLocation([625, 162]); let node581 = new UEBlueprintObject(); node581.setLocation([616, 122]); let node582 = new UEBlueprintObject(); node582.setLocation([1128, 99]); let node583 = new UEBlueprintObject(); node583.setLocation([833, 302]); let node584 = new UEBlueprintObject(); node584.setLocation([801, 167]); let node585 = new UEBlueprintObject(); node585.setLocation([376, 262]); let node586 = new UEBlueprintObject(); node586.setLocation([713, 112]); let node587 = new UEBlueprintObject(); node587.setLocation([982, 354]); let node588 = new UEBlueprintObject(); node588.setLocation([858, 200]); let node589 = new UEBlueprintObject(); node589.setLocation([1042, 261]); let node590 = new UEBlueprintObject(); node590.setLocation([907, 238]); let node591 = new UEBlueprintObject(); node591.setLocation([833, 110]); let node592 = new UEBlueprintObject(); node592.setLocation([980, 204]); let node593 = new UEBlueprintObject(); node593.setLocation([732, 303]); let node594 = new UEBlueprintObject(); node594.setLocation([590, 229]); let node595 = new UEBlueprintObject(); node595.setLocation([1027, 175]); let node596 = new UEBlueprintObject(); node596.setLocation([1283, 105]); let node597 = new UEBlueprintObject(); node597.setLocation([763, 107]); let node598 = new UEBlueprintObject(); node598.setLocation([765, 93]); let node599 = new UEBlueprintObject(); node599.setLocation([988, 250]); let node600 = new UEBlueprintObject(); node600.setLocation([985, 145]); let node601 = new UEBlueprintObject(); node601.setLocation([845, 283]); let node602 = new UEBlueprintObject(); node602.setLocation([484, 134]); let node603 = new UEBlueprintObject(); node603.setLocation([856, 169]); let node604 = new UEBlueprintObject(); node604.setLocation([841, 357]); let node605 = new UEBlueprintObject(); node605.setLocation([853, 213]); let node606 = new UEBlueprintObject(); node606.setLocation([1083, 95]); let node607 = new UEBlueprintObject(); node607.setLocation([1171, 275]); let node608 = new UEBlueprintObject(); node608.setLocation([498, 295]); let node609 = new UEBlueprintObject(); node609.setLocation([1122, 271]); let node610 = new UEBlueprintObject(); node610.setLocation([923, 14]); let node611 = new UEBlueprintObject(); node611.setLocation([704, 96]); let node612 = new UEBlueprintObject(); node612.setLocation([952, 178]); let node613 = new UEBlueprintObject(); node613.setLocation([706, 243]); let node614 = new UEBlueprintObject(); node614.setLocation([629, 106]); let node615 = new UEBlueprintObject(); node615.setLocation([727, 180]); let node616 = new UEBlueprintObject(); node616.setLocation([1107, 302]); let node617 = new UEBlueprintObject(); node617.setLocation([552, 142]); let node618 = new UEBlueprintObject(); node618.setLocation([1034, -98]); let node619 = new UEBlueprintObject(); node619.setLocation([830, 217]); let node620 = new UEBlueprintObject(); node620.setLocation([1037, 433]); let node621 = new UEBlueprintObject(); node621.setLocation([689, 277]); let node622 = new UEBlueprintObject(); node622.setLocation([796, 81]); let node623 = new UEBlueprintObject(); node623.setLocation([501, 279]); let node624 = new UEBlueprintObject(); node624.setLocation([784, 253]); let node625 = new UEBlueprintObject(); node625.setLocation([776, 259]); let node626 = new UEBlueprintObject(); node626.setLocation([481, 25]); let node627 = new UEBlueprintObject(); node627.setLocation([607, 111]); let node628 = new UEBlueprintObject(); node628.setLocation([535, -16]); let node629 = new UEBlueprintObject(); node629.setLocation([1249, 235]); let node630 = new UEBlueprintObject(); node630.setLocation([1037, 262]); let node631 = new UEBlueprintObject(); node631.setLocation([610, 113]); let node632 = new UEBlueprintObject(); node632.setLocation([796, 225]); let node633 = new UEBlueprintObject(); node633.setLocation([372, 335]); let node634 = new UEBlueprintObject(); node634.setLocation([714, 108]); let node635 = new UEBlueprintObject(); node635.setLocation([839, 137]); let node636 = new UEBlueprintObject(); node636.setLocation([693, 195]); let node637 = new UEBlueprintObject(); node637.setLocation([1072, 240]); let node638 = new UEBlueprintObject(); node638.setLocation([1243, 275]); let node639 = new UEBlueprintObject(); node639.setLocation([991, 174]); let node640 = new UEBlueprintObject(); node640.setLocation([859, 72]); let node641 = new UEBlueprintObject(); node641.setLocation([889, 176]); let node642 = new UEBlueprintObject(); node642.setLocation([596, 250]); let node643 = new UEBlueprintObject(); node643.setLocation([856, 95]); let node644 = new UEBlueprintObject(); node644.setLocation([1163, 233]); let node645 = new UEBlueprintObject(); node645.setLocation([695, 217]); let node646 = new UEBlueprintObject(); node646.setLocation([1091, 134]); let node647 = new UEBlueprintObject(); node647.setLocation([652, 296]); let node648 = new UEBlueprintObject(); node648.setLocation([880, 130]); let node649 = new UEBlueprintObject(); node649.setLocation([974, 269]); let node650 = new UEBlueprintObject(); node650.setLocation([856, 196]); let node651 = new UEBlueprintObject(); node651.setLocation([747, 341]); let node652 = new UEBlueprintObject(); node652.setLocation([1162, 143]); let node653 = new UEBlueprintObject(); node653.setLocation([615, 366]); let node654 = new UEBlueprintObject(); node654.setLocation([663, 152]); let node655 = new UEBlueprintObject(); node655.setLocation([934, 204]); let node656 = new UEBlueprintObject(); node656.setLocation([932, 56]); let node657 = new UEBlueprintObject(); node657.setLocation([854, 276]); let node658 = new UEBlueprintObject(); node658.setLocation([524, 200]); let node659 = new UEBlueprintObject(); node659.setLocation([693, 239]); let node660 = new UEBlueprintObject(); node660.setLocation([663, 300]); let node661 = new UEBlueprintObject(); node661.setLocation([673, 203]); let node662 = new UEBlueprintObject(); node662.setLocation([269, 178]); let node663 = new UEBlueprintObject(); node663.setLocation([569, 298]); let node664 = new UEBlueprintObject(); node664.setLocation([922, 218]); let node665 = new UEBlueprintObject(); node665.setLocation([886, 274]); let node666 = new UEBlueprintObject(); node666.setLocation([516, 169]); let node667 = new UEBlueprintObject(); node667.setLocation([739, 139]); let node668 = new UEBlueprintObject(); node668.setLocation([934, 346]); let node669 = new UEBlueprintObject(); node669.setLocation([829, 320]); let node670 = new UEBlueprintObject(); node670.setLocation([956, 485]); let node671 = new UEBlueprintObject(); node671.setLocation([437, 284]); let node672 = new UEBlueprintObject(); node672.setLocation([951, 339]); let node673 = new UEBlueprintObject(); node673.setLocation([973, 149]); let node674 = new UEBlueprintObject(); node674.setLocation([735, 165]); let node675 = new UEBlueprintObject(); node675.setLocation([438, 320]); let node676 = new UEBlueprintObject(); node676.setLocation([897, 263]); let node677 = new UEBlueprintObject(); node677.setLocation([831, 304]); let node678 = new UEBlueprintObject(); node678.setLocation([725, 228]); let node679 = new UEBlueprintObject(); node679.setLocation([844, 107]); let node680 = new UEBlueprintObject(); node680.setLocation([883, 274]); let node681 = new UEBlueprintObject(); node681.setLocation([540, 295]); let node682 = new UEBlueprintObject(); node682.setLocation([952, 253]); let node683 = new UEBlueprintObject(); node683.setLocation([1133, 185]); let node684 = new UEBlueprintObject(); node684.setLocation([329, 120]); let node685 = new UEBlueprintObject(); node685.setLocation([485, 277]); let node686 = new UEBlueprintObject(); node686.setLocation([402, 202]); let node687 = new UEBlueprintObject(); node687.setLocation([465, 262]); let node688 = new UEBlueprintObject(); node688.setLocation([790, 152]); let node689 = new UEBlueprintObject(); node689.setLocation([869, 145]); let node690 = new UEBlueprintObject(); node690.setLocation([889, 419]); let node691 = new UEBlueprintObject(); node691.setLocation([489, 202]); let node692 = new UEBlueprintObject(); node692.setLocation([973, 319]); let node693 = new UEBlueprintObject(); node693.setLocation([981, 153]); let node694 = new UEBlueprintObject(); node694.setLocation([1056, 157]); let node695 = new UEBlueprintObject(); node695.setLocation([886, 247]); let node696 = new UEBlueprintObject(); node696.setLocation([852, 122]); let node697 = new UEBlueprintObject(); node697.setLocation([597, 135]); let node698 = new UEBlueprintObject(); node698.setLocation([709, 179]); let node699 = new UEBlueprintObject(); node699.setLocation([682, 167]); let node700 = new UEBlueprintObject(); node700.setLocation([503, 155]); let node701 = new UEBlueprintObject(); node701.setLocation([680, 140]); let node702 = new UEBlueprintObject(); node702.setLocation([628, 297]); let node703 = new UEBlueprintObject(); node703.setLocation([875, 112]); let node704 = new UEBlueprintObject(); node704.setLocation([992, 234]); let node705 = new UEBlueprintObject(); node705.setLocation([1162, 15]); let node706 = new UEBlueprintObject(); node706.setLocation([1004, 202]); let node707 = new UEBlueprintObject(); node707.setLocation([759, 315]); let node708 = new UEBlueprintObject(); node708.setLocation([726, 194]); let node709 = new UEBlueprintObject(); node709.setLocation([809, 320]); let node710 = new UEBlueprintObject(); node710.setLocation([686, 279]); let node711 = new UEBlueprintObject(); node711.setLocation([581, 204]); let node712 = new UEBlueprintObject(); node712.setLocation([882, 89]); let node713 = new UEBlueprintObject(); node713.setLocation([664, 228]); let node714 = new UEBlueprintObject(); node714.setLocation([647, 157]); let node715 = new UEBlueprintObject(); node715.setLocation([1024, 96]); let node716 = new UEBlueprintObject(); node716.setLocation([575, 145]); let node717 = new UEBlueprintObject(); node717.setLocation([726, 381]); let node718 = new UEBlueprintObject(); node718.setLocation([596, 369]); let node719 = new UEBlueprintObject(); node719.setLocation([718, 329]); let node720 = new UEBlueprintObject(); node720.setLocation([641, 186]); let node721 = new UEBlueprintObject(); node721.setLocation([568, 105]); let node722 = new UEBlueprintObject(); node722.setLocation([825, 224]); let node723 = new UEBlueprintObject(); node723.setLocation([774, 194]); let node724 = new UEBlueprintObject(); node724.setLocation([892, 293]); let node725 = new UEBlueprintObject(); node725.setLocation([1062, 84]); let node726 = new UEBlueprintObject(); node726.setLocation([744, 127]); let node727 = new UEBlueprintObject(); node727.setLocation([731, 190]); let node728 = new UEBlueprintObject(); node728.setLocation([863, 241]); let node729 = new UEBlueprintObject(); node729.setLocation([763, 317]); let node730 = new UEBlueprintObject(); node730.setLocation([784, -42]); let node731 = new UEBlueprintObject(); node731.setLocation([759, 237]); let node732 = new UEBlueprintObject(); node732.setLocation([1035, 184]); let node733 = new UEBlueprintObject(); node733.setLocation([649, 171]); let node734 = new UEBlueprintObject(); node734.setLocation([773, 204]); let node735 = new UEBlueprintObject(); node735.setLocation([667, 196]); let node736 = new UEBlueprintObject(); node736.setLocation([755, 284]); let node737 = new UEBlueprintObject(); node737.setLocation([711, 293]); let node738 = new UEBlueprintObject(); node738.setLocation([623, 312]); let node739 = new UEBlueprintObject(); node739.setLocation([842, 168]); let node740 = new UEBlueprintObject(); node740.setLocation([877, 203]); let node741 = new UEBlueprintObject(); node741.setLocation([1219, 182]); let node742 = new UEBlueprintObject(); node742.setLocation([804, 232]); let node743 = new UEBlueprintObject(); node743.setLocation([697, 177]); let node744 = new UEBlueprintObject(); node744.setLocation([787, 216]); let node745 = new UEBlueprintObject(); node745.setLocation([783, 139]); let node746 = new UEBlueprintObject(); node746.setLocation([514, 368]); let node747 = new UEBlueprintObject(); node747.setLocation([717, 259]); let node748 = new UEBlueprintObject(); node748.setLocation([780, 207]); let node749 = new UEBlueprintObject(); node749.setLocation([966, 112]); let node750 = new UEBlueprintObject(); node750.setLocation([937, 356]); let node751 = new UEBlueprintObject(); node751.setLocation([968, 292]); let node752 = new UEBlueprintObject(); node752.setLocation([626, 29]); let node753 = new UEBlueprintObject(); node753.setLocation([796, 149]); let node754 = new UEBlueprintObject(); node754.setLocation([997, 232]); let node755 = new UEBlueprintObject(); node755.setLocation([787, 246]); let node756 = new UEBlueprintObject(); node756.setLocation([506, 361]); let node757 = new UEBlueprintObject(); node757.setLocation([609, 371]); let node758 = new UEBlueprintObject(); node758.setLocation([1088, 51]); let node759 = new UEBlueprintObject(); node759.setLocation([560, 141]); let node760 = new UEBlueprintObject(); node760.setLocation([1105, 42]); let node761 = new UEBlueprintObject(); node761.setLocation([794, 129]); let node762 = new UEBlueprintObject(); node762.setLocation([1090, 79]); let node763 = new UEBlueprintObject(); node763.setLocation([769, 160]); let node764 = new UEBlueprintObject(); node764.setLocation([940, 56]); let node765 = new UEBlueprintObject(); node765.setLocation([928, 160]); let node766 = new UEBlueprintObject(); node766.setLocation([751, 155]); let node767 = new UEBlueprintObject(); node767.setLocation([639, 332]); let node768 = new UEBlueprintObject(); node768.setLocation([1049, 200]); let node769 = new UEBlueprintObject(); node769.setLocation([1063, 205]); let node770 = new UEBlueprintObject(); node770.setLocation([690, 338]); let node771 = new UEBlueprintObject(); node771.setLocation([943, 129]); let node772 = new UEBlueprintObject(); node772.setLocation([989, 262]); let node773 = new UEBlueprintObject(); node773.setLocation([616, 219]); let node774 = new UEBlueprintObject(); node774.setLocation([769, 330]); let node775 = new UEBlueprintObject(); node775.setLocation([1149, 226]); let node776 = new UEBlueprintObject(); node776.setLocation([805, 233]); let node777 = new UEBlueprintObject(); node777.setLocation([567, 202]); let node778 = new UEBlueprintObject(); node778.setLocation([1078, 248]); let node779 = new UEBlueprintObject(); node779.setLocation([1068, 197]); let node780 = new UEBlueprintObject(); node780.setLocation([965, 58]); let node781 = new UEBlueprintObject(); node781.setLocation([926, 146]); let node782 = new UEBlueprintObject(); node782.setLocation([722, 247]); let node783 = new UEBlueprintObject(); node783.setLocation([1080, 190]); let node784 = new UEBlueprintObject(); node784.setLocation([838, 220]); let node785 = new UEBlueprintObject(); node785.setLocation([1039, 116]); let node786 = new UEBlueprintObject(); node786.setLocation([520, 63]); let node787 = new UEBlueprintObject(); node787.setLocation([1202, 202]); let node788 = new UEBlueprintObject(); node788.setLocation([411, 200]); let node789 = new UEBlueprintObject(); node789.setLocation([268, 139]); let node790 = new UEBlueprintObject(); node790.setLocation([915, 220]); let node791 = new UEBlueprintObject(); node791.setLocation([1228, 300]); let node792 = new UEBlueprintObject(); node792.setLocation([434, 108]); let node793 = new UEBlueprintObject(); node793.setLocation([386, -62]); let node794 = new UEBlueprintObject(); node794.setLocation([831, 132]); let node795 = new UEBlueprintObject(); node795.setLocation([647, 170]); let node796 = new UEBlueprintObject(); node796.setLocation([999, 246]); let node797 = new UEBlueprintObject(); node797.setLocation([715, 77]); let node798 = new UEBlueprintObject(); node798.setLocation([946, 205]); let node799 = new UEBlueprintObject(); node799.setLocation([1098, 378]); blueprint.addNode(node0, node1, node2, node3, node4, node5, node6, node7, node8, node9, node10, node11, node12, node13, node14, node15, node16, node17, node18, node19, node20, node21, node22, node23, node24, node25, node26, node27, node28, node29, node30, node31, node32, node33, node34, node35, node36, node37, node38, node39, node40, node41, node42, node43, node44, node45, node46, node47, node48, node49, node50, node51, node52, node53, node54, node55, node56, node57, node58, node59, node60, node61, node62, node63, node64, node65, node66, node67, node68, node69, node70, node71, node72, node73, node74, node75, node76, node77, node78, node79, node80, node81, node82, node83, node84, node85, node86, node87, node88, node89, node90, node91, node92, node93, node94, node95, node96, node97, node98, node99, node100, node101, node102, node103, node104, node105, node106, node107, node108, node109, node110, node111, node112, node113, node114, node115, node116, node117, node118, node119, node120, node121, node122, node123, node124, node125, node126, node127, node128, node129, node130, node131, node132, node133, node134, node135, node136, node137, node138, node139, node140, node141, node142, node143, node144, node145, node146, node147, node148, node149, node150, node151, node152, node153, node154, node155, node156, node157, node158, node159, node160, node161, node162, node163, node164, node165, node166, node167, node168, node169, node170, node171, node172, node173, node174, node175, node176, node177, node178, node179, node180, node181, node182, node183, node184, node185, node186, node187, node188, node189, node190, node191, node192, node193, node194, node195, node196, node197, node198, node199, node200, node201, node202, node203, node204, node205, node206, node207, node208, node209, node210, node211, node212, node213, node214, node215, node216, node217, node218, node219, node220, node221, node222, node223, node224, node225, node226, node227, node228, node229, node230, node231, node232, node233, node234, node235, node236, node237, node238, node239, node240, node241, node242, node243, node244, node245, node246, node247, node248, node249, node250, node251, node252, node253, node254, node255, node256, node257, node258, node259, node260, node261, node262, node263, node264, node265, node266, node267, node268, node269, node270, node271, node272, node273, node274, node275, node276, node277, node278, node279, node280, node281, node282, node283, node284, node285, node286, node287, node288, node289, node290, node291, node292, node293, node294, node295, node296, node297, node298, node299, node300, node301, node302, node303, node304, node305, node306, node307, node308, node309, node310, node311, node312, node313, node314, node315, node316, node317, node318, node319, node320, node321, node322, node323, node324, node325, node326, node327, node328, node329, node330, node331, node332, node333, node334, node335, node336, node337, node338, node339, node340, node341, node342, node343, node344, node345, node346, node347, node348, node349, node350, node351, node352, node353, node354, node355, node356, node357, node358, node359, node360, node361, node362, node363, node364, node365, node366, node367, node368, node369, node370, node371, node372, node373, node374, node375, node376, node377, node378, node379, node380, node381, node382, node383, node384, node385, node386, node387, node388, node389, node390, node391, node392, node393, node394, node395, node396, node397, node398, node399, node400, node401, node402, node403, node404, node405, node406, node407, node408, node409, node410, node411, node412, node413, node414, node415, node416, node417, node418, node419, node420, node421, node422, node423, node424, node425, node426, node427, node428, node429, node430, node431, node432, node433, node434, node435, node436, node437, node438, node439, node440, node441, node442, node443, node444, node445, node446, node447, node448, node449, node450, node451, node452, node453, node454, node455, node456, node457, node458, node459, node460, node461, node462, node463, node464, node465, node466, node467, node468, node469, node470, node471, node472, node473, node474, node475, node476, node477, node478, node479, node480, node481, node482, node483, node484, node485, node486, node487, node488, node489, node490, node491, node492, node493, node494, node495, node496, node497, node498, node499, node500, node501, node502, node503, node504, node505, node506, node507, node508, node509, node510, node511, node512, node513, node514, node515, node516, node517, node518, node519, node520, node521, node522, node523, node524, node525, node526, node527, node528, node529, node530, node531, node532, node533, node534, node535, node536, node537, node538, node539, node540, node541, node542, node543, node544, node545, node546, node547, node548, node549, node550, node551, node552, node553, node554, node555, node556, node557, node558, node559, node560, node561, node562, node563, node564, node565, node566, node567, node568, node569, node570, node571, node572, node573, node574, node575, node576, node577, node578, node579, node580, node581, node582, node583, node584, node585, node586, node587, node588, node589, node590, node591, node592, node593, node594, node595, node596, node597, node598, node599, node600, node601, node602, node603, node604, node605, node606, node607, node608, node609, node610, node611, node612, node613, node614, node615, node616, node617, node618, node619, node620, node621, node622, node623, node624, node625, node626, node627, node628, node629, node630, node631, node632, node633, node634, node635, node636, node637, node638, node639, node640, node641, node642, node643, node644, node645, node646, node647, node648, node649, node650, node651, node652, node653, node654, node655, node656, node657, node658, node659, node660, node661, node662, node663, node664, node665, node666, node667, node668, node669, node670, node671, node672, node673, node674, node675, node676, node677, node678, node679, node680, node681, node682, node683, node684, node685, node686, node687, node688, node689, node690, node691, node692, node693, node694, node695, node696, node697, node698, node699, node700, node701, node702, node703, node704, node705, node706, node707, node708, node709, node710, node711, node712, node713, node714, node715, node716, node717, node718, node719, node720, node721, node722, node723, node724, node725, node726, node727, node728, node729, node730, node731, node732, node733, node734, node735, node736, node737, node738, node739, node740, node741, node742, node743, node744, node745, node746, node747, node748, node749, node750, node751, node752, node753, node754, node755, node756, node757, node758, node759, node760, node761, node762, node763, node764, node765, node766, node767, node768, node769, node770, node771, node772, node773, node774, node775, node776, node777, node778, node779, node780, node781, node782, node783, node784, node785, node786, node787, node788, node789, node790, node791, node792, node793, node794, node795, node796, node797, node798, node799); + let node0 = new UEBlueprintObject(); node0.setLocation([985, 393]); let node1 = new UEBlueprintObject(); node1.setLocation([999, 114]); let node2 = new UEBlueprintObject(); node2.setLocation([811, 253]); let node3 = new UEBlueprintObject(); node3.setLocation([802, 146]); let node4 = new UEBlueprintObject(); node4.setLocation([597, 105]); let node5 = new UEBlueprintObject(); node5.setLocation([789, 233]); let node6 = new UEBlueprintObject(); node6.setLocation([549, 289]); let node7 = new UEBlueprintObject(); node7.setLocation([678, 193]); let node8 = new UEBlueprintObject(); node8.setLocation([1078, 244]); let node9 = new UEBlueprintObject(); node9.setLocation([751, 151]); let node10 = new UEBlueprintObject(); node10.setLocation([1046, -14]); let node11 = new UEBlueprintObject(); node11.setLocation([714, 267]); let node12 = new UEBlueprintObject(); node12.setLocation([767, 36]); let node13 = new UEBlueprintObject(); node13.setLocation([807, 219]); let node14 = new UEBlueprintObject(); node14.setLocation([1031, 70]); let node15 = new UEBlueprintObject(); node15.setLocation([906, 389]); let node16 = new UEBlueprintObject(); node16.setLocation([936, 131]); let node17 = new UEBlueprintObject(); node17.setLocation([689, 249]); let node18 = new UEBlueprintObject(); node18.setLocation([1153, 343]); let node19 = new UEBlueprintObject(); node19.setLocation([626, 209]); blueprint.addNode(node0, node1, node2, node3, node4, node5, node6, node7, node8, node9, node10, node11, node12, node13, node14, node15, node16, node17, node18, node19); + document.querySelector('body').appendChild(blueprint) let a = 123 diff --git a/ueblueprint.js b/ueblueprint.js index e2ba4b8..d2073b3 100644 --- a/ueblueprint.js +++ b/ueblueprint.js @@ -4,52 +4,106 @@ class Utility { } } -class UEBlueprintDrag { - constructor(blueprintNode, options) { - this.blueprintNode = blueprintNode; - this.mousePosition = [0, 0]; - this.stepSize = options?.stepSize; +/** + * This class manages the ui gesture of mouse click and drag. Tha actual operations are implemented by the subclasses. + */ +class UMouseClickDrag { + constructor(target, blueprint, options) { + this.target = target; + /** @type {import("../UEBlueprint").default}" */ + this.blueprint = blueprint; this.clickButton = options?.clickButton ?? 0; - this.exitDragAnyButton = options?.exitDragAnyButton ?? true; + this.exitAnyButton = options?.exitAnyButton ?? true; + this.looseTarget = options?.looseTarget ?? false; + this.started = false; + this.clickedPosition = [0, 0]; + let movementSpace = this.blueprint?.getGridDOMElement() ?? document; let self = this; + this.mouseDownHandler = function (e) { switch (e.button) { case self.clickButton: - self.clicked(e.clientX, e.clientY); - break; + // Either doesn't matter or consider the click only when clicking on the parent, not descandants + if (self.looseTarget || e.target == e.currentTarget) { + self.started = false; + // Attach the listeners + movementSpace.addEventListener('mousemove', self.mouseStartedMovingHandler); + document.addEventListener('mouseup', self.mouseUpHandler); + self.clickedPosition = [e.offsetX, e.offsetY]; + self.clicked(e); + } + break default: - if (!self.exitDragAnyButton) { + if (!self.exitAnyButton) { self.mouseUpHandler(e); } - break; + break } }; + + this.mouseStartedMovingHandler = function (e) { + e.preventDefault(); + + // Delegate from now on to self.mouseMoveHandler + movementSpace.removeEventListener('mousemove', self.mouseStartedMovingHandler); + movementSpace.addEventListener('mousemove', self.mouseMoveHandler); + + // Do actual actions + self.startDrag(e); + self.started = true; + }; + this.mouseMoveHandler = function (e) { - let mousePosition = self.snapToGrid(e.clientX, e.clientY); - const d = [mousePosition[0] - self.mousePosition[0], mousePosition[1] - self.mousePosition[1]]; - - if (d[0] == 0 && d[1] == 0) { - return; - } - - self.blueprintNode.addLocation(d); - - // Reassign the position of mouse - self.mousePosition = mousePosition; + e.preventDefault(); + self.dragTo(e); }; + this.mouseUpHandler = function (e) { - if (!self.exitDragAnyButton || e.button == self.clickButton) { + if (!self.exitAnyButton || e.button == self.clickButton) { // Remove the handlers of `mousemove` and `mouseup` - document.removeEventListener('mousemove', self.mouseMoveHandler); + movementSpace.removeEventListener('mousemove', self.mouseStartedMovingHandler); + movementSpace.removeEventListener('mousemove', self.mouseMoveHandler); document.removeEventListener('mouseup', self.mouseUpHandler); + self.endDrag(e); } }; - this.blueprintNode.addEventListener('mousedown', this.mouseDownHandler); - this.blueprintNode.addEventListener('contextmenu', e => e.preventDefault()); + + this.target.addEventListener('mousedown', this.mouseDownHandler); + if (this.clickButton == 2) { + this.target.addEventListener('contextmenu', this.preventDefault); + } + } + + preventDefault(e) { + e.preventDefault(); } unlistenDOMElement() { - this.blueprintNode.removeEventListener('mousedown', this.mouseDownHandler); + this.target.removeEventListener('mousedown', this.mouseDownHandler); + if (this.clickButton == 2) { + this.target.removeEventListener('contextmenu', this.preventDefault); + } + } + + /* Subclasses will override the following methods */ + clicked(e) { + } + + startDrag(e) { + } + + dragTo(e) { + } + + endDrag(e) { + } +} + +class UDrag extends UMouseClickDrag { + constructor(target, blueprint, options) { + super(target, blueprint, options); + this.stepSize = options?.stepSize; + this.mousePosition = [0, 0]; } snapToGrid(posX, posY) { @@ -59,115 +113,136 @@ class UEBlueprintDrag { ] } - clicked(x, y) { + startDrag(e) { if (!this.stepSize) { - this.stepSize = parseInt(getComputedStyle(this.blueprintNode).getPropertyValue('--ueb-grid-snap')); + this.stepSize = parseInt(getComputedStyle(this.target).getPropertyValue('--ueb-grid-snap')); } // Get the current mouse position - this.mousePosition = this.snapToGrid(x, y); - // Attach the listeners to `document` - document.addEventListener('mousemove', this.mouseMoveHandler); - document.addEventListener('mouseup', this.mouseUpHandler); + this.mousePosition = this.snapToGrid(e.clientX, e.clientY); + } + + dragTo(e) { + let mousePosition = this.snapToGrid(e.clientX, e.clientY); + const d = [mousePosition[0] - this.mousePosition[0], mousePosition[1] - this.mousePosition[1]]; + + if (d[0] == 0 && d[1] == 0) { + return + } + + this.target.addLocation(d); + + // Reassign the position of mouse + this.mousePosition = mousePosition; } } -class UEBlueprintDragScroll extends UEBlueprintDrag { - constructor(scrolledEntity, options) { - super(scrolledEntity, options); - this.minZoom = options?.minZoom ?? -12; +class UDragScroll extends UDrag { + + dragTo(e) { + const mousePosition = this.snapToGrid(e.clientX, e.clientY); + + // How far the mouse has been moved + const dx = mousePosition[0] - this.mousePosition[0]; + const dy = mousePosition[1] - this.mousePosition[1]; + + this.blueprint.scrollDelta([-dx, -dy]); + + // Reassign the position of mouse + this.mousePosition = mousePosition; + } + +} + +class USelect extends UMouseClickDrag { + + constructor(target, blueprint, options) { + super(target, blueprint, options); + + this.blueprint = blueprint; // blueprint is needed + this.stepSize = options?.stepSize; + this.mousePosition = [0, 0]; + } + + clicked(e) { + } + + startDrag(e) { + this.blueprint.startSelecting(this.clickedPosition); + } + + dragTo(e) { + let scaleCorrection = 1 / this.blueprint.getScale(); + const targetOffset = e.target.getBoundingClientRect(); + const currentTargetOffset = e.currentTarget.getBoundingClientRect(); + let offset = [ + e.offsetX + targetOffset.x * scaleCorrection - currentTargetOffset.x * scaleCorrection, + e.offsetY + targetOffset.y * scaleCorrection - currentTargetOffset.y * scaleCorrection + ]; + this.blueprint.doSelecting(offset); + } + + endDrag(e) { + if (this.started) { + this.blueprint.finishSelecting(); + } else { + this.blueprint.unselectAll(); + } + } +} + +class UMouseWheel { + + /** + * + * @param {HTMLElement} target + * @param {import("../UEBlueprint").default} blueprint + * @param {Object} options + */ + constructor(target, blueprint, options) { + this.target = target; + this.blueprint = blueprint; + this.looseTarget = options?.looseTarget ?? true; + this.movementSpace = this.blueprint?.getGridDOMElement() ?? document; let self = this; - this.mouseMoveHandler = function (e) { - let mousePosition = self.snapToGrid(e.clientX, e.clientY); - - // How far the mouse has been moved - const dx = mousePosition[0] - self.mousePosition[0]; - const dy = mousePosition[1] - self.mousePosition[1]; - - self.blueprintNode.scrollDelta([-dx, -dy]); - - // Reassign the position of mouse - self.mousePosition = mousePosition; - }; - this.mouseWheelHandler = function (e) { e.preventDefault(); - let zoomLevel = self.blueprintNode.getZoom(); - zoomLevel -= Math.sign(e.deltaY); - let scaleCorrection = 1 / self.blueprintNode.getScale(); - const targetOffset = e.target.getBoundingClientRect(); - const currentTargetOffset = e.currentTarget.getBoundingClientRect(); - let offset = [ - e.offsetX + targetOffset.x * scaleCorrection - currentTargetOffset.x * scaleCorrection, - e.offsetY + targetOffset.y * scaleCorrection - currentTargetOffset.y * scaleCorrection - ]; - self.blueprintNode.setZoom(zoomLevel, offset); + if (!self.looseTarget && e.target != e.currentTarget) { + return + } + let scaleCorrection = 1 / self.blueprint.getScale(); + let offset = [e.offsetX, e.offsetY]; + if (self.looseTarget) { + /* + * Compensating for having used the mouse wheel over a descendant of the target (the element listened for the 'wheel' event). + * We are interested to get the location relative to the listened target, not the exact target that caused the event. + */ + const targetOffset = e.target.getBoundingClientRect(); + const currentTargetOffset = e.currentTarget.getBoundingClientRect(); + offset = [ + offset[0] + targetOffset.x * scaleCorrection - currentTargetOffset.x * scaleCorrection, + offset[1] + targetOffset.y * scaleCorrection - currentTargetOffset.y * scaleCorrection + ]; + } + self.wheel(Math.sign(e.deltaY), offset); }; - this.blueprintNode.getGridDOMElement().addEventListener('wheel', this.mouseWheelHandler, false); - this.blueprintNode.getGridDOMElement().parentElement.addEventListener('wheel', e => e.preventDefault()); + this.movementSpace.addEventListener('wheel', this.mouseWheelHandler, false); + // Prevent movement space from being scrolled + this.movementSpace.parentElement?.addEventListener('wheel', e => e.preventDefault()); } + /* Subclasses will override the following method */ + wheel(location, variation) { + + } } -class UEBlueprintSelect { - constructor(blueprintNode, options) { - /** @type {import("./UEBlueprint.js").default;}" */ - this.blueprintNode = blueprintNode; - this.mousePosition = [0, 0]; - this.clickButton = options?.clickButton ?? 0; - this.exitSelectAnyButton = options?.exitSelectAnyButton ?? true; - let self = this; - - this.mouseDownHandler = function (e) { - switch (e.button) { - case self.clickButton: - self.clicked([e.offsetX, e.offsetY]); - break - default: - if (!self.exitSelectAnyButton) { - self.mouseUpHandler(e); - } - break - } - }; - - this.mouseMoveHandler = function (e) { - e.preventDefault(); - let scaleCorrection = 1 / self.blueprintNode.getScale(); - const targetOffset = e.target.getBoundingClientRect(); - const currentTargetOffset = e.currentTarget.getBoundingClientRect(); - let offset = [ - e.offsetX + targetOffset.x * scaleCorrection - currentTargetOffset.x * scaleCorrection, - e.offsetY + targetOffset.y * scaleCorrection - currentTargetOffset.y * scaleCorrection - ]; - self.blueprintNode.doSelecting(offset); - }; - - this.mouseUpHandler = function (e) { - if (!self.exitSelectAnyButton || e.button == self.clickButton) { - // Remove the handlers of `mousemove` and `mouseup` - self.blueprintNode.getGridDOMElement().removeEventListener('mousemove', self.mouseMoveHandler); - self.blueprintNode.finishSelecting(); - document.removeEventListener('mouseup', self.mouseUpHandler); - } - }; - - let gridElement = this.blueprintNode.getGridDOMElement(); - gridElement.addEventListener('mousedown', this.mouseDownHandler); - gridElement.addEventListener('contextmenu', e => e.preventDefault()); - } - - unlistenDOMElement() { - this.blueprintNode.removeEventListener('mousedown', this.mouseDownHandler); - } - - clicked(position) { - // Attach the listeners to `document` - this.blueprintNode.getGridDOMElement().addEventListener('mousemove', this.mouseMoveHandler); - document.addEventListener('mouseup', this.mouseUpHandler); - // Start selecting - this.blueprintNode.startSelecting(position); +class UZoom extends UMouseWheel { + wheel(variation, location) { + let zoomLevel = this.blueprint.getZoom(); + zoomLevel -= variation; + this.blueprint.setZoom(zoomLevel, location); } } @@ -237,13 +312,6 @@ class OrderedIndexArray { * @returns {number} The position into occupied by value into the array. */ insert(element, comparisonValue = null) { - let i = 0; - for (i = 0; i < this.length; ++i) { - if (element == this.array[i]) { - console.log("error"); - break; - } - } let position = this.getPosition(this.comparisonValueSupplier(element)); if ( position < this.currentPosition @@ -260,9 +328,6 @@ class OrderedIndexArray { this.shiftRight(position); this.array[position] = element; ++this.length; - if (this.length > this.array.length) { - console.log("error2"); - } return position } @@ -355,16 +420,16 @@ class FastSelectionModel { * @param {number[]} initialPosition Coordinates of the starting point of selection [primaryAxisValue, secondaryAxisValue]. * @param {Rectangle[]} rectangles Rectangles that can be selected by this object. * @param {(rect: Rectangle) => BoundariesInfo} boundariesFunc A function that, given a rectangle, it provides the boundaries of such rectangle. - * @param {(rect: Rectangle, selected: bool) => void} selectToggleFunction A function that selects or deselects individual rectangles. + * @param {(rect: Rectangle, selected: bool) => void} selectFunc A function that selects or deselects individual rectangles. */ - constructor(initialPosition, rectangles, boundariesFunc, selectToggleFunction) { + constructor(initialPosition, rectangles, boundariesFunc, selectFunc) { this.initialPosition = initialPosition; this.finalPosition = initialPosition; /** @type Metadata[] */ this.metadata = new Array(rectangles.length); this.primaryOrder = new OrderedIndexArray((element) => this.metadata[element].primaryBoundary); this.secondaryOrder = new OrderedIndexArray((element) => this.metadata[element].secondaryBoundary); - this.selectToggleFunction = selectToggleFunction; + this.selectFunc = selectFunc; this.rectangles = rectangles; this.primaryOrder.reserve(this.rectangles.length); this.secondaryOrder.reserve(this.rectangles.length); @@ -377,7 +442,7 @@ class FastSelectionModel { onSecondaryAxis: false }; this.metadata[index] = rectangleMetadata; - selectToggleFunction(rect, false); // Initially deselected (Eventually) + selectFunc(rect, false); // Initially deselected (Eventually) const rectangleBoundaries = boundariesFunc(rect); // Secondary axis first because it may be inserted in this.secondaryOrder during the primary axis check @@ -400,7 +465,7 @@ class FastSelectionModel { if (rectangleBoundaries.secondarySup < this.initialPosition[1] || this.initialPosition[1] < rectangleBoundaries.secondaryInf) { this.secondaryOrder.insert(index); } else { - selectToggleFunction(rect, true); + selectFunc(rect, true); } } }); @@ -413,22 +478,22 @@ class FastSelectionModel { this.boundaries = { // Primary axis negative expanding primaryN: { - 'value': this.primaryOrder.getPrevValue(), - 'index': this.primaryOrder.getPrev() + v: this.primaryOrder.getPrevValue(), + i: this.primaryOrder.getPrev() }, primaryP: { - 'value': this.primaryOrder.getNextValue(), - 'index': this.primaryOrder.getNext() + v: this.primaryOrder.getNextValue(), + i: this.primaryOrder.getNext() }, // Secondary axis negative expanding secondaryN: { - 'value': this.secondaryOrder.getPrevValue(), - 'index': this.secondaryOrder.getPrev() + v: this.secondaryOrder.getPrevValue(), + i: this.secondaryOrder.getPrev() }, // Secondary axis positive expanding secondaryP: { - 'value': this.secondaryOrder.getNextValue(), - 'index': this.secondaryOrder.getNext() + v: this.secondaryOrder.getNextValue(), + i: this.secondaryOrder.getNext() } }; } @@ -440,7 +505,7 @@ class FastSelectionModel { ]; const primaryBoundaryCrossed = (index, added) => { if (this.metadata[index].onSecondaryAxis) { - this.selectToggleFunction(this.rectangles[index], added); + this.selectFunc(this.rectangles[index], added); } else { if (added) { this.secondaryOrder.insert(index, finalPosition[1]); @@ -452,10 +517,10 @@ class FastSelectionModel { && Math.sign(secondaryBoundary - this.initialPosition[1]) == direction[1] ) { // Secondary axis is already satisfied then - this.selectToggleFunction(this.rectangles[index], true); + this.selectFunc(this.rectangles[index], true); } } else { - this.selectToggleFunction(this.rectangles[index], false); + this.selectFunc(this.rectangles[index], false); this.secondaryOrder.remove(index); } } @@ -463,35 +528,35 @@ class FastSelectionModel { this.selectTo(finalPosition); }; - if (finalPosition[0] < this.boundaries.primaryN.value) { + if (finalPosition[0] < this.boundaries.primaryN.v) { --this.primaryOrder.currentPosition; primaryBoundaryCrossed( - this.boundaries.primaryN.index, - this.initialPosition[0] > this.boundaries.primaryN.value && finalPosition[0] < this.initialPosition[0]); - } else if (finalPosition[0] > this.boundaries.primaryP.value) { + this.boundaries.primaryN.i, + this.initialPosition[0] > this.boundaries.primaryN.v && finalPosition[0] < this.initialPosition[0]); + } else if (finalPosition[0] > this.boundaries.primaryP.v) { ++this.primaryOrder.currentPosition; primaryBoundaryCrossed( - this.boundaries.primaryP.index, - this.initialPosition[0] < this.boundaries.primaryP.value && this.initialPosition[0] < finalPosition[0]); + this.boundaries.primaryP.i, + this.initialPosition[0] < this.boundaries.primaryP.v && this.initialPosition[0] < finalPosition[0]); } const secondaryBoundaryCrossed = (index, added) => { - this.selectToggleFunction(this.rectangles[index], added); + this.selectFunc(this.rectangles[index], added); this.computeBoundaries(finalPosition); this.selectTo(finalPosition); }; - if (finalPosition[1] < this.boundaries.secondaryN.value) { + if (finalPosition[1] < this.boundaries.secondaryN.v) { --this.secondaryOrder.currentPosition; secondaryBoundaryCrossed( - this.boundaries.secondaryN.index, - this.initialPosition[1] > this.boundaries.secondaryN.value && finalPosition[1] < this.initialPosition[1]); - } else if (finalPosition[1] > this.boundaries.secondaryP.value) { + this.boundaries.secondaryN.i, + this.initialPosition[1] > this.boundaries.secondaryN.v && finalPosition[1] < this.initialPosition[1]); + } else if (finalPosition[1] > this.boundaries.secondaryP.v) { ++this.secondaryOrder.currentPosition; secondaryBoundaryCrossed( - this.boundaries.secondaryP.index, - this.initialPosition[1] < this.boundaries.secondaryP.value && this.initialPosition[1] < finalPosition[1]); + this.boundaries.secondaryP.i, + this.initialPosition[1] < this.boundaries.secondaryP.v && this.initialPosition[1] < finalPosition[1]); } this.finalPosition = finalPosition; } @@ -499,7 +564,7 @@ class FastSelectionModel { } /** - * @typedef {import("./UEBlueprintObject.js").default} UEBlueprintObject + * @typedef {import("./UEBlueprintObject").default} UEBlueprintObject */ class UEBlueprint extends HTMLElement { @@ -555,8 +620,6 @@ class UEBlueprint extends HTMLElement { this.selectorElement = null; /** @type {HTMLElement} */ this.nodesContainerElement = null; - /** @type {IntersectionObserver} */ - this.selectorObserver = null; this.dragObject = null; this.selectObject = null; /** @type {Array} */ @@ -601,28 +664,19 @@ class UEBlueprint extends HTMLElement { this.nodesContainerElement = this.querySelector('[data-nodes]'); this.insertChildren(); - this.selectorObserver = new IntersectionObserver( - (entries, observer) => { - entries.map(entry => { - /** @type {import("./UEBlueprintObject.js").default;}" */ - let target = entry.target; - target.setSelected(entry.isIntersecting); - }); - }, { - threshold: [0.01], - root: this.selectorElement - }); - this.nodes.forEach(element => this.selectorObserver.observe(element)); - - this.dragObject = new UEBlueprintDragScroll(this, { + this.dragObject = new UDragScroll(this.getGridDOMElement(), this, { 'clickButton': 2, 'stepSize': 1, 'exitDragAnyButton': false }); - this.selectObject = new UEBlueprintSelect(this, { + this.zoomObject = new UZoom(this.getGridDOMElement(), this, { + looseTarget: true + }); + + this.selectObject = new USelect(this.getGridDOMElement(), this, { 'clickButton': 0, - 'exitSelectAnyButton': true + 'exitAnyButton': true }); } @@ -850,6 +904,13 @@ class UEBlueprint extends HTMLElement { this.selectionModel.selectTo(finalPosition); } + /** + * Unselect all nodes + */ + unselectAll() { + this.nodes.forEach(node => this.nodeSelectToggleFunction(node, false)); + } + /** * * @param {...UEBlueprintObject} blueprintNodes @@ -878,7 +939,9 @@ class UEBlueprintDraggableObject extends HTMLElement { } connectedCallback() { - this.dragObject = new UEBlueprintDrag(this); + this.dragObject = new UDrag(this, null, { + looseTarget: true + }); } disconnectedCallback() {