From 9d8a6415c538a7b76dbca4858166413800b56535 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 7 Jan 2020 16:09:24 +0100 Subject: [PATCH] container.displacement removed, code cleanead --- ChartsSpace/ViewPort.js | 9 ----- Container.js | 6 ---- Displace.js | 64 ----------------------------------- Frame.js | 74 ----------------------------------------- Panels/ProductsPanel.js | 1 - Spaces/PanelsSpace.js | 1 - SplashScreen.js | 1 - Utilities.js | 5 --- 8 files changed, 161 deletions(-) delete mode 100644 Displace.js diff --git a/ChartsSpace/ViewPort.js b/ChartsSpace/ViewPort.js index 129fe0071..1e14c8d18 100644 --- a/ChartsSpace/ViewPort.js +++ b/ChartsSpace/ViewPort.js @@ -31,7 +31,6 @@ function newViewPort () { zoomLevel: undefined, mousePosition: undefined, margins: MARGINS, - getDisplacement: getDisplacement, newZoomLevel: newZoomLevel, applyZoom: applyZoom, isMinZoom: isMinZoom, @@ -105,14 +104,6 @@ function newViewPort () { thisObject.height = thisObject.visibleArea.bottomRight.y - thisObject.visibleArea.topLeft.y } - function getDisplacement () { - let displacement = { - x: offset.x, - y: offset.y - } - return displacement - } - function raiseEvents () { let event = { newOffset: offset diff --git a/Container.js b/Container.js index 2753e96d9..d94375bdd 100644 --- a/Container.js +++ b/Container.js @@ -4,7 +4,6 @@ function newContainer () { id: Math.trunc(Math.random() * 10000000), type: 'Rectangle', frame: undefined, - displacement: undefined, eventHandler: undefined, parentContainer: undefined, isDraggeable: true, @@ -76,10 +75,6 @@ function newContainer () { thisObject.eventHandler = newEventHandler() thisObject.eventHandler.name = pName - - thisObject.displacement = newDisplacement() - thisObject.displacement.container = thisObject - thisObject.displacement.containerName = pName } function connectToParent ( @@ -111,7 +106,6 @@ function newContainer () { isConnectedToParent = true - thisObject.displacement.parentDisplacement = parentContainer.displacement thisObject.frame.parentFrame = parentContainer.frame thisObject.parentContainer = parentContainer diff --git a/Displace.js b/Displace.js deleted file mode 100644 index b5a3bab8f..000000000 --- a/Displace.js +++ /dev/null @@ -1,64 +0,0 @@ -  -/* - -We call displacement to the offset we can produce to the object which the displcement object is is a child from. -The displacement is a vector that displaces everything static drawn on on the context of the parent object. - -*/ - -function newDisplacement () { - let displacement = { - containerName: '', // This is for debugging purposes only. - parentDisplacement: undefined, // Here we store the displacement object of the parent cointainer, if exists. - container: undefined, - x: 0, // This is the actual x displacement. - y: 0, // This is the actual y displacement. - displace: displace, - undisplaceThisPoint: undisplaceThisPoint, - displaceThisPoint: displaceThisPoint - } - - return displacement - - function displace (amountX, amountY) { - /* First we check if by allowing this displacement we would produce the current frame to be beyond its limit. */ - - tempDisplacement = newDisplacement() - tempDisplacement.x = amountX - tempDisplacement.y = amountY - - if (this.container.frame.canYouMoveHere(tempDisplacement)) { - /* Now we displace */ - - displacement.x = displacement.x + amountX - displacement.y = displacement.y + amountY - - return true - } - - return false - } - - function displaceThisPoint (point) { - if (this.parentDisplacement !== undefined) { - point = this.parentDisplacement.displaceThisPoint(point) - } - - point.x = point.x + displacement.x - point.y = point.y + displacement.y - - return point - } - - function undisplaceThisPoint (point) { - if (this.parentDisplacement !== undefined) { - point = this.parentDisplacement.undisplaceThisPoint(point) - } - - point.x = point.x - displacement.x - point.y = point.y - displacement.y - - return point - } -} - diff --git a/Frame.js b/Frame.js index a726eae7d..ac1b216f8 100644 --- a/Frame.js +++ b/Frame.js @@ -20,7 +20,6 @@ function newFrame () { isThisPointHere: isThisPointHere, // This function return true is the point received as parameter lives within this frame. isThisScreenPointHere: isThisScreenPointHere, isInViewPort: isInViewPort, - canYouMoveHere: canYouMoveHere, initialize: initialize } @@ -150,78 +149,6 @@ function newFrame () { return point } - function canYouMoveHere (tempDisplacement) { - /* - - The current frame has a position and a displacement. We need to check that none of the boundaries points of the frame fall outside of its container frame. - First we apply the theoreticall displacement. - - */ - - point1 = { - x: thisObject.position.x, - y: thisObject.position.y - } - - point2 = { - x: thisObject.position.x + thisObject.width, - y: thisObject.position.y - } - - point3 = { - x: thisObject.position.x + thisObject.width, - y: thisObject.position.y + thisObject.height - } - - point4 = { - x: thisObject.position.x, - y: thisObject.position.y + thisObject.height - } - - /* Now the transformations. */ - - if (thisObject.parentFrame !== undefined) { - // If there is not a parent then there is no point to check bounderies. - - point1 = thisObject.parentFrame.frameThisPoint(point1) - point2 = thisObject.parentFrame.frameThisPoint(point2) - point3 = thisObject.parentFrame.frameThisPoint(point3) - point4 = thisObject.parentFrame.frameThisPoint(point4) - - /* We apply the temporary displacement. */ - - point1 = tempDisplacement.displaceThisPoint(point1) - point2 = tempDisplacement.displaceThisPoint(point2) - point3 = tempDisplacement.displaceThisPoint(point3) - point4 = tempDisplacement.displaceThisPoint(point4) - - /* We add the actual displacement. */ - - point1 = thisObject.container.displacement.displaceThisPoint(point1) - point2 = thisObject.container.displacement.displaceThisPoint(point2) - point3 = thisObject.container.displacement.displaceThisPoint(point3) - point4 = thisObject.container.displacement.displaceThisPoint(point4) - - if (thisObject.parentFrame.isThisPointHere(point1) === false) { - return false - } - - if (thisObject.parentFrame.isThisPointHere(point2) === false) { - return false - } - - if (thisObject.parentFrame.isThisPointHere(point3) === false) { - return false - } - - if (thisObject.parentFrame.isThisPointHere(point4) === false) { - return false - } - } - - return true - } - function isThisPointHere (point, outsideViewPort, dontTransform) { // The second parameter is usefull when you want to check a point that you already know is outside the viewport. @@ -236,7 +163,6 @@ function newFrame () { in order to have the point on the containers coordinate system and be able to compare it with its dimmensions. */ if (dontTransform === false || dontTransform === undefined) { if (outsideViewPort === true) { - checkPoint = thisObject.container.displacement.undisplaceThisPoint(checkPoint) checkPoint = thisObject.container.frame.unframeThisPoint(checkPoint) } else { checkPoint = unTransformThisPoint(checkPoint, thisObject.container) diff --git a/Panels/ProductsPanel.js b/Panels/ProductsPanel.js index a46ddf5b5..d106d7327 100644 --- a/Panels/ProductsPanel.js +++ b/Panels/ProductsPanel.js @@ -224,7 +224,6 @@ function newProductsPanel () { cardsMap.set(productCard.code, productCard) /* Container Stuff */ - productCard.container.displacement.parentDisplacement = thisObject.container.displacement productCard.container.frame.parentFrame = thisObject.container.frame productCard.container.parentContainer = thisObject.container productCard.container.isWheelable = true diff --git a/Spaces/PanelsSpace.js b/Spaces/PanelsSpace.js index a984bd306..f312770ee 100644 --- a/Spaces/PanelsSpace.js +++ b/Spaces/PanelsSpace.js @@ -23,7 +23,6 @@ function newPanelsSpace () { thisObject.container = container thisObject.container.isDraggeable = false - container.displacement.containerName = 'Panels Space' container.frame.containerName = 'Panels Space' panelsMap = new Map() diff --git a/SplashScreen.js b/SplashScreen.js index 86e429b7d..38f75d5ef 100644 --- a/SplashScreen.js +++ b/SplashScreen.js @@ -19,7 +19,6 @@ function newSplashScreen () { resize() - container.displacement.containerName = 'Splash Screen' container.frame.containerName = 'Splash Screen' container.frame.position.x = 0 diff --git a/Utilities.js b/Utilities.js index 4ab4c825a..c4991c43d 100644 --- a/Utilities.js +++ b/Utilities.js @@ -14,10 +14,6 @@ function transformThisPoint (point, container) { point = container.frame.frameThisPoint(point) - /* We add the possible displacement */ - - point = container.displacement.displaceThisPoint(point) - /* We viewport Transformation. */ point = viewPort.zoomThisPoint(point) @@ -27,7 +23,6 @@ function transformThisPoint (point, container) { function unTransformThisPoint (point, container) { point = viewPort.unzoomThisPoint(point) - point = container.displacement.undisplaceThisPoint(point) point = container.frame.unframeThisPoint(point) return point