From 8a06a8b0804a8d33754d840124d934027726cc30 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 21 Dec 2019 20:04:12 +0100 Subject: [PATCH 001/264] Lighting path implemented with plotter manager --- ChartsSpace/PlottersManager.js | 12 +- .../FunctionLibraries/ProtocolNode.js | 1818 +---------------- DesignerSpace/Workspace/Workspace.js | 4 +- Plotter.js | 2 +- 4 files changed, 100 insertions(+), 1736 deletions(-) diff --git a/ChartsSpace/PlottersManager.js b/ChartsSpace/PlottersManager.js index 127d0ce6b..2fc2cb453 100644 --- a/ChartsSpace/PlottersManager.js +++ b/ChartsSpace/PlottersManager.js @@ -184,7 +184,17 @@ function newPlottersManager () { /* We take a snapwhot of the current product definition to be used by the plotter. */ let functionLibraryProtocolNode = newProtocolNode() - productDefinition = functionLibraryProtocolNode.getProtocolNode(pProductCard.product.node, false, true, true, false, false, true) + let lightingPath = 'Product Definition->' + + 'Record Definition->Record Property->' + + 'Data Building Procedure->Procedure Loop->Javascript Code->' + + 'Calculations Procedure->Procedure Initialization->Javascript Code->' + + 'Plotter Module->Shapes->' + + 'Chart Points->Point->Point Formula->' + + 'Polygon->Polygon Body->Style->Style Condition->Style->' + + 'Polygon Border->Style->Style Condition->Style->' + + 'Polygon Vertex->Point->' + + 'Plotter Panel->Javascript Code->Panel Data->Data Formula->' + productDefinition = functionLibraryProtocolNode.getProtocolNode(pProductCard.product.node, false, true, true, false, lightingPath) } else { plotter = getNewPlotter(pProductCard.product.plotter.devTeam, pProductCard.product.plotter.codeName, pProductCard.product.plotter.moduleName) } diff --git a/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js b/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js index 10038442a..b1219aa89 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js +++ b/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js @@ -9,1754 +9,108 @@ function newProtocolNode () { } return thisObject - function getProtocolNode (node, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) { + function getProtocolNode (node, removePersonalData, parseCode, includeIds, includePayload, lightingPath) { if (node === undefined) { return } - switch (node.type) { - case 'Javascript Code': - { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Condition': - { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - javascriptCode: getProtocolNode(node.javascriptCode, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Situation': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - conditions: [] - } - for (let m = 0; m < node.conditions.length; m++) { - let condition = getProtocolNode(node.conditions[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (condition !== undefined) { - object.conditions.push(condition) - } - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object + let nodeDefinition = APP_SCHEMA_MAP.get(node.type) + if (nodeDefinition !== undefined) { + if (removePersonalData === true && nodeDefinition.isPersonalData === true) { return } + let object = { + type: node.type, + subType: node.subType, + name: node.name, + code: node.code } - case 'Formula': - { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Next Phase Event': - { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - situations: [], - announcements: [] - } - for (let m = 0; m < node.situations.length; m++) { - let situation = getProtocolNode(node.situations[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (situation !== undefined) { - object.situations.push(situation) - } - } - for (let m = 0; m < node.announcements.length; m++) { - let announcement = getProtocolNode(node.announcements[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (announcement !== undefined) { - object.announcements.push(announcement) - } - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Phase': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - announcements: [], - formula: getProtocolNode(node.formula, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), - nextPhaseEvent: getProtocolNode(node.nextPhaseEvent, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - for (let m = 0; m < node.announcements.length; m++) { - let announcement = getProtocolNode(node.announcements[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (announcement !== undefined) { - object.announcements.push(announcement) - } - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Stop': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - phases: [] - } - for (let m = 0; m < node.phases.length; m++) { - let phase = getProtocolNode(node.phases[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (phase !== undefined) { - object.phases.push(phase) - } - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Take Profit': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - phases: [] - } + /* Children Nodes */ + if (nodeDefinition.properties !== undefined) { + for (let i = 0; i < nodeDefinition.properties.length; i++) { + let property = nodeDefinition.properties[i] - for (let m = 0; m < node.phases.length; m++) { - let phase = getProtocolNode(node.phases[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (phase !== undefined) { - object.phases.push(phase) - } - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Take Position Event': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - situations: [], - announcements: [] - } - - for (let m = 0; m < node.situations.length; m++) { - let situation = getProtocolNode(node.situations[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (situation !== undefined) { - object.situations.push(situation) - } - } - for (let m = 0; m < node.announcements.length; m++) { - let announcement = getProtocolNode(node.announcements[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (announcement !== undefined) { - object.announcements.push(announcement) - } - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Trigger On Event': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - situations: [], - announcements: [] - } - - for (let m = 0; m < node.situations.length; m++) { - let situation = getProtocolNode(node.situations[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - object.situations.push(situation) - } - for (let m = 0; m < node.announcements.length; m++) { - let announcement = getProtocolNode(node.announcements[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (announcement !== undefined) { - object.announcements.push(announcement) - } - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Trigger Off Event': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - situations: [], - announcements: [] - } - - for (let m = 0; m < node.situations.length; m++) { - let situation = getProtocolNode(node.situations[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (situation !== undefined) { - object.situations.push(situation) - } - } - for (let m = 0; m < node.announcements.length; m++) { - let announcement = getProtocolNode(node.announcements[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (announcement !== undefined) { - object.announcements.push(announcement) - } - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Initial Definition': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - stopLoss: getProtocolNode(node.stopLoss, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), - takeProfit: getProtocolNode(node.takeProfit, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), - positionSize: getProtocolNode(node.positionSize, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), - positionRate: getProtocolNode(node.positionRate, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Open Execution': { - let object = { - type: node.type, - subType: node.subType, - name: node.name - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Close Execution': { - let object = { - type: node.type, - subType: node.subType, - name: node.name - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Position Size': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - formula: getProtocolNode(node.formula, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Position Rate': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - formula: getProtocolNode(node.formula, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Trigger Stage': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - triggerOn: getProtocolNode(node.triggerOn, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), - triggerOff: getProtocolNode(node.triggerOff, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), - takePosition: getProtocolNode(node.takePosition, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Open Stage': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - initialDefinition: getProtocolNode(node.initialDefinition, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), - openExecution: getProtocolNode(node.openExecution, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Manage Stage': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - stopLoss: getProtocolNode(node.stopLoss, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), - takeProfit: getProtocolNode(node.takeProfit, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Close Stage': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - closeExecution: getProtocolNode(node.closeExecution, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Strategy': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - triggerStage: getProtocolNode(node.triggerStage, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), - openStage: getProtocolNode(node.openStage, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), - manageStage: getProtocolNode(node.manageStage, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), - closeStage: getProtocolNode(node.closeStage, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Base Asset': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code - } - if (parseCode) { - object.code = JSON.parse(node.code) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Time Range': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code - } - if (parseCode) { - object.code = JSON.parse(node.code) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Time Period': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code - } - if (parseCode) { - object.code = JSON.parse(node.code) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Slippage': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code - } - if (parseCode) { - object.code = JSON.parse(node.code) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Fee Structure': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code - } - if (parseCode) { - object.code = JSON.parse(node.code) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Parameters': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - baseAsset: getProtocolNode(node.baseAsset, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), - timeRange: getProtocolNode(node.timeRange, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), - timePeriod: getProtocolNode(node.timePeriod, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), - slippage: getProtocolNode(node.slippage, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), - feeStructure: getProtocolNode(node.feeStructure, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), - key: getProtocolNode(node.key, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Trading System': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - strategies: [], - parameters: getProtocolNode(node.parameters, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - - for (let m = 0; m < node.strategies.length; m++) { - let strategy = getProtocolNode(node.strategies[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (strategy !== undefined) { - object.strategies.push(strategy) - } - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Personal Data': { - if (removePersonalData === true) { return } - let object = { - type: node.type, - subType: node.subType, - name: node.name, - exchangeAccounts: [] - } - - for (let m = 0; m < node.exchangeAccounts.length; m++) { - let exchangeAccount = getProtocolNode(node.exchangeAccounts[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (exchangeAccount !== undefined) { - object.exchangeAccounts.push(exchangeAccount) - } - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Exchange Account': { - if (removePersonalData === true) { return } - let object = { - type: node.type, - subType: node.subType, - name: node.name, - assets: [], - keys: [] - } - - for (let m = 0; m < node.assets.length; m++) { - let asset = getProtocolNode(node.assets[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (asset !== undefined) { - object.assets.push(asset) - } - } - for (let m = 0; m < node.keys.length; m++) { - let key = getProtocolNode(node.keys[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (key !== undefined) { - object.keys.push(key) - } - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Exchange Account Asset': { - if (removePersonalData === true) { return } - let object = { - type: node.type, - subType: node.subType, - name: node.name - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Exchange Account Key': { - if (removePersonalData === true) { return } - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code - } - if (parseCode) { - object.code = JSON.parse(node.code) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Social Bots': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - bots: [] - } - - for (let m = 0; m < node.bots.length; m++) { - let bot = getProtocolNode(node.bots[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (bot !== undefined) { - object.bots.push(bot) - } - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Telegram Bot': { - if (removePersonalData === true) { return } - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code, - announcements: [] - } - - for (let m = 0; m < node.announcements.length; m++) { - let announcement = getProtocolNode(node.announcements[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (announcement !== undefined) { - object.announcements.push(announcement) - } - } - if (parseCode) { - object.code = JSON.parse(node.code) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Announcement': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code, - formula: getProtocolNode(node.formula, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Layer Manager': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - layers: [] - } - - for (let m = 0; m < node.layers.length; m++) { - let layer = getProtocolNode(node.layers[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (layer !== undefined) { - object.layers.push(layer) - } - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Layer': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code - } - if (parseCode) { - object.code = JSON.parse(node.code) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Task Manager': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - tasks: [] - } - - for (let m = 0; m < node.tasks.length; m++) { - let task = getProtocolNode(node.tasks[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (task !== undefined) { - object.tasks.push(task) - } - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Task': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - bot: getProtocolNode(node.bot, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Sensor Bot Instance': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code, - processes: [] - } - - for (let m = 0; m < node.processes.length; m++) { - let process = getProtocolNode(node.processes[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (process !== undefined) { - object.processes.push(process) - } - } - if (parseCode) { - object.code = JSON.parse(node.code) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Indicator Bot Instance': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code, - processes: [] - } - - for (let m = 0; m < node.processes.length; m++) { - let process = getProtocolNode(node.processes[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (process !== undefined) { - object.processes.push(process) - } - } - if (parseCode) { - object.code = JSON.parse(node.code) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Trading Bot Instance': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code, - processes: [] - } - - for (let m = 0; m < node.processes.length; m++) { - let process = getProtocolNode(node.processes[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (process !== undefined) { - object.processes.push(process) - } - } - if (parseCode) { - object.code = JSON.parse(node.code) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Process Instance': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code, - session: getProtocolNode(node.session, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - if (parseCode) { - object.code = JSON.parse(node.code) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - if (followReferenceParent) { - object.referenceParent = getProtocolNode(node.payload.referenceParent, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - return object - } - case 'Backtesting Session': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code, - parameters: getProtocolNode(node.parameters, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), - layerManager: getProtocolNode(node.layerManager, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), - socialBots: getProtocolNode(node.socialBots, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - if (parseCode) { - object.code = JSON.parse(object.code) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - if (followReferenceParent) { - object.referenceParent = getProtocolNode(node.payload.referenceParent, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - return object - } - case 'Live Trading Session': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code, - parameters: getProtocolNode(node.parameters, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), - layerManager: getProtocolNode(node.layerManager, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), - socialBots: getProtocolNode(node.socialBots, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - if (parseCode) { - object.code = JSON.parse(node.code) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - if (followReferenceParent) { - object.referenceParent = getProtocolNode(node.payload.referenceParent, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - return object - } - case 'Fordward Testing Session': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code, - parameters: getProtocolNode(node.parameters, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), - layerManager: getProtocolNode(node.layerManager, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), - socialBots: getProtocolNode(node.socialBots, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - if (parseCode) { - object.code = JSON.parse(object.code) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - if (followReferenceParent) { - object.referenceParent = getProtocolNode(node.payload.referenceParent, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - return object - } - case 'Paper Trading Session': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code, - parameters: getProtocolNode(node.parameters, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), - layerManager: getProtocolNode(node.layerManager, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), - socialBots: getProtocolNode(node.socialBots, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - if (parseCode) { - object.code = JSON.parse(node.code) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - if (followReferenceParent) { - object.referenceParent = getProtocolNode(node.payload.referenceParent, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - return object - } - case 'Network Node': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - taskManagers: [] - } - if (node.taskManagers !== undefined) { - for (let m = 0; m < node.taskManagers.length; m++) { - let taskManager = getProtocolNode(node.taskManagers[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (taskManager !== undefined) { - object.taskManagers.push(taskManager) - } - } - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Network': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - networkNodes: [] - } - if (node.networkNodes !== undefined) { - for (let m = 0; m < node.networkNodes.length; m++) { - let networkNode = getProtocolNode(node.networkNodes[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (networkNode !== undefined) { - object.networkNodes.push(networkNode) - } - } - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Definition': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - tradingSystem: getProtocolNode(node.tradingSystem, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), - personalData: getProtocolNode(node.personalData, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Team': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code, - sensorBots: [], - indicatorBots: [], - tradingBots: [], - plotters: [] - } - if (followAncestors) { - object.parentNode = getProtocolNode(node.payload.parentNode, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - - if (excludeChildren !== true) { - if (node.sensorBots !== undefined) { - for (let m = 0; m < node.sensorBots.length; m++) { - let sensorBot = getProtocolNode(node.sensorBots[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (sensorBot !== undefined) { - object.sensorBots.push(sensorBot) - } - } - } - if (node.indicatorBots !== undefined) { - for (let m = 0; m < node.indicatorBots.length; m++) { - let indicatorBot = getProtocolNode(node.indicatorBots[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (indicatorBot !== undefined) { - object.indicatorBots.push(indicatorBot) - } - } - } - if (node.tradingBots !== undefined) { - for (let m = 0; m < node.tradingBots.length; m++) { - let tradingBot = getProtocolNode(node.tradingBots[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (tradingBot !== undefined) { - object.tradingBots.push(tradingBot) - } - } - } - if (node.plotters !== undefined) { - for (let m = 0; m < node.plotters.length; m++) { - let plotter = getProtocolNode(node.plotters[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (plotter !== undefined) { - object.plotters.push(plotter) - } - } - } - } - - if (parseCode) { - object.code = JSON.parse(node.code) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Sensor Bot': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code, - processes: [], - products: [] - } - if (followAncestors) { - object.parentNode = getProtocolNode(node.payload.parentNode, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - if (excludeChildren !== true) { - if (node.processes !== undefined) { - for (let m = 0; m < node.processes.length; m++) { - let process = getProtocolNode(node.processes[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (process !== undefined) { - object.processes.push(process) - } - } - } - if (node.products !== undefined) { - for (let m = 0; m < node.products.length; m++) { - let product = getProtocolNode(node.products[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (product !== undefined) { - object.products.push(product) - } - } - } - } - if (parseCode) { - object.code = JSON.parse(node.code) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Indicator Bot': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code, - processes: [], - products: [] - } - if (followAncestors) { - object.parentNode = getProtocolNode(node.payload.parentNode, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - if (excludeChildren !== true) { - /* Children are added only when not following ancestors */ - if (node.processes !== undefined) { - for (let m = 0; m < node.processes.length; m++) { - let process = getProtocolNode(node.processes[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (process !== undefined) { - object.processes.push(process) - } - } - } - if (node.products !== undefined) { - for (let m = 0; m < node.products.length; m++) { - let product = getProtocolNode(node.products[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (product !== undefined) { - object.products.push(product) - } - } - } - } - if (parseCode) { - object.code = JSON.parse(node.code) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Trading Bot': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code, - processes: [], - products: [] - } - if (followAncestors) { - object.parentNode = getProtocolNode(node.payload.parentNode, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - if (excludeChildren !== true) { - /* Children are added only when not following ancestors */ - if (node.processes !== undefined) { - for (let m = 0; m < node.processes.length; m++) { - let process = getProtocolNode(node.processes[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (process !== undefined) { - object.processes.push(process) - } - } - } - if (node.products !== undefined) { - for (let m = 0; m < node.products.length; m++) { - let product = getProtocolNode(node.products[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (product !== undefined) { - object.products.push(product) - } - } - } - } - if (parseCode) { - object.code = JSON.parse(node.code) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Process Definition': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code - } - if (parseCode) { - object.code = JSON.parse(node.code) - } - - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - if (followAncestors) { - object.parentNode = getProtocolNode(node.payload.parentNode, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - if (excludeChildren !== true) { - object.processOutput = getProtocolNode(node.processOutput, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - object.processDependencies = getProtocolNode(node.processDependencies, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - object.statusReport = getProtocolNode(node.statusReport, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - object.executionStartedEvent = getProtocolNode(node.executionStartedEvent, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - object.executionFinishedEvent = getProtocolNode(node.executionFinishedEvent, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - - if (includeParent) { - followAncestors = true - excludeChildren = true - object.parentNode = getProtocolNode(node.payload.parentNode, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - return object - } - case 'Process Output': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - outputDatasets: [] - } - if (node.outputDatasets !== undefined) { - for (let m = 0; m < node.outputDatasets.length; m++) { - let outputDataset = getProtocolNode(node.outputDatasets[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (outputDataset !== undefined) { - object.outputDatasets.push(outputDataset) - } - } - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Process Dependencies': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - statusDependencies: [], - dataDependencies: [] - } - if (node.statusDependencies !== undefined) { - for (let m = 0; m < node.statusDependencies.length; m++) { - let statusDependency = getProtocolNode(node.statusDependencies[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (statusDependency !== undefined) { - object.statusDependencies.push(statusDependency) - } - } - } - if (node.dataDependencies !== undefined) { - for (let m = 0; m < node.dataDependencies.length; m++) { - let dataDependency = getProtocolNode(node.dataDependencies[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (dataDependency !== undefined) { - object.dataDependencies.push(dataDependency) - } - } - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Status Report': { - let object = { - type: node.type, - subType: node.subType, - name: node.name - } - if (includeParent) { - followAncestors = true - excludeChildren = true - object.parentNode = getProtocolNode(node.payload.parentNode, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Execution Started Event': { - let object = { - type: node.type, - subType: node.subType, - name: node.name - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - if (followReferenceParent) { - object.referenceParent = getProtocolNode(node.payload.referenceParent, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - return object - } - case 'Execution Finished Event': { - let object = { - type: node.type, - subType: node.subType, - name: node.name - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - if (includeParent) { - object.parentNode = { - type: node.payload.parentNode.type, - subType: node.payload.parentNode.subType, - name: node.payload.parentNode.name, - id: node.payload.parentNode.id, - code: JSON.parse(node.payload.parentNode.code) - } - } - return object - } - case 'Calculations Procedure': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - initialization: getProtocolNode(node.initialization, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), - loop: getProtocolNode(node.loop, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Data Building Procedure': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - initialization: getProtocolNode(node.initialization, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), - loop: getProtocolNode(node.loop, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Procedure Initialization': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - javascriptCode: getProtocolNode(node.javascriptCode, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Procedure Loop': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - javascriptCode: getProtocolNode(node.javascriptCode, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Output Dataset': { - let object = { - type: node.type, - subType: node.subType, - name: node.name - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - if (followReferenceParent) { - object.referenceParent = getProtocolNode(node.payload.referenceParent, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - return object - } - case 'Status Dependency': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code - } - if (includeIds) { - object.id = node.id - } - if (parseCode) { - object.code = JSON.parse(node.code) - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - if (followReferenceParent) { - object.referenceParent = getProtocolNode(node.payload.referenceParent, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - return object - } - case 'Data Dependency': { - let object = { - type: node.type, - subType: node.subType, - name: node.name - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - if (followReferenceParent) { - object.referenceParent = getProtocolNode(node.payload.referenceParent, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - return object - } - case 'Product Definition': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code, - datasets: [] - } - if (excludeChildren !== true) { - if (excludeType !== 'Dataset Definition') { - if (node.datasets !== undefined) { - for (let m = 0; m < node.datasets.length; m++) { - let dataset = getProtocolNode(node.datasets[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (dataset !== undefined) { - object.datasets.push(dataset) + switch (property.type) { + case 'node': { + if (node[property.name] !== undefined) { + let newLightingPath = getNreLightingPath(lightingPath, node.type, property.childType) + if (newLightingPath !== undefined) { + object[property.name] = getProtocolNode(node[property.name], removePersonalData, parseCode, includeIds, includePayload, newLightingPath) } } + break } - } - object.record = getProtocolNode(node.record, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - object.calculations = getProtocolNode(node.calculations, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - object.dataBuilding = getProtocolNode(node.dataBuilding, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - if (followAncestors) { - excludeChildren = true - object.parentNode = getProtocolNode(node.payload.parentNode, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - if (parseCode) { - object.code = JSON.parse(node.code) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - if (followReferenceParent) { - object.referenceParent = getProtocolNode(node.payload.referenceParent, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - return object - } - case 'Record Definition': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - properties: [] - } - if (node.properties !== undefined) { - for (let m = 0; m < node.properties.length; m++) { - let property = getProtocolNode(node.properties[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (property !== undefined) { - object.properties.push(property) - } - } - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Record Property': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code, - formula: getProtocolNode(node.formula, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - if (parseCode) { - object.code = JSON.parse(node.code) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Dataset Definition': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code - } - if (parseCode) { - object.code = JSON.parse(node.code) - } - if (includeParent) { - followAncestors = true - excludeType = 'Dataset Definition' - object.parentNode = getProtocolNode(node.payload.parentNode, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Plotter': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code, - modules: [] - } - if (excludeChildren !== true) { - if (node.modules !== undefined) { - for (let m = 0; m < node.modules.length; m++) { - let module = getProtocolNode(node.modules[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (module !== undefined) { - object.modules.push(module) - } - } - } - } - - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - case 'Plotter Module': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code, - panels: [] - } - if (excludeChildren !== true) { - object.javascriptCode = getProtocolNode(node.javascriptCode, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - object.shapes = getProtocolNode(node.shapes, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - - if (includeParent) { - followAncestors = true - excludeChildren = true - object.parentNode = getProtocolNode(node.payload.parentNode, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - followAncestors = false - includeParent = false - } - if (node.panels !== undefined) { - for (let m = 0; m < node.panels.length; m++) { - let panel = getProtocolNode(node.panels[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (panel !== undefined) { - object.panels.push(panel) - } - } - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } - - default: { - let nodeDefinition = APP_SCHEMA_MAP.get(node.type) - if (nodeDefinition !== undefined) { - if (removePersonalData === true && nodeDefinition.isPersonalData === true) { return } - let object = { - type: node.type, - subType: node.subType, - name: node.name, - code: node.code - } - - if (excludeChildren !== true) { - /* Children Nodes */ - if (nodeDefinition.properties !== undefined) { - for (let i = 0; i < nodeDefinition.properties.length; i++) { - let property = nodeDefinition.properties[i] - - switch (property.type) { - case 'node': { - if (node[property.name] !== undefined) { - if (excludeType !== property.childType) { - object[property.name] = getProtocolNode(node[property.name], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } + case 'array': { + if (node[property.name] !== undefined) { + let newLightingPath = getNreLightingPath(lightingPath, node.type, property.childType) + if (newLightingPath !== undefined) { + let nodePropertyArray = node[property.name] + object[property.name] = [] + for (let m = 0; m < nodePropertyArray.length; m++) { + let protocolNode = getProtocolNode(nodePropertyArray[m], removePersonalData, parseCode, includeIds, includePayload, newLightingPath) + if (protocolNode !== undefined) { + object[property.name].push(protocolNode) } - break - } - case 'array': { - if (node[property.name] !== undefined) { - if (excludeType !== property.childType) { - let nodePropertyArray = node[property.name] - object[property.name] = [] - for (let m = 0; m < nodePropertyArray.length; m++) { - let protocolNode = getProtocolNode(nodePropertyArray[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - if (protocolNode !== undefined) { - object[property.name].push(protocolNode) - } - } - } - } - break } } } + break } } - - /* Ancestors Nodes */ - if (includeParent) { - if (nodeDefinition.followAncestors !== undefined) { - followAncestors = nodeDefinition.followAncestors - } - if (nodeDefinition.excludeChildren !== undefined) { - excludeChildren = nodeDefinition.excludeChildren - } - if (nodeDefinition.excludeType !== undefined) { - excludeType = nodeDefinition.excludeType - } - object.parentNode = getProtocolNode(node.payload.parentNode, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - - /* Ancestors Nodes */ - if (followAncestors) { - if (nodeDefinition.excludeChildren !== undefined) { - excludeChildren = nodeDefinition.excludeChildren - } - object.parentNode = getProtocolNode(node.payload.parentNode, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - - if (parseCode && object.code !== undefined && nodeDefinition.editors !== undefined) { - if (nodeDefinition.editors.config === true) { - try { - object.code = JSON.parse(node.code) - } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] getProtocolNode -> default -> err = ' + err.stack) } - if (ERROR_LOG === true) { logger.write('[ERROR] getProtocolNode -> default -> node.type = ' + node.type) } - if (ERROR_LOG === true) { logger.write('[ERROR] getProtocolNode -> default -> node.name = ' + node.name) } - if (ERROR_LOG === true) { logger.write('[ERROR] getProtocolNode -> default -> node.code = ' + node.code) } - if (ERROR_LOG === true) { logger.write('[ERROR] getProtocolNode -> default -> node.id = ' + node.id) } - } - } - } - - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - if (followReferenceParent) { - object.referenceParent = getProtocolNode(node.payload.referenceParent, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - return object } } + + /* Parent Nodes */ + if (node.payload.parentNode !== undefined) { + let newLightingPath = getNreLightingPath(lightingPath, node.type, node.payload.parentNode.type) + if (newLightingPath !== undefined) { + object.parentNode = getProtocolNode(node.payload.parentNode, removePersonalData, parseCode, includeIds, includePayload, newLightingPath) + } + } + if (node.payload.referenceParent !== undefined) { + let newLightingPath = getNreLightingPath(lightingPath, node.type, node.payload.referenceParent.type) + if (newLightingPath !== undefined) { + object.referenceParent = getProtocolNode(node.payload.referenceParent, removePersonalData, parseCode, includeIds, includePayload, newLightingPath) + } + } + + if (parseCode && object.code !== undefined && nodeDefinition.editors !== undefined) { + if (nodeDefinition.editors.config === true) { + try { + object.code = JSON.parse(node.code) + } catch (err) { + if (ERROR_LOG === true) { logger.write('[ERROR] getProtocolNode -> default -> err = ' + err.stack) } + if (ERROR_LOG === true) { logger.write('[ERROR] getProtocolNode -> default -> node.type = ' + node.type) } + if (ERROR_LOG === true) { logger.write('[ERROR] getProtocolNode -> default -> node.name = ' + node.name) } + if (ERROR_LOG === true) { logger.write('[ERROR] getProtocolNode -> default -> node.code = ' + node.code) } + if (ERROR_LOG === true) { logger.write('[ERROR] getProtocolNode -> default -> node.id = ' + node.id) } + } + } + } + + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + + return object + } + } + + function getNreLightingPath (lightingPath, currentNodeType, nextNodeType) { + if (lightingPath === undefined) { return } + + if (currentNodeType === undefined) { return } + if (nextNodeType === undefined) { return } + + let currentNodePosition = lightingPath.indexOf(currentNodeType) + let nextNodePosition = lightingPath.indexOf(nextNodeType) + + let newLightingPath = lightingPath.substring(nextNodePosition, lightingPath.length + 1) + + if (nextNodePosition > currentNodePosition) { + return newLightingPath + } else { + return } } diff --git a/DesignerSpace/Workspace/Workspace.js b/DesignerSpace/Workspace/Workspace.js index 21b84ffd5..8ef065d6f 100644 --- a/DesignerSpace/Workspace/Workspace.js +++ b/DesignerSpace/Workspace/Workspace.js @@ -112,8 +112,8 @@ function newWorkspace () { function physics () { if (thisObject.enabled !== true) { return } - let textToSave = stringifyWorkspace() - window.localStorage.setItem(CANVAS_APP_NAME + '.' + 'Workspace', textToSave) + let textToSave// = stringifyWorkspace() + // window.localStorage.setItem(CANVAS_APP_NAME + '.' + 'Workspace', textToSave) if (workingAtTask > 0) { circularProgressBar.physics() diff --git a/Plotter.js b/Plotter.js index bf5265a6c..d0f3df203 100644 --- a/Plotter.js +++ b/Plotter.js @@ -459,7 +459,7 @@ function newPlotter () { /* In case the plotter is configured to a certain slot, we calculate the slot coordinate system too. */ if (productDefinition.referenceParent.code === undefined) { return } - plotterModuleConfig = JSON.parse(productDefinition.referenceParent.code) + plotterModuleConfig = productDefinition.referenceParent.code if (plotterModuleConfig.slot === undefined) { return } slotCoordinateSystem = newTimeLineCoordinateSystem() From c2f94e84ac1ff463e3dfc76b255117b92823ab21 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 22 Dec 2019 14:25:27 +0100 Subject: [PATCH 002/264] Lighting Paths Implemented with Tasks --- ChartsSpace/PlottersManager.js | 10 ++-- .../FunctionLibraries/ProtocolNode.js | 49 ++++++++++++------- .../FunctionLibraries/TaskFunctions.js | 28 ++++++++++- 3 files changed, 64 insertions(+), 23 deletions(-) diff --git a/ChartsSpace/PlottersManager.js b/ChartsSpace/PlottersManager.js index 2fc2cb453..8196289a4 100644 --- a/ChartsSpace/PlottersManager.js +++ b/ChartsSpace/PlottersManager.js @@ -184,17 +184,17 @@ function newPlottersManager () { /* We take a snapwhot of the current product definition to be used by the plotter. */ let functionLibraryProtocolNode = newProtocolNode() - let lightingPath = 'Product Definition->' + - 'Record Definition->Record Property->' + - 'Data Building Procedure->Procedure Loop->Javascript Code->' + - 'Calculations Procedure->Procedure Initialization->Javascript Code->' + + let lightingPath = '->Product Definition->' + + 'Record Definition->Record Property->Formula->' + + 'Data Building Procedure->Procedure Loop->Javascript Code->Procedure Initialization->Javascript Code->' + + 'Calculations Procedure->Procedure Loop->Javascript Code->Procedure Initialization->Javascript Code->' + 'Plotter Module->Shapes->' + 'Chart Points->Point->Point Formula->' + 'Polygon->Polygon Body->Style->Style Condition->Style->' + 'Polygon Border->Style->Style Condition->Style->' + 'Polygon Vertex->Point->' + 'Plotter Panel->Javascript Code->Panel Data->Data Formula->' - productDefinition = functionLibraryProtocolNode.getProtocolNode(pProductCard.product.node, false, true, true, false, lightingPath) + productDefinition = functionLibraryProtocolNode.getProtocolNode(pProductCard.product.node, false, true, true, false, false, lightingPath) } else { plotter = getNewPlotter(pProductCard.product.plotter.devTeam, pProductCard.product.plotter.codeName, pProductCard.product.plotter.moduleName) } diff --git a/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js b/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js index b1219aa89..83d2a79dd 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js +++ b/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js @@ -9,7 +9,7 @@ function newProtocolNode () { } return thisObject - function getProtocolNode (node, removePersonalData, parseCode, includeIds, includePayload, lightingPath) { + function getProtocolNode (node, removePersonalData, parseCode, includeIds, includePayload, includeReferencesInSavedPayload, lightingPath) { if (node === undefined) { return } let nodeDefinition = APP_SCHEMA_MAP.get(node.type) @@ -30,25 +30,40 @@ function newProtocolNode () { switch (property.type) { case 'node': { if (node[property.name] !== undefined) { - let newLightingPath = getNreLightingPath(lightingPath, node.type, property.childType) - if (newLightingPath !== undefined) { - object[property.name] = getProtocolNode(node[property.name], removePersonalData, parseCode, includeIds, includePayload, newLightingPath) + if (lightingPath === undefined) { + object[property.name] = getProtocolNode(node[property.name], removePersonalData, parseCode, includeIds, includeReferencesInSavedPayload, includePayload) + } else { + let newLightingPath = getNewLightingPath(lightingPath, node.type, property.childType) + if (newLightingPath !== undefined) { + object[property.name] = getProtocolNode(node[property.name], removePersonalData, parseCode, includeIds, includePayload, includeReferencesInSavedPayload, newLightingPath) + } } } break } case 'array': { if (node[property.name] !== undefined) { - let newLightingPath = getNreLightingPath(lightingPath, node.type, property.childType) - if (newLightingPath !== undefined) { + if (lightingPath === undefined) { let nodePropertyArray = node[property.name] object[property.name] = [] for (let m = 0; m < nodePropertyArray.length; m++) { - let protocolNode = getProtocolNode(nodePropertyArray[m], removePersonalData, parseCode, includeIds, includePayload, newLightingPath) + let protocolNode = getProtocolNode(nodePropertyArray[m], removePersonalData, parseCode, includeIds, includeReferencesInSavedPayload, includePayload) if (protocolNode !== undefined) { object[property.name].push(protocolNode) } } + } else { + let newLightingPath = getNewLightingPath(lightingPath, node.type, property.childType) + if (newLightingPath !== undefined) { + let nodePropertyArray = node[property.name] + object[property.name] = [] + for (let m = 0; m < nodePropertyArray.length; m++) { + let protocolNode = getProtocolNode(nodePropertyArray[m], removePersonalData, parseCode, includeIds, includePayload, includeReferencesInSavedPayload, newLightingPath) + if (protocolNode !== undefined) { + object[property.name].push(protocolNode) + } + } + } } } break @@ -59,15 +74,15 @@ function newProtocolNode () { /* Parent Nodes */ if (node.payload.parentNode !== undefined) { - let newLightingPath = getNreLightingPath(lightingPath, node.type, node.payload.parentNode.type) + let newLightingPath = getNewLightingPath(lightingPath, node.type, node.payload.parentNode.type) if (newLightingPath !== undefined) { - object.parentNode = getProtocolNode(node.payload.parentNode, removePersonalData, parseCode, includeIds, includePayload, newLightingPath) + object.parentNode = getProtocolNode(node.payload.parentNode, removePersonalData, parseCode, includeIds, includePayload, includeReferencesInSavedPayload, newLightingPath) } } if (node.payload.referenceParent !== undefined) { - let newLightingPath = getNreLightingPath(lightingPath, node.type, node.payload.referenceParent.type) + let newLightingPath = getNewLightingPath(lightingPath, node.type, node.payload.referenceParent.type) if (newLightingPath !== undefined) { - object.referenceParent = getProtocolNode(node.payload.referenceParent, removePersonalData, parseCode, includeIds, includePayload, newLightingPath) + object.referenceParent = getProtocolNode(node.payload.referenceParent, removePersonalData, parseCode, includeIds, includePayload, includeReferencesInSavedPayload, newLightingPath) } } @@ -89,21 +104,21 @@ function newProtocolNode () { object.id = node.id } if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) + object.savedPayload = getSavedPayload(node, includeReferencesInSavedPayload) } return object } } - function getNreLightingPath (lightingPath, currentNodeType, nextNodeType) { + function getNewLightingPath (lightingPath, currentNodeType, nextNodeType) { if (lightingPath === undefined) { return } if (currentNodeType === undefined) { return } if (nextNodeType === undefined) { return } - let currentNodePosition = lightingPath.indexOf(currentNodeType) - let nextNodePosition = lightingPath.indexOf(nextNodeType) + let currentNodePosition = lightingPath.indexOf('->' + currentNodeType + '->') + let nextNodePosition = lightingPath.indexOf('->' + nextNodeType + '->') let newLightingPath = lightingPath.substring(nextNodePosition, lightingPath.length + 1) @@ -114,7 +129,7 @@ function newProtocolNode () { } } - function getSavedPayload (node, includeReferences) { + function getSavedPayload (node, includeReferencesInSavedPayload) { if (node.payload === undefined) { return } let savedPayload = { position: { @@ -137,7 +152,7 @@ function newProtocolNode () { } } - if (includeReferences) { + if (includeReferencesInSavedPayload) { /* Next for the ones that have a reference parent, we include it */ if (node.payload.referenceParent !== undefined) { savedPayload.referenceParent = { diff --git a/DesignerSpace/Workspace/FunctionLibraries/TaskFunctions.js b/DesignerSpace/Workspace/FunctionLibraries/TaskFunctions.js index aec7aebc4..979fdc8ac 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/TaskFunctions.js +++ b/DesignerSpace/Workspace/FunctionLibraries/TaskFunctions.js @@ -24,10 +24,36 @@ function newTaskFunctions () { process.payload.uiObject.run() } + let lightingPath = '->Task->' + + 'Sensor Bot Instance->' + + 'Indicator Bot Instance->' + + 'Trading Bot Instance->' + + 'Process Instance->Process Definition->' + + 'Process Output->Output Dataset->Dataset Definition->Product Definition->' + + 'Process Dependencies->' + + 'Status Dependency->Status Report->Process Definition->' + + 'Data Dependency->Dataset Definition->Product Definition->' + + 'Record Definition->Record Property->Formula->' + + 'Data Building Procedure->' + + 'Procedure Initialization->Javascript Code->' + + 'Procedure Loop->Javascript Code->' + + 'Calculations Procedure->' + + 'Procedure Initialization->Javascript Code->' + + 'Procedure Loop->Javascript Code->' + + 'Status Report->' + + 'Execution Finished Event->' + + 'Execution Started Event->Execution Finished Event->Process Definition->' + + 'Sensor Bot->' + + 'Indicator Bot->' + + 'Trading Bot->' + + 'Team->' + + let definition = functionLibraryProtocolNode.getProtocolNode(node, false, true, true, false, false, lightingPath) + let event = { taskId: node.id, taskName: node.name, - definition: JSON.stringify(functionLibraryProtocolNode.getProtocolNode(node, false, true, true, false, false, true, true)) // <- We need to do this workaround in order no to send unescaped charactars to the taskManager. + definition: JSON.stringify(definition) // <- We need to do this workaround in order no to send unescaped charactars to the taskManager. } if (node.payload.parentNode === undefined) { From 7de1262bc533d1aeeab55213683c321f84cfa07b Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 22 Dec 2019 16:37:46 +0100 Subject: [PATCH 003/264] Backtesting Tested with lighting path at task --- DesignerSpace/Workspace/FunctionLibraries/TaskFunctions.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/DesignerSpace/Workspace/FunctionLibraries/TaskFunctions.js b/DesignerSpace/Workspace/FunctionLibraries/TaskFunctions.js index 979fdc8ac..8b153578c 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/TaskFunctions.js +++ b/DesignerSpace/Workspace/FunctionLibraries/TaskFunctions.js @@ -28,7 +28,9 @@ function newTaskFunctions () { 'Sensor Bot Instance->' + 'Indicator Bot Instance->' + 'Trading Bot Instance->' + - 'Process Instance->Process Definition->' + + 'Process Instance->' + + 'Backtesting Session->Live Trading Session->Paper Trading Session->Fordward Testing Session->' + + 'Process Definition->' + 'Process Output->Output Dataset->Dataset Definition->Product Definition->' + 'Process Dependencies->' + 'Status Dependency->Status Report->Process Definition->' + From ce18e08bb8b31c3ecb5b7e75e34c4e58b95dae17 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 23 Dec 2019 12:26:26 +0100 Subject: [PATCH 004/264] let the workspace be saved again --- DesignerSpace/Workspace/Workspace.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DesignerSpace/Workspace/Workspace.js b/DesignerSpace/Workspace/Workspace.js index 8ef065d6f..21b84ffd5 100644 --- a/DesignerSpace/Workspace/Workspace.js +++ b/DesignerSpace/Workspace/Workspace.js @@ -112,8 +112,8 @@ function newWorkspace () { function physics () { if (thisObject.enabled !== true) { return } - let textToSave// = stringifyWorkspace() - // window.localStorage.setItem(CANVAS_APP_NAME + '.' + 'Workspace', textToSave) + let textToSave = stringifyWorkspace() + window.localStorage.setItem(CANVAS_APP_NAME + '.' + 'Workspace', textToSave) if (workingAtTask > 0) { circularProgressBar.physics() From 07af3dab5e1a3dc768ffdc1cf3eeac8b3de5726d Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 23 Dec 2019 12:58:47 +0100 Subject: [PATCH 005/264] Count Children from APP SCHEMA --- .../FunctionLibraries/NodeChildren.js | 1484 +---------------- 1 file changed, 9 insertions(+), 1475 deletions(-) diff --git a/DesignerSpace/Workspace/FunctionLibraries/NodeChildren.js b/DesignerSpace/Workspace/FunctionLibraries/NodeChildren.js index e27991ae5..e606f89ed 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/NodeChildren.js +++ b/DesignerSpace/Workspace/FunctionLibraries/NodeChildren.js @@ -6,231 +6,7 @@ function newNodeChildren () { return thisObject function childrenCount (parentNode, childNode) { - switch (parentNode.type) { - - case 'Definition': { - return countChildrenDefinition(parentNode, childNode) - } - case 'Network': { - return countChildrenNetwork(parentNode, childNode) - } - case 'Team': { - return countChildrenTeam(parentNode, childNode) - } - case 'Sensor Bot': { - return countChildrenSensorBot(parentNode, childNode) - } - case 'Indicator Bot': { - return countChildrenIndicatorBot(parentNode, childNode) - } - case 'Trading Bot': { - return countChildrenTradingBot(parentNode, childNode) - } - case 'Process Definition': { - return countChildrenProcessDefinition(parentNode, childNode) - } - case 'Process Output': { - return countChildrenProcessOutput(parentNode, childNode) - } - case 'Process Dependencies': { - return countChildrenProcessDependencies(parentNode, childNode) - } - case 'Status Rerport': { - return countChildrenStatusRerport(parentNode, childNode) - } - case 'Execution Started Event': { - return countChildrenExecutionStartedEvent(parentNode, childNode) - } - case 'Execution Finished Event': { - return countChildrenExecutionFinishedEvent(parentNode, childNode) - } - case 'Calculations Procedure': { - return countChildrenCalculationsProcedure(parentNode, childNode) - } - case 'Data Building Procedure': { - return countChildrenDataBuildingProcedure(parentNode, childNode) - } - case 'Procedure Initialization': { - return countChildrenProcedureInitialization(parentNode, childNode) - } - case 'Procedure Loop': { - return countChildrenProcedureLoop(parentNode, childNode) - } - case 'Output Dataset': { - return countChildrenOutputDataset(parentNode, childNode) - } - case 'Status Dependency': { - return countChildrenStatusDependency(parentNode, childNode) - } - case 'Data Dependency': { - return countChildrenDataDependency(parentNode, childNode) - } - case 'Product Definition': { - return countChildrenProductDefinition(parentNode, childNode) - } - case 'Record Definition': { - return countChildrenRecordDefinition(parentNode, childNode) - } - case 'Record Property': { - return countChildrenRecordProperty(parentNode, childNode) - } - case 'Dataset Definition': { - return countChildrenDatasetDefinition(parentNode, childNode) - } - case 'Plotter': { - return countChildrenPlotter(parentNode, childNode) - } - case 'Plotter Module': { - return countChildrenPlotterModule(parentNode, childNode) - } - case 'Network Node': { - return countChildrenNetworkNode(parentNode, childNode) - } - case 'Social Bots': { - return countChildrenSocialBots(parentNode, childNode) - } - case 'Telegram Bot': { - return countChildrenTelegramBot(parentNode, childNode) - } - case 'Announcement': { - return countChildrenAnnouncement(parentNode, childNode) - } - case 'Layer Manager': { - return countChildrenLayerManager(parentNode, childNode) - } - case 'Layer': { - return countChildrenLayer(parentNode, childNode) - } - case 'Task Manager': { - return countChildrenTaskManager(parentNode, childNode) - } - case 'Task': { - return countChildrenTask(parentNode, childNode) - } - case 'Sensor Bot Instance': { - return countChildrenSensorBotInstance(parentNode, childNode) - } - case 'Indicator Bot Instance': { - return countChildrenIndicatorBotInstance(parentNode, childNode) - } - case 'Trading Bot Instance': { - return countChildrenTradingBotInstance(parentNode, childNode) - } - case 'Process Instance': { - return countChildrenProcessInstance(parentNode, childNode) - } - case 'Backtesting Session': { - return countBacktestingSession(parentNode, childNode) - } - case 'Live Trading Session': { - return countLiveTradingSession(parentNode, childNode) - } - case 'Fordward Testing Session': { - return countFordwardTestingSession(parentNode, childNode) - } - case 'Paper Trading Session': { - return countPaperTradingSession(parentNode, childNode) - } - case 'Personal Data': { - return countChildrenPersonalData(parentNode, childNode) - } - case 'Exchange Account': { - return countChildrenExchangeAccount(parentNode, childNode) - } - case 'Exchange Account Asset': { - return countChildrenExchangeAccountAsset(parentNode, childNode) - } - case 'Exchange Account Key': { - return countChildrenExchangeAccountKey(parentNode, childNode) - } - case 'Trading System': { - return countChildrenTradingSystem(parentNode, childNode) - } - case 'Parameters': { - return countChildrenParameters(parentNode, childNode) - } - case 'Base Asset': { - return countChildrenBaseAsset(parentNode, childNode) - } - case 'Time Range': { - return countChildrenTimeRange(parentNode, childNode) - } - case 'Time Period': { - return countChildrenTimePeriod(parentNode, childNode) - } - case 'Slippage': { - return countChildrenSlippage(parentNode, childNode) - } - case 'Fee Structure': { - return countChildrenFeeStructure(parentNode, childNode) - } - case 'Strategy': { - return countChildrenStrategy(parentNode, childNode) - } - case 'Trigger Stage': { - return countChildrenTriggerStage(parentNode, childNode) - } - case 'Open Stage': { - return countChildrenOpenStage(parentNode, childNode) - } - case 'Manage Stage': { - return countChildrenManageStage(parentNode, childNode) - } - case 'Close Stage': { - return countChildrenCloseStage(parentNode, childNode) - } - case 'Position Size': { - return countChildrenPositionSize(parentNode, childNode) - } - case 'Position Rate': { - return countChildrenPositionSize(parentNode, childNode) - } - case 'Initial Definition': { - return countChildrenInitialDefinition(parentNode, childNode) - } - case 'Open Execution': { - return countChildrenOpenExecution(parentNode, childNode) - } - case 'Close Execution': { - return countChildrenCloseExecution(parentNode, childNode) - } - case 'Next Phase Event': { - return countChildrenEvent(parentNode, childNode) - } - case 'Trigger On Event': { - return countChildrenEvent(parentNode, childNode) - } - case 'Trigger Off Event': { - return countChildrenEvent(parentNode, childNode) - } - case 'Take Position Event': { - return countChildrenEvent(parentNode, childNode) - } - case 'Stop': { - return countChildrenStop(parentNode, childNode) - } - case 'Take Profit': { - return countChildrenTakeProfit(parentNode, childNode) - } - case 'Phase': { - return countChildrenPhase(parentNode, childNode) - } - case 'Formula': { - return countChildrenFormula(parentNode, childNode) - } - case 'Situation': { - return countChildrenSituation(parentNode, childNode) - } - case 'Condition': { - return countChildrenCondition(parentNode, childNode) - } - case 'Javascript Code': { - return countChildrenJavascriptCode(parentNode, childNode) - } - default: { - return countChildrenUiObject(parentNode, childNode) - } - } + return countChildrenUiObject(parentNode, childNode) } function countChildrenUiObject (parentNode, childNode) { @@ -241,14 +17,19 @@ function newNodeChildren () { let nodeDefinition = APP_SCHEMA_MAP.get(parentNode.type) if (nodeDefinition !== undefined) { if (nodeDefinition.properties !== undefined) { + let previousPropertyName // Since there are cases where there are many properties with the same name,because they can hold nodes of different types but only one at the time, we have to avoind counting each property of those as individual children. + for (let i = 0; i < nodeDefinition.properties.length; i++) { let property = nodeDefinition.properties[i] if (parentNode[property.name] !== undefined) { switch (property.type) { case 'node': { - response.childrenCount++ - if (parentNode[property.name].id === childNode.id) { - response.childIndex = response.childrenCount + if (property.name !== previousPropertyName) { + response.childrenCount++ + if (parentNode[property.name].id === childNode.id) { + response.childIndex = response.childrenCount + } + previousPropertyName = property.name } } break @@ -271,1251 +52,4 @@ function newNodeChildren () { return response } - - function countChildrenDefinition (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - if (parentNode.tradingSystem !== undefined) { - response.childrenCount++ - if (parentNode.tradingSystem.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - if (parentNode.personalData !== undefined) { - response.childrenCount++ - if (parentNode.personalData.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - return response - } - - function countChildrenNetwork (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - if (parentNode.networkNodes !== undefined) { - for (let i = 0; i < parentNode.networkNodes.length; i++) { - let child = parentNode.networkNodes[i] - response.childrenCount++ - if (child.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - } - return response - } - - function countChildrenTeam (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - if (parentNode.sensorBots !== undefined) { - for (let i = 0; i < parentNode.sensorBots.length; i++) { - let child = parentNode.sensorBots[i] - response.childrenCount++ - if (child.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - } - if (parentNode.indicatorBots !== undefined) { - for (let i = 0; i < parentNode.indicatorBots.length; i++) { - let child = parentNode.indicatorBots[i] - response.childrenCount++ - if (child.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - } - if (parentNode.tradingBots !== undefined) { - for (let i = 0; i < parentNode.tradingBots.length; i++) { - let child = parentNode.tradingBots[i] - response.childrenCount++ - if (child.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - } - if (parentNode.plotters !== undefined) { - for (let i = 0; i < parentNode.plotters.length; i++) { - let child = parentNode.plotters[i] - response.childrenCount++ - if (child.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - } - return response - } - - function countChildrenSensorBot (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - if (parentNode.processes !== undefined) { - for (let i = 0; i < parentNode.processes.length; i++) { - let child = parentNode.processes[i] - response.childrenCount++ - if (child.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - } - if (parentNode.products !== undefined) { - for (let i = 0; i < parentNode.products.length; i++) { - let child = parentNode.products[i] - response.childrenCount++ - if (child.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - } - return response - } - - function countChildrenIndicatorBot (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - if (parentNode.processes !== undefined) { - for (let i = 0; i < parentNode.processes.length; i++) { - let child = parentNode.processes[i] - response.childrenCount++ - if (child.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - } - if (parentNode.products !== undefined) { - for (let i = 0; i < parentNode.products.length; i++) { - let child = parentNode.products[i] - response.childrenCount++ - if (child.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - } - return response - } - - function countChildrenTradingBot (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - if (parentNode.processes !== undefined) { - for (let i = 0; i < parentNode.processes.length; i++) { - let child = parentNode.processes[i] - response.childrenCount++ - if (child.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - } - if (parentNode.products !== undefined) { - for (let i = 0; i < parentNode.products.length; i++) { - let child = parentNode.products[i] - response.childrenCount++ - if (child.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - } - return response - } - - function countChildrenProcessDefinition (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - if (parentNode.processOutput !== undefined) { - response.childrenCount++ - if (parentNode.processOutput.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - if (parentNode.processDependencies !== undefined) { - response.childrenCount++ - if (parentNode.processDependencies.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - if (parentNode.statusReport !== undefined) { - response.childrenCount++ - if (parentNode.statusReport.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - if (parentNode.executionStartedEvent !== undefined) { - response.childrenCount++ - if (parentNode.executionStartedEvent.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - if (parentNode.executionFinishedEvent !== undefined) { - response.childrenCount++ - if (parentNode.executionFinishedEvent.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - return response - } - - function countChildrenProcessOutput (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - if (parentNode.outputDatasets !== undefined) { - for (let i = 0; i < parentNode.outputDatasets.length; i++) { - let child = parentNode.outputDatasets[i] - response.childrenCount++ - if (child.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - } - return response - } - - function countChildrenProcessDependencies (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - if (parentNode.statusDependencies !== undefined) { - for (let i = 0; i < parentNode.statusDependencies.length; i++) { - let child = parentNode.statusDependencies[i] - response.childrenCount++ - if (child.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - } - if (parentNode.dataDependencies !== undefined) { - for (let i = 0; i < parentNode.dataDependencies.length; i++) { - let child = parentNode.dataDependencies[i] - response.childrenCount++ - if (child.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - } - return response - } - - function countChildrenStatusRerport (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - return response - } - - function countChildrenExecutionStartedEvent (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - return response - } - - function countChildrenExecutionFinishedEvent (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - return response - } - - function countChildrenCalculationsProcedure (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - if (parentNode.initialization !== undefined) { - response.childrenCount++ - if (parentNode.initialization.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - if (parentNode.loop !== undefined) { - response.childrenCount++ - if (parentNode.loop.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - return response - } - - function countChildrenDataBuildingProcedure (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - if (parentNode.initialization !== undefined) { - response.childrenCount++ - if (parentNode.initialization.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - if (parentNode.loop !== undefined) { - response.childrenCount++ - if (parentNode.loop.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - return response - } - - function countChildrenProcedureInitialization (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - if (parentNode.javascriptCode !== undefined) { - response.childrenCount++ - if (parentNode.javascriptCode.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - return response - } - - function countChildrenProcedureLoop (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - if (parentNode.javascriptCode !== undefined) { - response.childrenCount++ - if (parentNode.javascriptCode.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - return response - } - - function countChildrenOutputDataset (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - return response - } - - function countChildrenStatusDependency (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - return response - } - - function countChildrenDataDependency (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - return response - } - - function countChildrenProductDefinition (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - if (parentNode.record !== undefined) { - response.childrenCount++ - if (parentNode.record.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - - if (parentNode.datasets !== undefined) { - for (let i = 0; i < parentNode.datasets.length; i++) { - let child = parentNode.datasets[i] - response.childrenCount++ - if (child.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - } - - if (parentNode.calculations !== undefined) { - response.childrenCount++ - if (parentNode.calculations.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - if (parentNode.dataBuilding !== undefined) { - response.childrenCount++ - if (parentNode.dataBuilding.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - return response - } - - function countChildrenRecordDefinition (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - - if (parentNode.properties !== undefined) { - for (let i = 0; i < parentNode.properties.length; i++) { - let child = parentNode.properties[i] - response.childrenCount++ - if (child.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - } - return response - } - - function countChildrenRecordProperty (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - if (parentNode.formula !== undefined) { - response.childrenCount++ - if (parentNode.formula.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - return response - } - - function countChildrenDatasetDefinition (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - return response - } - - function countChildrenPlotter (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - if (parentNode.modules !== undefined) { - for (let i = 0; i < parentNode.modules.length; i++) { - let child = parentNode.modules[i] - response.childrenCount++ - if (child.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - } - return response - } - - function countChildrenPlotterModule (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - if (parentNode.javascriptCode !== undefined) { - response.childrenCount++ - if (parentNode.javascriptCode.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - if (parentNode.shapes !== undefined) { - response.childrenCount++ - if (parentNode.shapes.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - if (parentNode.panels !== undefined) { - for (let i = 0; i < parentNode.panels.length; i++) { - let child = parentNode.panels[i] - response.childrenCount++ - if (child.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - } - return response - } - - function countChildrenNetworkNode (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - if (parentNode.taskManagers !== undefined) { - for (let i = 0; i < parentNode.taskManagers.length; i++) { - let child = parentNode.taskManagers[i] - response.childrenCount++ - if (child.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - } - return response - } - - function countChildrenSocialBots (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - - for (let i = 0; i < parentNode.bots.length; i++) { - let child = parentNode.bots[i] - response.childrenCount++ - if (child.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - return response - } - - function countChildrenTelegramBot (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - - for (let i = 0; i < parentNode.announcements.length; i++) { - let child = parentNode.announcements[i] - response.childrenCount++ - if (child.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - return response - } - - function countChildrenAnnouncement (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - if (parentNode.formula !== undefined) { - response.childrenCount++ - if (parentNode.formula.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - return response - } - - function countChildrenLayerManager (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - - for (let i = 0; i < parentNode.layers.length; i++) { - let child = parentNode.layers[i] - response.childrenCount++ - if (child.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - return response - } - - function countChildrenLayer (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - return response - } - - function countChildrenTaskManager (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - - for (let i = 0; i < parentNode.tasks.length; i++) { - let child = parentNode.tasks[i] - response.childrenCount++ - if (child.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - return response - } - - function countChildrenTask (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - if (parentNode.bot !== undefined) { - response.childrenCount++ - if (parentNode.bot.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - return response - } - - function countChildrenSensorBotInstance (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - - for (let i = 0; i < parentNode.processes.length; i++) { - let child = parentNode.processes[i] - response.childrenCount++ - if (child.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - return response - } - - function countChildrenIndicatorBotInstance (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - - for (let i = 0; i < parentNode.processes.length; i++) { - let child = parentNode.processes[i] - response.childrenCount++ - if (child.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - return response - } - - function countChildrenTradingBotInstance (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - - for (let i = 0; i < parentNode.processes.length; i++) { - let child = parentNode.processes[i] - response.childrenCount++ - if (child.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - return response - } - - function countChildrenProcessInstance (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - if (parentNode.session !== undefined) { - response.childrenCount++ - if (parentNode.session.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - return response - } - - function countBacktestingSession (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - if (parentNode.parameters !== undefined) { - response.childrenCount++ - if (parentNode.parameters.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - if (parentNode.layerManager !== undefined) { - response.childrenCount++ - if (parentNode.layerManager.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - if (parentNode.socialBots !== undefined) { - response.childrenCount++ - if (parentNode.socialBots.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - return response - } - - function countLiveTradingSession (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - if (parentNode.parameters !== undefined) { - response.childrenCount++ - if (parentNode.parameters.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - if (parentNode.layerManager !== undefined) { - response.childrenCount++ - if (parentNode.layerManager.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - if (parentNode.socialBots !== undefined) { - response.childrenCount++ - if (parentNode.socialBots.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - return response - } - - function countFordwardTestingSession (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - if (parentNode.parameters !== undefined) { - response.childrenCount++ - if (parentNode.parameters.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - if (parentNode.layerManager !== undefined) { - response.childrenCount++ - if (parentNode.layerManager.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - if (parentNode.socialBots !== undefined) { - response.childrenCount++ - if (parentNode.socialBots.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - return response - } - - function countPaperTradingSession (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - if (parentNode.parameters !== undefined) { - response.childrenCount++ - if (parentNode.parameters.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - if (parentNode.layerManager !== undefined) { - response.childrenCount++ - if (parentNode.layerManager.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - if (parentNode.socialBots !== undefined) { - response.childrenCount++ - if (parentNode.socialBots.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - return response - } - - function countChildrenPersonalData (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - - for (let i = 0; i < parentNode.exchangeAccounts.length; i++) { - let child = parentNode.exchangeAccounts[i] - response.childrenCount++ - if (child.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - return response - } - - function countChildrenExchangeAccount (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - - for (let i = 0; i < parentNode.assets.length; i++) { - let child = parentNode.assets[i] - response.childrenCount++ - if (child.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - - for (let i = 0; i < parentNode.keys.length; i++) { - let child = parentNode.keys[i] - response.childrenCount++ - if (child.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - return response - } - - function countChildrenExchangeAccountAsset (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - return response - } - - function countChildrenExchangeAccountKey (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - return response - } - - function countChildrenTradingSystem (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - - for (let i = 0; i < parentNode.strategies.length; i++) { - let child = parentNode.strategies[i] - response.childrenCount++ - if (child.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - - if (parentNode.parameters !== undefined) { - response.childrenCount++ - if (parentNode.parameters.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - return response - } - - function countChildrenParameters (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - if (parentNode.baseAsset !== undefined) { - response.childrenCount++ - if (parentNode.baseAsset.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - if (parentNode.timeRange !== undefined) { - response.childrenCount++ - if (parentNode.timeRange.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - if (parentNode.timePeriod !== undefined) { - response.childrenCount++ - if (parentNode.timePeriod.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - if (parentNode.slippage !== undefined) { - response.childrenCount++ - if (parentNode.slippage.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - if (parentNode.feeStructure !== undefined) { - response.childrenCount++ - if (parentNode.feeStructure.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - if (parentNode.key !== undefined) { - response.childrenCount++ - if (parentNode.key.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - return response - } - - function countChildrenBaseAsset (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - return response - } - - function countChildrenTimeRange (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - return response - } - - function countChildrenTimePeriod (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - return response - } - - function countChildrenSlippage (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - return response - } - - function countChildrenFeeStructure (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - return response - } - - function countChildrenStrategy (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - if (parentNode.triggerStage !== undefined) { - response.childrenCount++ - if (parentNode.triggerStage.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - if (parentNode.openStage !== undefined) { - response.childrenCount++ - if (parentNode.openStage.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - if (parentNode.manageStage !== undefined) { - response.childrenCount++ - if (parentNode.manageStage.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - if (parentNode.closeStage !== undefined) { - response.childrenCount++ - if (parentNode.closeStage.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - return response - } - - function countChildrenTriggerStage (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - if (parentNode.triggerOn !== undefined) { - response.childrenCount++ - if (parentNode.triggerOn.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - if (parentNode.triggerOff !== undefined) { - response.childrenCount++ - if (parentNode.triggerOff.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - if (parentNode.takePosition !== undefined) { - response.childrenCount++ - if (parentNode.takePosition.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - return response - } - - function countChildrenOpenStage (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - if (parentNode.initialDefinition !== undefined) { - response.childrenCount++ - if (parentNode.initialDefinition.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - if (parentNode.openExecution !== undefined) { - response.childrenCount++ - if (parentNode.openExecution.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - return response - } - - function countChildrenManageStage (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - if (parentNode.stopLoss !== undefined) { - response.childrenCount++ - if (parentNode.stopLoss.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - if (parentNode.takeProfit !== undefined) { - response.childrenCount++ - if (parentNode.takeProfit.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - return response - } - - function countChildrenCloseStage (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - if (parentNode.closeExecution !== undefined) { - response.childrenCount++ - if (parentNode.closeExecution.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - return response - } - - function countChildrenPositionSize (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - if (parentNode.formula !== undefined) { - response.childrenCount++ - if (parentNode.formula.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - return response - } - - function countChildrenPositionRate (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - if (parentNode.formula !== undefined) { - response.childrenCount++ - if (parentNode.formula.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - return response - } - - function countChildrenInitialDefinition (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - if (parentNode.positionSize !== undefined) { - response.childrenCount++ - if (parentNode.positionSize.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - if (parentNode.stopLoss !== undefined) { - response.childrenCount++ - if (parentNode.stopLoss.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - if (parentNode.takeProfit !== undefined) { - response.childrenCount++ - if (parentNode.takeProfit.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - if (parentNode.positionRate !== undefined) { - response.childrenCount++ - if (parentNode.positionRate.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - return response - } - - function countChildrenOpenExecution (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - return response - } - - function countChildrenCloseExecution (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - return response - } - - function countChildrenEvent (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - for (let i = 0; i < parentNode.situations.length; i++) { - let child = parentNode.situations[i] - response.childrenCount++ - if (child.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - for (let i = 0; i < parentNode.announcements.length; i++) { - let child = parentNode.announcements[i] - response.childrenCount++ - if (child.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - return response - } - - function countChildrenStop (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - for (let i = 0; i < parentNode.phases.length; i++) { - let child = parentNode.phases[i] - - if (child.id === childNode.id) { - if (childNode.payload.chainParent !== undefined) { - if (childNode.payload.chainParent.id === parentNode.id) { - response.childrenCount++ - response.childIndex = response.childrenCount - } - } - } - } - return response - } - - function countChildrenTakeProfit (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - for (let i = 0; i < parentNode.phases.length; i++) { - let child = parentNode.phases[i] - - if (child.id === childNode.id) { - if (childNode.payload.chainParent !== undefined) { - if (childNode.payload.chainParent.id === parentNode.id) { - response.childrenCount++ - response.childIndex = response.childrenCount - } - } - } - } - return response - } - - function countChildrenPhase (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - if (parentNode.formula !== undefined) { - response.childrenCount++ - if (parentNode.formula.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - if (parentNode.nextPhaseEvent !== undefined) { - response.childrenCount++ - if (parentNode.nextPhaseEvent.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - for (let i = 0; i < parentNode.announcements.length; i++) { - let child = parentNode.announcements[i] - response.childrenCount++ - if (child.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - return response - } - - function countChildrenFormula (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - return response - } - - function countChildrenSituation (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - for (let i = 0; i < parentNode.conditions.length; i++) { - let child = parentNode.conditions[i] - response.childrenCount++ - if (child.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - return response - } - - function countChildrenCondition (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - if (parentNode.javascriptCode !== undefined) { - response.childrenCount++ - if (parentNode.javascriptCode.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - return response - } - - function countChildrenJavascriptCode (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - return response - } } From 1d572ae444dc3ecd21ff908ff15e00f8574dd430 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 23 Dec 2019 13:33:40 +0100 Subject: [PATCH 006/264] Deleting nodes based on APP SCHEMA --- .../FunctionLibraries/NodeDeleter.js | 1663 +---------------- .../FunctionLibraries/ProtocolNode.js | 1 + DesignerSpace/Workspace/Workspace.js | 277 +-- FloatingSpace/FloatingObject.js | 1 + 4 files changed, 5 insertions(+), 1937 deletions(-) diff --git a/DesignerSpace/Workspace/FunctionLibraries/NodeDeleter.js b/DesignerSpace/Workspace/FunctionLibraries/NodeDeleter.js index c5765dc79..92d89b278 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/NodeDeleter.js +++ b/DesignerSpace/Workspace/FunctionLibraries/NodeDeleter.js @@ -1,75 +1,7 @@ function newNodeDeleter () { thisObject = { - deleteUIObject: deleteUIObject, - deleteDefinition: deleteDefinition, - deleteNetwork: deleteNetwork, - deleteNetworkNode: deleteNetworkNode, - deleteTeam: deleteTeam, - deleteSensorBot: deleteSensorBot, - deleteIndicatorBot: deleteIndicatorBot, - deleteTradingBot: deleteTradingBot, - deleteProcessDefinition: deleteProcessDefinition, - deleteStatusReport: deleteStatusReport, - deleteExecutionStartedEvent: deleteExecutionStartedEvent, - deleteExecutionFinishedEvent: deleteExecutionFinishedEvent, - deleteCalculationsProcedure: deleteCalculationsProcedure, - deleteDataBuildingProcedure: deleteDataBuildingProcedure, - deleteProcedureInitialization: deleteProcedureInitialization, - deleteProcessDependencies: deleteProcessDependencies, - deleteProcedureLoop: deleteProcedureLoop, - deleteOutputDataset: deleteOutputDataset, - deleteStatusDependency: deleteStatusDependency, - deleteDataDependency: deleteDataDependency, - deleteProductDefinition: deleteProductDefinition, - deleteRecordDefinition: deleteRecordDefinition, - deleteRecordProperty: deleteRecordProperty, - deleteDatasetDefinition: deleteDatasetDefinition, - deletePlotter: deletePlotter, - deletePlotterModule: deletePlotterModule, - deleteSocialBots: deleteSocialBots, - deleteSocialBot: deleteSocialBot, - deleteAnnouncement: deleteAnnouncement, - deleteLayerManager: deleteLayerManager, - deleteLayer: deleteLayer, - deleteTaskManager: deleteTaskManager, - deleteTask: deleteTask, - deleteSensorBotInstance: deleteBotInstance, - deleteIndicatorBotInstance: deleteBotInstance, - deleteTradingBotInstance: deleteBotInstance, - deleteProcessInstance: deleteProcessInstance, - deletePersonalData: deletePersonalData, - deleteExchangeAccount: deleteExchangeAccount, - deleteExchangeAccountAsset: deleteExchangeAccountAsset, - deleteExchangeAccountKey: deleteExchangeAccountKey, deleteWorkspace: deleteWorkspace, - deleteTradingSystem: deleteTradingSystem, - deleteBacktestingSession: deleteBacktestingSession, - deleteLiveTradingSession: deleteLiveTradingSession, - deleteFordwardTestingSession: deleteFordwardTestingSession, - deletePaperTradingSession: deletePaperTradingSession, - deleteParameters: deleteParameters, - deleteBaseAsset: deleteBaseAsset, - deleteTimeRange: deleteTimeRange, - deleteTimePeriod: deleteTimePeriod, - deleteSlippage: deleteSlippage, - deleteFeeStructure: deleteFeeStructure, - deleteStrategy: deleteStrategy, - deleteTriggerStage: deleteTriggerStage, - deleteOpenStage: deleteOpenStage, - deleteManageStage: deleteManageStage, - deleteCloseStage: deleteCloseStage, - deletePositionSize: deletePositionSize, - deletePositionRate: deletePositionRate, - deleteInitialDefinition: deleteInitialDefinition, - deleteOpenExecution: deleteOpenExecution, - deleteCloseExecution: deleteCloseExecution, - deleteEvent: deleteEvent, - deleteManagedItem: deleteManagedItem, - deletePhase: deletePhase, - deleteFormula: deleteFormula, - deleteSituation: deleteSituation, - deleteCondition: deleteCondition, - deleteJavascriptCode: deleteJavascriptCode + deleteUIObject: deleteUIObject } return thisObject @@ -82,301 +14,7 @@ function newNodeDeleter () { if (node.rootNodes !== undefined) { while (node.rootNodes.length > 0) { let rootNode = node.rootNodes[0] - switch (rootNode.type) { - - case 'Definition': { - deleteDefinition(rootNode, rootNodes, true) - break - } - case 'Network': { - deleteNetwork(rootNode, rootNodes) - break - } - case 'Network Node': { - deleteNetworkNode(rootNode, rootNodes) - break - } - case 'Team': { - deleteTeam(rootNode, rootNodes) - break - } - case 'Sensor Bot': { - deleteSensorBot(rootNode, rootNodes) - break - } - case 'Indicator Bot': { - deleteIndicatorBot(rootNode, rootNodes) - break - } - case 'Trading Bot': { - deleteTradingBot(rootNode, rootNodes) - break - } - case 'Process Definition': { - deleteProcessDefinition(rootNode, rootNodes) - break - } - case 'Process Output': { - deleteProcessOutput(rootNode, rootNodes) - break - } - case 'Process Dependencies': { - deleteProcessDependencies(rootNode, rootNodes) - break - } - case 'Status Report': { - deleteStatusReport(rootNode, rootNodes) - break - } - case 'Execution Started Event': { - deleteExecutionStartedEvent(rootNode, rootNodes) - break - } - case 'Execution Finished Event': { - deleteExecutionFinishedEvent(rootNode, rootNodes) - break - } - case 'Calculations Procedure': { - deleteCalculationsProcedure(rootNode, rootNodes) - break - } - case 'Data Building Procedure': { - deleteDataBuildingProcedure(rootNode, rootNodes) - break - } - case 'Procedure Initialization': { - deleteProcedureInitialization(rootNode, rootNodes) - break - } - case 'Procedure Loop': { - deleteProcedureLoop(rootNode, rootNodes) - break - } - case 'Output Dataset': { - deleteOutputDataset(rootNode, rootNodes) - break - } - case 'Status Dependency': { - deleteStatusDependency(rootNode, rootNodes) - break - } - case 'Data Dependency': { - deleteDataDependency(rootNode, rootNodes) - break - } - case 'Product Definition': { - deleteProductDefinition(rootNode, rootNodes) - break - } - case 'Record Definition': { - deleteRecordDefinition(rootNode, rootNodes) - break - } - case 'Record Property': { - deleteRecordProperty(rootNode, rootNodes) - break - } - case 'Dataset Definition': { - deleteDatasetDefinition(rootNode, rootNodes) - break - } - case 'Plotter': { - deletePlotter(rootNode, rootNodes) - break - } - case 'Plotter Module': { - deletePlotterModule(rootNode, rootNodes) - break - } - case 'Social Bots': { - deleteSocialBots(rootNode, rootNodes) - break - } - case 'Telegram Bot': { - deleteSocialBot(rootNode, rootNodes) - break - } - case 'Announcement': { - deleteAnnouncement(rootNode, rootNodes) - break - } - case 'Layer Manager': { - deleteLayerManager(rootNode, rootNodes) - break - } - case 'Layer': { - deleteLayer(rootNode, rootNodes) - break - } - case 'Task Manager': { - deleteTaskManager(rootNode, rootNodes) - break - } - case 'Task': { - deleteTask(rootNode, rootNodes) - break - } - case 'Sensor Bot Instance': { - deleteBotInstance(rootNode, rootNodes) - break - } - case 'Indicator Bot Instance': { - deleteBotInstance(rootNode, rootNodes) - break - } - case 'Trading Bot Instance': { - deleteBotInstance(rootNode, rootNodes) - break - } - case 'Process Instance': { - deleteProcessInstance(rootNode, rootNodes) - break - } - case 'Personal Data': { - deletePersonalData(rootNode, rootNodes) - break - } - case 'Exchange Account': { - deleteExchangeAccount(rootNode, rootNodes) - break - } - case 'Exchange Account Asset': { - deleteExchangeAccountAsset(rootNode, rootNodes) - break - } - case 'Exchange Account Key': { - deleteExchangeAccountKey(rootNode, rootNodes) - break - } - case 'Trading System': { - deleteTradingSystem(rootNode, rootNodes) - break - } - case 'Backtesting Session': { - deleteBacktestingSession(rootNode, rootNodes) - break - } - case 'Live Trading Session': { - deleteLiveTradingSession(rootNode, rootNodes) - break - } - case 'Fordward Testing Session': { - deleteFordwardTestingSession(rootNode, rootNodes) - break - } - case 'Paper Trading Session': { - deletePaperTradingSession(rootNode, rootNodes) - break - } - case 'Parameters': { - deleteParameters(rootNode, rootNodes) - break - } - case 'Base Asset': { - deleteBaseAsset(rootNode, rootNodes) - break - } - case 'Time Range': { - deleteTimeRange(rootNode, rootNodes) - break - } - case 'Time Period': { - deleteTimePeriod(rootNode, rootNodes) - break - } - case 'Slippage': { - deleteSlippage(rootNode, rootNodes) - break - } - case 'Fee Structure': { - deleteFeeStructure(rootNode, rootNodes) - break - } - case 'Strategy': { - deleteStrategy(rootNode, rootNodes) - break - } - case 'Trigger Stage': { - deleteTriggerStage(rootNode, rootNodes) - break - } - case 'Open Stage': { - deleteOpenStage(rootNode, rootNodes) - break - } - case 'Manage Stage': { - deleteManageStage(rootNode, rootNodes) - break - } - case 'Close Stage': { - deleteCloseStage(rootNode, rootNodes) - break - } - case 'Position Size': { - deletePositionSize(rootNode, rootNodes) - break - } - case 'Position Rate': { - deletePositionRate(rootNode, rootNodes) - break - } - case 'Initial Definition': { - deleteInitialDefinition(rootNode, rootNodes) - break - } - case 'Open Execution': { - deleteOpenExecution(rootNode, rootNodes) - break - } - case 'Close Execution': { - deleteCloseExecution(rootNode, rootNodes) - break - } - case 'Trigger On Event': { - deleteEvent(rootNode, rootNodes) - break - } - case 'Trigger Off Event': { - deleteEvent(rootNode, rootNodes) - break - } - case 'Take Position Event': { - deleteEvent(rootNode, rootNodes) - break - } - case 'Next Phase Event': { - deleteEvent(rootNode, rootNodes) - break - } - case 'Managed Item': { - deleteManagedItem(rootNode, rootNodes) - break - } - case 'Phase': { - deletePhase(rootNode, rootNodes) - break - } - case 'Formula': { - deleteFormula(rootNode, rootNodes) - break - } - case 'Situation': { - deleteSituation(rootNode, rootNodes) - break - } - case 'Condition': { - deleteCondition(rootNode, rootNodes) - break - } - case 'Javascript Code': { - deleteJavascriptCode(rootNode, rootNodes) - break - } - - default: { - deleteUIObject(rootNode, rootNodes) - } - } + deleteUIObject(rootNode, rootNodes) } } @@ -451,1303 +89,6 @@ function newNodeDeleter () { } } - function deleteDefinition (node, rootNodes) { - let payload = node.payload - - if (node.tradingSystem !== undefined) { - deleteTradingSystem(node.tradingSystem, rootNodes) - } - if (node.personalData !== undefined) { - deletePersonalData(node.personalData, rootNodes) - } - completeDeletion(node, rootNodes) - destroyUiObject(node) - cleanNode(node) - } - - function deleteNetwork (node, rootNodes) { - let payload = node.payload - - if (node.networkNodes !== undefined) { - while (node.networkNodes.length > 0) { - deleteNetworkNode(node.networkNodes[0], rootNodes) - } - } - - completeDeletion(node, rootNodes) - destroyUiObject(node) - cleanNode(node) - } - - function deleteNetworkNode (node, rootNodes) { - let payload = node.payload - - if (payload.parentNode !== undefined) { - for (let j = 0; j < payload.parentNode.networkNodes.length; j++) { - let networkNode = payload.parentNode.networkNodes[j] - if (networkNode.id === node.id) { - payload.parentNode.networkNodes.splice(j, 1) - } - } - } - - if (node.taskManagers !== undefined) { - while (node.taskManagers.length > 0) { - deleteTaskManager(node.taskManagers[0], rootNodes) - } - } - - completeDeletion(node, rootNodes) - destroyUiObject(node) - cleanNode(node) - } - - function deleteTeam (node, rootNodes) { - let payload = node.payload - - if (node.sensorBots !== undefined) { - while (node.sensorBots.length > 0) { - deleteSensorBot(node.sensorBots[0], rootNodes) - } - } - - if (node.indicatorBots !== undefined) { - while (node.indicatorBots.length > 0) { - deleteIndicatorBot(node.indicatorBots[0], rootNodes) - } - } - - if (node.tradingBots !== undefined) { - while (node.tradingBots.length > 0) { - deleteTradingBot(node.tradingBots[0], rootNodes) - } - } - - if (node.plotters !== undefined) { - while (node.plotters.length > 0) { - deletePlotter(node.plotters[0], rootNodes) - } - } - - completeDeletion(node, rootNodes) - destroyUiObject(node) - cleanNode(node) - } - - function deleteSensorBot (node, rootNodes) { - let payload = node.payload - - if (payload.parentNode !== undefined) { - for (let j = 0; j < payload.parentNode.sensorBots.length; j++) { - let sensorBot = payload.parentNode.sensorBots[j] - if (sensorBot.id === node.id) { - payload.parentNode.sensorBots.splice(j, 1) - } - } - } - - if (node.processes !== undefined) { - while (node.processes.length > 0) { - deleteProcessDefinition(node.processes[0], rootNodes) - } - } - - if (node.products !== undefined) { - while (node.products.length > 0) { - deleteProductDefinition(node.products[0], rootNodes) - } - } - - completeDeletion(node, rootNodes) - destroyUiObject(node) - cleanNode(node) - } - - function deleteIndicatorBot (node, rootNodes) { - let payload = node.payload - - if (payload.parentNode !== undefined) { - for (let j = 0; j < payload.parentNode.indicatorBots.length; j++) { - let indicatorBot = payload.parentNode.indicatorBots[j] - if (indicatorBot.id === node.id) { - payload.parentNode.indicatorBots.splice(j, 1) - } - } - } - - if (node.processes !== undefined) { - while (node.processes.length > 0) { - deleteProcessDefinition(node.processes[0], rootNodes) - } - } - - if (node.products !== undefined) { - while (node.products.length > 0) { - deleteProductDefinition(node.products[0], rootNodes) - } - } - - completeDeletion(node, rootNodes) - destroyUiObject(node) - cleanNode(node) - } - - function deleteTradingBot (node, rootNodes) { - let payload = node.payload - - if (payload.parentNode !== undefined) { - for (let j = 0; j < payload.parentNode.tradingBots.length; j++) { - let tradingBot = payload.parentNode.tradingBots[j] - if (tradingBot.id === node.id) { - payload.parentNode.tradingBots.splice(j, 1) - } - } - } - - if (node.processes !== undefined) { - while (node.processes.length > 0) { - deleteProcessDefinition(node.processes[0], rootNodes) - } - } - - if (node.products !== undefined) { - while (node.products.length > 0) { - deleteProductDefinition(node.products[0], rootNodes) - } - } - - completeDeletion(node, rootNodes) - destroyUiObject(node) - cleanNode(node) - } - - function deleteProcessDefinition (node, rootNodes) { - let payload = node.payload - - if (payload.parentNode !== undefined) { - for (let j = 0; j < payload.parentNode.processes.length; j++) { - let process = payload.parentNode.processes[j] - if (process.id === node.id) { - payload.parentNode.processes.splice(j, 1) - } - } - } - - if (node.processOutput !== undefined) { - deleteProcessOutput(node.processOutput, rootNodes) - } - - if (node.processDependencies !== undefined) { - deleteProcessDependencies(node.processDependencies, rootNodes) - } - - if (node.statusReport !== undefined) { - deleteStatusReport(node.statusReport, rootNodes) - } - - if (node.executionStartedEvent !== undefined) { - deleteExecutionStartedEvent(node.executionStartedEvent, rootNodes) - } - - if (node.executionFinishedEvent !== undefined) { - deleteExecutionFinishedEvent(node.executionFinishedEvent, rootNodes) - } - - completeDeletion(node, rootNodes) - destroyUiObject(node) - cleanNode(node) - } - - function deleteProcessOutput (node, rootNodes) { - let payload = node.payload - - if (node.outputDatasets !== undefined) { - while (node.outputDatasets.length > 0) { - deleteOutputDataset(node.outputDatasets[0], rootNodes) - } - } - - completeDeletion(node, rootNodes) - destroyUiObject(node) - cleanNode(node) - } - - function deleteProcessDependencies (node, rootNodes) { - let payload = node.payload - - if (node.statusDependencies !== undefined) { - while (node.statusDependencies.length > 0) { - deleteStatusDependency(node.statusDependencies[0], rootNodes) - } - } - - if (node.dataDependencies !== undefined) { - while (node.dataDependencies.length > 0) { - deleteDataDependency(node.dataDependencies[0], rootNodes) - } - } - - completeDeletion(node, rootNodes) - destroyUiObject(node) - cleanNode(node) - } - - function deleteStatusReport (node, rootNodes) { - let payload = node.payload - - if (payload.parentNode !== undefined) { - payload.parentNode.statusReport = undefined - } - - completeDeletion(node, rootNodes) - destroyUiObject(node) - cleanNode(node) - } - - function deleteExecutionStartedEvent (node, rootNodes) { - let payload = node.payload - - if (payload.parentNode !== undefined) { - payload.parentNode.executionStartedEvent = undefined - } - - completeDeletion(node, rootNodes) - destroyUiObject(node) - cleanNode(node) - } - - function deleteExecutionFinishedEvent (node, rootNodes) { - let payload = node.payload - - if (payload.parentNode !== undefined) { - payload.parentNode.executionFinishedEvent = undefined - } - - completeDeletion(node, rootNodes) - destroyUiObject(node) - cleanNode(node) - } - - function deleteCalculationsProcedure (node, rootNodes) { - let payload = node.payload - - if (payload.parentNode !== undefined) { - payload.parentNode.calculations = undefined - } - - if (node.initialization !== undefined) { - deleteProcedureInitialization(node.initialization, rootNodes) - } - - if (node.loop !== undefined) { - deleteProcedureLoop(node.loop, rootNodes) - } - - completeDeletion(node, rootNodes) - destroyUiObject(node) - cleanNode(node) - } - - function deleteDataBuildingProcedure (node, rootNodes) { - let payload = node.payload - - if (payload.parentNode !== undefined) { - payload.parentNode.dataBuilding = undefined - } - - if (node.initialization !== undefined) { - deleteProcedureInitialization(node.initialization, rootNodes) - } - - if (node.loop !== undefined) { - deleteProcedureLoop(node.loop, rootNodes) - } - - completeDeletion(node, rootNodes) - destroyUiObject(node) - cleanNode(node) - } - - function deleteProcedureInitialization (node, rootNodes) { - let payload = node.payload - - if (payload.parentNode !== undefined) { - payload.parentNode.initialization = undefined - } - - if (node.code !== undefined) { - deleteParameters(node.code, rootNodes) - } - - completeDeletion(node, rootNodes) - destroyUiObject(node) - cleanNode(node) - } - - function deleteProcedureLoop (node, rootNodes) { - let payload = node.payload - - if (payload.parentNode !== undefined) { - payload.parentNode.loop = undefined - } - - if (node.javascriptCode !== undefined) { - deleteJavascriptCode(node.javascriptCode, rootNodes) - } - - completeDeletion(node, rootNodes) - destroyUiObject(node) - cleanNode(node) - } - - function deleteOutputDataset (node, rootNodes) { - let payload = node.payload - - if (payload.parentNode !== undefined) { - for (let j = 0; j < payload.parentNode.outputDatasets.length; j++) { - let outputDataset = payload.parentNode.outputDatasets[j] - if (outputDataset.id === node.id) { - payload.parentNode.outputDatasets.splice(j, 1) - } - } - } - - completeDeletion(node, rootNodes) - destroyUiObject(node) - cleanNode(node) - } - - function deleteStatusDependency (node, rootNodes) { - let payload = node.payload - - if (payload.parentNode !== undefined) { - for (let j = 0; j < payload.parentNode.statusDependencies.length; j++) { - let statusDependency = payload.parentNode.statusDependencies[j] - if (statusDependency.id === node.id) { - payload.parentNode.statusDependencies.splice(j, 1) - } - } - } - - completeDeletion(node, rootNodes) - destroyUiObject(node) - cleanNode(node) - } - - function deleteDataDependency (node, rootNodes) { - let payload = node.payload - - if (payload.parentNode !== undefined) { - for (let j = 0; j < payload.parentNode.dataDependencies.length; j++) { - let dataDependency = payload.parentNode.dataDependencies[j] - if (dataDependency.id === node.id) { - payload.parentNode.dataDependencies.splice(j, 1) - } - } - } - - completeDeletion(node, rootNodes) - destroyUiObject(node) - cleanNode(node) - } - - function deleteProductDefinition (node, rootNodes) { - let payload = node.payload - - if (payload.parentNode !== undefined) { - for (let j = 0; j < payload.parentNode.products.length; j++) { - let product = payload.parentNode.products[j] - if (product.id === node.id) { - payload.parentNode.products.splice(j, 1) - } - } - } - - if (node.record !== undefined) { - deleteRecordDefinition(node.record, rootNodes) - } - - if (node.datasets !== undefined) { - while (node.datasets.length > 0) { - deleteDatasetDefinition(node.datasets[0], rootNodes) - } - } - - if (node.calculations !== undefined) { - deleteCalculationsProcedure(node.calculations, rootNodes) - } - - if (node.dataBuilding !== undefined) { - deleteDataBuildingProcedure(node.dataBuilding, rootNodes) - } - - completeDeletion(node, rootNodes) - destroyUiObject(node) - cleanNode(node) - } - - function deleteRecordDefinition (node, rootNodes) { - let payload = node.payload - - if (payload.parentNode !== undefined) { - payload.parentNode.record = undefined - } - - if (node.properties !== undefined) { - while (node.properties.length > 0) { - deleteRecordProperty(node.properties[0], rootNodes) - } - } - - completeDeletion(node, rootNodes) - destroyUiObject(node) - cleanNode(node) - } - - function deleteRecordProperty (node, rootNodes) { - let payload = node.payload - - if (payload.parentNode !== undefined) { - for (let j = 0; j < payload.parentNode.properties.length; j++) { - let property = payload.parentNode.properties[j] - if (property.id === node.id) { - payload.parentNode.properties.splice(j, 1) - } - } - } - - if (node.formula !== undefined) { - deleteFormula(node.formula, rootNodes) - } - - completeDeletion(node, rootNodes) - destroyUiObject(node) - cleanNode(node) - } - - function deleteDatasetDefinition (node, rootNodes) { - let payload = node.payload - - if (payload.parentNode !== undefined) { - for (let j = 0; j < payload.parentNode.datasets.length; j++) { - let dataset = payload.parentNode.datasets[j] - if (dataset.id === node.id) { - payload.parentNode.datasets.splice(j, 1) - } - } - } - - completeDeletion(node, rootNodes) - destroyUiObject(node) - cleanNode(node) - } - - function deletePlotter (node, rootNodes) { - let payload = node.payload - - if (payload.parentNode !== undefined) { - for (let j = 0; j < payload.parentNode.plotters.length; j++) { - let plotter = payload.parentNode.plotters[j] - if (plotter.id === node.id) { - payload.parentNode.plotters.splice(j, 1) - } - } - } - - if (node.modules !== undefined) { - while (node.modules.length > 0) { - deletePlotterModule(node.modules[0], rootNodes) - } - } - - completeDeletion(node, rootNodes) - destroyUiObject(node) - cleanNode(node) - } - - function deletePlotterModule (node, rootNodes) { - let payload = node.payload - - if (payload.parentNode !== undefined) { - for (let j = 0; j < payload.parentNode.modules.length; j++) { - let module = payload.parentNode.modules[j] - if (module.id === node.id) { - payload.parentNode.modules.splice(j, 1) - } - } - } - - if (node.javascriptCode !== undefined) { - deleteJavascriptCode(node.javascriptCode, rootNodes) - } - - if (node.shapes !== undefined) { - deleteUIObject(node.shapes, rootNodes) - } - - if (node.panels !== undefined) { - while (node.panels.length > 0) { - deleteUIObject(node.panels[0], rootNodes) - } - } - - completeDeletion(node, rootNodes) - destroyUiObject(node) - cleanNode(node) - } - - function deleteSocialBots (node, rootNodes) { - let payload = node.payload - if (payload.parentNode !== undefined) { - payload.parentNode.socialBots = undefined - } - if (node.bots !== undefined) { - while (node.bots.length > 0) { - deleteSocialBot(node.bots[0], rootNodes) - } - } - completeDeletion(node, rootNodes) - destroyUiObject(node) - cleanNode(node) - } - - function deleteSocialBot (node, rootNodes) { - let payload = node.payload - if (payload.parentNode !== undefined) { - for (let j = 0; j < payload.parentNode.bots.length; j++) { - let bot = payload.parentNode.bots[j] - if (bot.id === node.id) { - payload.parentNode.bots.splice(j, 1) - } - } - } - if (node.announcements !== undefined) { - while (node.announcements.length > 0) { - deleteAnnouncement(node.announcements[0], rootNodes) - } - } - completeDeletion(node, rootNodes) - destroyUiObject(node) - cleanNode(node) - } - - function deleteAnnouncement (node, rootNodes) { - let payload = node.payload - if (payload.parentNode !== undefined) { - for (let j = 0; j < payload.parentNode.announcements.length; j++) { - let announcement = payload.parentNode.announcements[j] - if (announcement.id === node.id) { - payload.parentNode.announcements.splice(j, 1) - } - } - } - if (node.formula !== undefined) { - deleteFormula(node.formula, rootNodes) - } - completeDeletion(node, rootNodes) - destroyUiObject(node) - cleanNode(node) - } - - function deleteLayerManager (node, rootNodes) { - let payload = node.payload - if (payload.parentNode !== undefined) { - payload.parentNode.layerManager = undefined - } - if (node.layers !== undefined) { - while (node.layers.length > 0) { - deleteLayer(node.layers[0], rootNodes) - } - } - completeDeletion(node, rootNodes) - destroyUiObject(node) - cleanNode(node) - } - - function deleteLayer (node, rootNodes) { - let payload = node.payload - if (payload.parentNode !== undefined) { - for (let j = 0; j < payload.parentNode.layers.length; j++) { - let layer = payload.parentNode.layers[j] - if (layer.id === node.id) { - payload.parentNode.layers.splice(j, 1) - } - } - } - completeDeletion(node, rootNodes) - destroyUiObject(node) - cleanNode(node) - } - - function deleteTaskManager (node, rootNodes) { - let payload = node.payload - if (payload.parentNode !== undefined) { - for (let j = 0; j < payload.parentNode.taskManagers.length; j++) { - let taskManager = payload.parentNode.taskManagers[j] - if (taskManager.id === node.id) { - payload.parentNode.taskManagers.splice(j, 1) - } - } - } - if (node.tasks !== undefined) { - while (node.tasks.length > 0) { - deleteTask(node.tasks[0], rootNodes) - } - } - completeDeletion(node, rootNodes) - destroyUiObject(node) - cleanNode(node) - } - - function deleteTask (node, rootNodes) { - let payload = node.payload - if (payload.parentNode !== undefined) { - for (let j = 0; j < payload.parentNode.tasks.length; j++) { - let task = payload.parentNode.tasks[j] - if (task.id === node.id) { - payload.parentNode.tasks.splice(j, 1) - } - } - } - if (node.bot !== undefined) { - deleteBotInstance(node.bot, rootNodes) - } - completeDeletion(node, rootNodes) - destroyUiObject(node) - cleanNode(node) - } - - function deleteBotInstance (node, rootNodes) { - let payload = node.payload - if (payload.parentNode !== undefined) { - payload.parentNode.bot = undefined - } - if (node.processes !== undefined) { - while (node.processes.length > 0) { - deleteProcessInstance(node.processes[0], rootNodes) - } - } - - completeDeletion(node, rootNodes) - destroyUiObject(node) - cleanNode(node) - } - - function deleteProcessInstance (node, rootNodes) { - let payload = node.payload - if (payload.parentNode !== undefined) { - for (let j = 0; j < payload.parentNode.processes.length; j++) { - let task = payload.parentNode.processes[j] - if (task.id === node.id) { - payload.parentNode.processes.splice(j, 1) - } - } - } - - if (node.session !== undefined) { - switch (node.session.type) { - case 'Backtesting Session': { - deleteBacktestingSession(node.session, rootNodes) - break - } - case 'Live Trading Session': { - deleteLiveTradingSession(node.session, rootNodes) - break - } - case 'Fordward Testing Session': { - deleteFordwardTestingSession(node.session, rootNodes) - break - } - case 'Paper Trading Session': { - deletePaperTradingSession(node.session, rootNodes) - break - } - } - } - - completeDeletion(node, rootNodes) - destroyUiObject(node) - cleanNode(node) - } - - function deleteBacktestingSession (node, rootNodes) { - deleteSession(node, rootNodes) - } - - function deleteLiveTradingSession (node, rootNodes) { - deleteSession(node, rootNodes) - } - - function deleteFordwardTestingSession (node, rootNodes) { - deleteSession(node, rootNodes) - } - - function deletePaperTradingSession (node, rootNodes) { - deleteSession(node, rootNodes) - } - - function deleteSession (node, rootNodes) { - let payload = node.payload - - if (payload.parentNode !== undefined) { - payload.parentNode.session = undefined - } - - if (node.parameters !== undefined) { - deleteParameters(node.parameters, rootNodes) - } - - if (node.layerManager !== undefined) { - deleteLayerManager(node.layerManager, rootNodes) - } - - if (node.socialBots !== undefined) { - deleteSocialBots(node.socialBots, rootNodes) - } - - completeDeletion(node, rootNodes) - destroyUiObject(node) - cleanNode(node) - } - - function deletePersonalData (node, rootNodes) { - let payload = node.payload - - if (payload.parentNode !== undefined) { - payload.parentNode.personalData = undefined - } - - if (node.exchangeAccounts !== undefined) { - while (node.exchangeAccounts.length > 0) { - deleteExchangeAccount(node.exchangeAccounts[0], rootNodes) - } - } - - completeDeletion(node, rootNodes) - destroyUiObject(node) - cleanNode(node) - } - - function deleteExchangeAccount (node, rootNodes) { - let payload = node.payload - if (payload.parentNode !== undefined) { - for (let j = 0; j < payload.parentNode.exchangeAccounts.length; j++) { - let exchangeAccount = payload.parentNode.exchangeAccounts[j] - if (exchangeAccount.id === node.id) { - payload.parentNode.exchangeAccounts.splice(j, 1) - } - } - } - if (node.assets !== undefined) { - while (node.assets.length > 0) { - deleteExchangeAccountAsset(node.assets[0], rootNodes) - } - } - if (node.keys !== undefined) { - while (node.keys.length > 0) { - deleteExchangeAccountKey(node.keys[0], rootNodes) - } - } - - completeDeletion(node, rootNodes) - destroyUiObject(node) - cleanNode(node) - } - - function deleteExchangeAccountAsset (node, rootNodes) { - let payload = node.payload - if (payload.parentNode !== undefined) { - for (let j = 0; j < payload.parentNode.assets.length; j++) { - let asset = payload.parentNode.assets[j] - if (asset.id === node.id) { - payload.parentNode.assets.splice(j, 1) - } - } - } else { - completeDeletion(node, rootNodes) - } - destroyUiObject(node) - cleanNode(node) - } - - function deleteExchangeAccountKey (node, rootNodes) { - let payload = node.payload - if (payload.parentNode !== undefined) { - if (payload.parentNode.keys !== undefined) { - for (let j = 0; j < payload.parentNode.keys.length; j++) { - let key = payload.parentNode.keys[j] - if (key.id === node.id) { - payload.parentNode.keys.splice(j, 1) - } - } - } - if (payload.parentNode.key !== undefined) { - payload.parentNode.key = undefined - } - } else { - completeDeletion(node, rootNodes) - } - destroyUiObject(node) - cleanNode(node) - } - - function deleteTradingSystem (node, rootNodes) { - let payload = node.payload - - if (payload.parentNode !== undefined) { - payload.parentNode.tradingSystem = undefined - } - - if (node.strategies !== undefined) { - while (node.strategies.length > 0) { - deleteStrategy(node.strategies[0], rootNodes) - } - } - - if (node.parameters !== undefined) { - deleteParameters(node.parameters, rootNodes) - } - - completeDeletion(node, rootNodes) - destroyUiObject(node) - cleanNode(node) - } - - function deleteParameters (node, rootNodes) { - let payload = node.payload - if (payload.parentNode !== undefined) { - payload.parentNode.parameters = undefined - } else { - completeDeletion(node, rootNodes) - } - if (node.baseAsset !== undefined) { - deleteBaseAsset(node.baseAsset, rootNodes) - } - if (node.timeRange !== undefined) { - deleteTimeRange(node.timeRange, rootNodes) - } - if (node.timePeriod !== undefined) { - deleteTimePeriod(node.timePeriod, rootNodes) - } - if (node.slippage !== undefined) { - deleteSlippage(node.slippage, rootNodes) - } - if (node.feeStructure !== undefined) { - deleteFeeStructure(node.feeStructure, rootNodes) - } - if (node.key !== undefined) { - deleteExchangeAccountKey(node.key, rootNodes) - } - destroyUiObject(node) - cleanNode(node) - } - - function deleteBaseAsset (node, rootNodes) { - let payload = node.payload - if (payload.parentNode !== undefined) { - payload.parentNode.baseAsset = undefined - } else { - completeDeletion(node, rootNodes) - } - destroyUiObject(node) - cleanNode(node) - } - - function deleteTimeRange (node, rootNodes) { - let payload = node.payload - if (payload.parentNode !== undefined) { - payload.parentNode.timeRange = undefined - } else { - completeDeletion(node, rootNodes) - } - destroyUiObject(node) - cleanNode(node) - } - - function deleteTimePeriod (node, rootNodes) { - let payload = node.payload - if (payload.parentNode !== undefined) { - payload.parentNode.timePeriod = undefined - } else { - completeDeletion(node, rootNodes) - } - destroyUiObject(node) - cleanNode(node) - } - - function deleteSlippage (node, rootNodes) { - let payload = node.payload - if (payload.parentNode !== undefined) { - payload.parentNode.slippage = undefined - } else { - completeDeletion(node, rootNodes) - } - destroyUiObject(node) - cleanNode(node) - } - - function deleteFeeStructure (node, rootNodes) { - let payload = node.payload - if (payload.parentNode !== undefined) { - payload.parentNode.feeStructure = undefined - } else { - completeDeletion(node, rootNodes) - } - destroyUiObject(node) - cleanNode(node) - } - - function deleteStrategy (node, rootNodes) { - let payload = node.payload - if (payload.parentNode !== undefined) { - for (let j = 0; j < payload.parentNode.strategies.length; j++) { - let strategy = payload.parentNode.strategies[j] - if (strategy.id === node.id) { - payload.parentNode.strategies.splice(j, 1) - } - } - } else { - completeDeletion(node, rootNodes) - } - if (node.triggerStage !== undefined) { - deleteTriggerStage(node.triggerStage, rootNodes) - } - if (node.openStage !== undefined) { - deleteOpenStage(node.openStage, rootNodes) - } - if (node.manageStage !== undefined) { - deleteManageStage(node.manageStage, rootNodes) - } - if (node.closeStage !== undefined) { - deleteCloseStage(node.closeStage, rootNodes) - } - destroyUiObject(node) - cleanNode(node) - } - - function deleteTriggerStage (node, rootNodes) { - let payload = node.payload - if (payload.parentNode !== undefined) { - payload.parentNode.triggerStage = undefined - } else { - completeDeletion(node, rootNodes) - } - if (node.triggerOn !== undefined) { - deleteEvent(node.triggerOn, rootNodes) - } - if (node.triggerOff !== undefined) { - deleteEvent(node.triggerOff, rootNodes) - } - if (node.takePosition !== undefined) { - deleteEvent(node.takePosition, rootNodes) - } - destroyUiObject(node) - cleanNode(node) - } - - function deleteOpenStage (node, rootNodes) { - let payload = node.payload - if (payload.parentNode !== undefined) { - payload.parentNode.openStage = undefined - } else { - completeDeletion(node, rootNodes) - } - if (node.initialDefinition !== undefined) { - deleteInitialDefinition(node.initialDefinition, rootNodes) - } - - if (node.openExecution !== undefined) { - deleteOpenExecution(node.openExecution, rootNodes) - } - - destroyUiObject(node) - cleanNode(node) - } - - function deleteManageStage (node, rootNodes) { - let payload = node.payload - if (payload.parentNode !== undefined) { - payload.parentNode.manageStage = undefined - } else { - completeDeletion(node, rootNodes) - } - if (node.stopLoss !== undefined) { - deleteManagedItem(node.stopLoss, rootNodes) - } - if (node.takeProfit !== undefined) { - deleteManagedItem(node.takeProfit, rootNodes) - } - destroyUiObject(node) - cleanNode(node) - } - - function deleteCloseStage (node, rootNodes) { - let payload = node.payload - if (payload.parentNode !== undefined) { - payload.parentNode.closeStage = undefined - } else { - completeDeletion(node, rootNodes) - } - if (node.closeExecution !== undefined) { - deleteCloseExecution(node.closeExecution, rootNodes) - } - destroyUiObject(node) - cleanNode(node) - } - - function deletePositionSize (node, rootNodes) { - let payload = node.payload - if (payload.parentNode !== undefined) { - payload.parentNode.positionSize = undefined - } else { - completeDeletion(node, rootNodes) - } - if (node.formula !== undefined) { - deleteFormula(node.formula, rootNodes) - } - destroyUiObject(node) - cleanNode(node) - } - - function deletePositionRate (node, rootNodes) { - let payload = node.payload - if (payload.parentNode !== undefined) { - payload.parentNode.positionRate = undefined - } else { - completeDeletion(node, rootNodes) - } - if (node.formula !== undefined) { - deleteFormula(node.formula, rootNodes) - } - destroyUiObject(node) - cleanNode(node) - } - - function deleteInitialDefinition (node, rootNodes) { - let payload = node.payload - if (payload.parentNode !== undefined) { - payload.parentNode.initialDefinition = undefined - } else { - completeDeletion(node, rootNodes) - } - if (node.stopLoss !== undefined) { - deleteManagedItem(node.stopLoss, rootNodes) - } - if (node.takeProfit !== undefined) { - deleteManagedItem(node.takeProfit, rootNodes) - } - if (node.positionSize !== undefined) { - deletePositionSize(node.positionSize, rootNodes) - } - if (node.positionRate !== undefined) { - deletePositionSize(node.positionRate, rootNodes) - } - destroyUiObject(node) - cleanNode(node) - } - - function deleteOpenExecution (node, rootNodes) { - let payload = node.payload - if (payload.parentNode !== undefined) { - payload.parentNode.openExecution = undefined - } else { - completeDeletion(node, rootNodes) - } - destroyUiObject(node) - cleanNode(node) - } - - function deleteCloseExecution (node, rootNodes) { - let payload = node.payload - if (payload.parentNode !== undefined) { - payload.parentNode.closeExecution = undefined - } else { - completeDeletion(node, rootNodes) - } - destroyUiObject(node) - cleanNode(node) - } - - function deleteEvent (node, rootNodes) { - let payload = node.payload - if (payload.parentNode !== undefined) { - switch (node.type) { - case 'Trigger On Event': { - payload.parentNode.triggerOn = undefined - break - } - case 'Trigger Off Event': { - payload.parentNode.triggerOff = undefined - break - } - case 'Take Position Event': { - payload.parentNode.takePosition = undefined - break - } - case 'Next Phase Event': { - payload.parentNode.nextPhaseEvent = undefined - break - } - } - } else { - completeDeletion(node, rootNodes) - } - - if (node.situations !== undefined) { - while (node.situations.length > 0) { - deleteSituation(node.situations[0], rootNodes) - } - } - - if (node.announcements !== undefined) { - while (node.announcements.length > 0) { - deleteAnnouncement(node.announcements[0], rootNodes) - } - } - destroyUiObject(node) - cleanNode(node) - } - - function deleteManagedItem (node, rootNodes) { - let payload = node.payload - if (payload.parentNode !== undefined) { - switch (node.type) { - case 'Stop': { - payload.parentNode.stopLoss = undefined - break - } - case 'Take Profit': { - payload.parentNode.takeProfit = undefined - break - } - } - } else { - completeDeletion(node, rootNodes) - } - - if (node.phases !== undefined) { - while (node.phases.length > 0) { - deletePhase(node.phases[0], rootNodes) - } - } - - destroyUiObject(node) - cleanNode(node) - } - - function deletePhase (node, rootNodes) { - let payload = node.payload - if (payload.parentNode !== undefined) { - for (let k = 0; k < payload.parentNode.phases.length; k++) { - let phase = payload.parentNode.phases[k] - if (phase.id === node.id) { - /* Before deleting this phase we need to give its chainParent to the next phase down the chain */ - if (k < payload.parentNode.phases.length - 1) { - payload.parentNode.phases[k + 1].payload.chainParent = payload.chainParent - } - /* Continue destroying this phase */ - payload.parentNode.phases.splice(k, 1) - } - } - } else { - completeDeletion(node, rootNodes) - } - - if (node.formula !== undefined) { - deleteFormula(node.formula, rootNodes) - } - - if (node.nextPhaseEvent !== undefined) { - deleteEvent(node.nextPhaseEvent, rootNodes) - } - - if (node.announcements !== undefined) { - while (node.announcements.length > 0) { - deleteAnnouncement(node.announcements[0], rootNodes) - } - } - destroyUiObject(node) - cleanNode(node) - } - - function deleteFormula (node, rootNodes) { - let payload = node.payload - if (payload.parentNode !== undefined) { - payload.parentNode.formula = undefined - } else { - completeDeletion(node, rootNodes) - } - - destroyUiObject(node) - cleanNode(node) - } - - function deleteSituation (node, rootNodes) { - let payload = node.payload - if (payload.parentNode !== undefined) { - for (let j = 0; j < payload.parentNode.situations.length; j++) { - let situation = payload.parentNode.situations[j] - if (situation.id === node.id) { - if (situation.conditions !== undefined) { - while (situation.conditions.length > 0) { - let condition = situation.conditions[0] - deleteCondition(condition, rootNodes) - } - } - - situation.conditions = [] - payload.parentNode.situations.splice(j, 1) - destroyUiObject(situation) - cleanNode(situation) - return - } - } - } else { - if (node.conditions !== undefined) { - while (node.conditions.length > 0) { - let condition = node.conditions[0] - deleteCondition(condition, rootNodes) - } - } - - node.conditions = [] - completeDeletion(node, rootNodes) - destroyUiObject(node) - cleanNode(node) - } - } - - function deleteCondition (node, rootNodes) { - let payload = node.payload - if (payload.parentNode !== undefined) { - for (let i = 0; i < payload.parentNode.conditions.length; i++) { - let condition = payload.parentNode.conditions[i] - if (condition.id === node.id) { - payload.parentNode.conditions.splice(i, 1) - } - } - } else { - completeDeletion(node, rootNodes) - } - if (node.javascriptCode !== undefined) { - deleteJavascriptCode(node.javascriptCode, rootNodes) - } - destroyUiObject(node) - cleanNode(node) - } - - function deleteJavascriptCode (node, rootNodes) { - let payload = node.payload - if (payload.parentNode !== undefined) { - payload.parentNode.javascriptCode = undefined - } else { - completeDeletion(node, rootNodes) - } - - destroyUiObject(node) - cleanNode(node) - } - function completeDeletion (node, rootNodes) { for (let i = 0; i < rootNodes.length; i++) { let rootNode = rootNodes[i] diff --git a/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js b/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js index 83d2a79dd..cd25e4d32 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js +++ b/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js @@ -11,6 +11,7 @@ function newProtocolNode () { function getProtocolNode (node, removePersonalData, parseCode, includeIds, includePayload, includeReferencesInSavedPayload, lightingPath) { if (node === undefined) { return } + if (node.payload === undefined) { return } let nodeDefinition = APP_SCHEMA_MAP.get(node.type) if (nodeDefinition !== undefined) { diff --git a/DesignerSpace/Workspace/Workspace.js b/DesignerSpace/Workspace/Workspace.js index 21b84ffd5..44cd63e67 100644 --- a/DesignerSpace/Workspace/Workspace.js +++ b/DesignerSpace/Workspace/Workspace.js @@ -689,282 +689,7 @@ function newWorkspace () { functionLibraryUiObjectsFromNodes.addPersonalData(payload.node) } break - case 'Delete Team': { - functionLibraryNodeDeleter.deleteTeam(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Sensor Bot': { - functionLibraryNodeDeleter.deleteSensorBot(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Indicator Bot': { - functionLibraryNodeDeleter.deleteIndicatorBot(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Trading Bot': { - functionLibraryNodeDeleter.deleteTradingBot(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Process Definition': { - functionLibraryNodeDeleter.deleteProcessDefinition(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Process Output': { - functionLibraryNodeDeleter.deleteProcessOutput(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Process Dependencies': { - functionLibraryNodeDeleter.deleteProcessDependencies(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Status Report': { - functionLibraryNodeDeleter.deleteStatusReport(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Execution Started Event': { - functionLibraryNodeDeleter.deleteExecutionStartedEvent(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Execution Finished Event': { - functionLibraryNodeDeleter.deleteExecutionFinishedEvent(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Calculations Procedure': { - functionLibraryNodeDeleter.deleteCalculationsProcedure(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Data Building Procedure': { - functionLibraryNodeDeleter.deleteDataBuildingProcedure(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Procedure Initialization': { - functionLibraryNodeDeleter.deleteProcedureInitialization(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Procedure Loop': { - functionLibraryNodeDeleter.deleteProcedureLoop(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Output Dataset': { - functionLibraryNodeDeleter.deleteOutputDataset(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Status Dependency': { - functionLibraryNodeDeleter.deleteStatusDependency(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Data Dependency': { - functionLibraryNodeDeleter.deleteDataDependency(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Product Definition': { - functionLibraryNodeDeleter.deleteProductDefinition(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Record Definition': { - functionLibraryNodeDeleter.deleteRecordDefinition(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Record Property': { - functionLibraryNodeDeleter.deleteRecordProperty(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Dataset Definition': { - functionLibraryNodeDeleter.deleteDatasetDefinition(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Plotter': { - functionLibraryNodeDeleter.deletePlotter(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Plotter Module': { - functionLibraryNodeDeleter.deletePlotterModule(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Network': { - functionLibraryNodeDeleter.deleteNetwork(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Network Node': { - functionLibraryNodeDeleter.deleteNetworkNode(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Social Bots': { - functionLibraryNodeDeleter.deleteSocialBots(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Social Bot': { - functionLibraryNodeDeleter.deleteSocialBot(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Announcement': { - functionLibraryNodeDeleter.deleteAnnouncement(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Layer Manager': { - functionLibraryNodeDeleter.deleteLayerManager(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Layer': { - functionLibraryNodeDeleter.deleteLayer(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Task Manager': { - functionLibraryNodeDeleter.deleteTaskManager(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Task': { - functionLibraryNodeDeleter.deleteTask(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Sensor Bot Instance': { - functionLibraryNodeDeleter.deleteSensorBotInstance(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Indicator Bot Instance': { - functionLibraryNodeDeleter.deleteIndicatorBotInstance(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Trading Bot Instance': { - functionLibraryNodeDeleter.deleteTradingBotInstance(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Process Instance': { - functionLibraryNodeDeleter.deleteProcessInstance(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Backtesting Session': { - functionLibraryNodeDeleter.deleteBacktestingSession(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Live Trading Session': { - functionLibraryNodeDeleter.deleteLiveTradingSession(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Fordward Testing Session': { - functionLibraryNodeDeleter.deleteFordwardTestingSession(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Paper Trading Session': { - functionLibraryNodeDeleter.deletePaperTradingSession(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Trading System': { - functionLibraryNodeDeleter.deleteTradingSystem(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Parameters': { - functionLibraryNodeDeleter.deleteParameters(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Base Asset': { - functionLibraryNodeDeleter.deleteBaseAsset(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Time Range': { - functionLibraryNodeDeleter.deleteTimeRange(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Time Period': { - functionLibraryNodeDeleter.deleteTimePeriod(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Slippage': { - functionLibraryNodeDeleter.deleteSlippage(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Fee Structure': { - functionLibraryNodeDeleter.deleteFeeStructure(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Strategy': { - functionLibraryNodeDeleter.deleteStrategy(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Trigger Stage': { - functionLibraryNodeDeleter.deleteTriggerStage(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Open Stage': { - functionLibraryNodeDeleter.deleteOpenStage(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Manage Stage': { - functionLibraryNodeDeleter.deleteManageStage(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Close Stage': { - functionLibraryNodeDeleter.deleteCloseStage(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Position Size': { - functionLibraryNodeDeleter.deletePositionSize(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Position Rate': { - functionLibraryNodeDeleter.deletePositionSize(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Initial Definition': { - functionLibraryNodeDeleter.deleteInitialDefinition(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Open Execution': { - functionLibraryNodeDeleter.deleteOpenExecution(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Close Execution': { - functionLibraryNodeDeleter.deleteCloseExecution(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Event': { - functionLibraryNodeDeleter.deleteEvent(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Managed Item': { - functionLibraryNodeDeleter.deleteManagedItem(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Phase': { - functionLibraryNodeDeleter.deletePhase(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Formula': { - functionLibraryNodeDeleter.deleteFormula(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Situation': { - functionLibraryNodeDeleter.deleteSituation(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Condition': { - functionLibraryNodeDeleter.deleteCondition(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Code': { - functionLibraryNodeDeleter.deleteJavascriptCode(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Exchange Account': { - functionLibraryNodeDeleter.deleteExchangeAccount(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Exchange Account Asset': { - functionLibraryNodeDeleter.deleteExchangeAccountAsset(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Exchange Account Key': { - functionLibraryNodeDeleter.deleteExchangeAccountKey(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Personal Data': { - functionLibraryNodeDeleter.deletePersonalData(payload.node, thisObject.workspaceNode.rootNodes) - break - } - case 'Delete Definition': { - functionLibraryNodeDeleter.deleteDefinition(payload.node, thisObject.workspaceNode.rootNodes) - break - } + default: } diff --git a/FloatingSpace/FloatingObject.js b/FloatingSpace/FloatingObject.js index 4c2eec098..45137cfa1 100644 --- a/FloatingSpace/FloatingObject.js +++ b/FloatingSpace/FloatingObject.js @@ -330,6 +330,7 @@ function newFloatingObject () { } function removeFocus () { + if (thisObject.payload === undefined) { return } if (thisObject.isOnFocus === true) { thisObject.targetRadius = thisObject.rawRadius * 1 thisObject.targetImageSize = thisObject.rawImageSize * 1 From 37b1baf757d81181bac88c17891fe758c1ddede1 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 23 Dec 2019 14:11:40 +0100 Subject: [PATCH 007/264] onFocus working with APP SCHEMA --- .../Workspace/FunctionLibraries/OnFocus.js | 1134 +---------------- 1 file changed, 31 insertions(+), 1103 deletions(-) diff --git a/DesignerSpace/Workspace/FunctionLibraries/OnFocus.js b/DesignerSpace/Workspace/FunctionLibraries/OnFocus.js index 481e3983b..abda9e954 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/OnFocus.js +++ b/DesignerSpace/Workspace/FunctionLibraries/OnFocus.js @@ -6,1115 +6,43 @@ function newOnFocus () { function getNodeThatIsOnFocus (node) { if (node === undefined) { return } - switch (node.type) { - case 'Javascript Code': - { - if (node.payload.uiObject.isOnFocus === true) { - return node - } - } - case 'Condition': - { - let child - child = getNodeThatIsOnFocus(node.javascriptCode) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Situation': { - let child - for (let m = 0; m < node.conditions.length; m++) { - child = getNodeThatIsOnFocus(node.conditions[m]) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Formula': - { - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Next Phase Event': - { - let child - for (let m = 0; m < node.situations.length; m++) { - child = getNodeThatIsOnFocus(node.situations[m]) - if (child !== undefined) { - return child - } - } - for (let m = 0; m < node.announcements.length; m++) { - child = getNodeThatIsOnFocus(node.announcements[m]) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Phase': { - let child - child = getNodeThatIsOnFocus(node.formula) - if (child !== undefined) { - return child - } - child = getNodeThatIsOnFocus(node.nextPhaseEvent) - if (child !== undefined) { - return child - } - for (let m = 0; m < node.announcements.length; m++) { - child = getNodeThatIsOnFocus(node.announcements[m]) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Stop': { - let child - for (let m = 0; m < node.phases.length; m++) { - child = getNodeThatIsOnFocus(node.phases[m]) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Take Profit': { - let child - for (let m = 0; m < node.phases.length; m++) { - child = getNodeThatIsOnFocus(node.phases[m]) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Take Position Event': { - let child - for (let m = 0; m < node.situations.length; m++) { - child = getNodeThatIsOnFocus(node.situations[m]) - if (child !== undefined) { - return child - } - } - for (let m = 0; m < node.announcements.length; m++) { - child = getNodeThatIsOnFocus(node.announcements[m]) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Trigger On Event': { - let child - for (let m = 0; m < node.situations.length; m++) { - child = getNodeThatIsOnFocus(node.situations[m]) - if (child !== undefined) { - return child - } - } - for (let m = 0; m < node.announcements.length; m++) { - child = getNodeThatIsOnFocus(node.announcements[m]) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Trigger Off Event': { - let child - for (let m = 0; m < node.situations.length; m++) { - child = getNodeThatIsOnFocus(node.situations[m]) - if (child !== undefined) { - return child - } - } - for (let m = 0; m < node.announcements.length; m++) { - child = getNodeThatIsOnFocus(node.announcements[m]) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Initial Definition': { - let child - child = getNodeThatIsOnFocus(node.stopLoss) - if (child !== undefined) { - return child - } - child = getNodeThatIsOnFocus(node.takeProfit) - if (child !== undefined) { - return child - } - child = getNodeThatIsOnFocus(node.positionSize) - if (child !== undefined) { - return child - } - child = getNodeThatIsOnFocus(node.positionRate) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Open Execution': { - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Close Execution': { - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Position Size': { - let child - child = getNodeThatIsOnFocus(node.formula) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Position Rate': { - let child - child = getNodeThatIsOnFocus(node.formula) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Trigger Stage': { - let child - child = getNodeThatIsOnFocus(node.triggerOn) - if (child !== undefined) { - return child - } - child = getNodeThatIsOnFocus(node.triggerOff) - if (child !== undefined) { - return child - } - child = getNodeThatIsOnFocus(node.takePosition) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Open Stage': { - let child - child = getNodeThatIsOnFocus(node.initialDefinition) - if (child !== undefined) { - return child - } - child = getNodeThatIsOnFocus(node.openExecution) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Manage Stage': { - let child - child = getNodeThatIsOnFocus(node.stopLoss) - if (child !== undefined) { - return child - } - child = getNodeThatIsOnFocus(node.takeProfit) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Close Stage': { - let child - child = getNodeThatIsOnFocus(node.closeExecution) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Strategy': { - let child - child = getNodeThatIsOnFocus(node.triggerStage) - if (child !== undefined) { - return child - } - child = getNodeThatIsOnFocus(node.openStage) - if (child !== undefined) { - return child - } - child = getNodeThatIsOnFocus(node.manageStage) - if (child !== undefined) { - return child - } - child = getNodeThatIsOnFocus(node.closeStage) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Base Asset': { - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Time Range': { - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Time Period': { - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Slippage': { - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Fee Structure': { - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Parameters': { - let child - child = getNodeThatIsOnFocus(node.baseAsset) - if (child !== undefined) { - return child - } - child = getNodeThatIsOnFocus(node.timeRange) - if (child !== undefined) { - return child - } - child = getNodeThatIsOnFocus(node.timePeriod) - if (child !== undefined) { - return child - } - child = getNodeThatIsOnFocus(node.slippage) - if (child !== undefined) { - return child - } - child = getNodeThatIsOnFocus(node.feeStructure) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Trading System': { - let child - child = getNodeThatIsOnFocus(node.parameters) - if (child !== undefined) { - return child - } - for (let m = 0; m < node.strategies.length; m++) { - child = getNodeThatIsOnFocus(node.strategies[m]) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Personal Data': { - let child - for (let m = 0; m < node.exchangeAccounts.length; m++) { - child = getNodeThatIsOnFocus(node.exchangeAccounts[m]) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Exchange Account': { - let child - for (let m = 0; m < node.assets.length; m++) { - child = getNodeThatIsOnFocus(node.assets[m]) - if (child !== undefined) { - return child - } - } - for (let m = 0; m < node.keys.length; m++) { - child = getNodeThatIsOnFocus(node.keys[m]) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Exchange Account Asset': { - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Exchange Account Key': { - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Social Bots': { - let child - for (let m = 0; m < node.bots.length; m++) { - child = getNodeThatIsOnFocus(node.bots[m]) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Telegram Bot': { - let child - for (let m = 0; m < node.announcements.length; m++) { - child = getNodeThatIsOnFocus(node.announcements[m]) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Announcement': { - child = getNodeThatIsOnFocus(node.formula) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Layer Manager': { - let child - for (let m = 0; m < node.layers.length; m++) { - child = getNodeThatIsOnFocus(node.layers[m]) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Layer': { - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Task Manager': { - let child - for (let m = 0; m < node.tasks.length; m++) { - child = getNodeThatIsOnFocus(node.tasks[m]) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Task': { - let child - child = getNodeThatIsOnFocus(node.bot) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Sensor Bot Instance': { - let child - for (let m = 0; m < node.processes.length; m++) { - child = getNodeThatIsOnFocus(node.processes[m]) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Indicator Bot Instance': { - let child - for (let m = 0; m < node.processes.length; m++) { - child = getNodeThatIsOnFocus(node.processes[m]) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Trading Bot Instance': { - let child - for (let m = 0; m < node.processes.length; m++) { - child = getNodeThatIsOnFocus(node.processes[m]) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Process Instance': { - let child - child = getNodeThatIsOnFocus(node.session) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } + if (node.payload === undefined) { return } + let nodeDefinition = APP_SCHEMA_MAP.get(node.type) + if (nodeDefinition !== undefined) { + /* First we ask the question to ourself */ + if (node.payload.uiObject.isOnFocus === true) { + return node } - case 'Backtesting Session': { - let child - child = getNodeThatIsOnFocus(node.parameters) - if (child !== undefined) { - return child - } - child = getNodeThatIsOnFocus(node.layerManager) - if (child !== undefined) { - return child - } - child = getNodeThatIsOnFocus(node.socialBots) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } + /* Then we check all of its own children nodes. */ + if (node.payload.floatingObject.isCollapsed !== true) { + if (nodeDefinition.properties !== undefined) { + for (let i = 0; i < nodeDefinition.properties.length; i++) { + let property = nodeDefinition.properties[i] - case 'Live Trading Session': { - let child - child = getNodeThatIsOnFocus(node.parameters) - if (child !== undefined) { - return child - } - child = getNodeThatIsOnFocus(node.layerManager) - if (child !== undefined) { - return child - } - child = getNodeThatIsOnFocus(node.socialBots) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - - case 'Fordward Testing Session': { - let child - child = getNodeThatIsOnFocus(node.parameters) - if (child !== undefined) { - return child - } - child = getNodeThatIsOnFocus(node.layerManager) - if (child !== undefined) { - return child - } - child = getNodeThatIsOnFocus(node.socialBots) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - - case 'Paper Trading Session': { - let child - child = getNodeThatIsOnFocus(node.parameters) - if (child !== undefined) { - return child - } - child = getNodeThatIsOnFocus(node.layerManager) - if (child !== undefined) { - return child - } - child = getNodeThatIsOnFocus(node.socialBots) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - - case 'Network Node': { - let child - for (let m = 0; m < node.taskManagers.length; m++) { - child = getNodeThatIsOnFocus(node.taskManagers[m]) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Network': { - let child - for (let m = 0; m < node.networkNodes.length; m++) { - child = getNodeThatIsOnFocus(node.networkNodes[m]) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Definition': { - let child - child = getNodeThatIsOnFocus(node.tradingSystem) - if (child !== undefined) { - return child - } - child = getNodeThatIsOnFocus(node.personalData) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Team': { - let child - - for (let m = 0; m < node.sensorBots.length; m++) { - child = getNodeThatIsOnFocus(node.sensorBots[m]) - if (child !== undefined) { - return child - } - } - for (let m = 0; m < node.indicatorBots.length; m++) { - child = getNodeThatIsOnFocus(node.indicatorBots[m]) - if (child !== undefined) { - return child - } - } - for (let m = 0; m < node.tradingBots.length; m++) { - child = getNodeThatIsOnFocus(node.tradingBots[m]) - if (child !== undefined) { - return child - } - } - for (let m = 0; m < node.plotters.length; m++) { - child = getNodeThatIsOnFocus(node.plotters[m]) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Sensor Bot': { - let child - for (let m = 0; m < node.processes.length; m++) { - child = getNodeThatIsOnFocus(node.processes[m]) - if (child !== undefined) { - return child - } - } - for (let m = 0; m < node.products.length; m++) { - child = getNodeThatIsOnFocus(node.products[m]) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Indicator Bot': { - let child - for (let m = 0; m < node.processes.length; m++) { - child = getNodeThatIsOnFocus(node.processes[m]) - if (child !== undefined) { - return child - } - } - for (let m = 0; m < node.products.length; m++) { - child = getNodeThatIsOnFocus(node.products[m]) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Trading Bot': { - let child - for (let m = 0; m < node.processes.length; m++) { - child = getNodeThatIsOnFocus(node.processes[m]) - if (child !== undefined) { - return child - } - } - for (let m = 0; m < node.products.length; m++) { - child = getNodeThatIsOnFocus(node.products[m]) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Process Definition': { - let child - child = getNodeThatIsOnFocus(node.processOutput) - if (child !== undefined) { - return child - } - child = getNodeThatIsOnFocus(node.processDependencies) - if (child !== undefined) { - return child - } - child = getNodeThatIsOnFocus(node.statusReport) - if (child !== undefined) { - return child - } - child = getNodeThatIsOnFocus(node.executionStartedEvent) - if (child !== undefined) { - return child - } - child = getNodeThatIsOnFocus(node.executionFinishedEvent) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Process Output': { - let child - for (let m = 0; m < node.outputDatasets.length; m++) { - child = getNodeThatIsOnFocus(node.outputDatasets[m]) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Process Dependencies': { - let child - for (let m = 0; m < node.statusDependencies.length; m++) { - child = getNodeThatIsOnFocus(node.statusDependencies[m]) - if (child !== undefined) { - return child - } - } - for (let m = 0; m < node.dataDependencies.length; m++) { - child = getNodeThatIsOnFocus(node.dataDependencies[m]) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Status Report': { - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Execution Started Event': { - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Execution Finished Event': { - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Calculations Procedure': { - let child - child = getNodeThatIsOnFocus(node.initialization) - if (child !== undefined) { - return child - } - child = getNodeThatIsOnFocus(node.loop) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Data Building Procedure': { - let child - child = getNodeThatIsOnFocus(node.initialization) - if (child !== undefined) { - return child - } - child = getNodeThatIsOnFocus(node.loop) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Procedure Initialization': { - let child - child = getNodeThatIsOnFocus(node.javascriptCode) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Procedure Loop': { - let child - child = getNodeThatIsOnFocus(node.javascriptCode) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Output Dataset': { - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Status Dependency': { - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Data Dependency': { - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Product Definition': { - let child - child = getNodeThatIsOnFocus(node.record) - if (child !== undefined) { - return child - } - for (let m = 0; m < node.datasets.length; m++) { - child = getNodeThatIsOnFocus(node.datasets[m]) - if (child !== undefined) { - return child - } - } - child = getNodeThatIsOnFocus(node.calculations) - if (child !== undefined) { - return child - } - child = getNodeThatIsOnFocus(node.dataBuilding) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Record Definition': { - let child - for (let m = 0; m < node.properties.length; m++) { - child = getNodeThatIsOnFocus(node.properties[m]) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Record Property': { - let child - child = getNodeThatIsOnFocus(node.formula) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Dataset Definition': { - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Plotter': { - let child - for (let m = 0; m < node.modules.length; m++) { - child = getNodeThatIsOnFocus(node.modules[m]) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - case 'Plotter Module': { - let child - child = getNodeThatIsOnFocus(node.javascriptCode) - if (child !== undefined) { - return child - } - child = getNodeThatIsOnFocus(node.shapes) - if (child !== undefined) { - return child - } - for (let m = 0; m < node.panels.length; m++) { - child = getNodeThatIsOnFocus(node.panels[m]) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return - } - } - default: { - if (node.payload === undefined) { return } - let nodeDefinition = APP_SCHEMA_MAP.get(node.type) - if (nodeDefinition !== undefined) { - /* First we ask the question to ourself */ - if (node.payload.uiObject.isOnFocus === true) { - return node - } - - /* Then we check all of its own children nodes. */ - if (node.payload.floatingObject.isCollapsed !== true) { - if (nodeDefinition.properties !== undefined) { - for (let i = 0; i < nodeDefinition.properties.length; i++) { - let property = nodeDefinition.properties[i] - - switch (property.type) { - case 'node': { - if (node[property.name] !== undefined) { - let child - child = getNodeThatIsOnFocus(node[property.name]) - if (child !== undefined) { - return child - } - } + switch (property.type) { + case 'node': { + if (node[property.name] !== undefined) { + let child + child = getNodeThatIsOnFocus(node[property.name]) + if (child !== undefined) { + return child } - break - case 'array': { - let nodePropertyArray = node[property.name] - if (nodePropertyArray !== undefined) { - for (let m = 0; m < nodePropertyArray.length; m++) { - child = getNodeThatIsOnFocus(nodePropertyArray[m]) - if (child !== undefined) { - return child - } - } - } - } - break } } + break + case 'array': { + let nodePropertyArray = node[property.name] + if (nodePropertyArray !== undefined) { + for (let m = 0; m < nodePropertyArray.length; m++) { + child = getNodeThatIsOnFocus(nodePropertyArray[m]) + if (child !== undefined) { + return child + } + } + } + } + break } } } From 1faf3795e7cf384c8c34433b226fa4e9326bd635 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 23 Dec 2019 14:25:07 +0100 Subject: [PATCH 008/264] Shortcut keys with APP SCHEMA --- .../FunctionLibraries/ShortcutKeys.js | 1112 +---------------- 1 file changed, 30 insertions(+), 1082 deletions(-) diff --git a/DesignerSpace/Workspace/FunctionLibraries/ShortcutKeys.js b/DesignerSpace/Workspace/FunctionLibraries/ShortcutKeys.js index 532d19bbe..a9ac89651 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/ShortcutKeys.js +++ b/DesignerSpace/Workspace/FunctionLibraries/ShortcutKeys.js @@ -6,1094 +6,42 @@ function newShortcutKeys () { function getNodeByShortcutKey (node, searchingKey) { if (node === undefined) { return } - switch (node.type) { - case 'Javascript Code': - { - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Condition': - { - let child - child = getNodeByShortcutKey(node.javascriptCode, searchingKey) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Situation': { - let child - for (let m = 0; m < node.conditions.length; m++) { - child = getNodeByShortcutKey(node.conditions[m], searchingKey) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Formula': - { - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Next Phase Event': - { - let child - for (let m = 0; m < node.situations.length; m++) { - child = getNodeByShortcutKey(node.situations[m], searchingKey) - if (child !== undefined) { - return child - } - } - for (let m = 0; m < node.announcements.length; m++) { - child = getNodeByShortcutKey(node.announcements[m], searchingKey) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Phase': { - let child - child = getNodeByShortcutKey(node.formula, searchingKey) - if (child !== undefined) { - return child - } - child = getNodeByShortcutKey(node.nextPhaseEvent, searchingKey) - if (child !== undefined) { - return child - } - for (let m = 0; m < node.announcements.length; m++) { - child = getNodeByShortcutKey(node.announcements[m], searchingKey) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Stop': { - let child - for (let m = 0; m < node.phases.length; m++) { - child = getNodeByShortcutKey(node.phases[m], searchingKey) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Take Profit': { - let child - for (let m = 0; m < node.phases.length; m++) { - child = getNodeByShortcutKey(node.phases[m], searchingKey) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Take Position Event': { - let child - for (let m = 0; m < node.situations.length; m++) { - child = getNodeByShortcutKey(node.situations[m], searchingKey) - if (child !== undefined) { - return child - } - } - for (let m = 0; m < node.announcements.length; m++) { - child = getNodeByShortcutKey(node.announcements[m], searchingKey) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Trigger On Event': { - let child - for (let m = 0; m < node.situations.length; m++) { - child = getNodeByShortcutKey(node.situations[m], searchingKey) - if (child !== undefined) { - return child - } - } - for (let m = 0; m < node.announcements.length; m++) { - child = getNodeByShortcutKey(node.announcements[m], searchingKey) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Trigger Off Event': { - let child - for (let m = 0; m < node.situations.length; m++) { - child = getNodeByShortcutKey(node.situations[m], searchingKey) - if (child !== undefined) { - return child - } - } - for (let m = 0; m < node.announcements.length; m++) { - child = getNodeByShortcutKey(node.announcements[m], searchingKey) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Initial Definition': { - let child - child = getNodeByShortcutKey(node.stopLoss, searchingKey) - if (child !== undefined) { - return child - } - child = getNodeByShortcutKey(node.takeProfit, searchingKey) - if (child !== undefined) { - return child - } - child = getNodeByShortcutKey(node.positionSize, searchingKey) - if (child !== undefined) { - return child - } - child = getNodeByShortcutKey(node.positionRate, searchingKey) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Open Execution': { - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Close Execution': { - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Position Size': { - let child - child = getNodeByShortcutKey(node.formula, searchingKey) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Position Rate': { - let child - child = getNodeByShortcutKey(node.formula, searchingKey) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Trigger Stage': { - let child - child = getNodeByShortcutKey(node.triggerOn, searchingKey) - if (child !== undefined) { - return child - } - child = getNodeByShortcutKey(node.triggerOff, searchingKey) - if (child !== undefined) { - return child - } - child = getNodeByShortcutKey(node.takePosition, searchingKey) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Open Stage': { - let child - child = getNodeByShortcutKey(node.initialDefinition, searchingKey) - if (child !== undefined) { - return child - } - child = getNodeByShortcutKey(node.openExecution, searchingKey) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Manage Stage': { - let child - child = getNodeByShortcutKey(node.stopLoss, searchingKey) - if (child !== undefined) { - return child - } - child = getNodeByShortcutKey(node.takeProfit, searchingKey) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Close Stage': { - let child - child = getNodeByShortcutKey(node.closeExecution, searchingKey) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Strategy': { - let child - child = getNodeByShortcutKey(node.triggerStage, searchingKey) - if (child !== undefined) { - return child - } - child = getNodeByShortcutKey(node.openStage, searchingKey) - if (child !== undefined) { - return child - } - child = getNodeByShortcutKey(node.manageStage, searchingKey) - if (child !== undefined) { - return child - } - child = getNodeByShortcutKey(node.closeStage, searchingKey) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Base Asset': { - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Time Range': { - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Time Period': { - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Slippage': { - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Fee Structure': { - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Parameters': { - let child - child = getNodeByShortcutKey(node.baseAsset, searchingKey) - if (child !== undefined) { - return child - } - child = getNodeByShortcutKey(node.timeRange, searchingKey) - if (child !== undefined) { - return child - } - child = getNodeByShortcutKey(node.timePeriod, searchingKey) - if (child !== undefined) { - return child - } - child = getNodeByShortcutKey(node.slippage, searchingKey) - if (child !== undefined) { - return child - } - child = getNodeByShortcutKey(node.feeStructure, searchingKey) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Trading System': { - let child - child = getNodeByShortcutKey(node.parameters, searchingKey) - if (child !== undefined) { - return child - } - for (let m = 0; m < node.strategies.length; m++) { - child = getNodeByShortcutKey(node.strategies[m], searchingKey) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Personal Data': { - let child - for (let m = 0; m < node.exchangeAccounts.length; m++) { - child = getNodeByShortcutKey(node.exchangeAccounts[m], searchingKey) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Exchange Account': { - let child - for (let m = 0; m < node.assets.length; m++) { - child = getNodeByShortcutKey(node.assets[m], searchingKey) - if (child !== undefined) { - return child - } - } - for (let m = 0; m < node.keys.length; m++) { - child = getNodeByShortcutKey(node.keys[m], searchingKey) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Exchange Account Asset': { - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Exchange Account Key': { - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Social Bots': { - let child - for (let m = 0; m < node.bots.length; m++) { - child = getNodeByShortcutKey(node.bots[m], searchingKey) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Telegram Bot': { - let child - for (let m = 0; m < node.announcements.length; m++) { - child = getNodeByShortcutKey(node.announcements[m], searchingKey) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Announcement': { - let child - child = getNodeByShortcutKey(node.formula, searchingKey) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Layer Manager': { - let child - for (let m = 0; m < node.layers.length; m++) { - child = getNodeByShortcutKey(node.layers[m], searchingKey) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Layer': { - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Task Manager': { - let child - for (let m = 0; m < node.tasks.length; m++) { - child = getNodeByShortcutKey(node.tasks[m], searchingKey) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Task': { - let child - child = getNodeByShortcutKey(node.bot, searchingKey) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Sensor Bot Instance': { - let child - for (let m = 0; m < node.processes.length; m++) { - child = getNodeByShortcutKey(node.processes[m], searchingKey) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Indicator Bot Instance': { - let child - for (let m = 0; m < node.processes.length; m++) { - child = getNodeByShortcutKey(node.processes[m], searchingKey) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Trading Bot Instance': { - let child - for (let m = 0; m < node.processes.length; m++) { - child = getNodeByShortcutKey(node.processes[m], searchingKey) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Process Instance': { - let child - child = getNodeByShortcutKey(node.session, searchingKey) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } + let nodeDefinition = APP_SCHEMA_MAP.get(node.type) + if (nodeDefinition !== undefined) { + /* Check Self first */ + if (node.payload.uiObject.shortcutKey === searchingKey) { + return node } - case 'Backtesting Session': { - let child - child = getNodeByShortcutKey(node.parameters, searchingKey) - if (child !== undefined) { - return child - } - child = getNodeByShortcutKey(node.layerManager, searchingKey) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } + /* Check all of its own children nodes. */ + if (node.payload.floatingObject.isCollapsed !== true) { + if (nodeDefinition.properties !== undefined) { + for (let i = 0; i < nodeDefinition.properties.length; i++) { + let property = nodeDefinition.properties[i] - case 'Live Trading Session': { - let child - child = getNodeByShortcutKey(node.parameters, searchingKey) - if (child !== undefined) { - return child - } - child = getNodeByShortcutKey(node.layerManager, searchingKey) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - - case 'Fordward Testing Session': { - let child - child = getNodeByShortcutKey(node.parameters, searchingKey) - if (child !== undefined) { - return child - } - child = getNodeByShortcutKey(node.layerManager, searchingKey) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - - case 'Paper Trading Session': { - let child - child = getNodeByShortcutKey(node.parameters, searchingKey) - if (child !== undefined) { - return child - } - child = getNodeByShortcutKey(node.layerManager, searchingKey) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - - case 'Network Node': { - let child - for (let m = 0; m < node.taskManagers.length; m++) { - child = getNodeByShortcutKey(node.taskManagers[m], searchingKey) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Network': { - let child - for (let m = 0; m < node.networkNodes.length; m++) { - child = getNodeByShortcutKey(node.networkNodes[m], searchingKey) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Definition': { - let child - child = getNodeByShortcutKey(node.tradingSystem, searchingKey) - if (child !== undefined) { - return child - } - child = getNodeByShortcutKey(node.personalData, searchingKey) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Team': { - let child - for (let m = 0; m < node.sensorBots.length; m++) { - child = getNodeByShortcutKey(node.sensorBots[m], searchingKey) - if (child !== undefined) { - return child - } - } - for (let m = 0; m < node.indicatorBots.length; m++) { - child = getNodeByShortcutKey(node.indicatorBots[m], searchingKey) - if (child !== undefined) { - return child - } - } - for (let m = 0; m < node.tradingBots.length; m++) { - child = getNodeByShortcutKey(node.tradingBots[m], searchingKey) - if (child !== undefined) { - return child - } - } - for (let m = 0; m < node.plotters.length; m++) { - child = getNodeByShortcutKey(node.plotters[m], searchingKey) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Sensor Bot': { - let child - for (let m = 0; m < node.processes.length; m++) { - child = getNodeByShortcutKey(node.processes[m], searchingKey) - if (child !== undefined) { - return child - } - } - for (let m = 0; m < node.products.length; m++) { - child = getNodeByShortcutKey(node.products[m], searchingKey) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Indicator Bot': { - let child - for (let m = 0; m < node.processes.length; m++) { - child = getNodeByShortcutKey(node.processes[m], searchingKey) - if (child !== undefined) { - return child - } - } - for (let m = 0; m < node.products.length; m++) { - child = getNodeByShortcutKey(node.products[m], searchingKey) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Trading Bot': { - let child - for (let m = 0; m < node.processes.length; m++) { - child = getNodeByShortcutKey(node.processes[m], searchingKey) - if (child !== undefined) { - return child - } - } - for (let m = 0; m < node.products.length; m++) { - child = getNodeByShortcutKey(node.products[m], searchingKey) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Process Definition': { - let child - child = getNodeByShortcutKey(node.processOutput, searchingKey) - if (child !== undefined) { - return child - } - child = getNodeByShortcutKey(node.processDependencies, searchingKey) - if (child !== undefined) { - return child - } - child = getNodeByShortcutKey(node.statusReport, searchingKey) - if (child !== undefined) { - return child - } - child = getNodeByShortcutKey(node.executionStartedEvent, searchingKey) - if (child !== undefined) { - return child - } - child = getNodeByShortcutKey(node.executionFinishedEvent, searchingKey) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Process Output': { - let child - for (let m = 0; m < node.outputDatasets.length; m++) { - child = getNodeByShortcutKey(node.outputDatasets[m], searchingKey) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Process Dependencies': { - let child - for (let m = 0; m < node.statusDependencies.length; m++) { - child = getNodeByShortcutKey(node.statusDependencies[m], searchingKey) - if (child !== undefined) { - return child - } - } - for (let m = 0; m < node.dataDependencies.length; m++) { - child = getNodeByShortcutKey(node.dataDependencies[m], searchingKey) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Status Report': { - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Execution Finished Procedure': { - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Calculations Procedure': { - let child - child = getNodeByShortcutKey(node.initialization, searchingKey) - if (child !== undefined) { - return child - } - child = getNodeByShortcutKey(node.loop, searchingKey) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Data Building Procedure': { - let child - child = getNodeByShortcutKey(node.initialization, searchingKey) - if (child !== undefined) { - return child - } - child = getNodeByShortcutKey(node.loop, searchingKey) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Procedure Initialization': { - let child - child = getNodeByShortcutKey(node.javascriptCode, searchingKey) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Procedure Loop': { - let child - child = getNodeByShortcutKey(node.javascriptCode, searchingKey) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Output Dataset': { - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Status Dependency': { - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Data Dependency': { - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Product Definition': { - let child - child = getNodeByShortcutKey(node.record, searchingKey) - if (child !== undefined) { - return child - } - for (let m = 0; m < node.datasets.length; m++) { - child = getNodeByShortcutKey(node.datasets[m], searchingKey) - if (child !== undefined) { - return child - } - } - child = getNodeByShortcutKey(node.calculations, searchingKey) - if (child !== undefined) { - return child - } - child = getNodeByShortcutKey(node.dataBuilding, searchingKey) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Record Definition': { - let child - for (let m = 0; m < node.properties.length; m++) { - child = getNodeByShortcutKey(node.properties[m], searchingKey) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Record Property': { - let child - child = getNodeByShortcutKey(node.formula, searchingKey) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Dataset Definition': { - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Plotter': { - let child - for (let m = 0; m < node.modules.length; m++) { - child = getNodeByShortcutKey(node.modules[m], searchingKey) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - case 'Plotter Module': { - let child - child = getNodeByShortcutKey(node.javascriptCode, searchingKey) - if (child !== undefined) { - return child - } - child = getNodeByShortcutKey(node.shapes, searchingKey) - if (child !== undefined) { - return child - } - for (let m = 0; m < node.panels.length; m++) { - child = getNodeByShortcutKey(node.panels[m], searchingKey) - if (child !== undefined) { - return child - } - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return - } - } - - default: { - let nodeDefinition = APP_SCHEMA_MAP.get(node.type) - if (nodeDefinition !== undefined) { - /* Check Self first */ - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } - - /* Check all of its own children nodes. */ - if (node.payload.floatingObject.isCollapsed !== true) { - if (nodeDefinition.properties !== undefined) { - for (let i = 0; i < nodeDefinition.properties.length; i++) { - let property = nodeDefinition.properties[i] - - switch (property.type) { - case 'node': { - if (node[property.name] !== undefined) { - let child - child = getNodeByShortcutKey(node[property.name], searchingKey) - if (child !== undefined) { - return child - } - } + switch (property.type) { + case 'node': { + if (node[property.name] !== undefined) { + let child + child = getNodeByShortcutKey(node[property.name], searchingKey) + if (child !== undefined) { + return child } - break - case 'array': { - let nodePropertyArray = node[property.name] - if (nodePropertyArray !== undefined) { - for (let m = 0; m < nodePropertyArray.length; m++) { - child = getNodeByShortcutKey(nodePropertyArray[m], searchingKey) - if (child !== undefined) { - return child - } - } - } - } - break } } + break + case 'array': { + let nodePropertyArray = node[property.name] + if (nodePropertyArray !== undefined) { + for (let m = 0; m < nodePropertyArray.length; m++) { + child = getNodeByShortcutKey(nodePropertyArray[m], searchingKey) + if (child !== undefined) { + return child + } + } + } + } + break } } } From 57b884d42692a7a67f43e931cdb81d2ab37d9ce2 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 23 Dec 2019 14:52:34 +0100 Subject: [PATCH 009/264] Chain Attach / Detach cleaned --- .../FunctionLibraries/ChainAttachDetach.js | 978 +----------------- 1 file changed, 2 insertions(+), 976 deletions(-) diff --git a/DesignerSpace/Workspace/FunctionLibraries/ChainAttachDetach.js b/DesignerSpace/Workspace/FunctionLibraries/ChainAttachDetach.js index c945827e6..df3519f05 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/ChainAttachDetach.js +++ b/DesignerSpace/Workspace/FunctionLibraries/ChainAttachDetach.js @@ -17,506 +17,6 @@ function newChainAttachDetach () { case 'Team': { return } - case 'Sensor Bot': { - let payload = node.payload - for (let i = 0; i < payload.parentNode.sensorBots.length; i++) { - let sensorBot = payload.parentNode.sensorBots[i] - if (sensorBot.id === node.id) { - payload.parentNode.sensorBots.splice(i, 1) - } - } - completeDetachment(node, rootNodes) - return - } - case 'Indicator Bot': { - let payload = node.payload - for (let i = 0; i < payload.parentNode.indicatorBots.length; i++) { - let indicatorBot = payload.parentNode.indicatorBots[i] - if (indicatorBot.id === node.id) { - payload.parentNode.indicatorBots.splice(i, 1) - } - } - completeDetachment(node, rootNodes) - return - } - case 'Trading Bot': { - let payload = node.payload - for (let i = 0; i < payload.parentNode.tradingBots.length; i++) { - let tradingBot = payload.parentNode.tradingBots[i] - if (tradingBot.id === node.id) { - payload.parentNode.tradingBots.splice(i, 1) - } - } - completeDetachment(node, rootNodes) - return - } - case 'Process Definition': { - let payload = node.payload - for (let i = 0; i < payload.parentNode.processes.length; i++) { - let process = payload.parentNode.processes[i] - if (process.id === node.id) { - payload.parentNode.processes.splice(i, 1) - } - } - completeDetachment(node, rootNodes) - return - } - case 'Process Output': { - node.payload.parentNode.processOutput = undefined - completeDetachment(node, rootNodes) - return - } - case 'Process Dependencies': { - node.payload.parentNode.processDependencies = undefined - completeDetachment(node, rootNodes) - return - } - case 'Status Report': { - node.payload.parentNode.statusReport = undefined - completeDetachment(node, rootNodes) - return - } - case 'Execution Started Event': { - node.payload.parentNode.executionStartedEvent = undefined - completeDetachment(node, rootNodes) - return - } - case 'Execution Finished Event': { - node.payload.parentNode.executionFinishedEvent = undefined - completeDetachment(node, rootNodes) - return - } - case 'Calculations Procedure': { - node.payload.parentNode.calculations = undefined - completeDetachment(node, rootNodes) - return - } - case 'Data Building Procedure': { - node.payload.parentNode.dataBuilding = undefined - completeDetachment(node, rootNodes) - return - } - case 'Procedure Initialization': { - node.payload.parentNode.initialization = undefined - completeDetachment(node, rootNodes) - return - } - case 'Procedure Loop': { - node.payload.parentNode.loop = undefined - completeDetachment(node, rootNodes) - return - } - case 'Output Dataset': { - let payload = node.payload - for (let i = 0; i < payload.parentNode.outputDatasets.length; i++) { - let outputDataset = payload.parentNode.outputDatasets[i] - if (outputDataset.id === node.id) { - payload.parentNode.outputDatasets.splice(i, 1) - } - } - completeDetachment(node, rootNodes) - return - } - case 'Status Dependency': { - let payload = node.payload - for (let i = 0; i < payload.parentNode.statusDependencies.length; i++) { - let statusDependency = payload.parentNode.statusDependencies[i] - if (statusDependency.id === node.id) { - payload.parentNode.statusDependencies.splice(i, 1) - } - } - completeDetachment(node, rootNodes) - return - } - case 'Data Dependency': { - let payload = node.payload - for (let i = 0; i < payload.parentNode.dataDependencies.length; i++) { - let dataDependency = payload.parentNode.dataDependencies[i] - if (dataDependency.id === node.id) { - payload.parentNode.dataDependencies.splice(i, 1) - } - } - completeDetachment(node, rootNodes) - return - } - case 'Product Definition': { - let payload = node.payload - for (let i = 0; i < payload.parentNode.products.length; i++) { - let product = payload.parentNode.products[i] - if (product.id === node.id) { - payload.parentNode.products.splice(i, 1) - } - } - completeDetachment(node, rootNodes) - return - } - case 'Record Definition': { - node.payload.parentNode.record = undefined - completeDetachment(node, rootNodes) - return - } - case 'Record Property': { - let payload = node.payload - for (let i = 0; i < payload.parentNode.properties.length; i++) { - let property = payload.parentNode.properties[i] - if (property.id === node.id) { - payload.parentNode.properties.splice(i, 1) - } - } - completeDetachment(node, rootNodes) - return - } - case 'Dataset Definition': { - let payload = node.payload - for (let i = 0; i < payload.parentNode.datasets.length; i++) { - let dataset = payload.parentNode.datasets[i] - if (dataset.id === node.id) { - payload.parentNode.datasets.splice(i, 1) - } - } - completeDetachment(node, rootNodes) - return - } - case 'Plotter': { - let payload = node.payload - for (let i = 0; i < payload.parentNode.plotters.length; i++) { - let plotter = payload.parentNode.plotters[i] - if (plotter.id === node.id) { - payload.parentNode.plotters.splice(i, 1) - } - } - completeDetachment(node, rootNodes) - return - } - case 'Plotter Module': { - let payload = node.payload - for (let i = 0; i < payload.parentNode.modules.length; i++) { - let module = payload.parentNode.modules[i] - if (module.id === node.id) { - payload.parentNode.modules.splice(i, 1) - } - } - completeDetachment(node, rootNodes) - return - } - case 'Network Node': { - let payload = node.payload - for (let i = 0; i < payload.parentNode.networkNodes.length; i++) { - let networkNode = payload.parentNode.networkNodes[i] - if (networkNode.id === node.id) { - payload.parentNode.networkNodes.splice(i, 1) - } - } - completeDetachment(node, rootNodes) - return - } - case 'Personal Data': { - node.payload.parentNode.personalData = undefined - completeDetachment(node, rootNodes) - return - } - case 'Exchange Account': { - let payload = node.payload - for (let i = 0; i < payload.parentNode.exchangeAccounts.length; i++) { - let strategy = payload.parentNode.exchangeAccounts[i] - if (strategy.id === node.id) { - payload.parentNode.exchangeAccounts.splice(i, 1) - } - } - completeDetachment(node, rootNodes) - return - } - case 'Exchange Account Asset': { - let payload = node.payload - for (let i = 0; i < payload.parentNode.assets.length; i++) { - let asset = payload.parentNode.assets[i] - if (asset.id === node.id) { - payload.parentNode.assets.splice(i, 1) - } - } - completeDetachment(node, rootNodes) - return - } - case 'Exchange Account Key': { - let payload = node.payload - if (payload.parentNode.keys !== undefined) { - for (let i = 0; i < payload.parentNode.keys.length; i++) { - let key = payload.parentNode.keys[i] - if (key.id === node.id) { - payload.parentNode.keys.splice(i, 1) - } - } - } - if (payload.parentNode.key !== undefined) { - payload.parentNode.key = undefined - } - completeDetachment(node, rootNodes) - return - } - case 'Social Bots': { - node.payload.parentNode.socialBots = undefined - completeDetachment(node, rootNodes) - return - } - case 'Telegram Bot': { - let payload = node.payload - for (let i = 0; i < payload.parentNode.bots.length; i++) { - let bot = payload.parentNode.bots[i] - if (bot.id === node.id) { - payload.parentNode.bots.splice(i, 1) - } - } - completeDetachment(node, rootNodes) - return - } - case 'Announcement': { - let payload = node.payload - for (let i = 0; i < payload.parentNode.announcements.length; i++) { - let announcement = payload.parentNode.announcements[i] - if (announcement.id === node.id) { - payload.parentNode.announcements.splice(i, 1) - } - } - completeDetachment(node, rootNodes) - return - } - case 'Layer Manager': { - node.payload.parentNode.layerManager = undefined - completeDetachment(node, rootNodes) - return - } - case 'Layer': { - let payload = node.payload - for (let i = 0; i < payload.parentNode.layers.length; i++) { - let layer = payload.parentNode.layers[i] - if (layer.id === node.id) { - payload.parentNode.layers.splice(i, 1) - } - } - completeDetachment(node, rootNodes) - return - } - case 'Task Manager': { - let payload = node.payload - for (let i = 0; i < payload.parentNode.taskManagers.length; i++) { - let taskManager = payload.parentNode.taskManagers[i] - if (taskManager.id === node.id) { - payload.parentNode.taskManagers.splice(i, 1) - } - } - completeDetachment(node, rootNodes) - return - } - case 'Task': { - let payload = node.payload - for (let i = 0; i < payload.parentNode.tasks.length; i++) { - let task = payload.parentNode.tasks[i] - if (task.id === node.id) { - payload.parentNode.tasks.splice(i, 1) - } - } - completeDetachment(node, rootNodes) - return - } - case 'Sensor Bot Instance': { - node.payload.parentNode.bot = undefined - completeDetachment(node, rootNodes) - return - } - case 'Indicator Bot Instance': { - node.payload.parentNode.bot = undefined - completeDetachment(node, rootNodes) - return - } - case 'Trading Bot Instance': { - node.payload.parentNode.bot = undefined - completeDetachment(node, rootNodes) - return - } - case 'Backtesting Session': { - node.payload.parentNode.session = undefined - completeDetachment(node, rootNodes) - return - } - case 'Live Trading Session': { - node.payload.parentNode.session = undefined - completeDetachment(node, rootNodes) - return - } - case 'Fordward Testing Session': { - node.payload.parentNode.session = undefined - completeDetachment(node, rootNodes) - return - } - case 'Paper Trading Session': { - node.payload.parentNode.session = undefined - completeDetachment(node, rootNodes) - return - } - case 'Process Instance': { - let payload = node.payload - for (let i = 0; i < payload.parentNode.processes.length; i++) { - let process = payload.parentNode.processes[i] - if (process.id === node.id) { - payload.parentNode.processes.splice(i, 1) - } - } - completeDetachment(node, rootNodes) - return - } - case 'Trading System': { - node.payload.parentNode.tradingSystem = undefined - completeDetachment(node, rootNodes) - return - } - case 'Base Asset': { - node.payload.parentNode.baseAsset = undefined - completeDetachment(node, rootNodes) - return - } - case 'Time Range': { - node.payload.parentNode.timeRange = undefined - completeDetachment(node, rootNodes) - return - } - case 'Time Period': { - node.payload.parentNode.timePeriod = undefined - completeDetachment(node, rootNodes) - return - } - case 'Slippage': { - node.payload.parentNode.slippage = undefined - completeDetachment(node, rootNodes) - return - } - case 'Fee Structure': { - node.payload.parentNode.feeStructure = undefined - completeDetachment(node, rootNodes) - return - } - case 'Parameters': { - node.payload.parentNode.parameters = undefined - completeDetachment(node, rootNodes) - return - } - case 'Strategy': { - let payload = node.payload - for (let i = 0; i < payload.parentNode.strategies.length; i++) { - let strategy = payload.parentNode.strategies[i] - if (strategy.id === node.id) { - payload.parentNode.strategies.splice(i, 1) - } - } - completeDetachment(node, rootNodes) - return - } - case 'Trigger Stage': { - node.payload.parentNode.triggerStage = undefined - completeDetachment(node, rootNodes) - return - } - case 'Open Stage': { - node.payload.parentNode.openStage = undefined - completeDetachment(node, rootNodes) - return - } - case 'Manage Stage': { - node.payload.parentNode.manageStage = undefined - completeDetachment(node, rootNodes) - return - } - case 'Close Stage': { - node.payload.parentNode.closeStage = undefined - completeDetachment(node, rootNodes) - return - } - case 'Position Size': { - node.payload.parentNode.positionSize = undefined - completeDetachment(node, rootNodes) - return - } - case 'Position Rate': { - node.payload.parentNode.positionRate = undefined - completeDetachment(node, rootNodes) - return - } - case 'Trigger On Event': { - node.payload.parentNode.triggerOn = undefined - completeDetachment(node, rootNodes) - return - } - case 'Trigger Off Event': { - node.payload.parentNode.triggerOff = undefined - completeDetachment(node, rootNodes) - return - } - case 'Take Position Event': { - node.payload.parentNode.takePosition = undefined - completeDetachment(node, rootNodes) - return - } - case 'Initial Definition': { - node.payload.parentNode.initialDefinition = undefined - completeDetachment(node, rootNodes) - return - } - case 'Open Execution': { - node.payload.parentNode.openExecution = undefined - completeDetachment(node, rootNodes) - return - } - case 'Close Execution': { - node.payload.parentNode.closeExecution = undefined - completeDetachment(node, rootNodes) - return - } - case 'Stop': { - node.payload.parentNode.stopLoss = undefined - completeDetachment(node, rootNodes) - return - } - case 'Take Profit': { - node.payload.parentNode.takeProfit = undefined - completeDetachment(node, rootNodes) - return - } - case 'Formula': { - node.payload.parentNode.formula = undefined - completeDetachment(node, rootNodes) - return - } - case 'Next Phase Event': { - node.payload.parentNode.nextPhaseEvent = undefined - completeDetachment(node, rootNodes) - return - } - case 'Javascript Code': { - node.payload.parentNode.javascriptCode = undefined - completeDetachment(node, rootNodes) - return - } - case 'Condition': { - let payload = node.payload - for (let i = 0; i < payload.parentNode.conditions.length; i++) { - let condition = payload.parentNode.conditions[i] - if (condition.id === node.id) { - payload.parentNode.conditions.splice(i, 1) - } - } - completeDetachment(node, rootNodes) - return - } - case 'Situation': { - let payload = node.payload - for (let i = 0; i < payload.parentNode.situations.length; i++) { - let situation = payload.parentNode.situations[i] - if (situation.id === node.id) { - payload.parentNode.situations.splice(i, 1) - } - } - completeDetachment(node, rootNodes) - return - } case 'Phase': { let payload = node.payload for (let i = 0; i < payload.parentNode.phases.length; i++) { @@ -580,293 +80,7 @@ function newChainAttachDetach () { function chainAttachNode (node, attachToNode, rootNodes) { switch (node.type) { - case 'Sensor Bot': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.sensorBots.push(node) - completeAttachment(node, rootNodes) - } - break - case 'Indicator Bot': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.indicatorBots.push(node) - completeAttachment(node, rootNodes) - } - break - case 'Trading Bot': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.tradingBots.push(node) - completeAttachment(node, rootNodes) - } - break - case 'Process Definition': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.processes.push(node) - completeAttachment(node, rootNodes) - } - break - case 'Process Output': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.processOutput = node - completeAttachment(node, rootNodes) - } - break - case 'Process Dependencies': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.processDependencies = node - completeAttachment(node, rootNodes) - } - break - case 'Status Report': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.statusReport = node - completeAttachment(node, rootNodes) - } - break - case 'Execution Started Event': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.executionStartedEvent = node - completeAttachment(node, rootNodes) - } - break - case 'Execution Finished Event': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.executionFinishedEvent = node - completeAttachment(node, rootNodes) - } - break - case 'Calculations Procedure': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.calculations = node - completeAttachment(node, rootNodes) - } - break - case 'Data Building Procedure': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.dataBuilding = node - completeAttachment(node, rootNodes) - } - break - case 'Procedure Initialization': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.initialization = node - completeAttachment(node, rootNodes) - } - break - case 'Procedure Loop': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.loop = node - completeAttachment(node, rootNodes) - } - break - case 'Output Dataset': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.outputDatasets.push(node) - completeAttachment(node, rootNodes) - } - break - case 'Status Dependency': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.statusDependencies.push(node) - completeAttachment(node, rootNodes) - } - break - case 'Data Dependency': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.dataDependencies.push(node) - completeAttachment(node, rootNodes) - } - break - case 'Product Definition': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.products.push(node) - completeAttachment(node, rootNodes) - } - break - case 'Record Definition': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.record = node - completeAttachment(node, rootNodes) - } - break - case 'Record Property': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.properties.push(node) - completeAttachment(node, rootNodes) - } - break - case 'Dataset Definition': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.datasets.push(node) - completeAttachment(node, rootNodes) - } - break - case 'Plotter': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.plotters.push(node) - completeAttachment(node, rootNodes) - } - break - case 'Plotter Module': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.modules.push(node) - completeAttachment(node, rootNodes) - } - break - case 'Network Node': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.networkNodes.push(node) - completeAttachment(node, rootNodes) - } - break - case 'Social Bots': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.socialBots = node - completeAttachment(node, rootNodes) - } - break - case 'Telegram Bot': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.bots.push(node) - completeAttachment(node, rootNodes) - } - break - case 'Announcement': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.announcements.push(node) - completeAttachment(node, rootNodes) - } - break - case 'Layer Manager': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.layerManager = node - completeAttachment(node, rootNodes) - } - break - case 'Layer': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.layers.push(node) - completeAttachment(node, rootNodes) - } - break - case 'Task Manager': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.taskManagers.push(node) - completeAttachment(node, rootNodes) - } - break - case 'Task': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.tasks.push(node) - completeAttachment(node, rootNodes) - } - break - case 'Sensor Bot Instance': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.bot = node - completeAttachment(node, rootNodes) - } - break - case 'Indicator Bot Instance': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.bot = node - completeAttachment(node, rootNodes) - } - break - case 'Trading Bot Instance': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.bot = node - completeAttachment(node, rootNodes) - } - break - case 'Process Instance': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.processes.push(node) - completeAttachment(node, rootNodes) - } - break - case 'Backtesting Session': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.session = node - completeAttachment(node, rootNodes) - } - break - case 'Live Trading Session': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.session = node - completeAttachment(node, rootNodes) - } - break - case 'Fordward Testing Session': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.session = node - completeAttachment(node, rootNodes) - } - break - case 'Paper Trading Session': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.session = node - completeAttachment(node, rootNodes) - } - break - case 'Personal Data': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.personalData = node - completeAttachment(node, rootNodes) - } - break - case 'Exchange Account': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.exchangeAccounts.push(node) - completeAttachment(node, rootNodes) - } - break - case 'Exchange Account Asset': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.assets.push(node) - completeAttachment(node, rootNodes) - } - break + case 'Exchange Account Key': { node.payload.parentNode = attachToNode node.payload.chainParent = attachToNode @@ -878,174 +92,7 @@ function newChainAttachDetach () { completeAttachment(node, rootNodes) } break - case 'Parameters': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.parameters = node - completeAttachment(node, rootNodes) - } - break - case 'Base Asset': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.baseAsset = node - completeAttachment(node, rootNodes) - } - break - case 'Time Range': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.timeRange = node - completeAttachment(node, rootNodes) - } - break - case 'Time Period': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.timePeriod = node - completeAttachment(node, rootNodes) - } - break - case 'Slippage': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.slippage = node - completeAttachment(node, rootNodes) - } - break - case 'Fee Structure': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.feeStructure = node - completeAttachment(node, rootNodes) - } - break - case 'Trading System': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.tradingSystem = node - completeAttachment(node, rootNodes) - } - break - case 'Strategy': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.strategies.push(node) - completeAttachment(node, rootNodes) - } - break - case 'Trigger Stage': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.triggerStage = node - completeAttachment(node, rootNodes) - } - break - case 'Open Stage': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.openStage = node - completeAttachment(node, rootNodes) - } - break - case 'Manage Stage': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.manageStage = node - completeAttachment(node, rootNodes) - } - break - case 'Close Stage': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.closeStage = node - completeAttachment(node, rootNodes) - } - break - case 'Position Size': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.positionSize = node - completeAttachment(node, rootNodes) - } - break - case 'Position Rate': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.positionRate = node - completeAttachment(node, rootNodes) - } - break - case 'Initial Definition': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.initialDefinition = node - completeAttachment(node, rootNodes) - } - break - case 'Open Execution': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.openExecution = node - completeAttachment(node, rootNodes) - } - break - case 'Close Execution': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.closeExecution = node - completeAttachment(node, rootNodes) - } - break - case 'Trigger On Event': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.triggerOn = node - completeAttachment(node, rootNodes) - } - break - case 'Trigger Off Event': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.triggerOff = node - completeAttachment(node, rootNodes) - } - break - case 'Take Position Event': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.takePosition = node - completeAttachment(node, rootNodes) - } - break - case 'Stop': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.stopLoss = node - completeAttachment(node, rootNodes) - } - break - case 'Take Profit': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.takeProfit = node - completeAttachment(node, rootNodes) - } - break - case 'Formula': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.formula = node - completeAttachment(node, rootNodes) - } - break - case 'Next Phase Event': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.nextPhaseEvent = node - completeAttachment(node, rootNodes) - } - break + case 'Phase': { switch (attachToNode.type) { case 'Stop': { @@ -1105,27 +152,6 @@ function newChainAttachDetach () { } } break - case 'Situation': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.situations.push(node) - completeAttachment(node, rootNodes) - } - break - case 'Condition': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.conditions.push(node) - completeAttachment(node, rootNodes) - } - break - case 'Javascript Code': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.javascriptCode = node - completeAttachment(node, rootNodes) - } - break default: { let nodeDefinition = APP_SCHEMA_MAP.get(node.type) if (nodeDefinition !== undefined) { From 6fe8f64c641cc72efabd69d5c58abc710b7a507c Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 23 Dec 2019 20:48:10 +0100 Subject: [PATCH 010/264] chain attachment from APP SCHEMA --- FloatingSpace/UiObject.js | 322 +------------------------------------- 1 file changed, 3 insertions(+), 319 deletions(-) diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index 1d4596695..ff45c392d 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -257,198 +257,7 @@ function newUiObject () { let compatibleTypes let compatibleSubTypes switch (thisObject.payload.node.type) { - case 'Sensor Bot': - compatibleTypes = '->' + 'Team' + '->' - compatibleSubTypes = undefined - break - case 'Indicator Bot': - compatibleTypes = '->' + 'Team' + '->' - compatibleSubTypes = undefined - break - case 'Trading Bot': - compatibleTypes = '->' + 'Team' + '->' - compatibleSubTypes = undefined - break - case 'Process Definition': - compatibleTypes = '->' + 'Sensor Bot' + '->' + 'Indicator Bot' + '->' + 'Trading Bot' + '->' - compatibleSubTypes = undefined - break - case 'Process Output': - compatibleTypes = '->' + 'Process Definition' + '->' - compatibleSubTypes = undefined - break - case 'Process Dependencies': - compatibleTypes = '->' + 'Process Definition' + '->' - compatibleSubTypes = undefined - break - case 'Status Report': - compatibleTypes = '->' + 'Process Definition' + '->' - compatibleSubTypes = undefined - break - case 'Execution Started Event': - compatibleTypes = '->' + 'Process Definition' + '->' - compatibleSubTypes = undefined - break - case 'Execution Finished Event': - compatibleTypes = '->' + 'Process Definition' + '->' - compatibleSubTypes = undefined - break - case 'Calculations Procedure': - compatibleTypes = '->' + 'Product Definition' + '->' - compatibleSubTypes = undefined - break - case 'Data Building Procedure': - compatibleTypes = '->' + 'Product Definition' + '->' - compatibleSubTypes = undefined - break - case 'Procedure Initialization': - compatibleTypes = '->' + 'Calculations Procedure' + '->' + 'Data Building Procedure' + '->' - compatibleSubTypes = undefined - break - case 'Procedure Loop': - compatibleTypes = '->' + 'Calculations Procedure' + '->' + 'Data Building Procedure' + '->' - compatibleSubTypes = undefined - break - case 'Output Dataset': - compatibleTypes = '->' + 'Process Output' + '->' - compatibleSubTypes = undefined - break - case 'Status Dependency': - compatibleTypes = '->' + 'Process Dependencies' + '->' - compatibleSubTypes = undefined - break - case 'Data Dependency': - compatibleTypes = '->' + 'Process Dependencies' + '->' - compatibleSubTypes = undefined - break - case 'Product Definition': - compatibleTypes = '->' + 'Sensor Bot' + '->' + 'Indicator Bot' + '->' + 'Trading Bot' + '->' - compatibleSubTypes = undefined - break - case 'Record Definition': - compatibleTypes = '->' + 'Product Definition' + '->' - compatibleSubTypes = undefined - break - case 'Record Property': - compatibleTypes = '->' + 'Record Definition' + '->' - compatibleSubTypes = undefined - break - case 'Dataset Definition': - compatibleTypes = '->' + 'Product Definition' + '->' - compatibleSubTypes = undefined - break - case 'Plotter': - compatibleTypes = '->' + 'Team' + '->' - compatibleSubTypes = undefined - break - case 'Plotter Module': - compatibleTypes = '->' + 'Plotter' + '->' - compatibleSubTypes = undefined - break - case 'Trading System': - compatibleTypes = '->' + 'Definition' + '->' - compatibleSubTypes = undefined - break - case 'Personal Data': - compatibleTypes = '->' + 'Definition' + '->' - compatibleSubTypes = undefined - break - case 'Network Node': - compatibleTypes = '->' + 'Network' + '->' - compatibleSubTypes = undefined - break - case 'Exchange Account': - compatibleTypes = '->' + 'Personal Data' + '->' - compatibleSubTypes = undefined - break - case 'Exchange Account Asset': - compatibleTypes = '->' + 'Exchange Account' + '->' - compatibleSubTypes = undefined - break - case 'Exchange Account Key': - compatibleTypes = '->' + 'Exchange Account' + '->' + 'Parameters' + '->' - compatibleSubTypes = undefined - break - case 'Parameters': - compatibleTypes = '->' + 'Trading System' + '->' + 'Backtesting Session' + '->' + 'Live Trading Session' + '->' + 'Paper Trading Session' + '->' + 'Fordward Testing Session' + '->' - compatibleSubTypes = '->' + 'Trading Process Instance' + '->' - break - case 'Backtesting Session': - compatibleTypes = '->' + 'Process Instance' + '->' - compatibleSubTypes = '->' + 'Trading Process Instance' + '->' - break - case 'Live Trading Session': - compatibleTypes = '->' + 'Process Instance' + '->' - compatibleSubTypes = '->' + 'Trading Process Instance' + '->' - break - case 'Paper Trading Session': - compatibleTypes = '->' + 'Process Instance' + '->' - compatibleSubTypes = '->' + 'Trading Process Instance' + '->' - break - case 'Fordward Testing Session': - compatibleTypes = '->' + 'Process Instance' + '->' - compatibleSubTypes = '->' + 'Trading Process Instance' + '->' - break - case 'Base Asset': - compatibleTypes = '->' + 'Parameters' + '->' - compatibleSubTypes = undefined - break - case 'Time Range': - compatibleTypes = '->' + 'Parameters' + '->' - compatibleSubTypes = undefined - break - case 'Time Period': - compatibleTypes = '->' + 'Parameters' + '->' - compatibleSubTypes = undefined - break - case 'Slippage': - compatibleTypes = '->' + 'Parameters' + '->' - compatibleSubTypes = undefined - break - case 'Fee Structure': - compatibleTypes = '->' + 'Parameters' + '->' - compatibleSubTypes = undefined - break - case 'Layer Manager': - compatibleTypes = '->' + 'Backtesting Session' + '->' + 'Live Trading Session' + '->' + 'Paper Trading Session' + '->' + 'Fordward Testing Session' + '->' - compatibleSubTypes = undefined - break - case 'Layer': - compatibleTypes = '->' + 'Layer Manager' + '->' - compatibleSubTypes = undefined - break - case 'Social Bots': - compatibleTypes = '->' + 'Backtesting Session' + '->' + 'Live Trading Session' + '->' + 'Paper Trading Session' + '->' + 'Fordward Testing Session' + '->' - compatibleSubTypes = undefined - break - case 'Telegram Bot': - compatibleTypes = '->' + 'Social Bots' + '->' - compatibleSubTypes = undefined - break - case 'Announcement': - compatibleTypes = '->' + 'Telegram Bot' + '->' + 'Trigger On Event' + '->' + 'Trigger Off Event' + '->' + 'Take Position Event' + '->' + 'Next Phase Event' + '->' + '->' + 'Phase' + '->' - compatibleSubTypes = undefined - break - case 'Task Manager': - compatibleTypes = '->' + 'Network Node' + '->' - compatibleSubTypes = undefined - break - case 'Task': - compatibleTypes = '->' + 'Task Manager' + '->' - compatibleSubTypes = undefined - break - case 'Sensor Bot Instance': - compatibleTypes = '->' + 'Task' + '->' - compatibleSubTypes = undefined - break - case 'Indicator Bot Instance': - compatibleTypes = '->' + 'Task' + '->' - compatibleSubTypes = undefined - break - case 'Trading Bot Instance': - compatibleTypes = '->' + 'Task' + '->' - compatibleSubTypes = undefined - break + case 'Process Instance': switch (thisObject.payload.node.subType) { case 'Sensor Process Instance': { @@ -466,90 +275,7 @@ function newUiObject () { } compatibleSubTypes = undefined break - case 'Strategy': - compatibleTypes = '->' + 'Trading System' + '->' - compatibleSubTypes = undefined - break - case 'Trigger Stage': - compatibleTypes = '->' + 'Strategy' + '->' - compatibleSubTypes = undefined - break - case 'Open Stage': - compatibleTypes = '->' + 'Strategy' + '->' - compatibleSubTypes = undefined - break - case 'Manage Stage': - compatibleTypes = '->' + 'Strategy' + '->' - compatibleSubTypes = undefined - break - case 'Close Stage': - compatibleTypes = '->' + 'Strategy' + '->' - compatibleSubTypes = undefined - break - case 'Position Size': - compatibleTypes = '->' + 'Initial Definition' + '->' - compatibleSubTypes = undefined - break - case 'Position Rate': - compatibleTypes = '->' + 'Initial Definition' + '->' - compatibleSubTypes = undefined - break - case 'Take Position Event': - compatibleTypes = '->' + 'Trigger Stage' + '->' - compatibleSubTypes = undefined - break - case 'Trigger Off Event': - compatibleTypes = '->' + 'Trigger Stage' + '->' - compatibleSubTypes = undefined - break - case 'Trigger On Event': - compatibleTypes = '->' + 'Trigger Stage' + '->' - compatibleSubTypes = undefined - break - case 'Initial Definition': - compatibleTypes = '->' + 'Open Stage' + '->' - compatibleSubTypes = undefined - break - case 'Open Execution': - compatibleTypes = '->' + 'Open Stage' + '->' - compatibleSubTypes = undefined - break - case 'Close Execution': - compatibleTypes = '->' + 'Close Stage' + '->' - compatibleSubTypes = undefined - break - case 'Stop': - compatibleTypes = '->' + 'Manage Stage' + '->' + 'Initial Definition' + '->' - compatibleSubTypes = undefined - break - case 'Take Profit': - compatibleTypes = '->' + 'Manage Stage' + '->' + 'Initial Definition' + '->' - compatibleSubTypes = undefined - break - case 'Phase': - compatibleTypes = '->' + 'Stop' + '->' + 'Take Profit' + '->' + 'Phase' + '->' - compatibleSubTypes = undefined - break - case 'Formula': - compatibleTypes = '->' + 'Position Size' + '->' + 'Position Rate' + '->' + 'Phase' + '->' + 'Announcement' + '->' + 'Record Property' + '->' - compatibleSubTypes = undefined - break - case 'Next Phase Event': - compatibleTypes = '->' + 'Phase' + '->' - compatibleSubTypes = undefined - break - case 'Situation': - compatibleTypes = '->' + 'Take Position Event' + '->' + 'Trigger On Event' + '->' + 'Trigger Off Event' + '->' + 'Next Phase Event' + '->' - compatibleSubTypes = undefined - break - case 'Condition': - compatibleTypes = '->' + 'Situation' + '->' - compatibleSubTypes = undefined - break - case 'Javascript Code': - compatibleTypes = '->' + 'Condition' + '->' + 'Procedure Initialization' + '->' + 'Procedure Loop' + '->' + 'Plotter Module' + '->' + 'Plotter Panel' + '->' - compatibleSubTypes = undefined - break + default: let nodeDefinition = APP_SCHEMA_MAP.get(thisObject.payload.node.type) if (nodeDefinition !== undefined) { @@ -601,49 +327,7 @@ function newUiObject () { } if (mustContinue === true) { continue } } - /* Discard legacy objects with busy coonection ports */ - if (thisObject.payload.node.type === 'Status Report' && nearbyNode.statusReport !== undefined) { continue } - if (thisObject.payload.node.type === 'Execution Started Event' && nearbyNode.executionStartedEvent !== undefined) { continue } - if (thisObject.payload.node.type === 'Execution Finished Event' && nearbyNode.executionFinishedEvent !== undefined) { continue } - if (thisObject.payload.node.type === 'Calculations Procedure' && nearbyNode.calculations !== undefined) { continue } - if (thisObject.payload.node.type === 'Data Building Procedure' && nearbyNode.dataBuilding !== undefined) { continue } - if (thisObject.payload.node.type === 'Procedure Initialization' && nearbyNode.initialization !== undefined) { continue } - if (thisObject.payload.node.type === 'Procedure Loop' && nearbyNode.loop !== undefined) { continue } - if (thisObject.payload.node.type === 'Record Definition' && nearbyNode.record !== undefined) { continue } - if (thisObject.payload.node.type === 'Task' && nearbyNode.task !== undefined) { continue } - if (thisObject.payload.node.type === 'Sensor Bot Instance' && nearbyNode.bot !== undefined) { continue } - if (thisObject.payload.node.type === 'Indicator Bot Instance' && nearbyNode.bot !== undefined) { continue } - if (thisObject.payload.node.type === 'Trading Bot Instance' && nearbyNode.bot !== undefined) { continue } - if (thisObject.payload.node.type === 'Process Instance' && nearbyNode.process !== undefined) { continue } - if (thisObject.payload.node.type === 'Trading System' && nearbyNode.tradingSystem !== undefined) { continue } - if (thisObject.payload.node.type === 'Personal Data' && nearbyNode.personalData !== undefined) { continue } - if (thisObject.payload.node.type === 'Parameters' && nearbyNode.parameters !== undefined) { continue } - if (thisObject.payload.node.type === 'Backtesting Session' && nearbyNode.session !== undefined) { continue } - if (thisObject.payload.node.type === 'Live Trading Session' && nearbyNode.session !== undefined) { continue } - if (thisObject.payload.node.type === 'Fordward Testing Session' && nearbyNode.session !== undefined) { continue } - if (thisObject.payload.node.type === 'Paper Trading Session' && nearbyNode.session !== undefined) { continue } - if (thisObject.payload.node.type === 'Base Asset' && nearbyNode.baseAsset !== undefined) { continue } - if (thisObject.payload.node.type === 'Time Range' && nearbyNode.timeRange !== undefined) { continue } - if (thisObject.payload.node.type === 'Time Period' && nearbyNode.timePeriod !== undefined) { continue } - if (thisObject.payload.node.type === 'Slippage' && nearbyNode.slippage !== undefined) { continue } - if (thisObject.payload.node.type === 'Fee Structure' && nearbyNode.feeStructure !== undefined) { continue } - if (thisObject.payload.node.type === 'Trigger Stage' && nearbyNode.triggerStage !== undefined) { continue } - if (thisObject.payload.node.type === 'Open Stage' && nearbyNode.openStage !== undefined) { continue } - if (thisObject.payload.node.type === 'Manage Stage' && nearbyNode.manageStage !== undefined) { continue } - if (thisObject.payload.node.type === 'Close Stage' && nearbyNode.closeStage !== undefined) { continue } - if (thisObject.payload.node.type === 'Position Size' && nearbyNode.positionSize !== undefined) { continue } - if (thisObject.payload.node.type === 'Position Rate' && nearbyNode.positionRate !== undefined) { continue } - if (thisObject.payload.node.type === 'Take Position Event' && nearbyNode.takePosition !== undefined) { continue } - if (thisObject.payload.node.type === 'Trigger Off Event' && nearbyNode.triggerOff !== undefined) { continue } - if (thisObject.payload.node.type === 'Trigger On Event' && nearbyNode.triggerOn !== undefined) { continue } - if (thisObject.payload.node.type === 'Initial Definition' && nearbyNode.initialDefinition !== undefined) { continue } - if (thisObject.payload.node.type === 'Open Execution' && nearbyNode.openExecution !== undefined) { continue } - if (thisObject.payload.node.type === 'Close Execution' && nearbyNode.closeExecution !== undefined) { continue } - if (thisObject.payload.node.type === 'Stop' && nearbyNode.stopLoss !== undefined) { continue } - if (thisObject.payload.node.type === 'Take Profit' && nearbyNode.takeProfit !== undefined) { continue } - if (thisObject.payload.node.type === 'Formula' && nearbyNode.formula !== undefined) { continue } - if (thisObject.payload.node.type === 'Next Phase Event' && nearbyNode.nextPhaseEvent !== undefined) { continue } - if (thisObject.payload.node.type === 'Javascript Code' && nearbyNode.javascriptCode !== undefined) { continue } + /* Here we check if the subtypes are compatible. */ if (nearbyNode.subType !== undefined && compatibleSubTypes !== undefined) { if (compatibleSubTypes.indexOf('->' + nearbyNode.subType + '->') < 0) { From 280c75f280d3deb7f972735902130b3b4644b99b Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 24 Dec 2019 13:13:27 +0100 Subject: [PATCH 011/264] Reference Attacments from APP SCHEMA --- FloatingSpace/UiObject.js | 65 ++++++++------------------------------- 1 file changed, 12 insertions(+), 53 deletions(-) diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index ff45c392d..4ed192a17 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -437,60 +437,19 @@ function newUiObject () { let nearbyFloatingObjects = thisObject.payload.floatingObject.nearbyFloatingObjects let compatibleTypes let compatibleSubTypes - switch (thisObject.payload.node.type) { - case 'Backtesting Session': - compatibleTypes = '->' + 'Definition' + '->' - compatibleSubTypes = undefined - break - case 'Live Trading Session': - compatibleTypes = '->' + 'Definition' + '->' - compatibleSubTypes = undefined - break - case 'Paper Trading Session': - compatibleTypes = '->' + 'Definition' + '->' - compatibleSubTypes = undefined - break - case 'Fordward Testing Session': - compatibleTypes = '->' + 'Definition' + '->' - compatibleSubTypes = undefined - break - case 'Output Dataset': - compatibleTypes = '->' + 'Dataset Definition' + '->' - compatibleSubTypes = undefined - break - case 'Data Dependency': - compatibleTypes = '->' + 'Dataset Definition' + '->' - compatibleSubTypes = undefined - break - case 'Status Dependency': - compatibleTypes = '->' + 'Status Report' + '->' - compatibleSubTypes = undefined - break - case 'Execution Started Event': - compatibleTypes = '->' + 'Execution Finished Event' + '->' - compatibleSubTypes = undefined - break - case 'Process Instance': - compatibleTypes = '->' + 'Process Definition' + '->' - compatibleSubTypes = undefined - break - case 'Product Definition': - compatibleTypes = '->' + 'Plotter Module' + '->' - compatibleSubTypes = undefined - break - default: - let nodeDefinition = APP_SCHEMA_MAP.get(thisObject.payload.node.type) - if (nodeDefinition !== undefined) { - if (nodeDefinition.referenceAttachesTo !== undefined) { - compatibleTypes = nodeDefinition.referenceAttachesTo.compatibleTypes - compatibleSubTypes = nodeDefinition.referenceAttachesTo.compatibleSubTypes - } else { - return - } - } else { - return - } + + let nodeDefinition = APP_SCHEMA_MAP.get(thisObject.payload.node.type) + if (nodeDefinition !== undefined) { + if (nodeDefinition.referenceAttachesTo !== undefined) { + compatibleTypes = nodeDefinition.referenceAttachesTo.compatibleTypes + compatibleSubTypes = nodeDefinition.referenceAttachesTo.compatibleSubTypes + } else { + return + } + } else { + return } + let foundCompatible = false referenceAttachToNode = undefined isReferenceAttaching = false From c5caf994440db286b3f1089c9989821e76c277e3 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 24 Dec 2019 13:24:01 +0100 Subject: [PATCH 012/264] Code cleanup --- FloatingSpace/Note.js | 334 --------------------------------- FloatingSpace/NoteSets.js | 314 ------------------------------- FloatingSpace/ProfileBall.js | 336 ---------------------------------- FloatingSpace/ProfileBalls.js | 62 ------- Spaces/FloatingSpace.js | 12 -- 5 files changed, 1058 deletions(-) delete mode 100644 FloatingSpace/Note.js delete mode 100644 FloatingSpace/NoteSets.js delete mode 100644 FloatingSpace/ProfileBall.js delete mode 100644 FloatingSpace/ProfileBalls.js diff --git a/FloatingSpace/Note.js b/FloatingSpace/Note.js deleted file mode 100644 index 6bb4e5858..000000000 --- a/FloatingSpace/Note.js +++ /dev/null @@ -1,334 +0,0 @@ -  -function newNote () { - const MODULE_NAME = 'Note' - - let thisObject = { - container: undefined, - physics: physics, - drawBackground: drawBackground, - drawMiddleground: drawMiddleground, - drawForeground: drawForeground, - drawOnFocus: drawOnFocus, - getContainer: getContainer, - initialize: initialize - } - - thisObject.container = newContainer() - thisObject.container.initialize(MODULE_NAME, 'Circle') - thisObject.container.isClickeable = false - thisObject.container.isDraggeable = false - thisObject.container.frame.radius = 0 - thisObject.container.frame.position.x = 0 - thisObject.container.frame.position.y = 0 - - return thisObject - - function initialize () { - thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) - thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick) - thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) - } - - function getContainer (point) { - let container - - if (thisObject.container.frame.isThisPointHere(point, true) === true) { - return thisObject.container - } else { - return undefined - } - } - - function physics () { - - } - - function onMouseOver () { - - } - - function onMouseNotOver () { - - } - - function onMouseClick (event) { - pPoint = event.point - pFloatingObject = event.parent - } - - function drawBackground (pFloatingObject) { - let point = { - x: pFloatingObject.payload.notes[pFloatingObject.payloadNoteIndex].position.x, - y: pFloatingObject.payload.notes[pFloatingObject.payloadNoteIndex].position.y - } - - point = viewPort.fitIntoVisibleArea(point) - - if (pFloatingObject.container.frame.radius > 1) { - /* Target Line */ - - browserCanvasContext.beginPath() - browserCanvasContext.moveTo(pFloatingObject.container.frame.position.x, pFloatingObject.container.frame.position.y) - browserCanvasContext.lineTo(point.x, point.y) - browserCanvasContext.strokeStyle = 'rgba(204, 204, 204, 0.5)' - browserCanvasContext.setLineDash([4, 2]) - browserCanvasContext.lineWidth = 1 - browserCanvasContext.stroke() - browserCanvasContext.setLineDash([0, 0]) - } - - if (pFloatingObject.container.frame.radius > 0.5) { - /* Target Spot */ - - var radius = 1 - - browserCanvasContext.beginPath() - browserCanvasContext.arc(point.x, point.y, radius, 0, Math.PI * 2, true) - browserCanvasContext.closePath() - browserCanvasContext.fillStyle = 'rgba(30, 30, 30, 1)' - browserCanvasContext.fill() - } - } - - function drawOnFocus () { - - } - - function drawMiddleground () { - - } - - function drawForeground (pFloatingObject) { - const BUBBLE_CORNERS_RADIUS = 5 - const TITLE_BAR_HEIGHT = 14 - - const BUBBLE_WIDTH = BUBBLE_CORNERS_RADIUS + pFloatingObject.container.frame.radius * 4 - const BUBBLE_HEIGHT = BUBBLE_CORNERS_RADIUS + pFloatingObject.container.frame.radius * 2 - - let borderPoint1 - let borderPoint2 - let borderPoint3 - let borderPoint4 - - let intialDisplace = { - x: pFloatingObject.container.frame.position.x - BUBBLE_WIDTH / 2, - y: pFloatingObject.container.frame.position.y - BUBBLE_HEIGHT / 2 - } - - if (pFloatingObject.container.frame.radius > 5) { - /* Rounded Background */ - - borderPoint1 = { - x: intialDisplace.x + BUBBLE_CORNERS_RADIUS, - y: intialDisplace.y + BUBBLE_CORNERS_RADIUS - } - - borderPoint2 = { - x: intialDisplace.x + BUBBLE_WIDTH - BUBBLE_CORNERS_RADIUS, - y: intialDisplace.y + BUBBLE_CORNERS_RADIUS - } - - borderPoint3 = { - x: intialDisplace.x + BUBBLE_WIDTH - BUBBLE_CORNERS_RADIUS, - y: intialDisplace.y + BUBBLE_HEIGHT - BUBBLE_CORNERS_RADIUS - } - - borderPoint4 = { - x: intialDisplace.x + BUBBLE_CORNERS_RADIUS, - y: intialDisplace.y + +BUBBLE_HEIGHT - BUBBLE_CORNERS_RADIUS - } - - titleBarPoint1 = { - x: intialDisplace.x + 0, - y: intialDisplace.y + TITLE_BAR_HEIGHT - } - - titleBarPoint2 = { - x: intialDisplace.x + BUBBLE_WIDTH, - y: intialDisplace.y + TITLE_BAR_HEIGHT - } - - /* We paint the panel background first */ - - browserCanvasContext.fillStyle = 'rgba(255, 249, 196, 0.75)' - browserCanvasContext.beginPath() - - browserCanvasContext.arc(borderPoint1.x, borderPoint1.y, BUBBLE_CORNERS_RADIUS, 1.0 * Math.PI, 1.5 * Math.PI) - browserCanvasContext.lineTo(borderPoint2.x, borderPoint2.y - BUBBLE_CORNERS_RADIUS) - browserCanvasContext.arc(borderPoint2.x, borderPoint2.y, BUBBLE_CORNERS_RADIUS, 1.5 * Math.PI, 2.0 * Math.PI) - browserCanvasContext.lineTo(borderPoint3.x + BUBBLE_CORNERS_RADIUS, borderPoint3.y) - browserCanvasContext.arc(borderPoint3.x, borderPoint3.y, BUBBLE_CORNERS_RADIUS, 0 * Math.PI, 0.5 * Math.PI) - browserCanvasContext.lineTo(borderPoint4.x, borderPoint4.y + BUBBLE_CORNERS_RADIUS) - browserCanvasContext.arc(borderPoint4.x, borderPoint4.y, BUBBLE_CORNERS_RADIUS, 0.5 * Math.PI, 1.0 * Math.PI) - browserCanvasContext.lineTo(borderPoint1.x - BUBBLE_CORNERS_RADIUS, borderPoint1.y) - - browserCanvasContext.closePath() - - browserCanvasContext.fill() - - browserCanvasContext.lineWidth = 0.1 - browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.DARK + ', 0.75)' - browserCanvasContext.stroke() - - /* We paint the title bar now */ - - browserCanvasContext.fillStyle = 'rgba(244, 224, 44, 0.75)' - browserCanvasContext.beginPath() - - browserCanvasContext.moveTo(titleBarPoint1.x, titleBarPoint1.y) - browserCanvasContext.lineTo(borderPoint1.x - BUBBLE_CORNERS_RADIUS, borderPoint1.y) - browserCanvasContext.arc(borderPoint1.x, borderPoint1.y, BUBBLE_CORNERS_RADIUS, 1.0 * Math.PI, 1.5 * Math.PI) - browserCanvasContext.lineTo(borderPoint2.x, borderPoint2.y - BUBBLE_CORNERS_RADIUS) - browserCanvasContext.arc(borderPoint2.x, borderPoint2.y, BUBBLE_CORNERS_RADIUS, 1.5 * Math.PI, 2.0 * Math.PI) - browserCanvasContext.lineTo(titleBarPoint2.x, titleBarPoint2.y) - - browserCanvasContext.closePath() - browserCanvasContext.fill() - - browserCanvasContext.lineWidth = 0.1 - browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.RUSTED_RED + ', 0.75)' - browserCanvasContext.stroke() - } - - if (pFloatingObject.container.frame.radius > 0.5) { - /* Image */ - - let imagePosition = { - x: pFloatingObject.container.frame.position.x, - y: pFloatingObject.container.frame.position.y + BUBBLE_HEIGHT / 2 - } - - if (pFloatingObject.payloadImageId !== undefined) { - let image = document.getElementById(pFloatingObject.payloadImageId) - - if (image !== null) { - browserCanvasContext.drawImage(image, imagePosition.x - pFloatingObject.currentImageSize / 2, imagePosition.y - pFloatingObject.currentImageSize / 2, pFloatingObject.currentImageSize, pFloatingObject.currentImageSize) - } - } - - /* Image Contourn */ - - browserCanvasContext.beginPath() - browserCanvasContext.arc(imagePosition.x, imagePosition.y, pFloatingObject.currentImageSize / 2, 0, Math.PI * 2, true) - browserCanvasContext.closePath() - browserCanvasContext.strokeStyle = 'rgba(30, 30, 30, 0.25)' - browserCanvasContext.lineWidth = 1 - browserCanvasContext.stroke() - - /* Labels */ - - if (pFloatingObject.container.frame.radius > 6) { - browserCanvasContext.strokeStyle = pFloatingObject.labelStrokeStyle - - const SIZE_PERCENTAGE = Math.trunc(pFloatingObject.container.frame.radius / pFloatingObject.targetRadius * 100) / 100 - let ALPHA - - if (pFloatingObject.targetRadius > 0) { - ALPHA = 0.5 - (1 - SIZE_PERCENTAGE) * 5 - } else { - // Object is dying... - - ALPHA = Math.trunc((0.5 - (100 - pFloatingObject.container.frame.radius / 100)) * 100) / 100 - - if (ALPHA < 0) { ALPHA = 0 } - } - - let labelPoint - let fontSize = 10 - - let label - - /* print the title */ - - label = pFloatingObject.payload.notes[pFloatingObject.payloadNoteIndex].title - - if (label !== undefined) { - if (SIZE_PERCENTAGE > 0.9) { - browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY - - let xOffset = label.length / 2 * fontSize * FONT_ASPECT_RATIO - let yOffset = (TITLE_BAR_HEIGHT - fontSize) / 2 + 2 - - labelPoint = { - x: intialDisplace.x + BUBBLE_WIDTH / 2 - xOffset, - y: intialDisplace.y + TITLE_BAR_HEIGHT - yOffset - } - - browserCanvasContext.fillStyle = 'rgba(30, 30, 30, ' + ALPHA + ')' - browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y) - } - } - - /* Message Body */ - - label = pFloatingObject.payload.notes[pFloatingObject.payloadNoteIndex].body - - if (label !== undefined) { - const WORDS_PER_ROW = 5 - const TOTAL_ROWS = 5 - - if (SIZE_PERCENTAGE > 0.9) { - let rawLabelArray = label.split(' ') - let labelArray = [] - - /* Lets check when words are to long we add an empty space to the same line so as to roll all other words forward. */ - - for (let i = 0; i < rawLabelArray.length; i++) { - let word = rawLabelArray[i] - - labelArray.push(word) - - if (word.length > 8) { - labelArray.push('') - } - - if (word.length > 10) { - labelArray.push('') - } - } - - /* Calculate each ROW */ - - let labelRows = [] - - for (let i = 0; i < TOTAL_ROWS; i++) { - let labelRow = '' - - for (let j = 0; j < WORDS_PER_ROW; j++) { - let newWord = labelArray[j + i * WORDS_PER_ROW] - - if (newWord !== undefined && newWord !== '') { - labelRow = labelRow + ' ' + newWord - } - } - - if (labelRow !== '') { - labelRows.push(labelRow) - } - } - - /* Now we plot each row. */ - - for (let i = 0; i < labelRows.length; i++) { - let labelRow = labelRows[i] - - let startingPosition = { - x: pFloatingObject.container.frame.position.x, - y: pFloatingObject.container.frame.position.y - labelRows.length / 2 * (fontSize * FONT_ASPECT_RATIO + 10) - } - - labelPoint = { - x: startingPosition.x - labelRow.length / 2 * fontSize * FONT_ASPECT_RATIO, - y: startingPosition.y + (i + 1) * (fontSize * FONT_ASPECT_RATIO + 10) - } - - browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY - browserCanvasContext.fillStyle = 'rgba(60, 60, 60, ' + ALPHA + ')' - browserCanvasContext.fillText(labelRow, labelPoint.x, labelPoint.y) - } - } - } - } - } - } -} diff --git a/FloatingSpace/NoteSets.js b/FloatingSpace/NoteSets.js deleted file mode 100644 index f9eaca6f4..000000000 --- a/FloatingSpace/NoteSets.js +++ /dev/null @@ -1,314 +0,0 @@ -  -function newNoteSets () { - /* - Different plotters will identify sets of notes whithin the data they are plotting. They will create with them arrays of Notes data. - On the other hand the floating space, and a floting layer in particular, manages Notes floating objects, which are visible entities - that floats on the screen. These entities are animated at a certain peace, and their life cycle differs from the life cycle of the - arrays of raw data plotters have. - - The purpose of this module, is to provide a mechnism of syncronization between the raw data and the visible floating objects and a - data structure wheere to store these floating objects. - - A NoteSet in this context is an array of Notes floating objects belonging to the same owner, which could be a certain bot for instance. - This module is capable of managing an array of NoteSets. - */ - - const MODULE_NAME = 'Note Sets' - const INFO_LOG = false - const INFO_WARN = true - const ERROR_LOG = true - const logger = newWebDebugLog() - logger.fileName = MODULE_NAME - - let thisObject = { - createNoteSet: createNoteSet, - destroyNoteSet: destroyNoteSet, - initialize: initialize, - finalize: finalize - } - - let noteSets = [] - let floatingLayer - - return thisObject - - function initialize (pFloatingLayer) { - floatingLayer = pFloatingLayer - } - - function finalize () { - floatingLayer.finalize() - floatingLayer = undefined - } - - function createNoteSet (pPayload, pEventHandler, callBackFunction) { - try { - /* - During the creating of a NoteSet, no floating objects are created yet. What we do here is to create the data structure which will allocate - the Notes floating objects, once we receive the array of notes raw data from the plotter. This array will come as an event raised by the - plotter everytime it's set of raw data changes. Remember that the plotter is not only filtering out notes based on how far they are from the - position the user gives to the viewport, but also, the plotter can be receiving actually new notes from its datasource. - */ - - if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> Entering function.') } - - let noteSet = { - imageId: pPayload.profile.imageId, - floatingNotes: [], - payload: pPayload, - handle: Math.floor((Math.random() * 10000000) + 1) - } - - noteSets.push(noteSet) - - pEventHandler.listenToEvent('Notes Changed', onNotesChanged, noteSets.length - 1) - - callBackFunction(GLOBAL.CUSTOM_OK_RESPONSE, noteSet.handle) - - function onNotesChanged (pNewNotes, pNoteSetIndex) { - try { - if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Entering function.') } - if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> pNewNotes.length = ' + pNewNotes.length) } - if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> pNoteSetIndex = ' + pNoteSetIndex) } - - let noteSet = noteSets[pNoteSetIndex] - let found = false - let newFloatingNotes - - /* - First we remove the old notes. This means that we are going to scan all the floating objects that we have, and see one by one if they - are still present on the raw data sent by the plotter. If it is not there, that means that the floating object must be discarded. - */ - - if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes.') } - - newFloatingNotes = [] // We will create a new array of Floating Notes as a result of this operation. - - /* - Here we scan the curren array of floating objects. We use the date + rate to create a unique key for each one, in order to be able to - compare it with the raw data. You will notice that instead of deleting from the current array what we actually do is to add the ones - that are still at the raw data array to a new array, and not adding the ones that are not. - */ - - for (let j = 0; j < noteSet.floatingNotes.length; j++) { - found = false - - let floatingNote = noteSet.floatingNotes[j] - let floatingNoteKey = floatingNote.date.toString() + floatingNote.rate.toString() - - if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> j = ' + j) } - - let i - - for (let i = 0; i < pNewNotes.length; i++) { - let plotterNote = pNewNotes[i] - let plotterNoteKey = plotterNote.date.toString() + plotterNote.rate.toString() - - if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> i = ' + i) } - if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> floatingNoteKey = ' + floatingNoteKey) } - if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> plotterNoteKey = ' + plotterNoteKey) } - - if (plotterNoteKey === floatingNoteKey) { - found = true - - if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> found = ' + found) } - break - } - } - - if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> End of For i.') } - if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> found = ' + found) } - - if (found === false) { - /* - Each time we identify a floatingObject that is not at the raw data anymore, we request the floatinglayer to kill it. - */ - - floatingLayer.removeFloatingObject(floatingNote.floatingHandle) - } else { - newFloatingNotes.push(floatingNote) - - if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> floatingNote.floatingHandle = ' + floatingNote.floatingHandle) } - if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> Added to newFloatingNotes.') } - if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> newFloatingNotes.length = ' + newFloatingNotes.length) } - - /* - We set a property at each floatingObject of which is the index of the note at the raw data array, so that it can later evaluate its position or its visibility. - */ - - let floatingObject = floatingLayer.getFloatingObject(floatingNote.floatingHandle) - floatingObject.payloadNoteIndex = i - - if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> floatingObject index updated.') } - if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> floatingObject.payloadNoteIndex = ' + i) } - } - } - - /* - We replace the current array, with the new one that only contains the surviving floating objects, meaning the ones that are still at the raw data received. - */ - - noteSet.floatingNotes = newFloatingNotes - - if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> noteSet.floatingNotes.length = ' + noteSet.floatingNotes.length) } - - /* - Second we add the new notes. There might be new notes at the raw data received that we didnt have before at the NodeSet array. To figure out which - ones are, we need to scan the raw data array and compare each element with the ones of the NodeSet array. Whenever we find one that is not there, - we add it. - */ - - if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes.') } - - newFloatingNotes = [] // We will create a new array of Floating Notes as a result of this operation. - - /* - We are using the date and rate as a unique key to identify each note. To prevent the cases of duplicate keys, we will check that at - least to consecutive records dont have the same key, and if they do, will ignore the second one. - */ - - let lastPlotterKey = '' - - for (let i = 0; i < pNewNotes.length; i++) { - found = false - - let plotterNote = pNewNotes[i] - let plotterNoteKey = plotterNote.date.toString() + plotterNote.rate.toString() - let floatingNote - let floatingNoteKey - - if (lastPlotterKey === plotterNoteKey) { - if (INFO_WARN === true) { logger.write('[WARN] createNoteSet -> onNotesChanged -> Add new Notes -> Duplicate record detected. Discarding it.') } - if (INFO_WARN === true) { logger.write('[WARN] createNoteSet -> onNotesChanged -> Add new Notes -> i = ' + i) } - continue - } - - lastPlotterKey = plotterNoteKey - - if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> i = ' + i) } - - for (let j = 0; j < noteSet.floatingNotes.length; j++) { - floatingNote = noteSet.floatingNotes[j] - floatingNoteKey = floatingNote.date.toString() + floatingNote.rate.toString() - - if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> j = ' + j) } - if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> floatingNoteKey = ' + floatingNoteKey) } - if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> plotterNoteKey = ' + plotterNoteKey) } - - if (plotterNoteKey === floatingNoteKey) { - found = true - - if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> found = ' + found) } - break - } - } - - if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> End of For j.') } - if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> found = ' + found) } - - if (found === false) { - /* - Before adding a new item to the array, we need to create a floatingObject of type Note. Once we set its basic parameters - we can it to our array and to the floating layer. - */ - - let floatingObject = newFloatingObject() - floatingObject.initialize('Note', '', floatingLayer) - - floatingObject.payload = noteSet.payload - floatingObject.payloadNoteIndex = i - floatingObject.payloadImageId = noteSet.imageId - - floatingObject.friction = 0.995 - - floatingObject.initializeMass(200) - - // let bodyText = pNewNotes[i].body; - let radius - - /* - if (bodyText.length < 100) { - radius = 100; - } else { - radius = bodyText.length; - } - */ - radius = 50 - - floatingObject.initializeRadius(radius) - floatingObject.initializeImageSize(15) - - floatingObject.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 0.5)' - floatingObject.labelStrokeStyle = 'rgba(60, 60, 60, 0.50)' - - floatingLayer.addFloatingObject(floatingObject) - - if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> New Note added to Layer.') } - - plotterNote.floatingHandle = floatingObject.handle - - if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> plotterNote.floatingHandle = ' + plotterNote.floatingHandle) } - - newFloatingNotes.push(plotterNote) - - if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> Added to newFloatingNotes.') } - if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> newFloatingNotes.length = ' + newFloatingNotes.length) } - } else { - newFloatingNotes.push(floatingNote) - - if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> Old Note Kept.') } - if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> floatingNote.floatingHandle = ' + floatingNote.floatingHandle) } - if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> Added to newFloatingNotes.') } - if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> newFloatingNotes.length = ' + newFloatingNotes.length) } - - let floatingObject = floatingLayer.getFloatingObject(floatingNote.floatingHandle) - floatingObject.payloadNoteIndex = i - - if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> floatingObject index updated.') } - if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> floatingObject.payloadNoteIndex = ' + i) } - } - } - - noteSet.floatingNotes = newFloatingNotes - - if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> noteSet.floatingNotes.length = ' + noteSet.floatingNotes.length) } - } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] createNoteSet -> onNotesChanged -> err = ' + err.stack) } - } - } - } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] createNoteSet -> err = ' + err.stack) } - callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) - } - } - - function destroyNoteSet (pHandle) { - try { - /* - Usually when a bot is disabled by the end user, or the zoom level changes to one where the notes must not be seen, this method - to destroy an entire NoteSet is executed. What we do in this situation is to localize the NoteSet to be destroyed and we need to - kill, one by one the floating objects in it. Finally we remove this NoteSet item from the NoteSets array. - */ - - if (INFO_LOG === true) { logger.write('[INFO] destroyNoteSet -> Entering function.') } - - for (let i = 0; i < noteSets.length; i++) { - let noteSet = noteSets[i] - - if (noteSet.handle === pHandle) { - for (let j = 0; j < noteSet.floatingNotes.length; j++) { - let floatingNote = noteSet.floatingNotes[j] - - floatingLayer.removeFloatingObject(floatingNote.floatingHandle) - } - - noteSets.splice(i, 1) // Delete item from array. - return - } - } - } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] destroyNoteSet -> err = ' + err.stack) } - } - } -} - diff --git a/FloatingSpace/ProfileBall.js b/FloatingSpace/ProfileBall.js deleted file mode 100644 index 18b853346..000000000 --- a/FloatingSpace/ProfileBall.js +++ /dev/null @@ -1,336 +0,0 @@ - -function newProfileBall () { - const MODULE_NAME = 'Profile Ball' - - let thisObject = { - container: undefined, - physics: physics, - drawBackground: drawBackground, - drawMiddleground: drawMiddleground, - drawForeground: drawForeground, - drawOnFocus: drawOnFocus, - getContainer: getContainer, - initialize: initialize - } - - thisObject.container = newContainer() - thisObject.container.initialize(MODULE_NAME, 'Circle') - thisObject.container.isClickeable = false - thisObject.container.isDraggeable = false - thisObject.container.frame.radius = 0 - thisObject.container.frame.position.x = 0 - thisObject.container.frame.position.y = 0 - - let ballStringMenu = [ - { - visible: false, - iconPathOn: 'Images/menu.icon.on.1.gif', - iconPathOff: 'Images/menu.icon.off.1.gif', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 60 - }/*, - { - visible: false, - iconPathOn: "Images/menu.icon.on.2.gif", - iconPathOff: "Images/menu.icon.off.2.gif", - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 20 * 1 - }, - { - visible: false, - iconPathOn: "Images/menu.icon.on.3.gif", - iconPathOff: "Images/menu.icon.off.3.gif", - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -20 - }, - { - visible: false, - iconPathOn: "Images/menu.icon.on.4.gif", - iconPathOff: "Images/menu.icon.off.4.gif", - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -60 - } */ - ] - - return thisObject - - function initialize () { - for (let i = 0; i < ballStringMenu.length; i++) { - let menuItem = ballStringMenu[i] - menuItem.iconOn = new Image() - menuItem.iconOn.onload = onImageLoad - function onImageLoad () { - menuItem.iconOff = new Image() - menuItem.iconOff.onload = onImageLoad - function onImageLoad () { - menuItem.canDrawIcon = true - } - menuItem.iconOff.src = window.canvasApp.urlPrefix + menuItem.iconPathOff - } - menuItem.iconOn.src = window.canvasApp.urlPrefix + menuItem.iconPathOn - menuItem.icon = menuItem.iconOn // The default value is ON. - } - - thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) - thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick) - thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) - } - - function getContainer (point) { - let container - - if (thisObject.container.frame.isThisPointHere(point, true) === true) { - return thisObject.container - } else { - return undefined - } - } - - function physics () { - // The menuItems also have a target. - - for (let i = 0; i < ballStringMenu.length; i++) { - let menuItem = ballStringMenu[i] - - if (Math.abs(menuItem.currentRadius - menuItem.targetRadius) >= 0.5) { - if (menuItem.currentRadius < menuItem.targetRadius) { - menuItem.currentRadius = menuItem.currentRadius + 0.5 - } else { - menuItem.currentRadius = menuItem.currentRadius - 0.5 - } - } - } - } - - function onMouseOver () { - for (let i = 0; i < ballStringMenu.length; i++) { - let menuItem = ballStringMenu[i] - - menuItem.targetRadius = menuItem.rawRadius * 1.5 - } - } - - function onMouseNotOver () { - for (let i = 0; i < ballStringMenu.length; i++) { - let menuItem = ballStringMenu[i] - - menuItem.targetRadius = menuItem.rawRadius * 0 - i * 5 - } - } - - function onMouseClick (event) { - /* What we need to do here is to check which menu item was clicked, if any. */ - - pPoint = event.point - pFloatingObject = event.parent - - let menuItemIndex - - for (let i = 0; i < ballStringMenu.length; i++) { - let menuItem = ballStringMenu[i] - - if (menuItem.canDrawIcon === true && menuItem.currentRadius > 1) { - let position = { - x: pFloatingObject.container.frame.position.x + pFloatingObject.currentImageSize / 2 * Math.cos(toRadians(menuItem.angle)), - y: pFloatingObject.container.frame.position.y - pFloatingObject.currentImageSize / 2 * Math.sin(toRadians(menuItem.angle)) - } - - browserCanvasContext.drawImage(menuItem.icon, position.x, position.y, menuItem.currentRadius * 2, menuItem.currentRadius * 2) - - let distance = Math.sqrt(Math.pow(position.x - pPoint.x, 2) + Math.pow(position.y - pPoint.y, 2)) - - if (distance < menuItem.currentRadius) { - menuItemIndex = i - } - } - } - - if (menuItemIndex !== undefined) { - switch (menuItemIndex) { - - case 0: { - // This menu item is to turn ON / OFF the plotting of this bot. - - if (pFloatingObject.payload.profile.plot === true) { - pFloatingObject.payload.profile.plot = false - - let menuItem = ballStringMenu[0] - menuItem.icon = menuItem.iconOff - } else { - pFloatingObject.payload.profile.plot = true - - let menuItem = ballStringMenu[0] - menuItem.icon = menuItem.iconOn - } - - break - } - - case 1: { - // This menu item is to turn ON the Debug Log pannel for the bot. - - break - } - } - } - } - - function drawBackground (pFloatingObject) { - let point = { - x: pFloatingObject.payload.targetPosition.x, - y: pFloatingObject.payload.targetPosition.y - } - - point = viewPort.fitIntoVisibleArea(point) - - if (pFloatingObject.container.frame.radius > 1) { - /* Target Line */ - - browserCanvasContext.beginPath() - browserCanvasContext.moveTo(pFloatingObject.container.frame.position.x, pFloatingObject.container.frame.position.y) - browserCanvasContext.lineTo(point.x, point.y) - browserCanvasContext.strokeStyle = 'rgba(204, 204, 204, 0.5)' - browserCanvasContext.setLineDash([4, 2]) - browserCanvasContext.lineWidth = 1 - browserCanvasContext.stroke() - browserCanvasContext.setLineDash([0, 0]) - } - - if (pFloatingObject.container.frame.radius > 0.5) { - /* Target Spot */ - - var radius = 1 - - browserCanvasContext.beginPath() - browserCanvasContext.arc(point.x, point.y, radius, 0, Math.PI * 2, true) - browserCanvasContext.closePath() - browserCanvasContext.fillStyle = 'rgba(30, 30, 30, 1)' - browserCanvasContext.fill() - } - } - - function drawOnFocus () { - - } - - function drawMiddleground () { - - } - - function drawForeground (pFloatingObject) { - if (pFloatingObject.container.frame.radius > 5) { - /* Contourn */ - - browserCanvasContext.beginPath() - browserCanvasContext.arc(pFloatingObject.container.frame.position.x, pFloatingObject.container.frame.position.y, pFloatingObject.container.frame.radius, 0, Math.PI * 2, true) - browserCanvasContext.closePath() - browserCanvasContext.strokeStyle = 'rgba(30, 30, 30, 0.75)' - browserCanvasContext.lineWidth = 1 - browserCanvasContext.stroke() - } - - if (pFloatingObject.container.frame.radius > 0.5) { - /* Main FloatingObject */ - - var alphaA - - if (pFloatingObject.container.frame.radius < 3) { - alphaA = 1 - } else { - alphaA = 0.75 - } - - alphaA = 0.75 - - browserCanvasContext.beginPath() - browserCanvasContext.arc(pFloatingObject.container.frame.position.x, pFloatingObject.container.frame.position.y, pFloatingObject.container.frame.radius, 0, Math.PI * 2, true) - browserCanvasContext.closePath() - - browserCanvasContext.fillStyle = pFloatingObject.fillStyle - - browserCanvasContext.fill() - } - - /* Image */ - - if (pFloatingObject.payload.profile.imageId !== undefined) { - let image = pFloatingObject.payload.profile.botAvatar - - if (image !== null && image !== undefined) { - browserCanvasContext.save() - browserCanvasContext.beginPath() - browserCanvasContext.arc(pFloatingObject.container.frame.position.x, pFloatingObject.container.frame.position.y, pFloatingObject.currentImageSize / 2, 0, Math.PI * 2, true) - browserCanvasContext.closePath() - browserCanvasContext.clip() - browserCanvasContext.drawImage(image, pFloatingObject.container.frame.position.x - pFloatingObject.currentImageSize / 2, pFloatingObject.container.frame.position.y - pFloatingObject.currentImageSize / 2, pFloatingObject.currentImageSize, pFloatingObject.currentImageSize) - browserCanvasContext.beginPath() - browserCanvasContext.arc(pFloatingObject.container.frame.position.x - pFloatingObject.currentImageSize / 2, pFloatingObject.container.frame.position.y - pFloatingObject.currentImageSize / 2, pFloatingObject.currentImageSize / 2, 0, Math.PI * 2, true) - browserCanvasContext.clip() - browserCanvasContext.closePath() - browserCanvasContext.restore() - } - } - - /* StringBall Menu */ - - for (let i = 0; i < ballStringMenu.length; i++) { - let menuItem = ballStringMenu[i] - - if (menuItem.canDrawIcon === true && menuItem.currentRadius > 1) { - let position = { - x: pFloatingObject.container.frame.position.x + pFloatingObject.currentImageSize / 2 * Math.cos(toRadians(menuItem.angle)), - y: pFloatingObject.container.frame.position.y - pFloatingObject.currentImageSize / 2 * Math.sin(toRadians(menuItem.angle)) - } - - browserCanvasContext.drawImage(menuItem.icon, position.x - menuItem.currentRadius, position.y - menuItem.currentRadius, menuItem.currentRadius * 2, menuItem.currentRadius * 2) - } - } - - /* Label Text */ - - if (pFloatingObject.container.frame.radius > 6) { - browserCanvasContext.strokeStyle = pFloatingObject.labelStrokeStyle - - let labelPoint - let fontSize = pFloatingObject.currentFontSize - - browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY - - let label - - label = pFloatingObject.payload.profile.subTitle - - if (label !== undefined) { - labelPoint = { - x: pFloatingObject.container.frame.position.x - label.length / 2 * fontSize * FONT_ASPECT_RATIO, - y: pFloatingObject.container.frame.position.y - pFloatingObject.currentImageSize / 2 - fontSize * FONT_ASPECT_RATIO - 10 - } - - browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY - browserCanvasContext.fillStyle = pFloatingObject.labelStrokeStyle - browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y) - } - - label = pFloatingObject.payload.profile.title - - if (label !== undefined) { - labelPoint = { - x: pFloatingObject.container.frame.position.x - label.length / 2 * fontSize * FONT_ASPECT_RATIO, - y: pFloatingObject.container.frame.position.y + pFloatingObject.currentImageSize / 2 + fontSize * FONT_ASPECT_RATIO + 15 - } - - browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY - browserCanvasContext.fillStyle = pFloatingObject.labelStrokeStyle - browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y) - } - } - } -} diff --git a/FloatingSpace/ProfileBalls.js b/FloatingSpace/ProfileBalls.js deleted file mode 100644 index 45f53e013..000000000 --- a/FloatingSpace/ProfileBalls.js +++ /dev/null @@ -1,62 +0,0 @@ - -function newProfileBalls () { - const MODULE_NAME = 'Profile Balls' - const INFO_LOG = false - const ERROR_LOG = true - const logger = newWebDebugLog() - logger.fileName = MODULE_NAME - - /* - - This object deals with Profile Balls, a type of Floating Object that shows profile info in a floating ball. - - */ - - let thisObject = { - - createNewProfileBall: createNewProfileBall, - destroyProfileBall: destroyProfileBall, - initialize: initialize, - finalize: finalize - - } - - let floatingLayer - - return thisObject - - function initialize (pFloatingLayer) { - floatingLayer = pFloatingLayer - } - - function finalize () { - floatingLayer.finalize() - floatingLayer = undefined - } - - function createNewProfileBall (pPayload, callBackFunction) { - let floatingObject = newFloatingObject() - floatingObject.initialize('Profile Ball', '', floatingLayer) - - floatingObject.payload = pPayload - - floatingObject.friction = 0.995 - - floatingObject.initializeMass(100) - floatingObject.initializeRadius(30) - floatingObject.initializeImageSize(50) - floatingObject.initializeFontSize(10) - - floatingObject.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 0.5)' - floatingObject.labelStrokeStyle = 'rgba(60, 60, 60, 0.50)' - - floatingLayer.addFloatingObject(floatingObject) - - callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE, floatingObject.handle) - } - - function destroyProfileBall (pFloatingObjectHandle) { - floatingLayer.removeFloatingObject(pFloatingObjectHandle) - } -} - diff --git a/Spaces/FloatingSpace.js b/Spaces/FloatingSpace.js index b82fde99e..f86b91b12 100644 --- a/Spaces/FloatingSpace.js +++ b/Spaces/FloatingSpace.js @@ -9,9 +9,7 @@ function newFloatingSpace () { let thisObject = { floatingLayer: undefined, // This is the array of floatingObjects being displayed - profileBalls: undefined, uiObjectConstructor: undefined, - noteSets: undefined, container: undefined, oneScreenUp: oneScreenUp, oneScreenDown: oneScreenDown, @@ -60,15 +58,11 @@ function newFloatingSpace () { thisObject.container.eventHandler.stopListening(eventSubscriptionId) thisObject.floatingLayer.finalize() - thisObject.profileBalls.finalize() thisObject.uiObjectConstructor.finalize() - thisObject.noteSets.finalize() thisObject.container.finalize() thisObject.floatingLayer = undefined - thisObject.profileBalls = undefined thisObject.uiObjectConstructor = undefined - thisObject.noteSets = undefined thisObject.container = undefined } @@ -76,12 +70,6 @@ function newFloatingSpace () { thisObject.floatingLayer = newFloatingLayer() thisObject.floatingLayer.initialize() - thisObject.profileBalls = newProfileBalls() - thisObject.profileBalls.initialize(thisObject.floatingLayer) - - thisObject.noteSets = newNoteSets() - thisObject.noteSets.initialize(thisObject.floatingLayer) - thisObject.uiObjectConstructor = newUiObjectConstructor() thisObject.uiObjectConstructor.initialize(thisObject.floatingLayer) From b6ca74d433f161d46bd8220cc4283d43e12d29d3 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 24 Dec 2019 13:35:23 +0100 Subject: [PATCH 013/264] Bug Fixed, now warming up when dropping a workspace --- DesignerSpace/Workspace/Workspace.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DesignerSpace/Workspace/Workspace.js b/DesignerSpace/Workspace/Workspace.js index 44cd63e67..d770649c2 100644 --- a/DesignerSpace/Workspace/Workspace.js +++ b/DesignerSpace/Workspace/Workspace.js @@ -138,14 +138,14 @@ function newWorkspace () { break case 5: canvas.chartSpace.finalize() + canvas.chartSpace.initialize() workingAtTask++ break case 6: - canvas.chartSpace.initialize() + canvas.floatingSpace.warmUp() workingAtTask = 0 circularProgressBar.visible = false break - } } } From a595d3f0a81bc90abef56ca8e8d0040ef7ab60fb Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 24 Dec 2019 17:17:56 +0100 Subject: [PATCH 014/264] HUGE BUG fixed, duplicating the creation of UI Objects --- .../FunctionLibraries/NodeCloning.js | 16 +- .../FunctionLibraries/NodeDeleter.js | 8 +- .../Workspace/FunctionLibraries/OnFocus.js | 14 +- .../FunctionLibraries/ProtocolNode.js | 16 +- .../FunctionLibraries/ShortcutKeys.js | 14 +- .../FunctionLibraries/UiObjectsFromNodes.js | 943 ++---------------- DesignerSpace/Workspace/Workspace.js | 2 +- FloatingSpace/FloatingObject.js | 9 +- FloatingSpace/UiObject.js | 6 +- FloatingSpace/UiObjectConstructor.js | 17 +- 10 files changed, 150 insertions(+), 895 deletions(-) diff --git a/DesignerSpace/Workspace/FunctionLibraries/NodeCloning.js b/DesignerSpace/Workspace/FunctionLibraries/NodeCloning.js index 79a791f6b..66fb01a3d 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/NodeCloning.js +++ b/DesignerSpace/Workspace/FunctionLibraries/NodeCloning.js @@ -30,13 +30,17 @@ function newNodeCloning () { /* Children Nodes */ if (nodeDefinition.properties !== undefined) { + let previousPropertyName // Since there are cases where there are many properties with the same name,because they can hold nodes of different types but only one at the time, we have to avoind counting each property of those as individual children. for (let i = 0; i < nodeDefinition.properties.length; i++) { let property = nodeDefinition.properties[i] switch (property.type) { case 'node': { - if (node[property.name] !== undefined) { - object[property.name] = cloneNode(node[property.name]) + if (property.name !== previousPropertyName) { + if (node[property.name] !== undefined) { + object[property.name] = cloneNode(node[property.name]) + } + previousPropertyName = property.name } break } @@ -79,13 +83,17 @@ function newNodeCloning () { /* Children Nodes */ if (nodeDefinition.properties !== undefined) { + let previousPropertyName // Since there are cases where there are many properties with the same name,because they can hold nodes of different types but only one at the time, we have to avoind counting each property of those as individual children. for (let i = 0; i < nodeDefinition.properties.length; i++) { let property = nodeDefinition.properties[i] switch (property.type) { case 'node': { - if (node[property.name] !== undefined) { - object[property.name] = redirectReferenceParents(node[property.name]) + if (property.name !== previousPropertyName) { + if (node[property.name] !== undefined) { + object[property.name] = redirectReferenceParents(node[property.name]) + } + previousPropertyName = property.name } break } diff --git a/DesignerSpace/Workspace/FunctionLibraries/NodeDeleter.js b/DesignerSpace/Workspace/FunctionLibraries/NodeDeleter.js index 92d89b278..cf1022d6f 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/NodeDeleter.js +++ b/DesignerSpace/Workspace/FunctionLibraries/NodeDeleter.js @@ -28,13 +28,17 @@ function newNodeDeleter () { if (nodeDefinition !== undefined) { /* Remove all of its own children nodes. */ if (nodeDefinition.properties !== undefined) { + let previousPropertyName // Since there are cases where there are many properties with the same name,because they can hold nodes of different types but only one at the time, we have to avoind counting each property of those as individual children. for (let i = 0; i < nodeDefinition.properties.length; i++) { let property = nodeDefinition.properties[i] switch (property.type) { case 'node': { - if (node[property.name] !== undefined) { - deleteUIObject(node[property.name], rootNodes) + if (property.name !== previousPropertyName) { + if (node[property.name] !== undefined) { + deleteUIObject(node[property.name], rootNodes) + } + previousPropertyName = property.name } } break diff --git a/DesignerSpace/Workspace/FunctionLibraries/OnFocus.js b/DesignerSpace/Workspace/FunctionLibraries/OnFocus.js index abda9e954..a45c9f76c 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/OnFocus.js +++ b/DesignerSpace/Workspace/FunctionLibraries/OnFocus.js @@ -17,17 +17,21 @@ function newOnFocus () { /* Then we check all of its own children nodes. */ if (node.payload.floatingObject.isCollapsed !== true) { if (nodeDefinition.properties !== undefined) { + let previousPropertyName // Since there are cases where there are many properties with the same name,because they can hold nodes of different types but only one at the time, we have to avoind counting each property of those as individual children. for (let i = 0; i < nodeDefinition.properties.length; i++) { let property = nodeDefinition.properties[i] switch (property.type) { case 'node': { - if (node[property.name] !== undefined) { - let child - child = getNodeThatIsOnFocus(node[property.name]) - if (child !== undefined) { - return child + if (property.name !== previousPropertyName) { + if (node[property.name] !== undefined) { + let child + child = getNodeThatIsOnFocus(node[property.name]) + if (child !== undefined) { + return child + } } + previousPropertyName = property.name } } break diff --git a/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js b/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js index cd25e4d32..f16aa80e6 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js +++ b/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js @@ -25,19 +25,23 @@ function newProtocolNode () { /* Children Nodes */ if (nodeDefinition.properties !== undefined) { + let previousPropertyName // Since there are cases where there are many properties with the same name,because they can hold nodes of different types but only one at the time, we have to avoind counting each property of those as individual children. for (let i = 0; i < nodeDefinition.properties.length; i++) { let property = nodeDefinition.properties[i] switch (property.type) { case 'node': { if (node[property.name] !== undefined) { - if (lightingPath === undefined) { - object[property.name] = getProtocolNode(node[property.name], removePersonalData, parseCode, includeIds, includeReferencesInSavedPayload, includePayload) - } else { - let newLightingPath = getNewLightingPath(lightingPath, node.type, property.childType) - if (newLightingPath !== undefined) { - object[property.name] = getProtocolNode(node[property.name], removePersonalData, parseCode, includeIds, includePayload, includeReferencesInSavedPayload, newLightingPath) + if (property.name !== previousPropertyName) { + if (lightingPath === undefined) { + object[property.name] = getProtocolNode(node[property.name], removePersonalData, parseCode, includeIds, includeReferencesInSavedPayload, includePayload) + } else { + let newLightingPath = getNewLightingPath(lightingPath, node.type, property.childType) + if (newLightingPath !== undefined) { + object[property.name] = getProtocolNode(node[property.name], removePersonalData, parseCode, includeIds, includePayload, includeReferencesInSavedPayload, newLightingPath) + } } + previousPropertyName = property.name } } break diff --git a/DesignerSpace/Workspace/FunctionLibraries/ShortcutKeys.js b/DesignerSpace/Workspace/FunctionLibraries/ShortcutKeys.js index a9ac89651..28e6afc2a 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/ShortcutKeys.js +++ b/DesignerSpace/Workspace/FunctionLibraries/ShortcutKeys.js @@ -16,17 +16,21 @@ function newShortcutKeys () { /* Check all of its own children nodes. */ if (node.payload.floatingObject.isCollapsed !== true) { if (nodeDefinition.properties !== undefined) { + let previousPropertyName // Since there are cases where there are many properties with the same name,because they can hold nodes of different types but only one at the time, we have to avoind counting each property of those as individual children. for (let i = 0; i < nodeDefinition.properties.length; i++) { let property = nodeDefinition.properties[i] switch (property.type) { case 'node': { - if (node[property.name] !== undefined) { - let child - child = getNodeByShortcutKey(node[property.name], searchingKey) - if (child !== undefined) { - return child + if (property.name !== previousPropertyName) { + if (node[property.name] !== undefined) { + let child + child = getNodeByShortcutKey(node[property.name], searchingKey) + if (child !== undefined) { + return child + } } + previousPropertyName = property.name } } break diff --git a/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js b/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js index e0217f098..565f6d332 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js +++ b/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js @@ -110,861 +110,46 @@ function newUiObjectsFromNodes () { } function createUiObjectFromNode (node, parentNode, chainParent, positionOffset) { - /* - Object.keys(node).forEach(function (key, index) { - // key: the name of the object key - // index: the ordinal position of the key within the object - if (key !== 'savedPayload') { - if (node.type === 'Indicator Bot') { - console.log('HERE') - } - if (Array.isArray(node[key]) === false) { - if ((typeof node[key] === 'object') && (node[key] !== null)) { - // this property is an object - - for (let i = 0; i < APP_SCHEMA_ARRAY.length; i++) { - let schemaNode = APP_SCHEMA_ARRAY[i] - if (schemaNode.type === node.type) { - if (schemaNode.properties === undefined) { - schemaNode.properties = [] - } - - let properties = schemaNode.properties - let found = false - for (let j = 0; j < properties.length; j++) { - let property = properties[j] - if (property.name === key && property.childType === node[key].type) { - found = true - } - } - if (found === false) { - let newProperty = { - name: key, - type: 'node', - childType: node[key].type - } - properties.push(newProperty) - } - setPropertyNameAtParent(node[key], key) - } - } - } - } else { - let childArray = node[key] - if (childArray.length > 0) { - let childType = childArray[0].type - for (let i = 0; i < APP_SCHEMA_ARRAY.length; i++) { - let schemaNode = APP_SCHEMA_ARRAY[i] - if (schemaNode.type === node.type) { - if (schemaNode.properties === undefined) { - schemaNode.properties = [] - } - - let properties = schemaNode.properties - let found = false - for (let j = 0; j < properties.length; j++) { - let property = properties[j] - if (property.name === key && property.childType === childType) { - found = true - } - } - if (found === false) { - let newProperty = { - name: key, - type: 'array', - childType: childType - } - properties.push(newProperty) - } - setPropertyNameAtParent(childArray[0], key) - } - } + /* Get node definition */ + let nodeDefinition = APP_SCHEMA_MAP.get(node.type) + if (nodeDefinition !== undefined) { + /* Resolve Initial Values */ + if (nodeDefinition.initialValues !== undefined) { + if (nodeDefinition.initialValues.code !== undefined) { + if (node.code === undefined) { + node.code = nodeDefinition.initialValues.code } } } - }) - function setPropertyNameAtParent (node, propName) { - for (let i = 0; i < APP_SCHEMA_ARRAY.length; i++) { - let schemaNode = APP_SCHEMA_ARRAY[i] - if (schemaNode.type === node.type) { - schemaNode.propertyNameAtParent = propName - } - } - } -*/ - switch (node.type) { - case 'Javascript Code': - { - createUiObject(false, 'Javascript Code', node.name, node, parentNode, chainParent, 'Javascript Code', positionOffset) - return - } - case 'Condition': - { - createUiObject(false, 'Condition', node.name, node, parentNode, chainParent, 'Condition', positionOffset) + /* Create Self */ + createUiObject(false, node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) - if (node.javascriptCode !== undefined) { - createUiObjectFromNode(node.javascriptCode, node, node, positionOffset) - } - return - } - case 'Situation': { - let situation = node - createUiObject(false, 'Situation', situation.name, situation, parentNode, chainParent, 'Situation', positionOffset) - for (let m = 0; m < node.conditions.length; m++) { - let condition = node.conditions[m] - createUiObjectFromNode(condition, situation, situation, positionOffset) - } - return - } - case 'Formula': - { - createUiObject(false, 'Formula', node.name, node, parentNode, chainParent, 'Formula', positionOffset) - return - } - case 'Next Phase Event': - { - createUiObject(false, 'Next Phase Event', node.name, node, parentNode, chainParent, 'Next Phase Event', positionOffset) - for (let m = 0; m < node.situations.length; m++) { - let situation = node.situations[m] - createUiObjectFromNode(situation, node, node, positionOffset) - } - if (node.announcements === undefined) { - node.announcements = [] - } - for (let m = 0; m < node.announcements.length; m++) { - let announcement = node.announcements[m] - createUiObjectFromNode(announcement, node, node, positionOffset) - } - return - } - case 'Phase': { - let phase = node - createUiObject(false, 'Phase', phase.name, phase, parentNode, chainParent, phase.subType, positionOffset) - - if (node.formula !== undefined) { - createUiObjectFromNode(node.formula, phase, phase, positionOffset) - } - if (node.nextPhaseEvent !== undefined) { - createUiObjectFromNode(node.nextPhaseEvent, phase, phase, positionOffset) - } - if (node.announcements === undefined) { - node.announcements = [] - } - for (let m = 0; m < node.announcements.length; m++) { - let announcement = node.announcements[m] - createUiObjectFromNode(announcement, node, node, positionOffset) - } - return - } - case 'Stop': { - let lastPhase - let stop = node - createUiObject(false, 'Stop', stop.name, stop, parentNode, chainParent, 'Stop', positionOffset) - for (let m = 0; m < node.phases.length; m++) { - let phase = node.phases[m] - let thisChainParent - if (m === 0) { - thisChainParent = node - } else { - thisChainParent = lastPhase - } - lastPhase = phase - createUiObjectFromNode(phase, stop, thisChainParent, positionOffset) - } - return - } - case 'Take Profit': { - let lastPhase - let takeProfit = node - createUiObject(false, 'Take Profit', takeProfit.name, takeProfit, parentNode, chainParent, 'Take Profit', positionOffset) - for (let m = 0; m < node.phases.length; m++) { - let phase = node.phases[m] - let thisChainParent - if (m === 0) { - thisChainParent = node - } else { - thisChainParent = lastPhase - } - lastPhase = phase - createUiObjectFromNode(phase, takeProfit, thisChainParent, positionOffset) - } - return - } - case 'Open Execution': - { - createUiObject(false, 'Open Execution', node.name, node, parentNode, chainParent, 'Open Execution', positionOffset) - return - } - case 'Close Execution': - { - createUiObject(false, 'Close Execution', node.name, node, parentNode, chainParent, 'Close Execution', positionOffset) - return - } - case 'Initial Definition': { - createUiObject(false, 'Initial Definition', node.name, node, parentNode, chainParent, 'Initial Definition', positionOffset) - - if (node.stopLoss !== undefined) { - createUiObjectFromNode(node.stopLoss, node, node, positionOffset) - } - if (node.takeProfit !== undefined) { - createUiObjectFromNode(node.takeProfit, node, node, positionOffset) - } - if (node.positionSize !== undefined) { - createUiObjectFromNode(node.positionSize, node, node, positionOffset) - } - if (node.positionRate !== undefined) { - createUiObjectFromNode(node.positionRate, node, node, positionOffset) - } - return - } - case 'Take Position Event': { - let event = node - createUiObject(false, 'Take Position Event', event.name, event, parentNode, chainParent, 'Take Position Event', positionOffset) - for (let m = 0; m < node.situations.length; m++) { - let situation = node.situations[m] - createUiObjectFromNode(situation, event, event, positionOffset) - } - if (node.announcements === undefined) { - node.announcements = [] - } - for (let m = 0; m < node.announcements.length; m++) { - let announcement = node.announcements[m] - createUiObjectFromNode(announcement, node, node, positionOffset) - } - return - } - case 'Trigger On Event': { - let event = node - createUiObject(false, 'Trigger On Event', event.name, event, parentNode, chainParent, 'Trigger On Event', positionOffset) - for (let m = 0; m < node.situations.length; m++) { - let situation = node.situations[m] - createUiObjectFromNode(situation, event, event, positionOffset) - } - if (node.announcements === undefined) { - node.announcements = [] - } - for (let m = 0; m < node.announcements.length; m++) { - let announcement = node.announcements[m] - createUiObjectFromNode(announcement, node, node, positionOffset) - } - return - } - case 'Trigger Off Event': { - let event = node - createUiObject(false, 'Trigger Off Event', event.name, event, parentNode, chainParent, 'Trigger Off Event', positionOffset) - for (let m = 0; m < node.situations.length; m++) { - let situation = node.situations[m] - createUiObjectFromNode(situation, event, event, positionOffset) - } - if (node.announcements === undefined) { - node.announcements = [] - } - for (let m = 0; m < node.announcements.length; m++) { - let announcement = node.announcements[m] - createUiObjectFromNode(announcement, node, node, positionOffset) - } - return - } - case 'Position Size': { - createUiObject(false, 'Position Size', node.name, node, parentNode, chainParent, 'Position Size', positionOffset) - if (node.formula !== undefined) { - createUiObjectFromNode(node.formula, node, node, positionOffset) - } - return - } - case 'Position Rate': { - createUiObject(false, 'Position Rate', node.name, node, parentNode, chainParent, 'Position Rate', positionOffset) - if (node.formula !== undefined) { - createUiObjectFromNode(node.formula, node, node, positionOffset) - } - return - } - case 'Trigger Stage': { - let stage = node - createUiObject(false, 'Trigger Stage', stage.name, stage, parentNode, chainParent, 'Trigger Stage', positionOffset) - - if (node.triggerOn !== undefined) { - createUiObjectFromNode(node.triggerOn, stage, stage, positionOffset) - } - if (node.triggerOff !== undefined) { - createUiObjectFromNode(node.triggerOff, stage, stage, positionOffset) - } - if (node.takePosition !== undefined) { - createUiObjectFromNode(node.takePosition, stage, stage, positionOffset) - } - return - } - case 'Open Stage': { - let stage = node - createUiObject(false, 'Open Stage', stage.name, stage, parentNode, chainParent, 'Open Stage', positionOffset) - - if (node.initialDefinition !== undefined) { - createUiObjectFromNode(node.initialDefinition, stage, stage, positionOffset) - } - if (node.openExecution !== undefined) { - createUiObjectFromNode(node.openExecution, stage, stage, positionOffset) - } - return - } - case 'Manage Stage': { - let stage = node - createUiObject(false, 'Manage Stage', stage.name, stage, parentNode, chainParent, 'Manage Stage', positionOffset) - - if (node.stopLoss !== undefined) { - createUiObjectFromNode(node.stopLoss, stage, stage, positionOffset) - } - if (node.takeProfit !== undefined) { - createUiObjectFromNode(node.takeProfit, stage, stage, positionOffset) - } - return - } - case 'Close Stage': { - let stage = node - createUiObject(false, 'Close Stage', stage.name, stage, parentNode, chainParent, 'Close Stage', positionOffset) - - if (node.closeExecution !== undefined) { - createUiObjectFromNode(node.closeExecution, stage, stage, positionOffset) - } - return - } - case 'Strategy': { - let strategy = node - createUiObject(false, 'Strategy', strategy.name, strategy, parentNode, chainParent, 'Strategy', positionOffset) - if (node.triggerStage !== undefined) { - createUiObjectFromNode(node.triggerStage, strategy, strategy, positionOffset) - } - if (node.openStage !== undefined) { - createUiObjectFromNode(node.openStage, strategy, strategy, positionOffset) - } - if (node.manageStage !== undefined) { - createUiObjectFromNode(node.manageStage, strategy, strategy, positionOffset) - } - if (node.closeStage !== undefined) { - createUiObjectFromNode(node.closeStage, strategy, strategy, positionOffset) - } - return - } - case 'Base Asset': { - createUiObject(false, 'Base Asset', node.name, node, parentNode, chainParent, 'Base Asset', positionOffset) - return - } - case 'Time Range': { - createUiObject(false, 'Time Range', node.name, node, parentNode, chainParent, 'Time Range', positionOffset) - return - } - case 'Time Period': { - createUiObject(false, 'Time Period', node.name, node, parentNode, chainParent, 'Time Period', positionOffset) - return - } - case 'Slippage': { - createUiObject(false, 'Slippage', node.name, node, parentNode, chainParent, 'Slippage', positionOffset) - return - } - case 'Fee Structure': { - createUiObject(false, 'Fee Structure', node.name, node, parentNode, chainParent, 'Fee Structure', positionOffset) - return - } - case 'Parameters': { - createUiObject(false, 'Parameters', node.name, node, parentNode, chainParent, 'Parameters', positionOffset) - if (node.baseAsset !== undefined) { - createUiObjectFromNode(node.baseAsset, node, node, positionOffset) - } - if (node.timeRange !== undefined) { - createUiObjectFromNode(node.timeRange, node, node, positionOffset) - } - if (node.timePeriod !== undefined) { - createUiObjectFromNode(node.timePeriod, node, node, positionOffset) - } - if (node.slippage !== undefined) { - createUiObjectFromNode(node.slippage, node, node, positionOffset) - } - if (node.feeStructure !== undefined) { - createUiObjectFromNode(node.feeStructure, node, node, positionOffset) - } - if (node.key !== undefined) { - createUiObjectFromNode(node.key, node, node, positionOffset) - } - return - } - case 'Trading System': { - let tradingSystem = node - createUiObject(false, 'Trading System', tradingSystem.name, tradingSystem, parentNode, chainParent, 'Trading System', positionOffset) - for (let m = 0; m < node.strategies.length; m++) { - let strategy = node.strategies[m] - createUiObjectFromNode(strategy, tradingSystem, tradingSystem, positionOffset) - } - if (node.parameters !== undefined) { - createUiObjectFromNode(node.parameters, node, node, positionOffset) - } - return - } - case 'Personal Data': { - createUiObject(false, 'Personal Data', node.name, node, parentNode, chainParent, 'Personal Data', positionOffset) - for (let m = 0; m < node.exchangeAccounts.length; m++) { - let exchangeAccount = node.exchangeAccounts[m] - createUiObjectFromNode(exchangeAccount, node, node, positionOffset) - } - return - } - case 'Exchange Account': { - createUiObject(false, 'Exchange Account', node.name, node, parentNode, chainParent, 'Exchange Account', positionOffset) - for (let m = 0; m < node.assets.length; m++) { - let asset = node.assets[m] - createUiObjectFromNode(asset, node, node, positionOffset) - } - for (let m = 0; m < node.keys.length; m++) { - let key = node.keys[m] - createUiObjectFromNode(key, node, node, positionOffset) - } - return - } - case 'Exchange Account Asset': { - createUiObject(false, 'Exchange Account Asset', node.name, node, parentNode, chainParent, 'Exchange Account Asset', positionOffset) - return - } - case 'Exchange Account Key': { - createUiObject(false, 'Exchange Account Key', node.name, node, parentNode, chainParent, 'Exchange Account Key', positionOffset) - return - } - case 'Definition': { - createUiObject(false, 'Definition', node.name, node, parentNode, chainParent, 'Definition', positionOffset) - if (node.tradingSystem !== undefined) { - createUiObjectFromNode(node.tradingSystem, node, node, positionOffset) - } - if (node.personalData !== undefined) { - createUiObjectFromNode(node.personalData, node, node, positionOffset) - } - return - } - case 'Network': { - createUiObject(false, 'Network', node.name, node, parentNode, chainParent, 'Network', positionOffset) - if (node.networkNodes !== undefined) { - for (let m = 0; m < node.networkNodes.length; m++) { - let networkNode = node.networkNodes[m] - createUiObjectFromNode(networkNode, node, node, positionOffset) - } - } - return - } - case 'Network Node': { - createUiObject(false, 'Network Node', node.name, node, parentNode, chainParent, 'Network Node', positionOffset) - if (node.taskManagers !== undefined) { - for (let m = 0; m < node.taskManagers.length; m++) { - let taskManager = node.taskManagers[m] - createUiObjectFromNode(taskManager, node, node, positionOffset) - } - } - return - } - case 'Social Bots': { - createUiObject(false, 'Social Bots', node.name, node, parentNode, chainParent, 'Social Bots', positionOffset) - for (let m = 0; m < node.bots.length; m++) { - let bot = node.bots[m] - createUiObjectFromNode(bot, node, node, positionOffset) - } - return - } - case 'Telegram Bot': { - createUiObject(false, 'Telegram Bot', node.name, node, parentNode, chainParent, 'Telegram Bot', positionOffset) - for (let m = 0; m < node.announcements.length; m++) { - let announcement = node.announcements[m] - createUiObjectFromNode(announcement, node, node, positionOffset) - } - return - } - case 'Announcement': { - createUiObject(false, 'Announcement', node.name, node, parentNode, chainParent, 'Announcement', positionOffset) - if (node.formula !== undefined) { - createUiObjectFromNode(node.formula, node, node, positionOffset) - } - return - } - case 'Layer Manager': { - createUiObject(false, 'Layer Manager', node.name, node, parentNode, chainParent, 'Layer Manager', positionOffset) - for (let m = 0; m < node.layers.length; m++) { - let layer = node.layers[m] - createUiObjectFromNode(layer, node, node, positionOffset) - } - return - } - case 'Layer': { - createUiObject(false, 'Layer', node.name, node, parentNode, chainParent, 'Layer', positionOffset) - return - } - case 'Task Manager': { - createUiObject(false, 'Task Manager', node.name, node, parentNode, chainParent, 'Task Manager', positionOffset) - for (let m = 0; m < node.tasks.length; m++) { - let task = node.tasks[m] - createUiObjectFromNode(task, node, node, positionOffset) - } - return - } - case 'Task': { - createUiObject(false, 'Task', node.name, node, parentNode, chainParent, 'Task', positionOffset) - if (node.bot !== undefined) { - createUiObjectFromNode(node.bot, node, node, positionOffset) - } - return - } - case 'Sensor Bot Instance': { - createUiObject(false, 'Sensor Bot Instance', node.name, node, parentNode, chainParent, 'Sensor Bot Instance', positionOffset) - for (let m = 0; m < node.processes.length; m++) { - let process = node.processes[m] - createUiObjectFromNode(process, node, node, positionOffset) - } - return - } - case 'Indicator Bot Instance': { - createUiObject(false, 'Indicator Bot Instance', node.name, node, parentNode, chainParent, 'Indicator Bot Instance', positionOffset) - for (let m = 0; m < node.processes.length; m++) { - let process = node.processes[m] - createUiObjectFromNode(process, node, node, positionOffset) - } - return - } - case 'Trading Bot Instance': { - createUiObject(false, 'Trading Bot Instance', node.name, node, parentNode, chainParent, 'Trading Bot Instance', positionOffset) - for (let m = 0; m < node.processes.length; m++) { - let process = node.processes[m] - createUiObjectFromNode(process, node, node, positionOffset) - } - return - } - case 'Process Instance': { - if (parentNode !== undefined) { - switch (parentNode.type) { - case 'Sensor Bot Instance': { - node.subType = 'Sensor Process Instance' - break - } - case 'Indicator Bot Instance': { - node.subType = 'Indicator Process Instance' - break - } - case 'Trading Bot Instance': { - node.subType = 'Trading Process Instance' - break - } - } - } - createUiObject(false, 'Process Instance', node.name, node, parentNode, chainParent, 'Process Instance', positionOffset) - if (node.session !== undefined) { - createUiObjectFromNode(node.session, node, node, positionOffset) - } - return - } - case 'Backtesting Session': { - createUiObject(false, 'Backtesting Session', node.name, node, parentNode, chainParent, 'Backtesting Session', positionOffset) - if (node.parameters !== undefined) { - createUiObjectFromNode(node.parameters, node, node, positionOffset) - } - if (node.layerManager !== undefined) { - createUiObjectFromNode(node.layerManager, node, node, positionOffset) - } - if (node.socialBots !== undefined) { - createUiObjectFromNode(node.socialBots, node, node, positionOffset) - } - return - } - case 'Live Trading Session': { - createUiObject(false, 'Live Trading Session', node.name, node, parentNode, chainParent, 'Live Trading Session', positionOffset) - if (node.parameters !== undefined) { - createUiObjectFromNode(node.parameters, node, node, positionOffset) - } - if (node.layerManager !== undefined) { - createUiObjectFromNode(node.layerManager, node, node, positionOffset) - } - if (node.socialBots !== undefined) { - createUiObjectFromNode(node.socialBots, node, node, positionOffset) - } - return - } - case 'Fordward Testing Session': { - createUiObject(false, 'Fordward Testing Session', node.name, node, parentNode, chainParent, 'Fordward Testing Session', positionOffset) - if (node.parameters !== undefined) { - createUiObjectFromNode(node.parameters, node, node, positionOffset) - } - if (node.layerManager !== undefined) { - createUiObjectFromNode(node.layerManager, node, node, positionOffset) - } - if (node.socialBots !== undefined) { - createUiObjectFromNode(node.socialBots, node, node, positionOffset) - } - return - } - case 'Paper Trading Session': { - createUiObject(false, 'Paper Trading Session', node.name, node, parentNode, chainParent, 'Paper Trading Session', positionOffset) - if (node.parameters !== undefined) { - createUiObjectFromNode(node.parameters, node, node, positionOffset) - } - if (node.layerManager !== undefined) { - createUiObjectFromNode(node.layerManager, node, node, positionOffset) - } - if (node.socialBots !== undefined) { - createUiObjectFromNode(node.socialBots, node, node, positionOffset) - } - return - } - - case 'Team': { - createUiObject(false, node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) - for (let m = 0; m < node.sensorBots.length; m++) { - let sensorBot = node.sensorBots[m] - createUiObjectFromNode(sensorBot, node, node, positionOffset) - } - for (let m = 0; m < node.indicatorBots.length; m++) { - let indicatorBot = node.indicatorBots[m] - createUiObjectFromNode(indicatorBot, node, node, positionOffset) - } - for (let m = 0; m < node.tradingBots.length; m++) { - let tradingBot = node.tradingBots[m] - createUiObjectFromNode(tradingBot, node, node, positionOffset) - } - for (let m = 0; m < node.plotters.length; m++) { - let plotter = node.plotters[m] - createUiObjectFromNode(plotter, node, node, positionOffset) - } - return - } - case 'Sensor Bot': { - createUiObject(false, node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) - for (let m = 0; m < node.processes.length; m++) { - let process = node.processes[m] - createUiObjectFromNode(process, node, node, positionOffset) - } - for (let m = 0; m < node.products.length; m++) { - let product = node.products[m] - createUiObjectFromNode(product, node, node, positionOffset) - } - return - } - case 'Indicator Bot': { - createUiObject(false, node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) - for (let m = 0; m < node.processes.length; m++) { - let process = node.processes[m] - createUiObjectFromNode(process, node, node, positionOffset) - } - for (let m = 0; m < node.products.length; m++) { - let product = node.products[m] - createUiObjectFromNode(product, node, node, positionOffset) - } - return - } - case 'Trading Bot': { - createUiObject(false, node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) - for (let m = 0; m < node.processes.length; m++) { - let process = node.processes[m] - createUiObjectFromNode(process, node, node, positionOffset) - } - for (let m = 0; m < node.products.length; m++) { - let product = node.products[m] - createUiObjectFromNode(product, node, node, positionOffset) - } - return - } - case 'Process Definition': { - createUiObject(false, node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) - if (node.processOutput !== undefined) { - createUiObjectFromNode(node.processOutput, node, node, positionOffset) - } - if (node.processDependencies !== undefined) { - createUiObjectFromNode(node.processDependencies, node, node, positionOffset) - } - if (node.statusReport !== undefined) { - createUiObjectFromNode(node.statusReport, node, node, positionOffset) - } - if (node.executionStartedEvent !== undefined) { - createUiObjectFromNode(node.executionStartedEvent, node, node, positionOffset) - } - if (node.executionFinishedEvent !== undefined) { - createUiObjectFromNode(node.executionFinishedEvent, node, node, positionOffset) - } - return - } - case 'Process Output': { - createUiObject(false, node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) - for (let m = 0; m < node.outputDatasets.length; m++) { - let outputDataset = node.outputDatasets[m] - createUiObjectFromNode(outputDataset, node, node, positionOffset) - } - return - } - case 'Process Dependencies': { - createUiObject(false, node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) - for (let m = 0; m < node.statusDependencies.length; m++) { - let statusDependency = node.statusDependencies[m] - createUiObjectFromNode(statusDependency, node, node, positionOffset) - } - for (let m = 0; m < node.dataDependencies.length; m++) { - let dataDependency = node.dataDependencies[m] - createUiObjectFromNode(dataDependency, node, node, positionOffset) - } - return - } - case 'Status Report': { - createUiObject(false, node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) - return - } - case 'Execution Started Event': { - createUiObject(false, node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) - return - } - case 'Execution Finished Event': { - createUiObject(false, node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) - return - } - case 'Calculations Procedure': { - createUiObject(false, node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) - if (node.initialization !== undefined) { - createUiObjectFromNode(node.initialization, node, node, positionOffset) - } - if (node.loop !== undefined) { - createUiObjectFromNode(node.loop, node, node, positionOffset) - } - return - } - case 'Data Building Procedure': { - createUiObject(false, node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) - if (node.initialization !== undefined) { - createUiObjectFromNode(node.initialization, node, node, positionOffset) - } - if (node.loop !== undefined) { - createUiObjectFromNode(node.loop, node, node, positionOffset) - } - return - } - case 'Procedure Initialization': { - createUiObject(false, node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) - - if (node.javascriptCode !== undefined) { - createUiObjectFromNode(node.javascriptCode, node, node, positionOffset) - } - return - } - case 'Procedure Loop': { - createUiObject(false, node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) - - if (node.javascriptCode !== undefined) { - createUiObjectFromNode(node.javascriptCode, node, node, positionOffset) - } - return - } - case 'Output Dataset': { - createUiObject(false, node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) - return - } - case 'Status Dependency': { - createUiObject(false, node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) - return - } - case 'Data Dependency': { - createUiObject(false, node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) - return - } - case 'Product Definition': { - createUiObject(false, node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) - if (node.record !== undefined) { - createUiObjectFromNode(node.record, node, node, positionOffset) - } - for (let m = 0; m < node.datasets.length; m++) { - let dataset = node.datasets[m] - createUiObjectFromNode(dataset, node, node, positionOffset) - } - if (node.calculations !== undefined) { - createUiObjectFromNode(node.calculations, node, node, positionOffset) - } - if (node.dataBuilding !== undefined) { - createUiObjectFromNode(node.dataBuilding, node, node, positionOffset) - } - return - } - case 'Record Definition': { - createUiObject(false, node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) - for (let m = 0; m < node.properties.length; m++) { - let property = node.properties[m] - createUiObjectFromNode(property, node, node, positionOffset) - } - return - } - case 'Record Property': { - createUiObject(false, node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) - if (node.formula !== undefined) { - createUiObjectFromNode(node.formula, node, node, positionOffset) - } - return - } - case 'Dataset Definition': { - createUiObject(false, node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) - return - } - case 'Plotter': { - createUiObject(false, node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) - for (let m = 0; m < node.modules.length; m++) { - let module = node.modules[m] - createUiObjectFromNode(module, node, node, positionOffset) - } - return - } - case 'Plotter Module': { - createUiObject(false, node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) - - if (node.javascriptCode !== undefined) { - createUiObjectFromNode(node.javascriptCode, node, node, positionOffset) - } - - if (node.shapes !== undefined) { - createUiObjectFromNode(node.shapes, node, node, positionOffset) - } - - for (let m = 0; m < node.panels.length; m++) { - let panel = node.panels[m] - createUiObjectFromNode(panel, node, node, positionOffset) - } - return - } - - default: { - /* Get node definition */ - let nodeDefinition = APP_SCHEMA_MAP.get(node.type) - if (nodeDefinition !== undefined) { - /* Resolve Initial Values */ - if (nodeDefinition.initialValues !== undefined) { - if (nodeDefinition.initialValues.code !== undefined) { - if (node.code === undefined) { - node.code = nodeDefinition.initialValues.code - } - } - } - - /* Create Self */ - createUiObject(false, node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) - - /* Create Children */ - if (nodeDefinition.properties !== undefined) { - for (let i = 0; i < nodeDefinition.properties.length; i++) { - let property = nodeDefinition.properties[i] - if (node[property.name] !== undefined) { - switch (property.type) { - case 'node': { - createUiObjectFromNode(node[property.name], node, node, positionOffset) - } - break - case 'array': { - let nodePropertyArray = node[property.name] - for (let m = 0; m < nodePropertyArray.length; m++) { - let arrayItem = nodePropertyArray[m] - createUiObjectFromNode(arrayItem, node, node, positionOffset) - } - } - break + /* Create Children */ + if (nodeDefinition.properties !== undefined) { + let previousPropertyName // Since there are cases where there are many properties with the same name,because they can hold nodes of different types but only one at the time, we have to avoind counting each property of those as individual children. + for (let i = 0; i < nodeDefinition.properties.length; i++) { + let property = nodeDefinition.properties[i] + if (node[property.name] !== undefined) { + switch (property.type) { + case 'node': { + if (property.name !== previousPropertyName) { + createUiObjectFromNode(node[property.name], node, node, positionOffset) + previousPropertyName = property.name } } + break + case 'array': { + let nodePropertyArray = node[property.name] + for (let m = 0; m < nodePropertyArray.length; m++) { + let arrayItem = nodePropertyArray[m] + createUiObjectFromNode(arrayItem, node, node, positionOffset) + } + } + break } } } - - return } } } @@ -2034,6 +1219,7 @@ function newUiObjectsFromNodes () { function createUiObject (userAddingNew, uiObjectType, name, node, parentNode, chainParent, title, positionOffset) { let payload = {} + /* Mechanism related to keeping references when cloning */ if (node.id === undefined) { node.id = newUniqueId() } else { @@ -2043,26 +1229,48 @@ function newUiObjectsFromNodes () { } } + /* Default Naming */ if (name === '' || name === undefined) { name = 'My ' + uiObjectType } - if (node.savedPayload !== undefined) { - /* If there is a position offset, we apply it here. */ - if (positionOffset !== undefined) { - node.savedPayload.targetPosition.x = node.savedPayload.targetPosition.x + positionOffset.x - node.savedPayload.targetPosition.y = node.savedPayload.targetPosition.y + positionOffset.y - node.savedPayload.position.x = node.savedPayload.position.x + positionOffset.x - node.savedPayload.position.y = node.savedPayload.position.y + positionOffset.y + + /* If we are creating this object as the result of restoring a backup, share or clone, we will bring some of the saved properties to the new running instance. */ + if (userAddingNew === false && uiObjectType !== 'Workspace') { + /* This following info can not be missing. */ + if (node.savedPayload === undefined) { + console.log('Node ' + node.type + ' without savedPayload.', node) + return + } + if (node.savedPayload.position === undefined) { + console.log('Node ' + node.type + ' without savedPayload.position.', node) + return + } + if (node.savedPayload.targetPosition === undefined) { + console.log('Node ' + node.type + ' without savedPayload.targetPosition.', node) + return } + console.log('Node ' + node.type + ' CREATED WITH NO PROBLEMS.') + + /* If there is not a position offset, which happens when we are dropping a node into the designer, we create a cero vector then. */ + if (positionOffset === undefined) { + positionOffset = { + x: 0, + y: 0 + } + } + + /* Adding the offset to the saved positions. */ + node.savedPayload.targetPosition.x = node.savedPayload.targetPosition.x + positionOffset.x + node.savedPayload.targetPosition.y = node.savedPayload.targetPosition.y + positionOffset.y + node.savedPayload.position.x = node.savedPayload.position.x + positionOffset.x + node.savedPayload.position.y = node.savedPayload.position.y + positionOffset.y + + /* Transferring the saved payload properties into the running instance being created. */ payload.targetPosition = { x: node.savedPayload.targetPosition.x, y: node.savedPayload.targetPosition.y } - node.savedPayload.targetPosition = undefined - if (payload.targetPosition.x === null) { payload.targetPosition.x = spawnPosition.x } - if (payload.targetPosition.y === null) { payload.targetPosition.y = spawnPosition.y } - /* Reference children connection to parents */ if (node.savedPayload.referenceParent !== undefined) { payload.referenceParent = mapOfNodes.get(node.savedPayload.referenceParent.id) @@ -2071,18 +1279,24 @@ function newUiObjectsFromNodes () { mapOfReferenceChildren.set(node.id, node) } } - } else { + } + + /* If we are adding a new object, then we set the initial values for position and targetPosition */ + if (userAddingNew === true || uiObjectType === 'Workspace') { + /* Workspace allways to the spawn position */ + if (uiObjectType === 'Workspace') { + payload.position = { + x: spawnPosition.x, + y: spawnPosition.y + } + } + + /* Chain parent pointing to the position of the chain parent if defined. */ if (chainParent === undefined) { payload.targetPosition = { x: spawnPosition.x, y: spawnPosition.y } - if (uiObjectType === 'Workspace' || uiObjectType === 'Trading System') { - payload.position = { - x: spawnPosition.x, - y: spawnPosition.y - } - } } else { payload.targetPosition = { x: chainParent.payload.position.x, @@ -2091,6 +1305,7 @@ function newUiObjectsFromNodes () { } } + /* Setting the title */ if (title !== undefined) { payload.subTitle = title } else { @@ -2106,6 +1321,8 @@ function newUiObjectsFromNodes () { node.payload = payload node.type = uiObjectType + + /* Now we mount the floating object where the UIOBject will be laying on top of */ canvas.floatingSpace.uiObjectConstructor.createUiObject(userAddingNew, payload) mapOfNodes.set(node.id, node) diff --git a/DesignerSpace/Workspace/Workspace.js b/DesignerSpace/Workspace/Workspace.js index d770649c2..3cdd7f7fe 100644 --- a/DesignerSpace/Workspace/Workspace.js +++ b/DesignerSpace/Workspace/Workspace.js @@ -113,7 +113,7 @@ function newWorkspace () { if (thisObject.enabled !== true) { return } let textToSave = stringifyWorkspace() - window.localStorage.setItem(CANVAS_APP_NAME + '.' + 'Workspace', textToSave) + // window.localStorage.setItem(CANVAS_APP_NAME + '.' + 'Workspace', textToSave) if (workingAtTask > 0) { circularProgressBar.physics() diff --git a/FloatingSpace/FloatingObject.js b/FloatingSpace/FloatingObject.js index 45137cfa1..95da8d8f8 100644 --- a/FloatingSpace/FloatingObject.js +++ b/FloatingSpace/FloatingObject.js @@ -188,8 +188,12 @@ function newFloatingObject () { if (thisObject.frozenManually !== false) { return } if (thisObject.payload === undefined) { return } let parent = thisObject.payload.chainParent - if (parent !== undefined && parent.payload !== undefined) { - thisObject.isFrozen = parent.payload.floatingObject.isFrozen + if (parent !== undefined) { + if (parent.payload !== undefined) { + if (parent.payload.floatingObject !== undefined) { + thisObject.isFrozen = parent.payload.floatingObject.isFrozen + } + } } } @@ -479,4 +483,3 @@ function newFloatingObject () { function updateRadius () { } } - diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index 4ed192a17..893272e0b 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -227,8 +227,10 @@ function newUiObject () { thisObject.payload.targetPosition.x = thisObject.payload.position.x, thisObject.payload.targetPosition.y = thisObject.payload.position.y } else { - thisObject.payload.targetPosition.x = thisObject.payload.chainParent.payload.position.x - thisObject.payload.targetPosition.y = thisObject.payload.chainParent.payload.position.y + if (thisObject.payload.chainParent.payload.position !== undefined) { + thisObject.payload.targetPosition.x = thisObject.payload.chainParent.payload.position.x + thisObject.payload.targetPosition.y = thisObject.payload.chainParent.payload.position.y + } } if (thisObject.circularProgressBar !== undefined) { diff --git a/FloatingSpace/UiObjectConstructor.js b/FloatingSpace/UiObjectConstructor.js index 00c0d4a65..f515a646a 100644 --- a/FloatingSpace/UiObjectConstructor.js +++ b/FloatingSpace/UiObjectConstructor.js @@ -31,14 +31,23 @@ function newUiObjectConstructor () { floatingObject.initialize('UI Object', payload) payload.floatingObject = floatingObject - if (payload.node.savedPayload !== undefined) { + /* + When this object is created based on a backup, share or clone, we will have a savedPayload that we will use to set the initial properties. + If it is a new object being created out of the user interface, we jusst continue with the construction process. + */ + if (userAddingNew === false && payload.node.type !== 'Workspace') { + let position = { + x: 0, + y: 0 + } + position = { x: payload.node.savedPayload.position.x, y: payload.node.savedPayload.position.y } - if (position.x === null) { position.x = spawnPosition.x } - if (position.y === null) { position.y = spawnPosition.y } + // if (position.x === undefined) { position.x = spawnPosition.x } + // if (position.y === undefined) { position.y = spawnPosition.y } floatingObject.setPosition(position) payload.node.savedPayload.position = undefined @@ -56,8 +65,8 @@ function newUiObjectConstructor () { } } + /* For brand new objects being created directly by the user, we will make them inherit some properties from their parents. */ if (userAddingNew === true) { - /* For brand new objects being created directly by the user, we will make them inherit some properties from their parents. */ if (payload.parentNode.payload.floatingObject.isTensed === true) { floatingObject.tensionToggle() } From 65359262b0177bc696d0a3519a3865a23501f903 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 24 Dec 2019 19:21:31 +0100 Subject: [PATCH 015/264] UI objects from node from APP SCHEMA --- .../FunctionLibraries/UiObjectsFromNodes.js | 1081 +---------------- DesignerSpace/Workspace/Workspace.js | 323 +---- FloatingSpace/UiObjectConstructor.js | 4 +- 3 files changed, 9 insertions(+), 1399 deletions(-) diff --git a/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js b/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js index 565f6d332..3d5264f9f 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js +++ b/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js @@ -4,69 +4,7 @@ function newUiObjectsFromNodes () { tryToConnectChildrenWithReferenceParents: tryToConnectChildrenWithReferenceParents, createUiObjectFromNode: createUiObjectFromNode, addUIObject: addUIObject, - addTeam: addTeam, - addSensorBot: addSensorBot, - addIndicatorBot: addIndicatorBot, - addTradingBot: addTradingBot, - addProcessDefinition: addProcessDefinition, - addMissingProcessDefinitionItems: addMissingProcessDefinitionItems, - addMissingProductDefinitionItems: addMissingProductDefinitionItems, - addProcessOutput: addProcessOutput, - addProcessDependencies: addProcessDependencies, - addStatusReport: addStatusReport, - addExecutionStartedEvent: addExecutionStartedEvent, - addExecutionFinishedEvent: addExecutionFinishedEvent, - addCalculationsProcedure: addCalculationsProcedure, - addDataBuildingProcedure: addDataBuildingProcedure, - addProcedureInitialization: addProcedureInitialization, - addProcedureLoop: addProcedureLoop, - addOutputDataset: addOutputDataset, - addStatusDependency: addStatusDependency, - addDataDependency: addDataDependency, - addProductDefinition: addProductDefinition, - addRecordDefinition: addRecordDefinition, - addRecordProperty: addRecordProperty, - addDatasetDefinition: addDatasetDefinition, - addPlotter: addPlotter, - addPlotterModule: addPlotterModule, - addDefinition: addDefinition, - addNetwork: addNetwork, - addNetworkNode: addNetworkNode, - addSocialBots: addSocialBots, - addTelegramBot: addTelegramBot, - addAnnouncement: addAnnouncement, - addLayerManager: addLayerManager, - addLayer: addLayer, - addTaskManager: addTaskManager, - addTask: addTask, - addSensorBotInstance: addSensorBotInstance, - addIndicatorBotInstance: addIndicatorBotInstance, - addTradingBotInstance: addTradingBotInstance, - addProcessInstance: addProcessInstance, - addBacktestingSession: addBacktestingSession, - addLiveTradingSession: addLiveTradingSession, - addFordwardTestingSession: addFordwardTestingSession, - addPaperTradingSession: addPaperTradingSession, - addTradingSystem: addTradingSystem, - addPersonalData: addPersonalData, - addExchangeAccount: addExchangeAccount, - addExchangeAccountAsset: addExchangeAccountAsset, - addExchangeAccountKey: addExchangeAccountKey, - addStrategy: addStrategy, - addParameters: addParameters, - addMissingParameters: addMissingParameters, - addMissingStages: addMissingStages, - addMissingEvents: addMissingEvents, - addMissingItems: addMissingItems, - addInitialDefinition: addInitialDefinition, - addOpenExecution: addOpenExecution, - addCloseExecution: addCloseExecution, - addPhase: addPhase, - addFormula: addFormula, - addNextPhaseEvent: addNextPhaseEvent, - addSituation: addSituation, - addCondition: addCondition, - addJavascriptCode: addJavascriptCode + addMissingChildren: addMissingChildren } let mapOfReferenceChildren = new Map() @@ -199,1021 +137,8 @@ function newUiObjectsFromNodes () { return object } - function addTeam (node) { - let team = { - name: 'New Team', - type: 'Team', - code: '{}', - sensorBots: [], - indicatorBots: [], - tradingBots: [], - plotters: [] - } - node.rootNodes.push(team) - createUiObject(true, team.type, team.name, team, undefined, undefined) - return team - } + function addMissingChildren (node) { - function addSensorBot (node) { - let object = { - type: 'Sensor Bot', - name: 'New Sensor Bot', - code: '{}', - processes: [], - products: [] - } - if (node.sensorBots === undefined) { - node.sensorBots = [] - } - node.sensorBots.push(object) - createUiObject(true, object.type, object.name, object, node, node) - - return object - } - - function addIndicatorBot (node) { - let object = { - type: 'Indicator Bot', - name: 'New Indicator Bot', - code: '{}', - processes: [], - products: [] - } - if (node.indicatorBots === undefined) { - node.indicatorBots = [] - } - node.indicatorBots.push(object) - createUiObject(true, object.type, object.name, object, node, node) - - return object - } - - function addTradingBot (node) { - let object = { - type: 'Trading Bot', - name: 'New Trading Bot', - code: '{}', - processes: [], - products: [] - } - if (node.tradingBots === undefined) { - node.tradingBots = [] - } - node.tradingBots.push(object) - createUiObject(true, object.type, object.name, object, node, node) - - return object - } - - function addProcessDefinition (node) { - let object = { - type: 'Process Definition', - name: 'New Process Definition', - code: '{}' - } - if (node.processes === undefined) { - node.processes = [] - } - node.processes.push(object) - createUiObject(true, object.type, object.name, object, node, node) - - return object - } - - function addMissingProcessDefinitionItems (node) { - addProcessOutput(node) - addProcessDependencies(node) - addStatusReport(node) - addExecutionStartedEvent(node) - addExecutionFinishedEvent(node) - } - - function addMissingProductDefinitionItems (node) { - addCalculationsProcedure(node) - addDataBuildingProcedure(node) - } - - function addProcessOutput (node) { - if (node.processOutput === undefined) { - node.processOutput = { - type: 'Process Output', - name: 'New Process Output', - outputDatasets: [] - } - createUiObject(true, node.processOutput.type, node.processOutput.name, node.processOutput, node, node) - } - return node.processOutput - } - - function addProcessDependencies (node) { - if (node.processDependencies === undefined) { - node.processDependencies = { - type: 'Process Dependencies', - name: 'New Process Dependencies', - statusDependencies: [], - dataDependencies: [] - } - createUiObject(true, node.processDependencies.type, node.processDependencies.name, node.processDependencies, node, node) - } - return node.processDependencies - } - - function addStatusReport (node) { - if (node.statusReport === undefined) { - node.statusReport = { - type: 'Status Report', - name: 'New Status Report' - } - createUiObject(true, node.statusReport.type, node.statusReport.name, node.statusReport, node, node) - } - return node.statusReport - } - - function addExecutionStartedEvent (node) { - if (node.executionStartedEvent === undefined) { - node.executionStartedEvent = { - type: 'Execution Started Event', - name: 'New Execution Started Event' - } - createUiObject(true, node.executionStartedEvent.type, node.executionStartedEvent.name, node.executionStartedEvent, node, node) - } - return node.executionStartedEvent - } - - function addExecutionFinishedEvent (node) { - if (node.executionFinishedEvent === undefined) { - node.executionFinishedEvent = { - type: 'Execution Finished Event', - name: 'New Execution Finished Event' - } - createUiObject(true, node.executionFinishedEvent.type, node.executionFinishedEvent.name, node.executionFinishedEvent, node, node) - } - return node.executionFinishedEvent - } - - function addCalculationsProcedure (node) { - if (node.calculations === undefined) { - node.calculations = { - type: 'Calculations Procedure', - name: 'New Calculations Procedure' - } - createUiObject(true, node.calculations.type, node.calculations.name, node.calculations, node, node) - } - return node.calculations - } - - function addDataBuildingProcedure (node) { - if (node.dataBuilding === undefined) { - node.dataBuilding = { - type: 'Data Building Procedure', - name: 'New Data Building Procedure' - } - createUiObject(true, node.dataBuilding.type, node.dataBuilding.name, node.dataBuilding, node, node) - } - return node.dataBuilding - } - - function addProcedureInitialization (node) { - if (node.initialization === undefined) { - node.initialization = { - type: 'Procedure Initialization', - name: 'New Procedure Initialization' - } - createUiObject(true, node.initialization.type, node.initialization.name, node.initialization, node, node) - } - return node.initialization - } - - function addProcedureLoop (node) { - if (node.loop === undefined) { - node.loop = { - type: 'Procedure Loop', - name: 'New Procedure Loop' - } - createUiObject(true, node.loop.type, node.loop.name, node.loop, node, node) - } - return node.loop - } - - function addOutputDataset (node) { - let object = { - type: 'Output Dataset', - name: 'New Output Dataset' - } - if (node.outputDatasets === undefined) { - node.outputDatasets = [] - } - node.outputDatasets.push(object) - createUiObject(true, object.type, object.name, object, node, node) - - return object - } - - function addStatusDependency (node) { - let object = { - type: 'Status Dependency', - name: 'New Status Dependency', - code: '{ \n\"mainUtility\": \"Self Reference|Market Starting Point|Market Ending Point\"\n}' - } - if (node.statusDependencies === undefined) { - node.statusDependencies = [] - } - node.statusDependencies.push(object) - createUiObject(true, object.type, object.name, object, node, node) - - return object - } - - function addDataDependency (node) { - let object = { - type: 'Data Dependency', - name: 'New Data Dependency' - } - if (node.dataDependencies === undefined) { - node.dataDependencies = [] - } - node.dataDependencies.push(object) - createUiObject(true, object.type, object.name, object, node, node) - - return object - } - - function addProductDefinition (node) { - let object = { - type: 'Product Definition', - name: 'New Product Definition', - code: '{}', - datasets: [] - } - if (node.products === undefined) { - node.products = [] - } - node.products.push(object) - createUiObject(true, object.type, object.name, object, node, node) - - return object - } - - function addRecordDefinition (node) { - if (node.record === undefined) { - node.record = { - type: 'Record Definition', - name: 'New Record Definition', - properties: [] - } - createUiObject(true, node.record.type, node.record.name, node.record, node, node) - } - return node.record - } - - function addRecordProperty (node) { - let object = { - type: 'Record Property', - name: 'New Record Property', - code: '{}', - formula: { - code: DEFAULT_FORMULA_TEXT - } - } - if (node.properties === undefined) { - node.properties = [] - } - node.properties.push(object) - createUiObject(true, object.type, object.name, object, node, node) - createUiObject(true, 'Formula', '', object.formula, object, object) - - return object - } - - function addDatasetDefinition (node) { - let object = { - type: 'Dataset Definition', - name: 'New Dataset Definition', - code: '{}' - } - if (node.datasets === undefined) { - node.datasets = [] - } - node.datasets.push(object) - createUiObject(true, object.type, object.name, object, node, node) - - return object - } - - function addPlotter (node) { - let object = { - type: 'Plotter', - name: 'New Plotter', - code: '{}', - modules: [] - } - if (node.plotters === undefined) { - node.plotters = [] - } - node.plotters.push(object) - createUiObject(true, object.type, object.name, object, node, node) - - return object - } - - function addPlotterModule (node) { - let object = { - type: 'Plotter Module', - name: 'New Plotter Module', - code: '{}', - panels: [] - } - if (node.modules === undefined) { - node.modules = [] - } - node.modules.push(object) - createUiObject(true, object.type, object.name, object, node, node) - - return object - } - - function addNetwork (node) { - let network = { - name: 'Superalgos' - } - node.rootNodes.push(network) - createUiObject(true, 'Network', network.name, network, node, undefined, 'Network') - - return network - } - - function addNetworkNode (node) { - let networkNode = { - name: 'New Network Node' - } - if (node.networkNodes === undefined) { - node.networkNodes = [] - } - node.networkNodes.push(networkNode) - createUiObject(true, 'Network Node', networkNode.name, networkNode, node, node, 'Network Node') - - return networkNode - } - - function addSocialBots (node) { - if (node.socialBots === undefined) { - node.socialBots = { - name: 'New Social Bots', - bots: [] - } - createUiObject(true, 'Social Bots', node.socialBots.name, node.socialBots, node, node, 'Social Bots') - } - - return node.socialBots - } - - function addTelegramBot (node) { - let bot = { - name: 'New Telegram Bot', - code: '{ \n\"botToken\": \"Paste here the bot token obtained from Telegram Bot Father\",\n\"chatId\": \"Write here the chat or group id where the announcements are going to be sent to, as it is a number with no quotes please.\"\n}', - announcements: [] - } - node.bots.push(bot) - createUiObject(true, 'Telegram Bot', bot.name, bot, node, node, 'Telegram Bot') - - return bot - } - - function addAnnouncement (node) { - let announcement = { - name: 'Announcement via ' + node.type, - code: '{ \n\"text\": \"Write here what you want to announce.\",\n\"botType\": \"' + node.type + '\",\n\"botId\": \"' + node.id + '\"\n}' - } - node.announcements.push(announcement) - createUiObject(true, 'Announcement', announcement.name, announcement, node, node, 'Announcement') - - return announcement - } - - function addLayerManager (node) { - if (node.layerManager === undefined) { - node.layerManager = { - name: 'New Layer Manager', - layers: [] - } - createUiObject(true, 'Layer Manager', node.layerManager.name, node.layerManager, node, node, 'Layer Manager') - } - - return node.layerManager - } - - function addLayer (node) { - let layer = { - name: 'New Layer', - code: '{ \n\"product\": \"Type here the codeName of the Product\"\n}' - } - node.layers.push(layer) - createUiObject(true, 'Layer', layer.name, layer, node, node, 'Layer') - - return layer - } - - function addTaskManager (node) { - let taskManager = { - name: 'New Task Manager', - tasks: [] - } - if (node.taskManagers === undefined) { - node.taskManagers = [] - } - node.taskManagers.push(taskManager) - createUiObject(true, 'Task Manager', taskManager.name, taskManager, node, node, 'Task Manager') - - return taskManager - } - - function addTask (node) { - let task = { - name: 'New Task' - } - node.tasks.push(task) - createUiObject(true, 'Task', task.name, task, node, node, 'Task') - - return task - } - - function addSensorBotInstance (node) { - if (node.bot === undefined) { - node.bot = { - processes: [], - code: '{}' - } - createUiObject(true, 'Sensor Bot Instance', '', node.bot, node, node) - } - return node.bot - } - - function addIndicatorBotInstance (node) { - if (node.bot === undefined) { - node.bot = { - processes: [], - code: '{}' - } - createUiObject(true, 'Indicator Bot Instance', '', node.bot, node, node) - } - return node.bot - } - - function addTradingBotInstance (node) { - if (node.bot === undefined) { - node.bot = { - processes: [], - code: '{}' - } - createUiObject(true, 'Trading Bot Instance', '', node.bot, node, node) - } - return node.bot - } - - function addProcessInstance (node) { - let process = { - name: 'New Process Instance', - code: '{}' - } - - switch (node.type) { - case 'Sensor Bot Instance': { - process.subType = 'Sensor Process Instance' - process.name = 'Sensor Process Instance' - break - } - case 'Indicator Bot Instance': { - process.subType = 'Indicator Process Instance' - process.name = 'Indicator Process Instance' - break - } - case 'Trading Bot Instance': { - process.subType = 'Trading Process Instance' - process.name = 'Trading Process Instance' - break - } - } - node.processes.push(process) - createUiObject(true, 'Process Instance', process.name, process, node, node, 'Process Instance') - - return process - } - - function addBacktestingSession (node) { - if (node.session === undefined) { - node.session = { - name: 'New Backtesting Session', - code: '{ \n\"folderName\": \"Type here the folder name where you want the logs of this process to be stored to.\"\n}' - } - createUiObject(true, 'Backtesting Session', '', node.session, node, node) - } - - return node.session - } - - function addLiveTradingSession (node) { - if (node.session === undefined) { - node.session = { - name: 'New Live Trading Session', - code: '{}' - } - createUiObject(true, 'Live Trading Session', '', node.session, node, node) - } - - return node.session - } - - function addFordwardTestingSession (node) { - if (node.session === undefined) { - node.session = { - name: 'New Fordward Testing Session', - code: '{ \n\"folderName\": \"Type here the folder name where you want the logs of this process to be stored to.\",\n\"balancePercentage\": \"Type here the the % of the balance to be used in this test.\"\n}' - } - createUiObject(true, 'Fordward Testing Session', '', node.session, node, node) - } - - return node.session - } - - function addPaperTradingSession (node) { - if (node.session === undefined) { - node.session = { - name: 'New Paper Trading Session', - code: '{ \n\"folderName\": \"Type here the folder name where you want the logs of this process to be stored to.\"\n}' - } - createUiObject(true, 'Paper Trading Session', '', node.session, node, node) - } - - return node.session - } - - function addDefinition (node) { - let definition = { - name: 'New Definition' - } - node.rootNodes.push(definition) - createUiObject(true, 'Definition', definition.name, definition, node, undefined, 'Definition') - - return definition - } - - function addTradingSystem (node) { - if (node.tradingSystem === undefined) { - node.tradingSystem = { - strategies: [] - } - createUiObject(true, 'Trading System', '', node.tradingSystem, node, node) - } - return node.tradingSystem - } - - function addPersonalData (node) { - if (node.personalData === undefined) { - node.personalData = { - exchangeAccounts: [] - } - createUiObject(true, 'Personal Data', '', node.personalData, node, node) - } - - return node.personalData - } - - function addExchangeAccount (parentNode) { - let personalData = parentNode - let exchangeAccount = { - name: 'New Account', - assets: [], - keys: [] - } - personalData.exchangeAccounts.push(exchangeAccount) - createUiObject(true, 'Exchange Account', exchangeAccount.name, exchangeAccount, personalData, personalData, 'Exchange Account') - - return exchangeAccount - } - - function addExchangeAccountAsset (parentNode) { - let exchangeAccount = parentNode - let asset = { - name: 'New Asset' - } - exchangeAccount.assets.push(asset) - createUiObject(true, 'Exchange Account Asset', asset.name, asset, exchangeAccount, exchangeAccount, 'Account Asset') - - return asset - } - - function addExchangeAccountKey (parentNode) { - let exchangeAccount = parentNode - let key = { - name: 'New Key', - code: '{ \n\"name\": \"Paste your exchange API here\",\n"secret\": \"Paste your exchange API secret key here. Exchange keys are filtered out and NOT exported when using the SHARE menu option on any node at your workspace. Exchange keys ARE downloaded when using the DOWNLOAD button or the CLONE button.\"\n}' - } - if (exchangeAccount.keys !== undefined) { - exchangeAccount.keys.push(key) - } else { - exchangeAccount.key = key - } - - createUiObject(true, 'Exchange Account Key', key.name, key, exchangeAccount, exchangeAccount, 'Account Key') - - return key - } - - function addStrategy (parentNode) { - let strategyParent = parentNode - let strategy = { - name: 'New Strategy', - active: true, - triggerStage: { - triggerOn: { - situations: [] - }, - triggerOff: { - situations: [] - }, - takePosition: { - situations: [] - }, - positionSize: { - formula: { - code: DEFAULT_FORMULA_TEXT - } - } - }, - openStage: { - initialDefinition: { - stopLoss: { - phases: [], - maxPhases: 1 - }, - takeProfit: { - phases: [], - maxPhases: 1 - } - } - }, - manageStage: { - stopLoss: { - phases: [] - }, - takeProfit: { - phases: [] - } - }, - closeStage: { - } - } - - strategyParent.strategies.push(strategy) - createUiObject(true, 'Strategy', strategy.name, strategy, strategyParent, strategyParent, 'Strategy') - createUiObject(true, 'Trigger Stage', '', strategy.triggerStage, strategy, strategy, 'Trigger Stage') - createUiObject(true, 'Open Stage', '', strategy.openStage, strategy, strategy, 'Open Stage') - createUiObject(true, 'Manage Stage', '', strategy.manageStage, strategy, strategy, 'Manage Stage') - createUiObject(true, 'Close Stage', '', strategy.closeStage, strategy, strategy, 'Close Stage') - createUiObject(true, 'Trigger On Event', '', strategy.triggerStage.triggerOn, strategy.triggerStage, strategy.triggerStage) - createUiObject(true, 'Trigger Off Event', '', strategy.triggerStage.triggerOff, strategy.triggerStage, strategy.triggerStage) - createUiObject(true, 'Take Position Event', '', strategy.triggerStage.takePosition, strategy.triggerStage, strategy.triggerStage) - createUiObject(true, 'Initial Definition', '', strategy.openStage.initialDefinition, strategy.openStage, strategy.openStage) - createUiObject(true, 'Position Size', '', strategy.openStage.initialDefinition.positionSize, strategy.openStage.initialDefinition, strategy.openStage.initialDefinition) - createUiObject(true, 'Position Rate', '', strategy.openStage.initialDefinition.positionRate, strategy.openStage.initialDefinition, strategy.openStage.initialDefinition) - createUiObject(true, 'Stop', '', strategy.manageStage.stopLoss, strategy.manageStage, strategy.manageStage) - createUiObject(true, 'Take Profit', '', strategy.manageStage.takeProfit, strategy.manageStage, strategy.manageStage) - createUiObject(true, 'Stop', 'Initial Stop', strategy.openStage.initialDefinition.stopLoss, strategy.openStage.initialDefinition, strategy.openStage.initialDefinition) - createUiObject(true, 'Take Profit', 'Initial Take Profit', strategy.openStage.initialDefinition.takeProfit, strategy.openStage.initialDefinition, strategy.openStage.initialDefinition) - createUiObject(true, 'Formula', '', strategy.triggerStage.positionSize.formula, strategy.triggerStage.positionSize, strategy.triggerStage.positionSize) - - return strategy - } - - function addParameters (node) { - if (node.parameters === undefined) { - node.parameters = { - name: 'Parameters' - } - createUiObject(true, 'Parameters', '', node.parameters, node, node) - addMissingParameters(node.parameters) - } - - return node.parameters - } - - function addMissingParameters (node) { - if (node.baseAsset === undefined) { - node.baseAsset = { - name: 'Base Asset', - code: '{ \n\"name\": \"BTC\",\n"initialBalance\": 0.001,\n\"minimumBalance\": 0.0001,\n\"maximumBalance\": 0.1\n}' - } - createUiObject(true, 'Base Asset', '', node.baseAsset, node, node) - } - if (node.timeRange === undefined) { - node.timeRange = { - name: 'Time Range', - code: '{ \n\"initialDatetime\": \"2019-07-01T00:00:00.000Z\",\n\"finalDatetime\": \"2019-09-01T00:00:00.000Z\"\n}' - } - createUiObject(true, 'Time Range', '', node.timeRange, node, node) - } - if (node.timePeriod === undefined) { - node.timePeriod = { - name: 'Time Period', - code: '{ \n\"value\": \"01-hs\"\n}' - } - createUiObject(true, 'Time Period', '', node.timePeriod, node, node) - } - if (node.slippage === undefined) { - node.slippage = { - name: 'Slippage', - code: '{ \n\"positionRate\": 0.1,\n"stopLoss\": 0.2,\n"takeProfit\": 0.3\n}' - } - createUiObject(true, 'Slippage', '', node.slippage, node, node) - } - if (node.feeStructure === undefined) { - node.feeStructure = { - name: 'Fee Structure', - code: '{ \n\"maker\": 0.15,\n"taker\": 0.25\n}' - } - createUiObject(true, 'Fee Structure', '', node.feeStructure, node, node) - } - } - - function addMissingStages (node) { - if (node.triggerStage === undefined) { - node.triggerStage = { - triggerOn: { - situations: [] - }, - triggerOff: { - situations: [] - }, - takePosition: { - situations: [] - }, - positionSize: { - formula: { - code: DEFAULT_FORMULA_TEXT - } - } - } - createUiObject(true, 'Trigger Stage', '', node.triggerStage, node, node, 'Trigger Stage') - createUiObject(true, 'Trigger On Event', '', node.triggerStage.triggerOn, node.triggerStage, node.triggerStage) - createUiObject(true, 'Trigger Off Event', '', node.triggerStage.triggerOff, node.triggerStage, node.triggerStage) - createUiObject(true, 'Take Position Event', '', node.triggerStage.takePosition, node.triggerStage, node.triggerStage) - createUiObject(true, 'Formula', '', node.triggerStage.positionSize.formula, node.triggerStage.positionSize, node.triggerStage.positionSize) - } - if (node.openStage === undefined) { - node.openStage = { - initialDefinition: { - stopLoss: { - phases: [], - maxPhases: 1 - }, - takeProfit: { - phases: [], - maxPhases: 1 - } - } - } - createUiObject(true, 'Open Stage', '', node.openStage, node, node, 'Open Stage') - createUiObject(true, 'Initial Definition', '', node.openStage.initialDefinition, node.openStage, node.openStage) - createUiObject(true, 'Stop', 'Initial Stop', node.openStage.initialDefinition.stopLoss, node.openStage.initialDefinition, node.openStage.initialDefinition) - createUiObject(true, 'Take Profit', 'Initial Take Profit', node.openStage.initialDefinition.takeProfit, node.openStage.initialDefinition, node.openStage.initialDefinition) - createUiObject(true, 'Position Size', 'Position Size', node.openStage.initialDefinition.positionSize, node.openStage.initialDefinition, node.openStage.initialDefinition) - createUiObject(true, 'Position Rate', 'Position Rate', node.openStage.initialDefinition.positionRate, node.openStage.initialDefinition, node.openStage.initialDefinition) - } - if (node.manageStage === undefined) { - node.manageStage = { - stopLoss: { - phases: [] - }, - takeProfit: { - phases: [] - } - } - createUiObject(true, 'Manage Stage', '', node.manageStage, node, node, 'Manage Stage') - createUiObject(true, 'Stop', '', node.manageStage.stopLoss, node.manageStage, node.manageStage) - createUiObject(true, 'Take Profit', '', node.manageStage.takeProfit, node.manageStage, node.manageStage) - } - if (node.closeStage === undefined) { - node.closeStage = { - } - createUiObject(true, 'Close Stage', '', node.closeStage, node, node, 'Close Stage') - } - } - - function addMissingEvents (node) { - if (node.triggerOn === undefined) { - node.triggerOn = { - situations: [], - announcements: [] - } - createUiObject(true, 'Trigger On Event', '', node.triggerOn, node, node) - } - if (node.triggerOff === undefined) { - node.triggerOff = { - situations: [], - announcements: [] - } - createUiObject(true, 'Trigger Off Event', '', node.triggerOff, node, node) - } - if (node.takePosition === undefined) { - node.takePosition = { - situations: [], - announcements: [] - } - createUiObject(true, 'Take Position Event', '', node.takePosition, node, node) - } - } - - function addMissingItems (node) { - if (node.type === 'Initial Definition') { - if (node.stopLoss === undefined) { - node.stopLoss = { - phases: [], - maxPhases: 1 - } - createUiObject(true, 'Stop', 'Initial Stop', node.stopLoss, node, node) - } - if (node.takeProfit === undefined) { - node.takeProfit = { - phases: [], - maxPhases: 1 - } - createUiObject(true, 'Take Profit', 'Initial Take Profit', node.takeProfit, node, node) - } - if (node.positionSize === undefined) { - node.positionSize = { - name: 'Position Size', - formula: { - code: DEFAULT_FORMULA_TEXT - } - } - createUiObject(true, 'Position Size', '', node.positionSize, node, node) - createUiObject(true, 'Formula', '', node.positionSize.formula, node.positionSize, node.positionSize) - } - if (node.positionRate === undefined) { - node.positionRate = { - name: 'Position Rate', - formula: { - code: DEFAULT_FORMULA_TEXT - } - } - createUiObject(true, 'Position Rate', '', node.positionRate, node, node) - createUiObject(true, 'Formula', '', node.positionRate.formula, node.positionRate, node.positionRate) - } - } else { - if (node.stopLoss === undefined) { - node.stopLoss = { - phases: [] - } - createUiObject(true, 'Stop', '', node.stopLoss, node, node) - } - if (node.takeProfit === undefined) { - node.takeProfit = { - phases: [] - } - createUiObject(true, 'Take Profit', '', node.takeProfit, node, node) - } - } - } - - function addInitialDefinition (node) { - if (node.initialDefinition === undefined) { - node.initialDefinition = { - stopLoss: { - phases: [], - maxPhases: 1 - }, - takeProfit: { - phases: [], - maxPhases: 1 - } - } - createUiObject(true, 'Initial Definition', '', node.initialDefinition, node, node) - createUiObject(true, 'Stop', 'Initial Stop', node.initialDefinition.stopLoss, node.initialDefinition, node.initialDefinition) - createUiObject(true, 'Take Profit', 'Initial Take Profit', node.initialDefinition.takeProfit, node.initialDefinition, node.initialDefinition) - createUiObject(true, 'Position Size', '', node.initialDefinition.positionSize, node.initialDefinition, node.initialDefinition) - createUiObject(true, 'Formula', '', node.initialDefinition.positionSize.formula, node.initialDefinition.positionSize, node.initialDefinition.positionSize) - createUiObject(true, 'Position Rate', '', node.initialDefinition.positionRate, node.initialDefinition, node.initialDefinition) - createUiObject(true, 'Formula', '', node.initialDefinition.positionRate.formula, node.initialDefinition.positionRate, node.initialDefinition.positionRate) - } - - return node.initialDefinition - } - - function addOpenExecution (node) { - if (node.openExecution === undefined) { - node.openExecution = {} - createUiObject(true, 'Open Execution', '', node.openExecution, node, node) - } - - return node.openExecution - } - - function addCloseExecution (node) { - if (node.closeExecution === undefined) { - node.closeExecution = {} - createUiObject(true, 'Close Execution', '', node.closeExecution, node, node) - } - - return node.closeExecution - } - - function addFormula (node) { - if (node.formula === undefined) { - node.formula = { - code: DEFAULT_FORMULA_TEXT - } - createUiObject(true, 'Formula', '', node.formula, node, node) - } - - return node.formula - } - - function addNextPhaseEvent (node) { - if (node.nextPhaseEvent === undefined) { - node.nextPhaseEvent = { - situations: [], - announcements: [] - } - createUiObject(true, 'Next Phase Event', '', node.nextPhaseEvent, node, node) - } - - return node.nextPhaseEvent - } - - function addJavascriptCode (node) { - if (node.javascriptCode === undefined) { - node.javascriptCode = { - code: DEFAULT_CODE_TEXT - } - createUiObject(true, 'Javascript Code', '', node.javascriptCode, node, node) - } - - return node.javascriptCode - } - - function addPhase (parentNode) { - if (parentNode.maxPhases !== undefined) { - if (parentNode.phases.length >= parentNode.maxPhases) { - return - } - } - let phaseParent = parentNode - let m = phaseParent.phases.length - - if (phaseParent.payload.parentNode !== undefined) { - if (phaseParent.payload.parentNode.type === 'Initial Definition' && m > 0) { return } - } - - let phase = { - name: 'New Phase', - announcements: [], - formula: { - code: DEFAULT_FORMULA_TEXT - }, - nextPhaseEvent: { - situations: [] - } - } - phaseParent.phases.push(phase) - let phaseChainParent - if (m > 0) { - phaseChainParent = phaseParent.phases[m - 1] - } else { - phaseChainParent = phaseParent - } - createUiObject(true, 'Phase', phase.name, phase, phaseParent, phaseChainParent, 'Phase') - createUiObject(true, 'Formula', '', phase.formula, phase, phase, 'Formula') - createUiObject(true, 'Next Phase Event', '', phase.nextPhaseEvent, phase, phase) - - return phase - } - - function addSituation (parentNode) { - let m = parentNode.situations.length - let situation = { - name: 'New Situation', - conditions: [] - } - parentNode.situations.push(situation) - createUiObject(true, 'Situation', situation.name, situation, parentNode, parentNode, 'Situation') - - return situation - } - - function addCondition (parentNode) { - let situation = parentNode - let m = situation.conditions.length - let condition = { - name: 'New Condition', - code: { - code: DEFAULT_CODE_TEXT - } - } - situation.conditions.push(condition) - createUiObject(true, 'Condition', condition.name, condition, situation, situation, 'Condition') - createUiObject(true, 'Javascript Code', '', condition.code, condition, condition, 'Javascript Code') - - return condition } function createUiObject (userAddingNew, uiObjectType, name, node, parentNode, chainParent, title, positionOffset) { @@ -1248,8 +173,6 @@ function newUiObjectsFromNodes () { return } - console.log('Node ' + node.type + ' CREATED WITH NO PROBLEMS.') - /* If there is not a position offset, which happens when we are dropping a node into the designer, we create a cero vector then. */ if (positionOffset === undefined) { positionOffset = { diff --git a/DesignerSpace/Workspace/Workspace.js b/DesignerSpace/Workspace/Workspace.js index 3cdd7f7fe..a34d7c2d7 100644 --- a/DesignerSpace/Workspace/Workspace.js +++ b/DesignerSpace/Workspace/Workspace.js @@ -277,6 +277,11 @@ function newWorkspace () { functionLibraryUiObjectsFromNodes.addUIObject(payload.node, relatedUiObject) } break + case 'Add Missing Children': + { + functionLibraryUiObjectsFromNodes.addUIObject(payload.node, relatedUiObject) + } + break case 'Delete UI Object': { functionLibraryNodeDeleter.deleteUIObject(payload.node, thisObject.workspaceNode.rootNodes) @@ -374,324 +379,6 @@ function newWorkspace () { functionLibrarySessionFunctions.stopSession(payload.node, functionLibraryProtocolNode, callBackFunction) } break - case 'Add Definition': - { - functionLibraryUiObjectsFromNodes.addDefinition(payload.node) - } - break - case 'Add Team': - { - functionLibraryUiObjectsFromNodes.addTeam(payload.node) - } - break - case 'Add Sensor Bot': - { - functionLibraryUiObjectsFromNodes.addSensorBot(payload.node) - } - break - case 'Add Indicator Bot': - { - functionLibraryUiObjectsFromNodes.addIndicatorBot(payload.node) - } - break - case 'Add Trading Bot': - { - functionLibraryUiObjectsFromNodes.addTradingBot(payload.node) - } - break - case 'Add Process Definition': - { - functionLibraryUiObjectsFromNodes.addProcessDefinition(payload.node) - } - break - case 'Add Missing Process Definition Items': - { - functionLibraryUiObjectsFromNodes.addMissingProcessDefinitionItems(payload.node) - } - break - case 'Add Missing Product Definition Items': - { - functionLibraryUiObjectsFromNodes.addMissingProductDefinitionItems(payload.node) - } - break - case 'Add Process Output': - { - functionLibraryUiObjectsFromNodes.addProcessOutput(payload.node) - } - break - case 'Add Process Dependencies': - { - functionLibraryUiObjectsFromNodes.addProcessDependencies(payload.node) - } - break - case 'Add Status Report': - { - functionLibraryUiObjectsFromNodes.addStatusReport(payload.node) - } - break - case 'Add Execution Started Event': - { - functionLibraryUiObjectsFromNodes.addExecutionStartedEvent(payload.node) - } - break - case 'Add Execution Finished Event': - { - functionLibraryUiObjectsFromNodes.addExecutionFinishedEvent(payload.node) - } - break - case 'Add Calculations Procedure': - { - functionLibraryUiObjectsFromNodes.addCalculationsProcedure(payload.node) - } - break - case 'Add Data Building Procedure': - { - functionLibraryUiObjectsFromNodes.addDataBuildingProcedure(payload.node) - } - break - case 'Add Procedure Initialization': - { - functionLibraryUiObjectsFromNodes.addProcedureInitialization(payload.node) - } - break - case 'Add Procedure Loop': - { - functionLibraryUiObjectsFromNodes.addProcedureLoop(payload.node) - } - break - case 'Add Output Dataset': - { - functionLibraryUiObjectsFromNodes.addOutputDataset(payload.node) - } - break - case 'Add Status Dependency': - { - functionLibraryUiObjectsFromNodes.addStatusDependency(payload.node) - } - break - case 'Add Data Dependency': - { - functionLibraryUiObjectsFromNodes.addDataDependency(payload.node) - } - break - case 'Add Product Definition': - { - functionLibraryUiObjectsFromNodes.addProductDefinition(payload.node) - } - break - case 'Add Record Definition': - { - functionLibraryUiObjectsFromNodes.addRecordDefinition(payload.node) - } - break - case 'Add Record Property': - { - functionLibraryUiObjectsFromNodes.addRecordProperty(payload.node) - } - break - case 'Add Dataset Definition': - { - functionLibraryUiObjectsFromNodes.addDatasetDefinition(payload.node) - } - break - case 'Add Plotter': - { - functionLibraryUiObjectsFromNodes.addPlotter(payload.node) - } - break - case 'Add Plotter Module': - { - functionLibraryUiObjectsFromNodes.addPlotterModule(payload.node) - } - break - case 'Add Network': - { - functionLibraryUiObjectsFromNodes.addNetwork(payload.node) - } - break - case 'Add Network Node': - { - functionLibraryUiObjectsFromNodes.addNetworkNode(payload.node) - } - break - case 'Add Social Bots': - { - functionLibraryUiObjectsFromNodes.addSocialBots(payload.node) - } - break - case 'Add Telegram Bot': - { - functionLibraryUiObjectsFromNodes.addTelegramBot(payload.node) - } - break - case 'Add Announcement': - { - functionLibraryUiObjectsFromNodes.addAnnouncement(payload.node) - } - break - case 'Add Layer Manager': - { - functionLibraryUiObjectsFromNodes.addLayerManager(payload.node) - } - break - case 'Add Layer': - { - functionLibraryUiObjectsFromNodes.addLayer(payload.node) - } - break - case 'Add Task Manager': - { - functionLibraryUiObjectsFromNodes.addTaskManager(payload.node) - } - break - case 'Add Task': - { - functionLibraryUiObjectsFromNodes.addTask(payload.node) - } - break - case 'Add Sensor Bot Instance': - { - functionLibraryUiObjectsFromNodes.addSensorBotInstance(payload.node) - } - break - case 'Add Indicator Bot Instance': - { - functionLibraryUiObjectsFromNodes.addIndicatorBotInstance(payload.node) - } - break - case 'Add Trading Bot Instance': - { - functionLibraryUiObjectsFromNodes.addTradingBotInstance(payload.node) - } - break - case 'Add Process Instance': - { - functionLibraryUiObjectsFromNodes.addProcessInstance(payload.node) - } - break - case 'Add Backtesting Session': - { - functionLibraryUiObjectsFromNodes.addBacktestingSession(payload.node) - } - break - case 'Add Live Trading Session': - { - functionLibraryUiObjectsFromNodes.addLiveTradingSession(payload.node) - } - break - case 'Add Fordward Testing Session': - { - functionLibraryUiObjectsFromNodes.addFordwardTestingSession(payload.node) - } - break - case 'Add Paper Trading Session': - { - functionLibraryUiObjectsFromNodes.addPaperTradingSession(payload.node) - } - break - case 'Add Strategy': - { - functionLibraryUiObjectsFromNodes.addStrategy(payload.node) - } - break - case 'Add Parameters': - { - functionLibraryUiObjectsFromNodes.addParameters(payload.node) - } - break - case 'Add Missing Parameters': - { - functionLibraryUiObjectsFromNodes.addMissingParameters(payload.node) - } - break - case 'Add Missing Stages': - { - functionLibraryUiObjectsFromNodes.addMissingStages(payload.node) - } - break - case 'Add Missing Events': - { - functionLibraryUiObjectsFromNodes.addMissingEvents(payload.node) - } - break - case 'Add Missing Items': - { - functionLibraryUiObjectsFromNodes.addMissingItems(payload.node) - } - break - case 'Add Initial Definition': - { - functionLibraryUiObjectsFromNodes.addInitialDefinition(payload.node) - } - break - case 'Add Open Execution': - { - functionLibraryUiObjectsFromNodes.addOpenExecution(payload.node) - } - break - case 'Add Close Execution': - { - functionLibraryUiObjectsFromNodes.addCloseExecution(payload.node) - } - break - case 'Add Phase': - { - functionLibraryUiObjectsFromNodes.addPhase(payload.node) - } - break - case 'Add Formula': - { - functionLibraryUiObjectsFromNodes.addFormula(payload.node) - } - break - case 'Add Next Phase Event': - { - functionLibraryUiObjectsFromNodes.addNextPhaseEvent(payload.node) - } - break - case 'Add Situation': - { - functionLibraryUiObjectsFromNodes.addSituation(payload.node) - } - break - case 'Add Condition': - { - functionLibraryUiObjectsFromNodes.addCondition(payload.node) - } - break - case 'Add Code': - { - functionLibraryUiObjectsFromNodes.addJavascriptCode(payload.node) - } - break - case 'Add Exchange Account': - { - functionLibraryUiObjectsFromNodes.addExchangeAccount(payload.node) - } - break - case 'Add Exchange Account Asset': - { - functionLibraryUiObjectsFromNodes.addExchangeAccountAsset(payload.node) - } - break - case 'Add Exchange Account Key': - { - functionLibraryUiObjectsFromNodes.addExchangeAccountKey(payload.node) - } - break - case 'Add Trading System': - { - functionLibraryUiObjectsFromNodes.addTradingSystem(payload.node) - } - break - case 'Add Personal Data': - { - functionLibraryUiObjectsFromNodes.addPersonalData(payload.node) - } - break - - default: - } } } diff --git a/FloatingSpace/UiObjectConstructor.js b/FloatingSpace/UiObjectConstructor.js index f515a646a..f232a7857 100644 --- a/FloatingSpace/UiObjectConstructor.js +++ b/FloatingSpace/UiObjectConstructor.js @@ -85,8 +85,8 @@ function newUiObjectConstructor () { for (let j = 0; j < menuItems.length; j++) { let item = menuItems[j] item.angle = undefined - if (item.action.indexOf('Add ') >= 0) { - // item.action = 'Add UI Object' + if (item.action.indexOf('Add ') >= 0 && item.action.indexOf('Missing') >= 0) { + item.action = 'Add Missing Children' } if (item.action.indexOf('Delete ') >= 0) { // item.action = 'Delete UI Object' From 2a771733a157a779501aeef10d03a77dad1f3df1 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 24 Dec 2019 19:47:21 +0100 Subject: [PATCH 016/264] Bug Fixed when creating head of hiriarchies --- .../FunctionLibraries/UiObjectsFromNodes.js | 17 ++++++++++++++--- DesignerSpace/Workspace/Workspace.js | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js b/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js index 3d5264f9f..7238889a3 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js +++ b/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js @@ -98,12 +98,19 @@ function newUiObjectsFromNodes () { type: type } - createUiObject(true, object.type, object.name, object, parent, parent) - let parentNodeDefinition = APP_SCHEMA_MAP.get(parent.type) if (parentNodeDefinition !== undefined) { /* Resolve Initial Values */ let nodeDefinition = APP_SCHEMA_MAP.get(object.type) + + if (nodeDefinition.isHierarchyHead === true) { + parent.rootNodes.push(object) + createUiObject(true, object.type, object.name, object, parent, undefined) + return object + } + + createUiObject(true, object.type, object.name, object, parent, parent) + if (nodeDefinition !== undefined) { if (nodeDefinition.initialValues !== undefined) { if (nodeDefinition.initialValues.code !== undefined) { @@ -114,12 +121,16 @@ function newUiObjectsFromNodes () { /* Connect to Parent */ if (parentNodeDefinition.properties !== undefined) { + let previousPropertyName // Since there are cases where there are many properties with the same name,because they can hold nodes of different types but only one at the time, we have to avoind counting each property of those as individual children. for (let i = 0; i < parentNodeDefinition.properties.length; i++) { let property = parentNodeDefinition.properties[i] if (property.childType === type) { switch (property.type) { case 'node': { - parent[property.name] = object + if (property.name !== previousPropertyName) { + parent[property.name] = object + previousPropertyName = property.name + } } break case 'array': { diff --git a/DesignerSpace/Workspace/Workspace.js b/DesignerSpace/Workspace/Workspace.js index a34d7c2d7..b2ed25415 100644 --- a/DesignerSpace/Workspace/Workspace.js +++ b/DesignerSpace/Workspace/Workspace.js @@ -113,7 +113,7 @@ function newWorkspace () { if (thisObject.enabled !== true) { return } let textToSave = stringifyWorkspace() - // window.localStorage.setItem(CANVAS_APP_NAME + '.' + 'Workspace', textToSave) + window.localStorage.setItem(CANVAS_APP_NAME + '.' + 'Workspace', textToSave) if (workingAtTask > 0) { circularProgressBar.physics() From e9c90b884fbe0e62418e24a26c2b43f71d1e4c9f Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 25 Dec 2019 10:36:51 +0100 Subject: [PATCH 017/264] Add missing children implemented --- .../FunctionLibraries/UiObjectsFromNodes.js | 16 ++++++++++++++++ DesignerSpace/Workspace/Workspace.js | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js b/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js index 7238889a3..4814a8993 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js +++ b/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js @@ -149,7 +149,23 @@ function newUiObjectsFromNodes () { } function addMissingChildren (node) { + let nodeDefinition = APP_SCHEMA_MAP.get(node.type) + /* Connect to Parent */ + if (nodeDefinition.properties !== undefined) { + let previousPropertyName // Since there are cases where there are many properties with the same name,because they can hold nodes of different types but only one at the time, we have to avoind counting each property of those as individual children. + for (let i = 0; i < nodeDefinition.properties.length; i++) { + let property = nodeDefinition.properties[i] + if (property.type === 'node') { + if (property.name !== previousPropertyName) { + if (node[property.name] === undefined) { + addUIObject(node, property.childType) + previousPropertyName = property.name + } + } + } + } + } } function createUiObject (userAddingNew, uiObjectType, name, node, parentNode, chainParent, title, positionOffset) { diff --git a/DesignerSpace/Workspace/Workspace.js b/DesignerSpace/Workspace/Workspace.js index b2ed25415..c5e2afcfe 100644 --- a/DesignerSpace/Workspace/Workspace.js +++ b/DesignerSpace/Workspace/Workspace.js @@ -279,7 +279,7 @@ function newWorkspace () { break case 'Add Missing Children': { - functionLibraryUiObjectsFromNodes.addUIObject(payload.node, relatedUiObject) + functionLibraryUiObjectsFromNodes.addMissingChildren(payload.node) } break case 'Delete UI Object': From dd85204c7b0432ca5ce4437104cab2dd6cb483c0 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 25 Dec 2019 11:04:35 +0100 Subject: [PATCH 018/264] Auto Add for children working --- .../FunctionLibraries/UiObjectsFromNodes.js | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js b/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js index 4814a8993..f4af73d5a 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js +++ b/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js @@ -144,6 +144,35 @@ function newUiObjectsFromNodes () { } } } + + /* Auto Add more Children */ + if (nodeDefinition.properties !== undefined) { + let previousPropertyName // Since there are cases where there are many properties with the same name,because they can hold nodes of different types but only one at the time, we have to avoind counting each property of those as individual children. + for (let i = 0; i < nodeDefinition.properties.length; i++) { + let property = nodeDefinition.properties[i] + + switch (property.type) { + case 'node': { + if (property.name !== previousPropertyName) { + if (property.autoAdd === true) { + addUIObject(object, property.childType) + previousPropertyName = property.name + } + } + } + break + case 'array': { + if (property.autoAdd === true) { + if (object[property.name] === undefined) { + object[property.name] = [] + } + addUIObject(object, property.childType) + } + } + break + } + } + } } return object } From f8f57165b18354e49af08a10b8c1aa6d14a0b456 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 25 Dec 2019 17:30:24 +0100 Subject: [PATCH 019/264] Announcements via Reference Parent --- .../FunctionLibraries/SessionFunctions.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js b/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js index 453fe61e7..e28e08a7b 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js +++ b/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js @@ -30,12 +30,27 @@ function newSessionFunctions () { let key = node.name + '-' + node.type + '-' + node.id - let thisNodeDefinition = node.payload.referenceParent + let lightingPath = '->Definition->' + + 'Trading System->' + + 'Parameters->' + + 'Base Asset->Time Range->Time Period->Slippage->Fee Structure->Exchange Account Key->' + + 'Strategy->' + + 'Trigger Stage->Trigger On Event->Trigger Off Event->Take Position Event->' + + 'Announcement->Telegram Bot->' + + 'Open Stage->Initial Definition->Open Execution->' + + 'Position Size->Position Rate->Formula->' + + 'Manage Stage->' + + 'Stop->Take Profit->' + + 'Phase->Formula->Next Phase Event->' + + 'Situation->Condition->Javascript Code->' + + 'Announcement->Telegram Bot->' + + let definition = functionLibraryProtocolNode.getProtocolNode(node.payload.referenceParent, false, true, true, false, false, lightingPath) /* Raise event to run the session */ let event = { session: JSON.stringify(functionLibraryProtocolNode.getProtocolNode(node, false, true, true)), - definition: JSON.stringify(functionLibraryProtocolNode.getProtocolNode(thisNodeDefinition, false, true, true)), + definition: JSON.stringify(definition), uiCurrentValues: getUICurrentValues() } From fb1a798843df7b4dd7f66bbb99a4d602a23fcbad Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 25 Dec 2019 18:06:46 +0100 Subject: [PATCH 020/264] Icons with rings --- FloatingSpace/CircularMenu.js | 41 ++++++++++++++++++---------- FloatingSpace/CircularMenuItem.js | 15 +++++++++- FloatingSpace/UiObjectConstructor.js | 23 ++++++++++------ 3 files changed, 56 insertions(+), 23 deletions(-) diff --git a/FloatingSpace/CircularMenu.js b/FloatingSpace/CircularMenu.js index 4e3efd955..ab9b5a958 100644 --- a/FloatingSpace/CircularMenu.js +++ b/FloatingSpace/CircularMenu.js @@ -48,7 +48,8 @@ function newCircularMenu () { /* Create the array of Menu Items */ let iconAndTextArray = [] - let iconOnlyArray = [] + let iconOnlyArray + let ringsArray = [[], [], []] for (let i = 0; i < menuItemsInitialValues.length; i++) { let menuItem = newCircularMenuItem() @@ -81,9 +82,15 @@ function newCircularMenu () { menuItem.confirmationLabel = menuItemInitialValue.confirmationLabel menuItem.disableIfPropertyIsDefined = menuItemInitialValue.disableIfPropertyIsDefined menuItem.propertyToCheckFor = menuItemInitialValue.propertyToCheckFor + menuItem.ring = menuItemInitialValue.ring if (menuItem.label === undefined) { menuItem.type = 'Icon Only' + + if (menuItem.ring === undefined) { + menutItem.ring = 1 + } + iconOnlyArray = ringsArray[menuItem.ring - 1] iconOnlyArray.push(menuItem) } else { menuItem.type = 'Icon & Text' @@ -95,22 +102,28 @@ function newCircularMenu () { menuItems.push(menuItem) } - /* Here we calculate the angles for each menu item, and then apply it if it was not previously defined. */ - let amplitud = 100 - let initialAngle = 230 - let step = amplitud / (iconOnlyArray.length - 1) + /* There are 3 possible rings of icons, we will go through each of them here. */ + let amplitudeArray = [80, 50, 40] + let initialAngleArray = [220, 205, 200] + for (let j = 1; j < 4; j++) { + let iconOnlyArray = ringsArray[j - 1] + /* Here we calculate the angles for each menu item, and then apply it if it was not previously defined. */ + let amplitude = amplitudeArray[j - 1] + let initialAngle = initialAngleArray[j - 1] + let step = amplitude / (iconOnlyArray.length - 1) - for (let i = 0; i < iconOnlyArray.length; i++) { - let menuItem = iconOnlyArray[i] - let angle = initialAngle - step * i - if (menuItem.angle === undefined) { - menuItem.angle = angle + for (let i = 0; i < iconOnlyArray.length; i++) { + let menuItem = iconOnlyArray[i] + let angle = initialAngle - step * i + if (menuItem.angle === undefined) { + menuItem.angle = angle + } } } - - amplitud = 140 - initialAngle = -70 - step = amplitud / 7 + /* Text and Icon */ + let amplitude = 140 + let initialAngle = -70 + step = amplitude / 7 let currentItem = (7 - iconAndTextArray.length) / 2 + 1 for (let i = 0; i < iconAndTextArray.length; i++) { let menuItem = iconAndTextArray[i] diff --git a/FloatingSpace/CircularMenuItem.js b/FloatingSpace/CircularMenuItem.js index e8679ff6b..71da46801 100644 --- a/FloatingSpace/CircularMenuItem.js +++ b/FloatingSpace/CircularMenuItem.js @@ -146,7 +146,20 @@ function newCircularMenuItem () { let radiousGrowthFactor if (thisObject.type === 'Icon Only') { - radiousGrowthFactor = 5 + switch (thisObject.ring) { + case 1: { + radiousGrowthFactor = 5 + break + } + case 2: { + radiousGrowthFactor = 3.5 + break + } + case 3: { + radiousGrowthFactor = 2 + break + } + } } else { radiousGrowthFactor = 4 } diff --git a/FloatingSpace/UiObjectConstructor.js b/FloatingSpace/UiObjectConstructor.js index f232a7857..961f589bc 100644 --- a/FloatingSpace/UiObjectConstructor.js +++ b/FloatingSpace/UiObjectConstructor.js @@ -137,7 +137,8 @@ function newUiObjectConstructor () { iconPathOff: 'menu-fix-unpinned', rawRadius: 8, targetRadius: 0, - currentRadius: 0 + currentRadius: 0, + ring: 1 } ) menuItemsInitialValues.push( @@ -152,7 +153,8 @@ function newUiObjectConstructor () { iconPathOff: 'menu-tensor-free-angles', rawRadius: 8, targetRadius: 0, - currentRadius: 0 + currentRadius: 0, + ring: 1 } ) menuItemsInitialValues.push( @@ -167,7 +169,8 @@ function newUiObjectConstructor () { iconPathOff: 'menu-mobility-freeze', rawRadius: 8, targetRadius: 0, - currentRadius: 0 + currentRadius: 0, + ring: 1 } ) menuItemsInitialValues.push( @@ -182,7 +185,8 @@ function newUiObjectConstructor () { iconPathOff: 'menu-tree-minus', rawRadius: 8, targetRadius: 0, - currentRadius: 0 + currentRadius: 0, + ring: 1 } ) menuItemsInitialValues.push( @@ -195,7 +199,8 @@ function newUiObjectConstructor () { iconPathOff: 'menu-backup', rawRadius: 8, targetRadius: 0, - currentRadius: 0 + currentRadius: 0, + ring: 2 } ) menuItemsInitialValues.push( @@ -208,7 +213,8 @@ function newUiObjectConstructor () { iconPathOff: 'clone', rawRadius: 8, targetRadius: 0, - currentRadius: 0 + currentRadius: 0, + ring: 2 } ) if (isPersonalData !== true) { @@ -222,9 +228,10 @@ function newUiObjectConstructor () { iconPathOff: 'menu-share', rawRadius: 8, targetRadius: 0, - currentRadius: 0 + currentRadius: 0, + ring: 2 } - ) + ) } } From e30f64dc0e6939e422fd7b35c719bff676327165 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 26 Dec 2019 10:45:50 +0100 Subject: [PATCH 021/264] Data Mine Refactoring --- ChartsSpace/PlottersManager.js | 10 +- Dashboard.js | 6 +- .../FunctionLibraries/ChainAttachDetach.js | 2 +- .../FunctionLibraries/TaskFunctions.js | 2 +- FloatingSpace/UiObject.js | 2 +- FloatingSpace/UiObjectTitle.js | 2 +- Panels/ProductCard.js | 112 +++++++++--------- Panels/ProductsPanel.js | 68 +++++------ ProductStorage.js | 10 +- Project.njsproj | 2 +- Spaces/DesignerSpace.js | 2 +- Spaces/FloatingSpace.js | 2 +- Spaces/PanelsSpace.js | 2 +- 13 files changed, 111 insertions(+), 111 deletions(-) diff --git a/ChartsSpace/PlottersManager.js b/ChartsSpace/PlottersManager.js index 8196289a4..64f7a288a 100644 --- a/ChartsSpace/PlottersManager.js +++ b/ChartsSpace/PlottersManager.js @@ -127,7 +127,7 @@ function newPlottersManager () { function initializeProductPlotter (pProductCard, callBack) { try { /* Before Initializing a Plotter, we need the Storage it will use, loaded with the files it will initially need. */ - let objName = pProductCard.devTeam.codeName + '-' + pProductCard.bot.codeName + '-' + pProductCard.product.codeName + let objName = pProductCard.dataMine.codeName + '-' + pProductCard.bot.codeName + '-' + pProductCard.product.codeName let storage = newProductStorage(objName) /* @@ -158,7 +158,7 @@ function newPlottersManager () { } } - storage.initialize(pProductCard.devTeam, pProductCard.bot, pProductCard.session, pProductCard.product, exchange, market, datetime, timePeriod, onProductStorageInitialized) + storage.initialize(pProductCard.dataMine, pProductCard.bot, pProductCard.session, pProductCard.product, exchange, market, datetime, timePeriod, onProductStorageInitialized) function onProductStorageInitialized (err) { try { @@ -196,7 +196,7 @@ function newPlottersManager () { 'Plotter Panel->Javascript Code->Panel Data->Data Formula->' productDefinition = functionLibraryProtocolNode.getProtocolNode(pProductCard.product.node, false, true, true, false, false, lightingPath) } else { - plotter = getNewPlotter(pProductCard.product.plotter.devTeam, pProductCard.product.plotter.codeName, pProductCard.product.plotter.moduleName) + plotter = getNewPlotter(pProductCard.product.plotter.dataMine, pProductCard.product.plotter.codeName, pProductCard.product.plotter.moduleName) } plotter.container.connectToParent(thisObject.container, true, true, false, true, true, true) @@ -224,7 +224,7 @@ function newPlottersManager () { let panelConfig = pProductCard.product.plotter.module.panels[i] let parameters = { - devTeam: pProductCard.product.plotter.devTeam, + dataMine: pProductCard.product.plotter.dataMine, plotterCodeName: pProductCard.product.plotter.codeName, moduleCodeName: pProductCard.product.plotter.moduleName, panelCodeName: panelConfig.codeName @@ -245,7 +245,7 @@ function newPlottersManager () { let panel = productDefinition.referenceParent.panels[i] let parameters = { - devTeam: pProductCard.product.plotter.devTeam, + dataMine: pProductCard.product.plotter.dataMine, plotterCodeName: pProductCard.product.plotter.codeName, moduleCodeName: pProductCard.product.plotter.moduleName, panelCodeName: panel.id diff --git a/Dashboard.js b/Dashboard.js index 230c680bb..de8915fb5 100644 --- a/Dashboard.js +++ b/Dashboard.js @@ -54,7 +54,7 @@ function newDashboard () { if (canvas !== undefined) { canvas.finalize() } - /* Here we check where we are executing. In case we are Local we need to create a Local Dummy User and Team. */ + /* Here we check where we are executing. In case we are Local we need to create a Local Dummy User and Data Mine. */ if (window.canvasApp.executingAt === 'Local') { window.localStorage.setItem(LOGGED_IN_ACCESS_TOKEN_LOCAL_STORAGE_KEY, 'Local Access Token') // Dummy Access Token @@ -67,9 +67,9 @@ function newDashboard () { userProfileChangedEventSubscriptionId = window.canvasApp.eventHandler.listenToEvent('User Profile Changed', userProfileChanged) browserResizedEventSubscriptionId = window.canvasApp.eventHandler.listenToEvent('Browser Resized', browserResized) - /* Here we used to have a call to the Teams Module to get the profile pictures. That was removed but to keep things working, we do this: */ + /* Here we used to have a call to the DataMines Module to get the profile pictures. That was removed but to keep things working, we do this: */ - window.canvasApp.context.teamProfileImages = new Map() + window.canvasApp.context.dataMineProfileImages = new Map() window.canvasApp.context.fbProfileImages = new Map() setTimeout(delayedStart, DEBUG_START_UP_DELAY) diff --git a/DesignerSpace/Workspace/FunctionLibraries/ChainAttachDetach.js b/DesignerSpace/Workspace/FunctionLibraries/ChainAttachDetach.js index df3519f05..10d5d09b2 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/ChainAttachDetach.js +++ b/DesignerSpace/Workspace/FunctionLibraries/ChainAttachDetach.js @@ -14,7 +14,7 @@ function newChainAttachDetach () { case 'Network': { return } - case 'Team': { + case 'Data Mine': { return } case 'Phase': { diff --git a/DesignerSpace/Workspace/FunctionLibraries/TaskFunctions.js b/DesignerSpace/Workspace/FunctionLibraries/TaskFunctions.js index 8b153578c..d9dcafed8 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/TaskFunctions.js +++ b/DesignerSpace/Workspace/FunctionLibraries/TaskFunctions.js @@ -48,7 +48,7 @@ function newTaskFunctions () { 'Sensor Bot->' + 'Indicator Bot->' + 'Trading Bot->' + - 'Team->' + 'Data Mine->' let definition = functionLibraryProtocolNode.getProtocolNode(node, false, true, true, false, false, lightingPath) diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index 893272e0b..d7b47cabf 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -1145,7 +1145,7 @@ function newUiObject () { browserCanvasContext.fill() - if (thisObject.payload.node.type === 'Definition' || thisObject.payload.node.type === 'Network' || thisObject.payload.node.type === 'Team') { + if (thisObject.payload.node.type === 'Definition' || thisObject.payload.node.type === 'Network' || thisObject.payload.node.type === 'Data Mine') { VISIBLE_RADIUS = thisObject.container.frame.radius * 2 let OPACITY = 1 diff --git a/FloatingSpace/UiObjectTitle.js b/FloatingSpace/UiObjectTitle.js index ace5efac0..834d79ed4 100644 --- a/FloatingSpace/UiObjectTitle.js +++ b/FloatingSpace/UiObjectTitle.js @@ -53,7 +53,7 @@ function newUiObjectTitle () { thisObject.allwaysVisible = true break } - case 'Team': { + case 'Data Mine': { thisObject.allwaysVisible = true break } diff --git a/Panels/ProductCard.js b/Panels/ProductCard.js index 0c51f0565..c4777ed5b 100644 --- a/Panels/ProductCard.js +++ b/Panels/ProductCard.js @@ -7,7 +7,7 @@ function newProductCard () { let thisObject = { container: undefined, status: PRODUCT_CARD_STATUS.OFF, - devTeam: undefined, + dataMine: undefined, bot: undefined, product: undefined, code: undefined, @@ -69,14 +69,14 @@ function newProductCard () { let timePeriod = INITIAL_TIME_PERIOD let datetime = NEW_SESSION_INITIAL_DATE - /* TODO We are in a transition period in which bots and teams images might be located at different places. + /* TODO We are in a transition period in which bots and dataMines images might be located at different places. What we are going to do then is to try to load them from both places and use the variable that finally gets an image. */ /* This is the legacy image storage. */ - let legacyTeamAvatar - let legacyTeamAvatarLoaded = false + let legacyDataMineAvatar + let legacyDataMineAvatarLoaded = false /* TODO Temporary code */ let legacyBotAvatar @@ -89,11 +89,11 @@ function newProductCard () { /* We are transitioning towards this */ - let teamAvatar // stores the avatar image of the team the bot portrayed at this card belongs to. - let teamAvatarLoaded = false + let dataMineAvatar // stores the avatar image of the dataMine the bot portrayed at this card belongs to. + let dataMineAvatarLoaded = false /* TODO Temporary code */ - let botAvatar // stores the avatar image of the team the bot portrayed at this card belongs to. + let botAvatar // stores the avatar image of the dataMine the bot portrayed at this card belongs to. let botAvatarLoaded = false /* Add an Event Handler */ @@ -111,14 +111,14 @@ function newProductCard () { thisObject.container = undefined thisObject.eventHandler = undefined thisObject.status = undefined - thisObject.devTeam = undefined + thisObject.dataMine = undefined thisObject.bot = undefined thisObject.product = undefined thisObject.code = undefined thisObject.fitFunction = undefined - legacyTeamAvatar = undefined - legacyTeamAvatarLoaded = undefined + legacyDataMineAvatar = undefined + legacyDataMineAvatarLoaded = undefined legacyBotAvatar = undefined legacyBotAvatarLoaded = undefined legacyPlotterBanner = undefined @@ -150,10 +150,10 @@ function newProductCard () { /* Add information that will later be needed. */ - let team = ecosystem.getTeam(thisObject.product.plotter.devTeam) + let dataMine = ecosystem.getDataMine(thisObject.product.plotter.dataMine) let plotter - if (team !== undefined) { - plotter = ecosystem.getPlotter(team, thisObject.product.plotter.codeName) + if (dataMine !== undefined) { + plotter = ecosystem.getPlotter(dataMine, thisObject.product.plotter.codeName) } if (plotter !== undefined) { @@ -212,13 +212,13 @@ function newProductCard () { /* WARNING THIS IS TEMPORARY CODE */ - const LEGACY_TEAM = thisObject.devTeam.codeName + const LEGACY_DATA_MINE = thisObject.dataMine.codeName const REPO = thisObject.bot.repo const PROFILE_PIC = thisObject.bot.profilePicture - /* The plotter banner, comes from the Legacy Location so far, no matter if the Team is at the Teams Modules or not. */ + /* The plotter banner, comes from the Legacy Location so far, no matter if the Data Mine is at the DataMines Modules or not. */ - const PLOTTER_TEAM = thisObject.product.plotter.devTeam + const PLOTTER_DATA_MINE = thisObject.product.plotter.dataMine const PLOTTER_REPO = thisObject.product.plotter.codeName const PLOTTER_PROFILE_PIC = thisObject.product.plotter.profilePicture @@ -230,7 +230,7 @@ function newProductCard () { } if (PLOTTER_PROFILE_PIC !== undefined) { - legacyPlotterBanner.src = window.canvasApp.urlPrefix + 'Images/' + PLOTTER_TEAM + '/' + PLOTTER_REPO + '/' + PLOTTER_PROFILE_PIC + legacyPlotterBanner.src = window.canvasApp.urlPrefix + 'Images/' + PLOTTER_DATA_MINE + '/' + PLOTTER_REPO + '/' + PLOTTER_PROFILE_PIC } else { if (thisObject.product.plotter.banner !== undefined) { legacyPlotterBanner.src = window.canvasApp.urlPrefix + 'Images/' + thisObject.product.plotter.banner + '-Banner.PNG' @@ -239,25 +239,25 @@ function newProductCard () { } } - const TEAM = thisObject.devTeam.codeName.toLowerCase() + const DATA_MINE = thisObject.dataMine.codeName.toLowerCase() const BOT = thisObject.bot.codeName.toLowerCase() - if (window.canvasApp.context.teamProfileImages.get(TEAM) === undefined) { - // This means this Team is a Lecay Team, still not at any Module. + if (window.canvasApp.context.dataMineProfileImages.get(DATA_MINE) === undefined) { + // This means this Data Mine is a Lecay Data Mine, still not at any Module. /* Here we will download the images still at the legacy storage. */ - legacyTeamAvatar = new Image() + legacyDataMineAvatar = new Image() - legacyTeamAvatar.onload = onLegacyImageLoad + legacyDataMineAvatar.onload = onLegacyImageLoad function onLegacyImageLoad () { - legacyTeamAvatarLoaded = true + legacyDataMineAvatarLoaded = true } - legacyTeamAvatar.src = window.canvasApp.urlPrefix + 'Images/' + LEGACY_TEAM + '/' + LEGACY_TEAM + '.png' + legacyDataMineAvatar.src = window.canvasApp.urlPrefix + 'Images/' + LEGACY_DATA_MINE + '/' + LEGACY_DATA_MINE + '.png' legacyBotAvatar = new Image() legacyBotAvatar.onload = onLegacyImageLoadBot @@ -267,23 +267,23 @@ function newProductCard () { thisObject.bot.avatar = legacyBotAvatar } - legacyBotAvatar.src = window.canvasApp.urlPrefix + 'Images/' + LEGACY_TEAM + '/' + REPO + '/' + PROFILE_PIC + legacyBotAvatar.src = window.canvasApp.urlPrefix + 'Images/' + LEGACY_DATA_MINE + '/' + REPO + '/' + PROFILE_PIC } else { /* - Here we will download the images of teams shareed at the Teams Module. - There might be Product Cards of bots beloging to teams not present currently at the Teams Module, in those cases + Here we will download the images of dataMines shareed at the DataMines Module. + There might be Product Cards of bots beloging to dataMines not present currently at the DataMines Module, in those cases nothing should happen. */ - teamAvatar = new Image() + dataMineAvatar = new Image() - teamAvatar.onload = onImageLoad + dataMineAvatar.onload = onImageLoad function onImageLoad () { - teamAvatarLoaded = true + dataMineAvatarLoaded = true } - teamAvatar.src = window.canvasApp.context.teamProfileImages.get(TEAM) + dataMineAvatar.src = window.canvasApp.context.dataMineProfileImages.get(DATA_MINE) botAvatar = new Image() botAvatar.onload = onImageLoadBot @@ -293,7 +293,7 @@ function newProductCard () { thisObject.bot.avatar = botAvatar } - botAvatar.src = window.canvasApp.context.fbProfileImages.get(TEAM + '-' + BOT) + botAvatar.src = window.canvasApp.context.fbProfileImages.get(DATA_MINE + '-' + BOT) } } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err.stack) } @@ -460,7 +460,7 @@ function newProductCard () { y: 0 } - const devTeamImageSize = 20 + const dataMineImageSize = 20 const botImageSize = 20 const plotterImageSize = { width: 180, @@ -470,32 +470,32 @@ function newProductCard () { lastMouseOver-- // Animating the mouse onMouseOver if (lastMouseOver > 0) { - /* First the Dev Team Profile Picture. */ - let teamImagePoint = { + /* First the Dev Data Mine Profile Picture. */ + let dataMineImagePoint = { x: 2, - y: thisObject.container.frame.height / 2 - devTeamImageSize / 2 + y: thisObject.container.frame.height / 2 - dataMineImageSize / 2 } - teamImagePoint = thisObject.container.frame.frameThisPoint(teamImagePoint) - fitImagePoint = thisObject.fitFunction(teamImagePoint) - let teamImage - if (legacyTeamAvatarLoaded === true) { - teamImage = legacyTeamAvatar + dataMineImagePoint = thisObject.container.frame.frameThisPoint(dataMineImagePoint) + fitImagePoint = thisObject.fitFunction(dataMineImagePoint) + let dataMineImage + if (legacyDataMineAvatarLoaded === true) { + dataMineImage = legacyDataMineAvatar } - if (teamAvatarLoaded === true) { - teamImage = teamAvatar + if (dataMineAvatarLoaded === true) { + dataMineImage = dataMineAvatar } - if (teamImage !== undefined && teamImagePoint.y === fitImagePoint.y) { - if (teamImage.naturalHeight !== 0) { + if (dataMineImage !== undefined && dataMineImagePoint.y === fitImagePoint.y) { + if (dataMineImage.naturalHeight !== 0) { /* The image is rounded before being displayed. */ browserCanvasContext.save() browserCanvasContext.beginPath() - browserCanvasContext.arc(teamImagePoint.x + devTeamImageSize / 2, teamImagePoint.y + devTeamImageSize / 2, devTeamImageSize / 2, 0, Math.PI * 2, true) + browserCanvasContext.arc(dataMineImagePoint.x + dataMineImageSize / 2, dataMineImagePoint.y + dataMineImageSize / 2, dataMineImageSize / 2, 0, Math.PI * 2, true) browserCanvasContext.closePath() browserCanvasContext.clip() - browserCanvasContext.drawImage(teamImage, teamImagePoint.x, teamImagePoint.y, devTeamImageSize, devTeamImageSize) + browserCanvasContext.drawImage(dataMineImage, dataMineImagePoint.x, dataMineImagePoint.y, dataMineImageSize, dataMineImageSize) browserCanvasContext.beginPath() - browserCanvasContext.arc(teamImagePoint.x, teamImagePoint.y, devTeamImageSize / 2, 0, Math.PI * 2, true) + browserCanvasContext.arc(dataMineImagePoint.x, dataMineImagePoint.y, dataMineImageSize / 2, 0, Math.PI * 2, true) browserCanvasContext.clip() browserCanvasContext.closePath() browserCanvasContext.restore() @@ -511,7 +511,7 @@ function newProductCard () { botImagePoint = thisObject.container.frame.frameThisPoint(botImagePoint) fitImagePoint = thisObject.fitFunction(botImagePoint) - let imageId = thisObject.bot.devTeam + '.' + thisObject.bot.profilePicture + let imageId = thisObject.bot.dataMine + '.' + thisObject.bot.profilePicture /* TODO Temporary code */ let botImage botImage = thisObject.bot.avatar @@ -545,7 +545,7 @@ function newProductCard () { y: plotterImagePoint.y + plotterImageSize.height } fitImagePoint = thisObject.fitFunction(fitImagePoint) - let imageId = thisObject.product.plotter.devTeam + '.' + thisObject.product.plotter.codeName + '.' + thisObject.product.plotter.moduleName + '.' + thisObject.product.plotter.profilePicture + let imageId = thisObject.product.plotter.dataMine + '.' + thisObject.product.plotter.codeName + '.' + thisObject.product.plotter.moduleName + '.' + thisObject.product.plotter.profilePicture let plotterImage = legacyPlotterBanner if (plotterImage !== undefined && plotterImagePoint.y + plotterImageSize.height === fitImagePoint.y) { if (plotterImage.naturalHeight !== 0) { @@ -627,13 +627,13 @@ function newProductCard () { browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY let label if (lastMouseOver > 0) { - /* devTeam */ - label = thisObject.devTeam.displayName + /* dataMine */ + label = thisObject.dataMine.displayName if (label.length > 10) { label = label.substring(1, 8) + '...' } labelPoint = { - x: 2 + devTeamImageSize / 2 - label.length / 2 * fontSize * FONT_ASPECT_RATIO, - y: thisObject.container.frame.height / 2 + devTeamImageSize / 2 + fontSize * FONT_ASPECT_RATIO + 5 + x: 2 + dataMineImageSize / 2 - label.length / 2 * fontSize * FONT_ASPECT_RATIO, + y: thisObject.container.frame.height / 2 + dataMineImageSize / 2 + fontSize * FONT_ASPECT_RATIO + 5 } labelPoint = thisObject.container.frame.frameThisPoint(labelPoint) @@ -647,7 +647,7 @@ function newProductCard () { labelPoint = { x: thisObject.container.frame.width - 8 - label.length / 2 * fontSize * FONT_ASPECT_RATIO, - y: thisObject.container.frame.height / 2 + devTeamImageSize / 2 + fontSize * FONT_ASPECT_RATIO + 5 + y: thisObject.container.frame.height / 2 + dataMineImageSize / 2 + fontSize * FONT_ASPECT_RATIO + 5 } labelPoint = thisObject.container.frame.frameThisPoint(labelPoint) @@ -675,7 +675,7 @@ function newProductCard () { } labelPoint = { x: thisObject.container.frame.width / 2 - label.length / 2 * fontSize * FONT_ASPECT_RATIO, - y: thisObject.container.frame.height / 2 - devTeamImageSize / 2 - fontSize * FONT_ASPECT_RATIO - 20 + y: thisObject.container.frame.height / 2 - dataMineImageSize / 2 - fontSize * FONT_ASPECT_RATIO - 20 } labelPoint = thisObject.container.frame.frameThisPoint(labelPoint) labelPoint = thisObject.fitFunction(labelPoint) diff --git a/Panels/ProductsPanel.js b/Panels/ProductsPanel.js index a28de7171..d52590b12 100644 --- a/Panels/ProductsPanel.js +++ b/Panels/ProductsPanel.js @@ -67,18 +67,18 @@ function newProductsPanel () { } /* For legacy plotters, we will add product cards based on the old ecosystem file */ - for (let i = 0; i < ecosystem.devTeams.length; i++) { - let devTeam = ecosystem.devTeams[i] + for (let i = 0; i < ecosystem.dataMines.length; i++) { + let dataMine = ecosystem.dataMines[i] - for (let j = 0; j < devTeam.bots.length; j++) { - let bot = devTeam.bots[j] + for (let j = 0; j < dataMine.bots.length; j++) { + let bot = dataMine.bots[j] if (bot.type !== 'Indicator Bot Instance') { continue } if (bot.products !== undefined) { for (let k = 0; k < bot.products.length; k++) { let product = bot.products[k] - addProductCard(devTeam, bot, product) + addProductCard(dataMine, bot, product) } } } @@ -88,19 +88,19 @@ function newProductsPanel () { let workspaceNode = canvas.designerSpace.workspace.workspaceNode for (let i = 0; i < workspaceNode.rootNodes.length; i++) { let rootNode = workspaceNode.rootNodes[i] - if (rootNode.type === 'Team') { - let teamNode = rootNode + if (rootNode.type === 'Data Mine') { + let dataMineNode = rootNode - let team = {} - if (teamNode.code === undefined) { continue } + let dataMine = {} + if (dataMineNode.code === undefined) { continue } try { - let code = JSON.parse(teamNode.code) - team.codeName = code.codeName + let code = JSON.parse(dataMineNode.code) + dataMine.codeName = code.codeName } catch (err) { continue } - for (let j = 0; j < teamNode.indicatorBots.length; j++) { - let botNode = teamNode.indicatorBots[j] + for (let j = 0; j < dataMineNode.indicatorBots.length; j++) { + let botNode = dataMineNode.indicatorBots[j] let bot = {} if (botNode.code === undefined) { continue } @@ -149,20 +149,20 @@ function newProductsPanel () { } if (plotterNode.payload.parentNode === undefined) { continue } - let plotterTeamNode = plotterNode.payload.parentNode + let plotterDataMineNode = plotterNode.payload.parentNode - let plotterTeam = {} - if (plotterTeamNode.code === undefined) { continue } + let plotterDataMine = {} + if (plotterDataMineNode.code === undefined) { continue } try { - let code = JSON.parse(plotterTeamNode.code) - plotterTeam.codeName = code.codeName + let code = JSON.parse(plotterDataMineNode.code) + plotterDataMine.codeName = code.codeName } catch (err) { continue } /* Conversion to fit old format */ product.plotter = plotter - product.plotter.devTeam = plotterTeam.codeName + product.plotter.dataMine = plotterDataMine.codeName product.plotter.moduleName = plotterModule.codeName product.plotter.banner = plotterModule.banner product.plotter.legacy = false @@ -171,8 +171,8 @@ function newProductsPanel () { product.dataSets = [] product.exchangeList = [{'name': 'Poloniex'}] product.node = productNode - team.displayName = teamNode.name - team.host = {'url': 'localhost'} + dataMine.displayName = dataMineNode.name + dataMine.host = {'url': 'localhost'} bot.displayName = botNode.name for (let m = 0; m < productNode.datasets.length; m++) { @@ -187,7 +187,7 @@ function newProductsPanel () { } } - addProductCard(team, bot, product) + addProductCard(dataMine, bot, product) } } } @@ -204,15 +204,15 @@ function newProductsPanel () { productCard.finalize() } - function addProductCard (devTeam, bot, product, session) { + function addProductCard (dataMine, bot, product, session) { /* Now we create Product objects */ let productCard = newProductCard() - productCard.devTeam = devTeam + productCard.dataMine = dataMine productCard.bot = bot productCard.product = product productCard.fitFunction = thisObject.fitFunction - productCard.code = exchange + '-' + market.assetB + '/' + market.assetA + '-' + devTeam.codeName + '-' + bot.codeName + '-' + product.codeName + productCard.code = exchange + '-' + market.assetB + '/' + market.assetA + '-' + dataMine.codeName + '-' + bot.codeName + '-' + product.codeName if (session !== undefined) { productCard.code = productCard.code + '-' + session.id @@ -397,7 +397,7 @@ function newProductsPanel () { let tradingBotInstance = tradingBotInstances[n] let code let instanceBot - let instanceTeam + let instanceDataMine for (let m = 0; m < tradingBotInstance.processes.length; m++) { let process = tradingBotInstance.processes[m] @@ -405,18 +405,18 @@ function newProductsPanel () { code = JSON.parse(process.payload.referenceParent.payload.parentNode.code) instanceBot = code.codeName code = JSON.parse(process.payload.referenceParent.payload.parentNode.payload.parentNode.code) - instanceTeam = code.codeName + instanceDataMine = code.codeName } catch (err) { continue } - for (let i = 0; i < ecosystem.devTeams.length; i++) { - let devTeam = ecosystem.devTeams[i] + for (let i = 0; i < ecosystem.dataMines.length; i++) { + let dataMine = ecosystem.dataMines[i] - for (let j = 0; j < devTeam.bots.length; j++) { - let bot = devTeam.bots[j] + for (let j = 0; j < dataMine.bots.length; j++) { + let bot = dataMine.bots[j] if (bot.type !== 'Trading Bot Instance') { continue } - if (devTeam.codeName === instanceTeam && bot.codeName === instanceBot) { + if (dataMine.codeName === instanceDataMine && bot.codeName === instanceBot) { /* We found an instance of the same Trading we are currently looking at. Next thing to do is to see its layers to see if we can match it with the current product. */ @@ -439,10 +439,10 @@ function newProductsPanel () { if (product.codeName === layerCode.product) { /* We have a layer that is matching the current product */ - let cardCode = exchange + '-' + market.assetB + '/' + market.assetA + '-' + devTeam.codeName + '-' + bot.codeName + '-' + product.codeName + '-' + process.session.id + let cardCode = exchange + '-' + market.assetB + '/' + market.assetA + '-' + dataMine.codeName + '-' + bot.codeName + '-' + product.codeName + '-' + process.session.id let cardFound = removeFromLocalProductCards(cardCode) if (cardFound !== true) { - productCard = addProductCard(devTeam, bot, product, process.session) + productCard = addProductCard(dataMine, bot, product, process.session) onProductCardStatusChanged(productCard) } } diff --git a/ProductStorage.js b/ProductStorage.js index bdb862032..3ad5d77f6 100644 --- a/ProductStorage.js +++ b/ProductStorage.js @@ -74,7 +74,7 @@ function newProductStorage (pName) { } } - function initialize (pDevTeam, pBot, pSession, pProduct, pExchange, pMarket, pDatetime, pTimePeriod, callBackFunction) { + function initialize (pdataMine, pBot, pSession, pProduct, pExchange, pMarket, pDatetime, pTimePeriod, callBackFunction) { try { datetime = pDatetime timePeriod = pTimePeriod @@ -90,7 +90,7 @@ function newProductStorage (pName) { dataSetsToLoad++ let marketFiles = newMarketFiles() - marketFiles.initialize(pDevTeam, pBot, pSession, pProduct, thisSet, pExchange, pMarket, onMarketFileReady) + marketFiles.initialize(pdataMine, pBot, pSession, pProduct, thisSet, pExchange, pMarket, onMarketFileReady) thisObject.marketFiles.push(marketFiles) } break @@ -99,7 +99,7 @@ function newProductStorage (pName) { dataSetsToLoad++ let dailyFiles = newDailyFiles() - dailyFiles.initialize(pDevTeam, pBot, pSession, pProduct, thisSet, pExchange, pMarket, pDatetime, pTimePeriod, onDailyFileReady) + dailyFiles.initialize(pdataMine, pBot, pSession, pProduct, thisSet, pExchange, pMarket, pDatetime, pTimePeriod, onDailyFileReady) thisObject.dailyFiles.push(dailyFiles) } break @@ -108,7 +108,7 @@ function newProductStorage (pName) { dataSetsToLoad++ let singleFile = newSingleFile() - singleFile.initialize(pDevTeam, pBot, pSession, pProduct, thisSet, pExchange, pMarket, onSingleFileReady) + singleFile.initialize(pdataMine, pBot, pSession, pProduct, thisSet, pExchange, pMarket, onSingleFileReady) thisObject.singleFile.push(singleFile) } break @@ -117,7 +117,7 @@ function newProductStorage (pName) { dataSetsToLoad++ let fileSequences = newFileSequence() - fileSequences.initialize(pDevTeam, pBot, pSession, pProduct, thisSet, pExchange, pMarket, onFileSequenceReady) + fileSequences.initialize(pdataMine, pBot, pSession, pProduct, thisSet, pExchange, pMarket, onFileSequenceReady) thisObject.fileSequences.push(fileSequences) } break diff --git a/Project.njsproj b/Project.njsproj index 7cc00eb05..b45882cef 100644 --- a/Project.njsproj +++ b/Project.njsproj @@ -106,7 +106,7 @@ Code - + Code diff --git a/Spaces/DesignerSpace.js b/Spaces/DesignerSpace.js index 3dff9ae53..eca3b7c49 100644 --- a/Spaces/DesignerSpace.js +++ b/Spaces/DesignerSpace.js @@ -139,7 +139,7 @@ function newDesignerSpace () { 'bot-indicator', 'bot-sensor', 'time-period', - 'team', + 'data-mine', 'procedure-loop', 'calculations-procedure', 'data-building-procedure', diff --git a/Spaces/FloatingSpace.js b/Spaces/FloatingSpace.js index f86b91b12..2c4ddef30 100644 --- a/Spaces/FloatingSpace.js +++ b/Spaces/FloatingSpace.js @@ -107,7 +107,7 @@ function newFloatingSpace () { if ( payload.node.type === 'Definition' || payload.node.type === 'Network' || - payload.node.type === 'Team' + payload.node.type === 'Data Mine' ) { return false } diff --git a/Spaces/PanelsSpace.js b/Spaces/PanelsSpace.js index b67add293..641758d0b 100644 --- a/Spaces/PanelsSpace.js +++ b/Spaces/PanelsSpace.js @@ -63,7 +63,7 @@ function newPanelsSpace () { panel.session = pSession panel.initialize(pPanelCode) } else { - panel = getNewPlotterPanel(pParameters.devTeam, pParameters.plotterCodeName, pParameters.moduleCodeName, pParameters.panelCodeName) + panel = getNewPlotterPanel(pParameters.dataMine, pParameters.plotterCodeName, pParameters.moduleCodeName, pParameters.panelCodeName) panel.fitFunction = canvas.chartSpace.fitIntoVisibleArea panel.container.isVisibleFunction = canvas.chartSpace.isThisPointVisible panel.session = pSession From 6b42383e871012089bba7694ed4b217b48e49732 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 26 Dec 2019 13:32:52 +0100 Subject: [PATCH 022/264] Generalizing chainedToTheSameType part 1 --- .../FunctionLibraries/NodeChildren.js | 34 ++++++---- .../FunctionLibraries/NodeDeleter.js | 8 +++ .../FunctionLibraries/UiObjectsFromNodes.js | 65 ++++++++++++++++--- 3 files changed, 87 insertions(+), 20 deletions(-) diff --git a/DesignerSpace/Workspace/FunctionLibraries/NodeChildren.js b/DesignerSpace/Workspace/FunctionLibraries/NodeChildren.js index e606f89ed..894dd0623 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/NodeChildren.js +++ b/DesignerSpace/Workspace/FunctionLibraries/NodeChildren.js @@ -14,13 +14,13 @@ function newNodeChildren () { childrenCount: 0, childIndex: undefined } - let nodeDefinition = APP_SCHEMA_MAP.get(parentNode.type) - if (nodeDefinition !== undefined) { - if (nodeDefinition.properties !== undefined) { + let parentNodeDefinition = APP_SCHEMA_MAP.get(parentNode.type) + if (parentNodeDefinition !== undefined) { + if (parentNodeDefinition.properties !== undefined) { let previousPropertyName // Since there are cases where there are many properties with the same name,because they can hold nodes of different types but only one at the time, we have to avoind counting each property of those as individual children. - for (let i = 0; i < nodeDefinition.properties.length; i++) { - let property = nodeDefinition.properties[i] + for (let i = 0; i < parentNodeDefinition.properties.length; i++) { + let property = parentNodeDefinition.properties[i] if (parentNode[property.name] !== undefined) { switch (property.type) { case 'node': { @@ -34,12 +34,24 @@ function newNodeChildren () { } break case 'array': { - let nodePropertyArray = parentNode[property.name] - for (let j = 0; j < nodePropertyArray.length; j++) { - let child = nodePropertyArray[j] - response.childrenCount++ - if (child.id === childNode.id) { - response.childIndex = response.childrenCount + let nodeDefinition = APP_SCHEMA_MAP.get(childNode.type) + if (nodeDefinition !== undefined) { + let nodePropertyArray = parentNode[property.name] + for (let j = 0; j < nodePropertyArray.length; j++) { + let child = nodePropertyArray[j] + if (nodeDefinition.chainedToSameType === true) { + if (j < 1) { + response.childrenCount++ + if (child.id === childNode.id) { + response.childIndex = response.childrenCount + } + } + } else { + response.childrenCount++ + if (child.id === childNode.id) { + response.childIndex = response.childrenCount + } + } } } } diff --git a/DesignerSpace/Workspace/FunctionLibraries/NodeDeleter.js b/DesignerSpace/Workspace/FunctionLibraries/NodeDeleter.js index cf1022d6f..46ad39fcb 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/NodeDeleter.js +++ b/DesignerSpace/Workspace/FunctionLibraries/NodeDeleter.js @@ -74,6 +74,14 @@ function newNodeDeleter () { for (let j = 0; j < nodePropertyArray.length; j++) { let arrayItem = nodePropertyArray[j] if (arrayItem.id === node.id) { + /* If this object is chained to the ones of the same type we need to give the next in the chain the reference to the current chain parent */ + if (nodeDefinition.chainedToSameType === true) { + if (j < nodePropertyArray.length - 1) { + let nextArrayItem = nodePropertyArray[j + 1] + nextArrayItem.payload.chainParent = node.payload.chainParent + } + } + nodePropertyArray.splice(j, 1) } } diff --git a/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js b/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js index f4af73d5a..9844134df 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js +++ b/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js @@ -60,6 +60,33 @@ function newUiObjectsFromNodes () { } } + /* For the cases where an node is not chained to its parent but to the one at the parent before it at its collection */ + if (nodeDefinition.chainedToSameType === true) { + let parentNodeDefinition = APP_SCHEMA_MAP.get(parentNode.type) + if (parentNodeDefinition !== undefined) { + if (parentNodeDefinition.properties !== undefined) { + for (let i = 0; i < parentNodeDefinition.properties.length; i++) { + let property = parentNodeDefinition.properties[i] + if (property.childType === node.type) { + if (property.type === 'array') { + if (parentNode[property.name] !== undefined) { + if (parentNode[property.name].length > 1) { + let nodeChildren = parentNode[property.name] + for (let j = 0; j < nodeChildren.length; j++) { + if (node.id === nodeChildren[j].id) { + if (j > 0) { + chainParent = nodeChildren[j - 1] + } + } + } + } + } + } + } + } + } + } + } /* Create Self */ createUiObject(false, node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) @@ -92,24 +119,44 @@ function newUiObjectsFromNodes () { } } - function addUIObject (parent, type) { + function addUIObject (parentNode, type) { let object = { name: 'New ' + type, type: type } - let parentNodeDefinition = APP_SCHEMA_MAP.get(parent.type) + let parentNodeDefinition = APP_SCHEMA_MAP.get(parentNode.type) if (parentNodeDefinition !== undefined) { /* Resolve Initial Values */ let nodeDefinition = APP_SCHEMA_MAP.get(object.type) if (nodeDefinition.isHierarchyHead === true) { - parent.rootNodes.push(object) - createUiObject(true, object.type, object.name, object, parent, undefined) + parentNode.rootNodes.push(object) + createUiObject(true, object.type, object.name, object, parentNode, undefined) return object } - createUiObject(true, object.type, object.name, object, parent, parent) + /* For the cases where an node is not chained to its parent but to the one at the parent before it at its collection */ + let chainParent = parentNode + if (nodeDefinition.chainedToSameType === true) { + if (parentNodeDefinition.properties !== undefined) { + for (let i = 0; i < parentNodeDefinition.properties.length; i++) { + let property = parentNodeDefinition.properties[i] + if (property.childType === type) { + if (property.type === 'array') { + if (parentNode[property.name] !== undefined) { + if (parentNode[property.name].length > 0) { + let nodeChildren = parentNode[property.name] + chainParent = nodeChildren[nodeChildren.length - 1] + } + } + } + } + } + } + } + + createUiObject(true, object.type, object.name, object, parentNode, chainParent) if (nodeDefinition !== undefined) { if (nodeDefinition.initialValues !== undefined) { @@ -128,16 +175,16 @@ function newUiObjectsFromNodes () { switch (property.type) { case 'node': { if (property.name !== previousPropertyName) { - parent[property.name] = object + parentNode[property.name] = object previousPropertyName = property.name } } break case 'array': { - if (parent[property.name] === undefined) { - parent[property.name] = [] + if (parentNode[property.name] === undefined) { + parentNode[property.name] = [] } - parent[property.name].push(object) + parentNode[property.name].push(object) } break } From a596068600c88bf2e3c698015cd1ce57ee31e4c1 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 26 Dec 2019 13:59:03 +0100 Subject: [PATCH 023/264] Bug Fixed attaching and detaching phases --- .../FunctionLibraries/ChainAttachDetach.js | 39 +++++++++++++---- .../FunctionLibraries/UiObjectsFromNodes.js | 42 ++++++++++++------- 2 files changed, 56 insertions(+), 25 deletions(-) diff --git a/DesignerSpace/Workspace/FunctionLibraries/ChainAttachDetach.js b/DesignerSpace/Workspace/FunctionLibraries/ChainAttachDetach.js index 10d5d09b2..c147dd7a2 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/ChainAttachDetach.js +++ b/DesignerSpace/Workspace/FunctionLibraries/ChainAttachDetach.js @@ -96,11 +96,6 @@ function newChainAttachDetach () { case 'Phase': { switch (attachToNode.type) { case 'Stop': { - if (attachToNode.maxPhases !== undefined) { - if (attachToNode.phases.length >= attachToNode.maxPhases) { - return - } - } node.payload.parentNode = attachToNode if (attachToNode.phases.length > 0) { let phase = attachToNode.phases[attachToNode.phases.length - 1] @@ -113,10 +108,36 @@ function newChainAttachDetach () { } break case 'Take Profit': { - if (attachToNode.maxPhases !== undefined) { - if (attachToNode.phases.length >= attachToNode.maxPhases) { - return - } + node.payload.parentNode = attachToNode + if (attachToNode.phases.length > 0) { + let phase = attachToNode.phases[attachToNode.phases.length - 1] + node.payload.chainParent = phase + } else { + node.payload.chainParent = attachToNode + } + attachToNode.phases.push(node) + completeAttachment(node, rootNodes) + } + break + case 'Initial Stop': { + if (attachToNode.phases.length >= 1) { + return + } + + node.payload.parentNode = attachToNode + if (attachToNode.phases.length > 0) { + let phase = attachToNode.phases[attachToNode.phases.length - 1] + node.payload.chainParent = phase + } else { + node.payload.chainParent = attachToNode + } + attachToNode.phases.push(node) + completeAttachment(node, rootNodes) + } + break + case 'Initial Take Profit': { + if (attachToNode.phases.length >= 1) { + return } node.payload.parentNode = attachToNode if (attachToNode.phases.length > 0) { diff --git a/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js b/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js index 9844134df..9278eaa6a 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js +++ b/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js @@ -62,21 +62,23 @@ function newUiObjectsFromNodes () { /* For the cases where an node is not chained to its parent but to the one at the parent before it at its collection */ if (nodeDefinition.chainedToSameType === true) { - let parentNodeDefinition = APP_SCHEMA_MAP.get(parentNode.type) - if (parentNodeDefinition !== undefined) { - if (parentNodeDefinition.properties !== undefined) { - for (let i = 0; i < parentNodeDefinition.properties.length; i++) { - let property = parentNodeDefinition.properties[i] - if (property.childType === node.type) { - if (property.type === 'array') { - if (parentNode[property.name] !== undefined) { - if (parentNode[property.name].length > 1) { - let nodeChildren = parentNode[property.name] - for (let j = 0; j < nodeChildren.length; j++) { - if (node.id === nodeChildren[j].id) { - if (j > 0) { + if (parentNode !== undefined) { + let parentNodeDefinition = APP_SCHEMA_MAP.get(parentNode.type) + if (parentNodeDefinition !== undefined) { + if (parentNodeDefinition.properties !== undefined) { + for (let i = 0; i < parentNodeDefinition.properties.length; i++) { + let property = parentNodeDefinition.properties[i] + if (property.childType === node.type) { + if (property.type === 'array') { + if (parentNode[property.name] !== undefined) { + if (parentNode[property.name].length > 1) { + let nodeChildren = parentNode[property.name] + for (let j = 0; j < nodeChildren.length; j++) { + if (node.id === nodeChildren[j].id) { + if (j > 0) { chainParent = nodeChildren[j - 1] } + } } } } @@ -156,8 +158,6 @@ function newUiObjectsFromNodes () { } } - createUiObject(true, object.type, object.name, object, parentNode, chainParent) - if (nodeDefinition !== undefined) { if (nodeDefinition.initialValues !== undefined) { if (nodeDefinition.initialValues.code !== undefined) { @@ -184,7 +184,15 @@ function newUiObjectsFromNodes () { if (parentNode[property.name] === undefined) { parentNode[property.name] = [] } - parentNode[property.name].push(object) + if (property.maxItems !== undefined) { + if (parentNode[property.name].length < property.maxItems) { + parentNode[property.name].push(object) + } else { + return // Object can not be created. + } + } else { + parentNode[property.name].push(object) + } } break } @@ -192,6 +200,8 @@ function newUiObjectsFromNodes () { } } + createUiObject(true, object.type, object.name, object, parentNode, chainParent) + /* Auto Add more Children */ if (nodeDefinition.properties !== undefined) { let previousPropertyName // Since there are cases where there are many properties with the same name,because they can hold nodes of different types but only one at the time, we have to avoind counting each property of those as individual children. From 412d72eb1276fdd31de95e781bf83c8b9b140ca4 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 27 Dec 2019 13:26:46 +0100 Subject: [PATCH 024/264] Time Frame Refectoring --- ChartsSpace/ChartUtilities.js | 28 +++---- ChartsSpace/PlottersManager.js | 18 ++--- ChartsSpace/TimelineChart.js | 30 ++++---- .../FunctionLibraries/SessionFunctions.js | 12 +-- Globals.js | 6 +- Panels/ProductCard.js | 16 ++-- Panels/TimeControlPanel.js | 12 +-- Plotter.js | 46 +++++------ ProductStorage.js | 24 +++--- .../{TimePeriodScale.js => TimeFrameScale.js} | 76 +++++++++---------- 10 files changed, 134 insertions(+), 134 deletions(-) rename Scales/{TimePeriodScale.js => TimeFrameScale.js} (80%) diff --git a/ChartsSpace/ChartUtilities.js b/ChartsSpace/ChartUtilities.js index e7d29bd8a..16f47e1d0 100644 --- a/ChartsSpace/ChartUtilities.js +++ b/ChartsSpace/ChartUtilities.js @@ -1,48 +1,48 @@ -function getSideDays (timePeriod) { +function getSideDays (timeFrame) { let daysOnSides - if (timePeriod < _1_HOUR_IN_MILISECONDS) { + if (timeFrame < _1_HOUR_IN_MILISECONDS) { daysOnSides = 1 } - if (timePeriod === _1_HOUR_IN_MILISECONDS) { + if (timeFrame === _1_HOUR_IN_MILISECONDS) { daysOnSides = 9 } - if (timePeriod === _2_HOURS_IN_MILISECONDS) { + if (timeFrame === _2_HOURS_IN_MILISECONDS) { daysOnSides = 10 } - if (timePeriod === _3_HOURS_IN_MILISECONDS) { + if (timeFrame === _3_HOURS_IN_MILISECONDS) { daysOnSides = 12 } - if (timePeriod === _4_HOURS_IN_MILISECONDS) { + if (timeFrame === _4_HOURS_IN_MILISECONDS) { daysOnSides = 20 } - if (timePeriod === _6_HOURS_IN_MILISECONDS) { + if (timeFrame === _6_HOURS_IN_MILISECONDS) { daysOnSides = 35 } - if (timePeriod === _8_HOURS_IN_MILISECONDS) { + if (timeFrame === _8_HOURS_IN_MILISECONDS) { daysOnSides = 44 } - if (timePeriod === _12_HOURS_IN_MILISECONDS) { + if (timeFrame === _12_HOURS_IN_MILISECONDS) { daysOnSides = 56 } - if (timePeriod === ONE_DAY_IN_MILISECONDS) { + if (timeFrame === ONE_DAY_IN_MILISECONDS) { daysOnSides = 154 } return daysOnSides } -function getCondenseFactor (timePeriod) { - switch (timePeriod) { +function getCondenseFactor (timeFrame) { + switch (timeFrame) { case _1_MINUTE_IN_MILISECONDS: return 1 case _5_MINUTES_IN_MILISECONDS: return 5 case _10_MINUTES_IN_MILISECONDS: return 10 @@ -51,8 +51,8 @@ function getCondenseFactor (timePeriod) { } } -function getTransparenceFactor (timePeriod) { - switch (timePeriod) { +function getTransparenceFactor (timeFrame) { + switch (timeFrame) { case _1_MINUTE_IN_MILISECONDS: return '0.12' case _5_MINUTES_IN_MILISECONDS: return '0.10' case _10_MINUTES_IN_MILISECONDS: return '0.08' diff --git a/ChartsSpace/PlottersManager.js b/ChartsSpace/PlottersManager.js index 64f7a288a..75b6c2811 100644 --- a/ChartsSpace/PlottersManager.js +++ b/ChartsSpace/PlottersManager.js @@ -6,14 +6,14 @@ function newPlottersManager () { let productPlotters = [] - let timePeriod = INITIAL_TIME_PERIOD + let timeFrame = INITIAL_TIME_PERIOD let datetime = NEW_SESSION_INITIAL_DATE let thisObject = { fitFunction: undefined, container: undefined, setDatetime: setDatetime, - setTimePeriod: setTimePeriod, + setTimeFrame: setTimeFrame, positionAtDatetime: positionAtDatetime, draw: draw, getContainer: getContainer, @@ -158,7 +158,7 @@ function newPlottersManager () { } } - storage.initialize(pProductCard.dataMine, pProductCard.bot, pProductCard.session, pProductCard.product, exchange, market, datetime, timePeriod, onProductStorageInitialized) + storage.initialize(pProductCard.dataMine, pProductCard.bot, pProductCard.session, pProductCard.product, exchange, market, datetime, timeFrame, onProductStorageInitialized) function onProductStorageInitialized (err) { try { @@ -203,7 +203,7 @@ function newPlottersManager () { plotter.container.frame.position.x = thisObject.container.frame.width / 2 - plotter.container.frame.width / 2 plotter.container.frame.position.y = thisObject.container.frame.height / 2 - plotter.container.frame.height / 2 plotter.fitFunction = thisObject.fitFunction - plotter.initialize(storage, exchange, market, datetime, timePeriod, onPlotterInizialized, productDefinition) + plotter.initialize(storage, exchange, market, datetime, timeFrame, onPlotterInizialized, productDefinition) function onPlotterInizialized () { try { @@ -316,14 +316,14 @@ function newPlottersManager () { } } - function setTimePeriod (pTimePeriod) { - timePeriod = pTimePeriod + function setTimeFrame (pTimeFrame) { + timeFrame = pTimeFrame if (initializationReady === true) { for (let i = 0; i < productPlotters.length; i++) { let productPlotter = productPlotters[i] - productPlotter.productCard.setTimePeriod(timePeriod) - productPlotter.storage.setTimePeriod(timePeriod) - productPlotter.plotter.setTimePeriod(timePeriod) + productPlotter.productCard.setTimeFrame(timeFrame) + productPlotter.storage.setTimeFrame(timeFrame) + productPlotter.plotter.setTimeFrame(timeFrame) } } } diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 1ade95cc3..6736c475c 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -8,7 +8,7 @@ function newTimelineChart () { let timeLineCoordinateSystem - let timePeriod = INITIAL_TIME_PERIOD + let timeFrame = INITIAL_TIME_PERIOD let datetime = NEW_SESSION_INITIAL_DATE let thisObject = { @@ -44,7 +44,7 @@ function newTimelineChart () { let market let productsPanelHandle - let timePeriodScale + let timeFrameScale setupContainer() return thisObject @@ -58,8 +58,8 @@ function newTimelineChart () { function finalize () { plotterManager.finalize() plotterManager = undefined - timePeriodScale.finalize() - timePeriodScale = undefined + timeFrameScale.finalize() + timeFrameScale = undefined canvas.panelsSpace.destroyPanel(productsPanelHandle) thisObject.container.finalize() @@ -120,7 +120,7 @@ function newTimelineChart () { logoAA.src = window.canvasApp.urlPrefix + 'Images/sa-logo-background.png' // moveToUserPosition(thisObject.container, timeLineCoordinateSystem, undefined, undefined, undefined, true) - timePeriod = INITIAL_TIME_PERIOD + timeFrame = INITIAL_TIME_PERIOD datetime = NEW_SESSION_INITIAL_DATE /* Event Subscriptions - we need this events to be fired first here and then in active Plotters. */ @@ -151,17 +151,17 @@ function newTimelineChart () { return } - timePeriodScale = newTimePeriodScale() - timePeriodScale.container.connectToParent(thisObject.container, false, false, false, true, true, true) - timePeriodScale.container.eventHandler.listenToEvent('Time Period Changed', function (event) { - let currentTimePeriod = timePeriod - timePeriod = event.timePeriod - if (timePeriod !== currentTimePeriod) { - plotterManager.setTimePeriod(timePeriod) + timeFrameScale = newTimeFrameScale() + timeFrameScale.container.connectToParent(thisObject.container, false, false, false, true, true, true) + timeFrameScale.container.eventHandler.listenToEvent('Time Frame Changed', function (event) { + let currentTimeFrame = timeFrame + timeFrame = event.timeFrame + if (timeFrame !== currentTimeFrame) { + plotterManager.setTimeFrame(timeFrame) } }) - timePeriodScale.initialize(timeLineCoordinateSystem) + timeFrameScale.initialize(timeLineCoordinateSystem) initializationReady = true callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) @@ -239,7 +239,7 @@ function newTimelineChart () { let container - container = timePeriodScale.getContainer(point) + container = timeFrameScale.getContainer(point) if (container !== undefined) { return container } @@ -289,7 +289,7 @@ function newTimelineChart () { if (thisObject.container.frame.isInViewPort()) { drawChartsBackground() plotterManager.draw() - timePeriodScale.draw() + timeFrameScale.draw() } } diff --git a/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js b/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js index e28e08a7b..15f7c7d31 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js +++ b/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js @@ -33,7 +33,7 @@ function newSessionFunctions () { let lightingPath = '->Definition->' + 'Trading System->' + 'Parameters->' + - 'Base Asset->Time Range->Time Period->Slippage->Fee Structure->Exchange Account Key->' + + 'Base Asset->Time Range->Time Frame->Slippage->Fee Structure->Exchange Account Key->' + 'Strategy->' + 'Trigger Stage->Trigger On Event->Trigger Off Event->Take Position Event->' + 'Announcement->Telegram Bot->' + @@ -58,15 +58,15 @@ function newSessionFunctions () { function getUICurrentValues () { let dateAtScreenCorner = new Date(window.localStorage.getItem('Date @ Screen Corner')) - let currentTimePeriod = JSON.parse(window.localStorage.getItem('Current Time Period')) + let currentTimeFrame = JSON.parse(window.localStorage.getItem('Current Time Frame')) - let timePeriodsMasterArray = [marketFilesPeriods, dailyFilePeriods] - let timePeriodArray = timePeriodsMasterArray[currentTimePeriod.filePeriodIndex] - let timePeriod = timePeriodArray[currentTimePeriod.timePeriodIndex][1] + let timeFramesMasterArray = [marketFilesPeriods, dailyFilePeriods] + let timeFrameArray = timeFramesMasterArray[currentTimeFrame.filePeriodIndex] + let timeFrame = timeFrameArray[currentTimeFrame.timeFrameIndex][1] let uiCurrentValues = { initialDatetime: dateAtScreenCorner, - timePeriod: timePeriod, + timeFrame: timeFrame, timestamp: (new Date()).valueOf() } diff --git a/Globals.js b/Globals.js index 4e09972ee..0c9c7149c 100644 --- a/Globals.js +++ b/Globals.js @@ -97,13 +97,13 @@ let dailyFilePeriods = dailyFilePeriods = JSON.parse(dailyFilePeriods); -function convertTimePeriodToName(pTimePeriod) { +function convertTimeFrameToName(pTimeFrame) { for (let i = 0; i < dailyFilePeriods.length; i++) { let period = dailyFilePeriods[i]; - if (period[0] === pTimePeriod) { + if (period[0] === pTimeFrame) { return period[1]; @@ -114,7 +114,7 @@ function convertTimePeriodToName(pTimePeriod) { let period = marketFilesPeriods[i]; - if (period[0] === pTimePeriod) { + if (period[0] === pTimeFrame) { return period[1]; diff --git a/Panels/ProductCard.js b/Panels/ProductCard.js index c4777ed5b..539aab0bd 100644 --- a/Panels/ProductCard.js +++ b/Panels/ProductCard.js @@ -16,7 +16,7 @@ function newProductCard () { turnOff: turnOff, turnOn: turnOn, setDatetime: setDatetime, - setTimePeriod: setTimePeriod, + setTimeFrame: setTimeFrame, onMarketFileLoaded: onMarketFileLoaded, onDailyFileLoaded: onDailyFileLoaded, onSingleFileLoaded: onSingleFileLoaded, @@ -66,7 +66,7 @@ function newProductCard () { opacity: 0.00 } - let timePeriod = INITIAL_TIME_PERIOD + let timeFrame = INITIAL_TIME_PERIOD let datetime = NEW_SESSION_INITIAL_DATE /* TODO We are in a transition period in which bots and dataMines images might be located at different places. @@ -122,7 +122,7 @@ function newProductCard () { legacyBotAvatar = undefined legacyBotAvatarLoaded = undefined legacyPlotterBanner = undefined - timePeriod = undefined + timeFrame = undefined datetime = undefined LOADING_FILL_STYLE = undefined @@ -328,13 +328,13 @@ function newProductCard () { datetime = pDatetime if (currentDate !== newDate) { - if (timePeriod <= _1_HOUR_IN_MILISECONDS) { + if (timeFrame <= _1_HOUR_IN_MILISECONDS) { dailyFileProgressBar.animatedValue = 0 } } } - function setTimePeriod (pTimePeriod) { + function setTimeFrame (pTimeFrame) { /* When the time period below or equal to 1 hour changes, this forces cursors to potentially load more files, thus we reset this counter and @@ -342,10 +342,10 @@ function newProductCard () { */ - if (timePeriod !== pTimePeriod) { - timePeriod = pTimePeriod + if (timeFrame !== pTimeFrame) { + timeFrame = pTimeFrame - if (timePeriod <= _1_HOUR_IN_MILISECONDS) { + if (timeFrame <= _1_HOUR_IN_MILISECONDS) { dailyFileProgressBar.animatedValue = 0 } } diff --git a/Panels/TimeControlPanel.js b/Panels/TimeControlPanel.js index 55d1baa11..7eba4062a 100644 --- a/Panels/TimeControlPanel.js +++ b/Panels/TimeControlPanel.js @@ -16,7 +16,7 @@ function newTimeControlPanel () { thisObject.container = container thisObject.container.frame.containerName = 'Current Datetime' - let timePeriod + let timeFrame let panelTabButton return thisObject @@ -48,7 +48,7 @@ function newTimeControlPanel () { thisObject.datetimeDisplay = datetimeDisplay viewPort.eventHandler.listenToEvent('Zoom Changed', onZoomChanged) - timePeriod = INITIAL_TIME_PERIOD + timeFrame = INITIAL_TIME_PERIOD } function onBotChangedTime (pNewDatetime) { @@ -59,7 +59,7 @@ function newTimeControlPanel () { function onZoomChanged (event) { if (event !== undefined) { // it is undefined when the level is just being animated. - timePeriod = recalculatePeriod(event.newLevel) + timeFrame = recalculatePeriod(event.newLevel) } } @@ -138,10 +138,10 @@ function newTimeControlPanel () { browserCanvasContext.fillStyle = 'rgba(60, 60, 60, 0.50)' browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y) - if (timePeriod > _45_MINUTES_IN_MILISECONDS) { - label = timePeriod / _1_HOUR_IN_MILISECONDS + ' hs' + if (timeFrame > _45_MINUTES_IN_MILISECONDS) { + label = timeFrame / _1_HOUR_IN_MILISECONDS + ' hs' } else { - label = timePeriod / _1_MINUTE_IN_MILISECONDS + ' min' + label = timeFrame / _1_MINUTE_IN_MILISECONDS + ' min' } /* Now we transform x on the actual coordinate on the canvas. */ diff --git a/Plotter.js b/Plotter.js index d0f3df203..00fa2a607 100644 --- a/Plotter.js +++ b/Plotter.js @@ -17,7 +17,7 @@ function newPlotter () { finalize: finalize, container: undefined, getContainer: getContainer, - setTimePeriod: setTimePeriod, + setTimeFrame: setTimeFrame, setDatetime: setDatetime, recalculateScale: recalculateScale, draw: draw, @@ -39,7 +39,7 @@ function newPlotter () { let atMousePositionFillStyles = new Map() let atMousePositionStrokeStyles = new Map() - let timePeriod // This will hold the current Time Period the user is at. + let timeFrame // This will hold the current Time Frame the user is at. let datetime // This will hold the current Datetime the user is at. let marketFile // This is the current Market File being plotted. @@ -77,7 +77,7 @@ function newPlotter () { dailyFiles = undefined datetime = undefined - timePeriod = undefined + timeFrame = undefined marketFile = undefined fileCursor = undefined @@ -94,14 +94,14 @@ function newPlotter () { } } - function initialize (pStorage, pExchange, pMarket, pDatetime, pTimePeriod, callBackFunction, pProductDefinition) { + function initialize (pStorage, pExchange, pMarket, pDatetime, pTimeFrame, callBackFunction, pProductDefinition) { try { /* Store the information received. */ marketFiles = pStorage.marketFiles[0] dailyFiles = pStorage.dailyFiles[0] datetime = pDatetime - timePeriod = pTimePeriod + timeFrame = pTimeFrame productDefinition = pProductDefinition @@ -111,8 +111,8 @@ function newPlotter () { recalculateScale() /* Now we set the right files according to current Period. */ - marketFile = marketFiles.getFile(pTimePeriod) - fileCursor = dailyFiles.getFileCursor(pTimePeriod) + marketFile = marketFiles.getFile(pTimeFrame) + fileCursor = dailyFiles.getFileCursor(pTimeFrame) /* Listen to the necesary events. */ zoomChangedEventSubscriptionId = viewPort.eventHandler.listenToEvent('Zoom Changed', onZoomChanged) @@ -137,7 +137,7 @@ function newPlotter () { function onMarketFilesUpdated () { try { - let newMarketFile = marketFiles.getFile(timePeriod) + let newMarketFile = marketFiles.getFile(timeFrame) if (newMarketFile !== undefined) { marketFile = newMarketFile mustRecalculateDataPoints = true @@ -150,7 +150,7 @@ function newPlotter () { function onDailyFilesUpdated () { try { - let newFileCursor = dailyFiles.getFileCursor(timePeriod) + let newFileCursor = dailyFiles.getFileCursor(timeFrame) if (newFileCursor !== undefined) { fileCursor = newFileCursor mustRecalculateDataPoints = true @@ -176,20 +176,20 @@ function newPlotter () { } } - function setTimePeriod (pTimePeriod) { + function setTimeFrame (pTimeFrame) { try { - if (timePeriod !== pTimePeriod) { - timePeriod = pTimePeriod + if (timeFrame !== pTimeFrame) { + timeFrame = pTimeFrame mustRecalculateDataPoints = true - if (timePeriod >= _1_HOUR_IN_MILISECONDS) { - let newMarketFile = marketFiles.getFile(pTimePeriod) + if (timeFrame >= _1_HOUR_IN_MILISECONDS) { + let newMarketFile = marketFiles.getFile(pTimeFrame) if (newMarketFile !== undefined) { marketFile = newMarketFile recalculate() } } else { - let newFileCursor = dailyFiles.getFileCursor(pTimePeriod) + let newFileCursor = dailyFiles.getFileCursor(pTimeFrame) if (newFileCursor !== undefined) { fileCursor = newFileCursor @@ -198,7 +198,7 @@ function newPlotter () { } } } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] setTimePeriod -> err = ' + err.stack) } + if (ERROR_LOG === true) { logger.write('[ERROR] setTimeFrame -> err = ' + err.stack) } } } @@ -228,7 +228,7 @@ function newPlotter () { function recalculate () { try { - if (timePeriod >= _1_HOUR_IN_MILISECONDS) { + if (timeFrame >= _1_HOUR_IN_MILISECONDS) { recalculateUsingMarketFiles() } else { recalculateUsingDailyFiles() @@ -272,14 +272,14 @@ function newPlotter () { return jsonifiedArray } - function calculationsProcedure (jsonArray, recordDefinition, calculationsProcedure, timePeriod) { + function calculationsProcedure (jsonArray, recordDefinition, calculationsProcedure, timeFrame) { /* This function has as an input an array of JSON objects, and it adds calculated properties to complete the set of properties that will be available. */ let system = { // These are the available system variables to be used in User Code and Formulas - timePeriod: timePeriod, + timeFrame: timeFrame, ONE_DAY_IN_MILISECONDS: ONE_DAY_IN_MILISECONDS } let variable = {} // This is the structure where the user will define its own variables that will be shared across different code blocks and formulas. @@ -348,7 +348,7 @@ function newPlotter () { if (fileCursor === undefined) { return } // We need to wait until there is a fileCursor if (fileCursor.files.size === 0) { return } // We need to wait until there are files in the cursor - let daysOnSides = getSideDays(timePeriod) + let daysOnSides = getSideDays(timeFrame) let leftDate = getDateFromPoint(viewPort.visibleArea.topLeft, thisObject.container, timeLineCoordinateSystem) let rightDate = getDateFromPoint(viewPort.visibleArea.topRight, thisObject.container, timeLineCoordinateSystem) @@ -373,7 +373,7 @@ function newPlotter () { /* Add the calculated properties */ if (productDefinition.calculations !== undefined) { - let calculationsResult = calculationsProcedure(jsonData, productDefinition.record, productDefinition.calculations, timePeriod) + let calculationsResult = calculationsProcedure(jsonData, productDefinition.record, productDefinition.calculations, timeFrame) records.push(...calculationsResult) // This adds records to the current array. } else { records.push(...jsonData)// This adds records to the current array. @@ -401,7 +401,7 @@ function newPlotter () { try { if (marketFile === undefined) { return } // Initialization not complete yet. - let daysOnSides = getSideDays(timePeriod) + let daysOnSides = getSideDays(timeFrame) let leftDate = getDateFromPoint(viewPort.visibleArea.topLeft, thisObject.container, timeLineCoordinateSystem) let rightDate = getDateFromPoint(viewPort.visibleArea.topRight, thisObject.container, timeLineCoordinateSystem) @@ -426,7 +426,7 @@ function newPlotter () { /* Add the calculated properties */ if (productDefinition.calculations !== undefined) { - let calculationsResult = calculationsProcedure(jsonData, productDefinition.record, productDefinition.calculations, timePeriod) + let calculationsResult = calculationsProcedure(jsonData, productDefinition.record, productDefinition.calculations, timeFrame) records.push(...calculationsResult) // This adds records to the current array. } else { records.push(...jsonData)// This adds records to the current array. diff --git a/ProductStorage.js b/ProductStorage.js index 3ad5d77f6..1b3323738 100644 --- a/ProductStorage.js +++ b/ProductStorage.js @@ -31,7 +31,7 @@ function newProductStorage (pName) { singleFile: [], fileSequences: [], setDatetime: setDatetime, - setTimePeriod: setTimePeriod, + setTimeFrame: setTimeFrame, initialize: initialize, finalize: finalize } @@ -43,7 +43,7 @@ function newProductStorage (pName) { thisObject.eventHandler.name = 'Storage-' + pName let datetime - let timePeriod + let timeFrame return thisObject @@ -74,10 +74,10 @@ function newProductStorage (pName) { } } - function initialize (pdataMine, pBot, pSession, pProduct, pExchange, pMarket, pDatetime, pTimePeriod, callBackFunction) { + function initialize (pdataMine, pBot, pSession, pProduct, pExchange, pMarket, pDatetime, pTimeFrame, callBackFunction) { try { datetime = pDatetime - timePeriod = pTimePeriod + timeFrame = pTimeFrame let dataSetsToLoad = 0 let dataSetsLoaded = 0 @@ -99,7 +99,7 @@ function newProductStorage (pName) { dataSetsToLoad++ let dailyFiles = newDailyFiles() - dailyFiles.initialize(pdataMine, pBot, pSession, pProduct, thisSet, pExchange, pMarket, pDatetime, pTimePeriod, onDailyFileReady) + dailyFiles.initialize(pdataMine, pBot, pSession, pProduct, thisSet, pExchange, pMarket, pDatetime, pTimeFrame, onDailyFileReady) thisObject.dailyFiles.push(dailyFiles) } break @@ -309,7 +309,7 @@ function newProductStorage (pName) { datetime = new Date(pDatetime) if (currentDate !== newDate) { - if (timePeriod <= _1_HOUR_IN_MILISECONDS) { + if (timeFrame <= _1_HOUR_IN_MILISECONDS) { for (let i = 0; i < thisObject.dailyFiles.length; i++) { thisObject.dailyFiles[i].setDatetime(pDatetime) } @@ -317,15 +317,15 @@ function newProductStorage (pName) { } } - function setTimePeriod (pTimePeriod) { - /* We are going to filter out the cases in which the timePeriod received is the same that the one we already know. */ + function setTimeFrame (pTimeFrame) { + /* We are going to filter out the cases in which the timeFrame received is the same that the one we already know. */ - if (timePeriod !== pTimePeriod) { - timePeriod = pTimePeriod + if (timeFrame !== pTimeFrame) { + timeFrame = pTimeFrame - if (timePeriod <= _1_HOUR_IN_MILISECONDS) { + if (timeFrame <= _1_HOUR_IN_MILISECONDS) { for (let i = 0; i < thisObject.dailyFiles.length; i++) { - thisObject.dailyFiles[i].setTimePeriod(pTimePeriod, datetime) + thisObject.dailyFiles[i].setTimeFrame(pTimeFrame, datetime) } } } diff --git a/Scales/TimePeriodScale.js b/Scales/TimeFrameScale.js similarity index 80% rename from Scales/TimePeriodScale.js rename to Scales/TimeFrameScale.js index a93330788..df39d022d 100644 --- a/Scales/TimePeriodScale.js +++ b/Scales/TimeFrameScale.js @@ -1,8 +1,8 @@ -function newTimePeriodScale () { - const MODULE_NAME = 'Time Period Scale' +function newTimeFrameScale () { + const MODULE_NAME = 'Time Frame Scale' let thisObject = { - timePeriod: undefined, + timeFrame: undefined, container: undefined, draw: draw, getContainer: getContainer, @@ -25,9 +25,9 @@ function newTimePeriodScale () { let timeLineCoordinateSystem let objectStorage = {} let filePeriodIndex = FILES_PERIOD_DEFAULT_VALUE - let timePeriodIndex = TIME_PERIOD_DEFAULT_VALUE - let timePeriodsMasterArray = [marketFilesPeriods, dailyFilePeriods] - let timePeriodLabel = '' + let timeFrameIndex = TIME_PERIOD_DEFAULT_VALUE + let timeFramesMasterArray = [marketFilesPeriods, dailyFilePeriods] + let timeFrameLabel = '' let onMouseWheelEventSubscriptionId let onMouseOverEventSubscriptionId @@ -66,7 +66,7 @@ function newTimePeriodScale () { onMouseWheelEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) readObjectState() - newTimePeriod() + newTimeFrame() onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', function (event) { mouse.position.x = event.x @@ -84,21 +84,21 @@ function newTimePeriodScale () { function onZoomChanged (event) { if (event !== undefined) { // it is undefined when the level is just being animated. - let currentTimePeriod = thisObject.timePeriod - let timePeriod = recalculatePeriod(event.newLevel) - if (timePeriod !== currentTimePeriod) { - for (let i = 0; i < timePeriodsMasterArray.length; i++) { - let timePeriodArray = timePeriodsMasterArray[i] - for (let j = 0; j < timePeriodArray.length; j++) { - let record = timePeriodArray[j] - if (timePeriod === record[0]) { + let currentTimeFrame = thisObject.timeFrame + let timeFrame = recalculatePeriod(event.newLevel) + if (timeFrame !== currentTimeFrame) { + for (let i = 0; i < timeFramesMasterArray.length; i++) { + let timeFrameArray = timeFramesMasterArray[i] + for (let j = 0; j < timeFrameArray.length; j++) { + let record = timeFrameArray[j] + if (timeFrame === record[0]) { filePeriodIndex = i - timePeriodIndex = j + timeFrameIndex = j } } } saveObjectState() - newTimePeriod() + newTimeFrame() } } } @@ -106,31 +106,31 @@ function newTimePeriodScale () { function onMouseWheel (event) { delta = event.wheelDelta if (delta < 0) { - timePeriodIndex-- - if (timePeriodIndex < 0) { + timeFrameIndex-- + if (timeFrameIndex < 0) { filePeriodIndex-- if (filePeriodIndex < 0) { filePeriodIndex = 0 - timePeriodIndex = 0 + timeFrameIndex = 0 } else { - timePeriodIndex = timePeriodsMasterArray[filePeriodIndex].length - 1 + timeFrameIndex = timeFramesMasterArray[filePeriodIndex].length - 1 } } } else { - timePeriodIndex++ - if (timePeriodIndex > timePeriodsMasterArray[filePeriodIndex].length - 1) { + timeFrameIndex++ + if (timeFrameIndex > timeFramesMasterArray[filePeriodIndex].length - 1) { filePeriodIndex++ - if (filePeriodIndex > timePeriodsMasterArray.length - 1) { - filePeriodIndex = timePeriodsMasterArray.length - 1 - timePeriodIndex = timePeriodsMasterArray[filePeriodIndex].length - 1 + if (filePeriodIndex > timeFramesMasterArray.length - 1) { + filePeriodIndex = timeFramesMasterArray.length - 1 + timeFrameIndex = timeFramesMasterArray[filePeriodIndex].length - 1 } else { - timePeriodIndex = 0 + timeFrameIndex = 0 } } } saveObjectState() - newTimePeriod() + newTimeFrame() } function getContainer (pPoint) { @@ -156,7 +156,7 @@ function newTimePeriodScale () { function saveObjectState () { objectStorage.filePeriodIndex = filePeriodIndex - objectStorage.timePeriodIndex = timePeriodIndex + objectStorage.timeFrameIndex = timeFrameIndex window.localStorage.setItem(MODULE_NAME, JSON.stringify(objectStorage)) } @@ -165,19 +165,19 @@ function newTimePeriodScale () { if (objectStorageString !== null && objectStorageString !== '') { objectStorage = JSON.parse(objectStorageString) filePeriodIndex = objectStorage.filePeriodIndex - timePeriodIndex = objectStorage.timePeriodIndex + timeFrameIndex = objectStorage.timeFrameIndex } } - function newTimePeriod () { - let timePeriodArray = timePeriodsMasterArray[filePeriodIndex] - thisObject.timePeriod = timePeriodArray[timePeriodIndex][0] - timePeriodLabel = timePeriodArray[timePeriodIndex][1] + function newTimeFrame () { + let timeFrameArray = timeFramesMasterArray[filePeriodIndex] + thisObject.timeFrame = timeFrameArray[timeFrameIndex][0] + timeFrameLabel = timeFrameArray[timeFrameIndex][1] let event = {} - event.timePeriod = thisObject.timePeriod - thisObject.container.eventHandler.raiseEvent('Time Period Changed', event) - window.localStorage.setItem('Current Time Period', JSON.stringify({filePeriodIndex: filePeriodIndex, timePeriodIndex: timePeriodIndex})) + event.timeFrame = thisObject.timeFrame + thisObject.container.eventHandler.raiseEvent('Time Frame Changed', event) + window.localStorage.setItem('Current Time Frame', JSON.stringify({filePeriodIndex: filePeriodIndex, timeFrameIndex: timeFrameIndex})) } function draw () { @@ -262,7 +262,7 @@ to be visible at the top of the viewPort. */ /* Common Variables */ - let label = timePeriodLabel.split('-') + let label = timeFrameLabel.split('-') let label1 = label[0] let label2 = label[1].toUpperCase() let fontSize1 = 20 From 63c44d44130bfab3e7c7c26f57fe094b9b3e5a0c Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 27 Dec 2019 15:48:18 +0100 Subject: [PATCH 025/264] isHierarchyHead --- FloatingSpace/UiObject.js | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index d7b47cabf..64c127ffe 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -1145,25 +1145,28 @@ function newUiObject () { browserCanvasContext.fill() - if (thisObject.payload.node.type === 'Definition' || thisObject.payload.node.type === 'Network' || thisObject.payload.node.type === 'Data Mine') { - VISIBLE_RADIUS = thisObject.container.frame.radius * 2 - let OPACITY = 1 + let nodeDefinition = APP_SCHEMA_MAP.get(thisObject.payload.node.type) + if (nodeDefinition !== undefined) { + if (nodeDefinition.isHierarchyHead === true) { + VISIBLE_RADIUS = thisObject.container.frame.radius * 2 + let OPACITY = 1 - browserCanvasContext.beginPath() - browserCanvasContext.arc(visiblePosition.x, visiblePosition.y, VISIBLE_RADIUS, 0, Math.PI * 2, true) - browserCanvasContext.closePath() - browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.LIGHT_GREY + ', ' + OPACITY + ')' - browserCanvasContext.lineWidth = 10 - browserCanvasContext.setLineDash([4, 16]) - browserCanvasContext.stroke() + browserCanvasContext.beginPath() + browserCanvasContext.arc(visiblePosition.x, visiblePosition.y, VISIBLE_RADIUS, 0, Math.PI * 2, true) + browserCanvasContext.closePath() + browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.LIGHT_GREY + ', ' + OPACITY + ')' + browserCanvasContext.lineWidth = 10 + browserCanvasContext.setLineDash([4, 16]) + browserCanvasContext.stroke() - browserCanvasContext.beginPath() - browserCanvasContext.arc(visiblePosition.x, visiblePosition.y, VISIBLE_RADIUS, 0, Math.PI * 2, true) - browserCanvasContext.closePath() - browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.LIGHT_GREY + ', ' + OPACITY + ')' - browserCanvasContext.lineWidth = 1 - browserCanvasContext.setLineDash([20, 20]) - browserCanvasContext.stroke() + browserCanvasContext.beginPath() + browserCanvasContext.arc(visiblePosition.x, visiblePosition.y, VISIBLE_RADIUS, 0, Math.PI * 2, true) + browserCanvasContext.closePath() + browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.LIGHT_GREY + ', ' + OPACITY + ')' + browserCanvasContext.lineWidth = 1 + browserCanvasContext.setLineDash([20, 20]) + browserCanvasContext.stroke() + } } if (thisObject.isOnFocus === true) { From b887a494e3920009b1bfdd88ed91a256d7047083 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 3 Jan 2020 15:39:28 +0100 Subject: [PATCH 026/264] New Icons --- Spaces/DesignerSpace.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/Spaces/DesignerSpace.js b/Spaces/DesignerSpace.js index eca3b7c49..c42df9dc7 100644 --- a/Spaces/DesignerSpace.js +++ b/Spaces/DesignerSpace.js @@ -173,7 +173,30 @@ function newDesignerSpace () { 'shapes-polygon', 'data-entry', 'data-formula', - 'clone' + 'clone', + 'exchange-account-asset', + 'exchange-account-key', + 'user-keys', + 'user-assets', + 'asset', + 'exchange-accounts', + 'user-account', + 'market', + 'exchange-assets', + 'crypto-exchanges', + 'crypto-exchange', + 'exchange-markets', + 'charting-system', + 'time-line-chart', + 'time-frame-scale', + 'time-scale', + 'rate-scale', + 'time-machine', + 'data-product', + 'single-market-data', + 'data-storage', + 'dataset', + 'viewport' ] for (let i = 0; i < iconsNames.length; i++) { From 84d2b9c1c08cc5201573d231365f9bfe8a9dd0d8 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 4 Jan 2020 19:00:10 +0100 Subject: [PATCH 027/264] New Icons --- Spaces/DesignerSpace.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/Spaces/DesignerSpace.js b/Spaces/DesignerSpace.js index c42df9dc7..cc8dc054e 100644 --- a/Spaces/DesignerSpace.js +++ b/Spaces/DesignerSpace.js @@ -196,7 +196,29 @@ function newDesignerSpace () { 'single-market-data', 'data-storage', 'dataset', - 'viewport' + 'viewport', + 'bitfinex', + 'binance', + 'kucoin', + 'bittrex', + 'kraken', + 'poloniex', + 'upbit', + 'monero', + 'tether', + 'tron', + 'stellar', + 'qtum', + 'neo', + 'litecoin', + 'ethereum-classic', + 'ethereum', + 'eos', + 'dash', + 'cardano', + 'bitcoin-cash', + 'bitcoin', + 'binance-coin' ] for (let i = 0; i < iconsNames.length; i++) { From 2e999c6f213bba76e0ad4d63a6e913367f570919 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 4 Jan 2020 20:32:27 +0100 Subject: [PATCH 028/264] Alternative Icons Implementation --- FloatingSpace/UiObject.js | 29 +++++++++++++++++++++++++++++ Spaces/DesignerSpace.js | 8 -------- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index 64c127ffe..e996f48f7 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -650,6 +650,35 @@ function newUiObject () { function iconPhysics () { icon = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.type) + let nodeDefinition = APP_SCHEMA_MAP.get(thisObject.payload.node.type) + if (nodeDefinition.alternativeIcons !== undefined) { + let nodeToUse = thisObject.payload.node + if (nodeDefinition.alternativeIcons === 'Use Reference Parent') { + if (thisObject.payload.node.payload.referenceParent !== undefined) { + nodeToUse = thisObject.payload.node.payload.referenceParent + } + } + nodeDefinition = APP_SCHEMA_MAP.get(nodeToUse.type) + let code = nodeToUse.code + try { + code = JSON.parse(code) + let alternativeIcon + let iconName + for (let i = 0; i < nodeDefinition.alternativeIcons.length; i++) { + alternativeIcon = nodeDefinition.alternativeIcons[i] + if (alternativeIcon.codeName === code.codeName) { + iconName = alternativeIcon.iconName + } + } + let newIcon = canvas.designerSpace.iconCollection.get(iconName) + if (newIcon !== undefined) { + icon = newIcon + } + } catch (err) { + // Nothing to do if JSON is baddly formated. + } + } + executingIcon = canvas.designerSpace.iconCollection.get('attractive') } diff --git a/Spaces/DesignerSpace.js b/Spaces/DesignerSpace.js index cc8dc054e..cf64de32d 100644 --- a/Spaces/DesignerSpace.js +++ b/Spaces/DesignerSpace.js @@ -35,14 +35,6 @@ function newDesignerSpace () { } function buildIconByUiObjectTypeMap () { - const relationshipArray = [] - - for (let i = 0; i < relationshipArray.length; i++) { - let record = relationshipArray[i] - let icon = thisObject.iconCollection.get(record[1]) - thisObject.iconByUiObjectType.set(record[0], icon) - } - /* Take types-icons relationships defined at the schema */ for (let i = 0; i < APP_SCHEMA_ARRAY.length; i++) { let nodeDefinition = APP_SCHEMA_ARRAY[i] From a760e7e651c9ea3971001696329012f0e43e0ee0 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 4 Jan 2020 21:10:05 +0100 Subject: [PATCH 029/264] Gran Parents Supported --- FloatingSpace/UiObject.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index e996f48f7..7d11245d1 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -658,6 +658,13 @@ function newUiObject () { nodeToUse = thisObject.payload.node.payload.referenceParent } } + if (nodeDefinition.alternativeIcons === 'Use Reference Gran Parent') { + if (thisObject.payload.node.payload.referenceParent !== undefined) { + if (thisObject.payload.node.payload.referenceParent.payload.referenceParent !== undefined) { + nodeToUse = thisObject.payload.node.payload.referenceParent.payload.referenceParent + } + } + } nodeDefinition = APP_SCHEMA_MAP.get(nodeToUse.type) let code = nodeToUse.code try { From 3d586592259cd8da8660fbf0e395fb77a067d714 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 5 Jan 2020 11:25:17 +0100 Subject: [PATCH 030/264] Exchange taken from UI --- DesignerSpace/Workspace/FunctionLibraries/TaskFunctions.js | 1 + 1 file changed, 1 insertion(+) diff --git a/DesignerSpace/Workspace/FunctionLibraries/TaskFunctions.js b/DesignerSpace/Workspace/FunctionLibraries/TaskFunctions.js index d9dcafed8..a8eee5f7b 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/TaskFunctions.js +++ b/DesignerSpace/Workspace/FunctionLibraries/TaskFunctions.js @@ -29,6 +29,7 @@ function newTaskFunctions () { 'Indicator Bot Instance->' + 'Trading Bot Instance->' + 'Process Instance->' + + 'Market Instance->Market->Exchange Markets->Crypto Exchange->' + 'Backtesting Session->Live Trading Session->Paper Trading Session->Fordward Testing Session->' + 'Process Definition->' + 'Process Output->Output Dataset->Dataset Definition->Product Definition->' + From b1e7a52d944469e511ffd07fa1d27c6de52efee2 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 5 Jan 2020 12:40:45 +0100 Subject: [PATCH 031/264] Market Base Asset --- DesignerSpace/Workspace/FunctionLibraries/TaskFunctions.js | 1 + 1 file changed, 1 insertion(+) diff --git a/DesignerSpace/Workspace/FunctionLibraries/TaskFunctions.js b/DesignerSpace/Workspace/FunctionLibraries/TaskFunctions.js index a8eee5f7b..9073bf7ff 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/TaskFunctions.js +++ b/DesignerSpace/Workspace/FunctionLibraries/TaskFunctions.js @@ -30,6 +30,7 @@ function newTaskFunctions () { 'Trading Bot Instance->' + 'Process Instance->' + 'Market Instance->Market->Exchange Markets->Crypto Exchange->' + + 'Market Base Asset->Market Quoted Asset->Asset->' + 'Backtesting Session->Live Trading Session->Paper Trading Session->Fordward Testing Session->' + 'Process Definition->' + 'Process Output->Output Dataset->Dataset Definition->Product Definition->' + From 39cfa06506b2b0556d019d7c35a35a88914117cf Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 5 Jan 2020 12:54:02 +0100 Subject: [PATCH 032/264] title allways visible from APP SCHEMA --- FloatingSpace/UiObjectTitle.js | 102 +-------------------------------- 1 file changed, 3 insertions(+), 99 deletions(-) diff --git a/FloatingSpace/UiObjectTitle.js b/FloatingSpace/UiObjectTitle.js index 834d79ed4..4fd311305 100644 --- a/FloatingSpace/UiObjectTitle.js +++ b/FloatingSpace/UiObjectTitle.js @@ -48,106 +48,10 @@ function newUiObjectTitle () { thisObject.payload = payload thisObject.allwaysVisible = false // Default value - switch (payload.node.type) { - case 'Definition': { + let nodeDefinition = APP_SCHEMA_MAP.get(thisObject.payload.node.type) + if (nodeDefinition !== undefined) { + if (nodeDefinition.isTitleAllwaysVisible === true) { thisObject.allwaysVisible = true - break - } - case 'Data Mine': { - thisObject.allwaysVisible = true - break - } - case 'Sensor Bot': { - thisObject.allwaysVisible = true - break - } - case 'Indicator Bot': { - thisObject.allwaysVisible = true - break - } - case 'Trading Bot': { - thisObject.allwaysVisible = true - break - } - case 'Process Definition': { - thisObject.allwaysVisible = true - break - } - case 'Product Definition': { - thisObject.allwaysVisible = true - break - } - case 'Dataset Definition': { - thisObject.allwaysVisible = true - break - } - case 'Record Property': { - thisObject.allwaysVisible = true - break - } - case 'Plotter': { - thisObject.allwaysVisible = true - break - } - case 'Plotter Module': { - thisObject.allwaysVisible = true - break - } - case 'Network': { - thisObject.allwaysVisible = true - break - } - case 'Announcement': { - thisObject.allwaysVisible = true - break - } - case 'Layer': { - thisObject.allwaysVisible = true - break - } - case 'Sensor Bot Instance': { - thisObject.allwaysVisible = true - break - } - case 'Indicator Bot Instance': { - thisObject.allwaysVisible = true - break - } - case 'Backtesting Session': { - thisObject.allwaysVisible = true - break - } - case 'Live Trading Session': { - thisObject.allwaysVisible = true - break - } - case 'Fordward Testing Session': { - thisObject.allwaysVisible = true - break - } - case 'Paper Trading Session': { - thisObject.allwaysVisible = true - break - } - case 'Workspace': { - thisObject.allwaysVisible = true - break - } - case 'Trading System': { - thisObject.allwaysVisible = true - break - } - case 'Strategy': { - thisObject.allwaysVisible = true - break - } - default: { - let nodeDefinition = APP_SCHEMA_MAP.get(thisObject.payload.node.type) - if (nodeDefinition !== undefined) { - if (nodeDefinition.isTitleAllwaysVisible === true) { - thisObject.allwaysVisible = true - } - } } } From 98389c3af8043138b96e7411a34c1348ffbbff46 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 5 Jan 2020 13:16:45 +0100 Subject: [PATCH 033/264] Title can be inhereted from reference Parent of Gran Parent --- FloatingSpace/UiObjectTitle.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/FloatingSpace/UiObjectTitle.js b/FloatingSpace/UiObjectTitle.js index 4fd311305..6841ad5de 100644 --- a/FloatingSpace/UiObjectTitle.js +++ b/FloatingSpace/UiObjectTitle.js @@ -84,6 +84,28 @@ function newUiObjectTitle () { if (thisObject.payload.title === undefined) { return } let title = trimTitle(thisObject.payload.title) + /* It is possible to override the default title by setting the APP SCHEMA property 'title' */ + let nodeDefinition = APP_SCHEMA_MAP.get(thisObject.payload.node.type) + if (nodeDefinition.title !== undefined) { + let nodeToUse = thisObject.payload.node + if (nodeDefinition.title === 'Use Reference Parent') { + if (thisObject.payload.node.payload.referenceParent !== undefined) { + nodeToUse = thisObject.payload.node.payload.referenceParent + } + } + if (nodeDefinition.title === 'Use Reference Gran Parent') { + if (thisObject.payload.node.payload.referenceParent !== undefined) { + if (thisObject.payload.node.payload.referenceParent.payload.referenceParent !== undefined) { + nodeToUse = thisObject.payload.node.payload.referenceParent.payload.referenceParent + } + } + } + thisObject.payload.title = nodeToUse.payload.title + thisObject.payload.name = thisObject.payload.node.name + title = trimTitle(thisObject.payload.title) + } + + /* Here we set the dimensions and position of this object */ const FRAME_HEIGHT = 25 const FRAME_WIDTH = title.length / 2 * thisObject.payload.floatingObject.currentFontSize * FONT_ASPECT_RATIO * 1.2 * 2 thisObject.container.frame.position.x = 0 - FRAME_WIDTH / 2 @@ -117,6 +139,9 @@ function newUiObjectTitle () { } function onMouseClick (event) { + let nodeDefinition = APP_SCHEMA_MAP.get(thisObject.payload.node.type) + if (nodeDefinition.title !== undefined) { return } + let checkPoint = { x: 0, y: 0 From 8911fa09c1cc4d2ea9abd48fc741cd246f297005 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 5 Jan 2020 15:15:09 +0100 Subject: [PATCH 034/264] baseAsset and quotedAsset refactoring --- ChartsSpace/PlottersManager.js | 4 ++-- ChartsSpace/TimeMachine.js | 4 ++-- ChartsSpace/TimelineChart.js | 8 ++++---- CockpitSpace/AssetBalances.js | 6 +++--- Dashboard.js | 4 ++-- Globals.js | 8 ++++---- Panels/ProductsPanel.js | 6 +++--- Spaces/CockpitSpace.js | 10 +++++----- 8 files changed, 25 insertions(+), 25 deletions(-) diff --git a/ChartsSpace/PlottersManager.js b/ChartsSpace/PlottersManager.js index 75b6c2811..f1b5728f1 100644 --- a/ChartsSpace/PlottersManager.js +++ b/ChartsSpace/PlottersManager.js @@ -229,7 +229,7 @@ function newPlottersManager () { moduleCodeName: pProductCard.product.plotter.moduleName, panelCodeName: panelConfig.codeName } - let panelOwner = exchange + ' ' + market.assetB + '/' + market.assetA + let panelOwner = exchange + ' ' + market.quotedAsset + '/' + market.baseAsset let plotterPanelHandle = canvas.panelsSpace.createNewPanel('Plotter Panel', parameters, panelOwner, pProductCard.session) let plotterPanel = canvas.panelsSpace.getPanel(plotterPanelHandle, panelOwner) /* Connect Panel to the Plotter via an Event. */ @@ -250,7 +250,7 @@ function newPlottersManager () { moduleCodeName: pProductCard.product.plotter.moduleName, panelCodeName: panel.id } - let panelOwner = exchange + ' ' + market.assetB + '/' + market.assetA + let panelOwner = exchange + ' ' + market.quotedAsset + '/' + market.baseAsset let plotterPanelHandle = canvas.panelsSpace.createNewPanel('Plotter Panel', parameters, panelOwner, pProductCard.session, panel) let plotterPanel = canvas.panelsSpace.getPanel(plotterPanelHandle, panelOwner) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 13add3ae8..d94df0324 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -172,8 +172,8 @@ function newTimeMachine () { if ( exchange === DEFAULT_EXCHANGE && - market.assetA === DEFAULT_MARKET.assetA && - market.assetB === DEFAULT_MARKET.assetB + market.baseAsset === DEFAULT_MARKET.baseAsset && + market.quotedAsset === DEFAULT_MARKET.quotedAsset ) { continue } initializeTimelineChart(exchange, market) diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 6736c475c..a5bca7edb 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -30,8 +30,8 @@ function newTimelineChart () { let productsPanel /* Background */ - let logoAssetA - let logoAssetB + let logoBaseAsset + let logoQuotedAsset let logoExchange let logoAA let canDrawLogoA = false @@ -80,7 +80,7 @@ function newTimelineChart () { saveUserPosition(thisObject.container, timeLineCoordinateSystem, event) }) - let panelOwner = exchange + ' ' + market.assetB + '/' + market.assetA + let panelOwner = exchange + ' ' + market.quotedAsset + '/' + market.baseAsset productsPanelHandle = canvas.panelsSpace.createNewPanel('Products Panel', undefined, panelOwner) let productsPanel = canvas.panelsSpace.getPanel(productsPanelHandle, panelOwner) productsPanel.initialize(exchange, market) @@ -278,7 +278,7 @@ function newTimelineChart () { function drawBackground () { if (thisObject.container.frame.isInViewPort()) { if (window.CHART_ON_FOCUS === '') { - window.CHART_ON_FOCUS = exchange + ' ' + market.assetB + '/' + market.assetA + window.CHART_ON_FOCUS = exchange + ' ' + market.quotedAsset + '/' + market.baseAsset drawChartsBackgroundImages() } diff --git a/CockpitSpace/AssetBalances.js b/CockpitSpace/AssetBalances.js index 5b7db2c35..d9fa9ff85 100644 --- a/CockpitSpace/AssetBalances.js +++ b/CockpitSpace/AssetBalances.js @@ -1,5 +1,5 @@ -function newAssetBalances () { +function newQuotedAssetalances () { const MODULE_NAME = 'Asset Balances' let thisObject = { @@ -87,10 +87,10 @@ function newAssetBalances () { speedometer.draw() } - drawAssetBalances() + drawQuotedAssetalances() } - function drawAssetBalances () { + function drawQuotedAssetalances () { if (thisObject.paramsArray === undefined) { return } let fontSize diff --git a/Dashboard.js b/Dashboard.js index de8915fb5..c4b0be206 100644 --- a/Dashboard.js +++ b/Dashboard.js @@ -85,8 +85,8 @@ function newDashboard () { let market = { id: 2, - assetA: 'USDT', - assetB: 'BTC' + baseAsset: 'USDT', + quotedAsset: 'BTC' } markets = new Map() diff --git a/Globals.js b/Globals.js index 0c9c7149c..281a3da9e 100644 --- a/Globals.js +++ b/Globals.js @@ -7,14 +7,14 @@ const CANVAS_APP_NAME = 'Canvas App' const SUPPORTED_EXCHANGES = ["Poloniex"]; const SUPPORTED_MARKETS = [ { - assetA: "USDT", - assetB: "BTC", + baseAsset: "USDT", + quotedAsset: "BTC", } ]; const DEFAULT_EXCHANGE = "Poloniex"; const DEFAULT_MARKET = { - assetA: "USDT", - assetB: "BTC", + baseAsset: "USDT", + quotedAsset: "BTC", }; UI_COLOR = { diff --git a/Panels/ProductsPanel.js b/Panels/ProductsPanel.js index d52590b12..a46ddf5b5 100644 --- a/Panels/ProductsPanel.js +++ b/Panels/ProductsPanel.js @@ -42,7 +42,7 @@ function newProductsPanel () { exchange = pExchange market = pMarket - thisObject.container.name = 'Layers @ ' + exchange + ' ' + market.assetB + '/' + market.assetA + thisObject.container.name = 'Layers @ ' + exchange + ' ' + market.quotedAsset + '/' + market.baseAsset thisObject.container.frame.containerName = thisObject.container.name thisObject.container.frame.width = UI_PANEL.WIDTH.LARGE thisObject.container.frame.height = UI_PANEL.HEIGHT.LARGE * 1.5 // viewPort.visibleArea.bottomLeft.y - viewPort.visibleArea.topLeft.y // UI_PANEL.HEIGHT.LARGE; @@ -212,7 +212,7 @@ function newProductsPanel () { productCard.bot = bot productCard.product = product productCard.fitFunction = thisObject.fitFunction - productCard.code = exchange + '-' + market.assetB + '/' + market.assetA + '-' + dataMine.codeName + '-' + bot.codeName + '-' + product.codeName + productCard.code = exchange + '-' + market.quotedAsset + '/' + market.baseAsset + '-' + dataMine.codeName + '-' + bot.codeName + '-' + product.codeName if (session !== undefined) { productCard.code = productCard.code + '-' + session.id @@ -439,7 +439,7 @@ function newProductsPanel () { if (product.codeName === layerCode.product) { /* We have a layer that is matching the current product */ - let cardCode = exchange + '-' + market.assetB + '/' + market.assetA + '-' + dataMine.codeName + '-' + bot.codeName + '-' + product.codeName + '-' + process.session.id + let cardCode = exchange + '-' + market.quotedAsset + '/' + market.baseAsset + '-' + dataMine.codeName + '-' + bot.codeName + '-' + product.codeName + '-' + process.session.id let cardFound = removeFromLocalProductCards(cardCode) if (cardFound !== true) { productCard = addProductCard(dataMine, bot, product, process.session) diff --git a/Spaces/CockpitSpace.js b/Spaces/CockpitSpace.js index 39c2f2a0a..bc9611a72 100644 --- a/Spaces/CockpitSpace.js +++ b/Spaces/CockpitSpace.js @@ -5,7 +5,7 @@ let thisObject = { container: undefined, status: 'BOTTOM', - assetBalances: undefined, + quotedAssetalances: undefined, fullscreen: undefined, toTop: toTop, toBottom: toBottom, @@ -40,7 +40,7 @@ thisObject.container.finalize() thisObject.container = undefined - thisObject.assetBalances = undefined + thisObject.quotedAssetalances = undefined thisObject.fullscreen = undefined } @@ -65,8 +65,8 @@ canvasBrowserResizedEventSubscriptionId = window.canvasApp.eventHandler.listenToEvent('Browser Resized', resize) selfMouseClickEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick) - thisObject.assetBalances = newAssetBalances() - thisObject.assetBalances.initialize() + thisObject.quotedAssetalances = newQuotedAssetalances() + thisObject.quotedAssetalances.initialize() thisObject.fullscreen = newFullScreen() thisObject.fullscreen.container.connectToParent(thisObject.container) @@ -171,7 +171,7 @@ drawBackground() - thisObject.assetBalances.draw() + thisObject.quotedAssetalances.draw() thisObject.fullscreen.draw() } From d118f1df1c379271f38a288b753e347f2b688e43 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 5 Jan 2020 17:26:37 +0100 Subject: [PATCH 035/264] Bug fixed --- Spaces/CockpitSpace.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Spaces/CockpitSpace.js b/Spaces/CockpitSpace.js index bc9611a72..b93494d0f 100644 --- a/Spaces/CockpitSpace.js +++ b/Spaces/CockpitSpace.js @@ -5,7 +5,7 @@ let thisObject = { container: undefined, status: 'BOTTOM', - quotedAssetalances: undefined, + assetBalances: undefined, fullscreen: undefined, toTop: toTop, toBottom: toBottom, @@ -40,7 +40,7 @@ thisObject.container.finalize() thisObject.container = undefined - thisObject.quotedAssetalances = undefined + thisObject.assetBalances = undefined thisObject.fullscreen = undefined } @@ -65,8 +65,8 @@ canvasBrowserResizedEventSubscriptionId = window.canvasApp.eventHandler.listenToEvent('Browser Resized', resize) selfMouseClickEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick) - thisObject.quotedAssetalances = newQuotedAssetalances() - thisObject.quotedAssetalances.initialize() + thisObject.assetBalances = newQuotedAssetalances() + thisObject.assetBalances.initialize() thisObject.fullscreen = newFullScreen() thisObject.fullscreen.container.connectToParent(thisObject.container) @@ -171,7 +171,7 @@ drawBackground() - thisObject.quotedAssetalances.draw() + thisObject.assetBalances.draw() thisObject.fullscreen.draw() } From 70f3e38a22ff970d2437b7e7f40b6cf58d056518 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 6 Jan 2020 13:47:21 +0100 Subject: [PATCH 036/264] Bug Fixed --- DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js | 1 + 1 file changed, 1 insertion(+) diff --git a/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js b/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js index 15f7c7d31..d7f2b61dc 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js +++ b/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js @@ -39,6 +39,7 @@ function newSessionFunctions () { 'Announcement->Telegram Bot->' + 'Open Stage->Initial Definition->Open Execution->' + 'Position Size->Position Rate->Formula->' + + 'Initial Stop->Initial Take Profit->' + 'Manage Stage->' + 'Stop->Take Profit->' + 'Phase->Formula->Next Phase Event->' + From bca250eed4254eb1fdd7c425fee96a1d5f4a7fe9 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 7 Jan 2020 08:45:38 +0100 Subject: [PATCH 037/264] Removing Logs --- ChartsSpace/TimelineChart.js | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index a5bca7edb..60f6a7a77 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -69,8 +69,6 @@ function newTimelineChart () { function initialize (pExchange, pMarket, pTimeLineCoordinateSystem, callBackFunction) { try { - if (INFO_LOG === true) { logger.write('[INFO] initialize -> Entering function.') } - /* We load the logow we will need for the background. */ exchange = pExchange market = pMarket @@ -141,8 +139,6 @@ function newTimelineChart () { plotterManager.initialize(productsPanel, pExchange, pMarket, onPlotterManagerReady) function onPlotterManagerReady (err) { - if (INFO_LOG === true) { logger.write('[INFO] initialize -> onPlotterManagerReady -> Entering function.') } - if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) { if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> onPlotterManagerReady -> Plotter Manager Initialization Failed. ') } if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> onPlotterManagerReady -> err= ' + err.stack) } @@ -174,8 +170,6 @@ function newTimelineChart () { } function onZoomChanged (event) { - if (INFO_LOG === true) { logger.write('[INFO] onZoomChanged -> Entering function.') } - if (initializationReady === true) { recalculateCurrentDatetime() @@ -184,8 +178,6 @@ function newTimelineChart () { } function setDatetime (pDatetime) { - if (INFO_LOG === true) { logger.write('[INFO] setDatetime -> Entering function.') } - /* This function is used when the time is changed through the user interface, but without zooming or panning. */ /* No matter if the day changed or not, we need to inform all visible Plotters. */ @@ -196,8 +188,6 @@ function newTimelineChart () { } function onOffsetChanged () { - if (INFO_LOG === true) { logger.write('[INFO] onOffsetChanged -> Entering function.') } - if (initializationReady === true) { if (thisObject.container.frame.isInViewPort()) { recalculateCurrentDatetime() @@ -207,8 +197,6 @@ function newTimelineChart () { } function recalculateCurrentDatetime () { - if (INFO_LOG === true) { logger.write('[INFO] recalculateCurrentDatetime -> Entering function.') } - /* The view port was moved or the view port zoom level was changed and the center of the screen points to a different datetime that we @@ -235,8 +223,6 @@ function newTimelineChart () { } function getContainer (point) { - if (INFO_LOG === true) { logger.write('[INFO] getContainer -> Entering function.') } - let container container = timeFrameScale.getContainer(point) From d9076ee6afde67d739982a726b4ca60658f600ee Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 7 Jan 2020 09:15:47 +0100 Subject: [PATCH 038/264] Removing Old Code --- ChartsSpace/TimeMachine.js | 14 --- ChartsSpace/TimelineChart.js | 2 - Panels/TimeControlPanel.js | 160 ----------------------------------- Spaces/PanelsSpace.js | 7 -- 4 files changed, 183 deletions(-) delete mode 100644 Panels/TimeControlPanel.js diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index d94df0324..e4dc88f5c 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -28,8 +28,6 @@ function newTimeMachine () { finalize: finalize } - let controlPanelHandle // We need this to destroy the Panel when this object is itself destroyed or no longer needs it... - // ... also to request a reference to the object for the cases we need it. const SEPARATION_BETWEEN_TIMELINE_CHARTS = 1.5 let timeLineCoordinateSystem = newTimeLineCoordinateSystem() @@ -82,12 +80,6 @@ function newTimeMachine () { } function initialize (callBackFunction) { - /* Each Time Machine has a Control Panel. */ - - let panelOwner = 'Global' - controlPanelHandle = canvas.panelsSpace.createNewPanel('Time Control Panel', undefined, panelOwner) - let controlPanel = canvas.panelsSpace.getPanel(controlPanelHandle, panelOwner) - recalculateScale() /* First, we initialize the market that we are going to show first on screen. Later all the other markets will be initialized on the background. */ @@ -114,9 +106,6 @@ function newTimeMachine () { thisObject.charts.push(timelineChart) - controlPanel.container.eventHandler.listenToEvent('Datetime Changed', timelineChart.setDatetime, undefined) - timelineChart.container.eventHandler.listenToEvent('Datetime Changed', controlPanel.setDatetime) - /* Each Time Machine has a Time Scale and a Right Scale. */ thisObject.timeScale = newTimeScale() @@ -197,9 +186,6 @@ function newTimeMachine () { function finalSteps () { thisObject.charts.push(timelineChart) - controlPanel.container.eventHandler.listenToEvent('Datetime Changed', timelineChart.setDatetime, undefined) - timelineChart.container.eventHandler.listenToEvent('Datetime Changed', controlPanel.setDatetime) - alreadyInitialized++ if (alreadyInitialized === leftToInitialize) { diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 60f6a7a77..41423dda7 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -218,8 +218,6 @@ function newTimelineChart () { datetime = newDate plotterManager.setDatetime(datetime) - - thisObject.container.eventHandler.raiseEvent('Datetime Changed', datetime) } function getContainer (point) { diff --git a/Panels/TimeControlPanel.js b/Panels/TimeControlPanel.js deleted file mode 100644 index 7eba4062a..000000000 --- a/Panels/TimeControlPanel.js +++ /dev/null @@ -1,160 +0,0 @@ -  -function newTimeControlPanel () { - let thisObject = { - container: undefined, - setDatetime: setDatetime, - datetimeDisplay: undefined, - stepDisplay: undefined, - draw: draw, - getContainer: getContainer, // returns the inner most container that holds the point received by parameter. - initialize: initialize - } - - let container = newContainer() - container.initialize() - container.isDraggeable = true - thisObject.container = container - thisObject.container.frame.containerName = 'Current Datetime' - - let timeFrame - let panelTabButton - - return thisObject - - function initialize () { - thisObject.container.frame.width = UI_PANEL.WIDTH.SMALL - thisObject.container.frame.height = UI_PANEL.HEIGHT.SMALL - - let position = { - x: (viewPort.visibleArea.topRight.x - viewPort.visibleArea.topLeft.x) / 2 - thisObject.container.frame.width / 2, - y: viewPort.visibleArea.bottomLeft.y - thisObject.container.frame.height - } - - thisObject.container.frame.position = position - - panelTabButton = newPanelTabButton() - panelTabButton.parentContainer = thisObject.container - panelTabButton.container.frame.parentFrame = thisObject.container.frame - panelTabButton.initialize() - - let datetime = NEW_SESSION_INITIAL_DATE - - let datetimeDisplay = { - currentDatetime: datetime, - addTime: addTime, - draw: drawTimeDisplay - } - - thisObject.datetimeDisplay = datetimeDisplay - - viewPort.eventHandler.listenToEvent('Zoom Changed', onZoomChanged) - timeFrame = INITIAL_TIME_PERIOD - } - - function onBotChangedTime (pNewDatetime) { - let newDatetime = new Date(pNewDatetime) - - thisObject.container.eventHandler.raiseEvent('Datetime Changed', newDatetime) - } - - function onZoomChanged (event) { - if (event !== undefined) { // it is undefined when the level is just being animated. - timeFrame = recalculatePeriod(event.newLevel) - } - } - - function getContainer (point) { - let container - - container = panelTabButton.getContainer(point) - if (container !== undefined) { return container } - - /* First we check if thisObject point is inside thisObject space. */ - - if (thisObject.container.frame.isThisPointHere(point, true) === true) { - /* The point does not belong to any inner container, so we return the current container. */ - - return thisObject.container - } else { - /* This point does not belong to thisObject space. */ - - return undefined - } - } - - function setDatetime (pDatetime) { - thisObject.datetimeDisplay.currentDatetime = new Date(pDatetime) - } - - function addTime (seconds) { - let newDate = thisObject.datetimeDisplay.currentDatetime - - newDate.setSeconds(newDate.getSeconds() + seconds) - thisObject.datetimeDisplay.currentDatetime = newDate - } - - function draw () { - return - thisObject.container.frame.draw(false, false, true) - thisObject.datetimeDisplay.draw() - panelTabButton.draw() - } - - function drawTimeDisplay () { - let fontSize = 10 - - let label = thisObject.datetimeDisplay.currentDatetime.toUTCString() - let labelArray = label.split(' ') - - label = labelArray[0] + ' ' + labelArray[1] + ' ' + labelArray[2] + ' ' + labelArray[3] - - /* Now we transform x on the actual coordinate on the canvas. */ - - let labelPoint = { - x: thisObject.container.frame.width / 2 - label.length / 2 * fontSize * FONT_ASPECT_RATIO, - y: thisObject.container.frame.height * 4.4 / 10 - } - - labelPoint = thisObject.container.frame.frameThisPoint(labelPoint) - - browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY - browserCanvasContext.fillStyle = 'rgba(60, 60, 60, 0.50)' - browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y) - - /* The time */ - - label = labelArray[4] + ' ' + labelArray[5] - - /* Now we transform x on the actual coordinate on the canvas. */ - - labelPoint = { - x: thisObject.container.frame.width / 2 - label.length / 2 * fontSize * FONT_ASPECT_RATIO, - y: thisObject.container.frame.height * 6.5 / 10 - } - - labelPoint = thisObject.container.frame.frameThisPoint(labelPoint) - - browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY - browserCanvasContext.fillStyle = 'rgba(60, 60, 60, 0.50)' - browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y) - - if (timeFrame > _45_MINUTES_IN_MILISECONDS) { - label = timeFrame / _1_HOUR_IN_MILISECONDS + ' hs' - } else { - label = timeFrame / _1_MINUTE_IN_MILISECONDS + ' min' - } - - /* Now we transform x on the actual coordinate on the canvas. */ - - labelPoint = { - x: thisObject.container.frame.width / 2 - label.length / 2 * fontSize * FONT_ASPECT_RATIO, - y: thisObject.container.frame.height * 8.5 / 10 - } - - labelPoint = thisObject.container.frame.frameThisPoint(labelPoint) - - browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY - browserCanvasContext.fillStyle = 'rgba(60, 60, 60, 0.50)' - browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y) - } -} diff --git a/Spaces/PanelsSpace.js b/Spaces/PanelsSpace.js index 641758d0b..a984bd306 100644 --- a/Spaces/PanelsSpace.js +++ b/Spaces/PanelsSpace.js @@ -40,13 +40,6 @@ function newPanelsSpace () { switch (pType) { - case 'Time Control Panel': - { - panel = newTimeControlPanel() - panel.initialize() - break - } - case 'Products Panel': { panel = newProductsPanel() From fb7487996dabd16538ed651ba8e63e55d969ab8e Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 7 Jan 2020 10:49:14 +0100 Subject: [PATCH 039/264] Chart Space synced with Designer --- ChartsSpace/TimeMachine.js | 35 +++++++++++++ Spaces/ChartSpace.js | 100 +++++++++++++++++++++++++------------ 2 files changed, 104 insertions(+), 31 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index e4dc88f5c..0ac35e528 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -249,6 +249,41 @@ function newTimeMachine () { childrenPhysics() } + function syncWithDesigner () { + let rootNodes = canvas.designerSpace.workspace.workspaceNode.rootNodes + for (let i = 0; i < rootNodes.length; i++) { + let rootNode = rootNodes[i] + if (rootNode.type === 'Charting System') { + let chartingSytemNode = rootNode + if (chartingSystem.timeMachines !== undefined) { + for (let j = 0; j < chartingSystem.timeMachines.length; j++) { + + } + } + } + } + + function initializeTimelineChart (exchange, market) { + let timelineChart = newTimelineChart() + + timelineChart.container.connectToParent(thisObject.container, true, true, false, true, true, true) + + timelineChart.container.frame.height = thisObject.container.frame.height + + timelineChart.container.frame.position.x = thisObject.container.frame.width / 2 - timelineChart.container.frame.width / 2 + timelineChart.container.frame.position.y = timelineChart.container.frame.height * SEPARATION_BETWEEN_TIMELINE_CHARTS * position + + position++ + + timelineChart.initialize(exchange, market, timeLineCoordinateSystem, onTimelineChartInitialized) + + function onTimelineChartInitialized () { + thisObject.charts.push(timelineChart) + chartsMap.set() + } + } + } + function thisObjectPhysics () { /* Screen Corner Date Calculation */ diff --git a/Spaces/ChartSpace.js b/Spaces/ChartSpace.js index d7bb2c624..47b188569 100644 --- a/Spaces/ChartSpace.js +++ b/Spaces/ChartSpace.js @@ -31,6 +31,8 @@ function newChartSpace () { } let canvasBrowserResizedEventSubscriptionId + let timeMachinesMap = new Map() + let syncWithDesignerLoop = 0 const PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT = 25 @@ -51,45 +53,17 @@ function newChartSpace () { timeMachine.finalize() } + thisObject.timeMachines = undefined + timeMachinesMap = undefined + thisObject.container.eventHandler.stopListening(canvasBrowserResizedEventSubscriptionId) thisObject.container.finalize() thisObject.container = undefined - setupContainer() } function initialize () { - let initializedCounter = 0 - let toInitialize = 1 - canvasBrowserResizedEventSubscriptionId = window.canvasApp.eventHandler.listenToEvent('Browser Resized', resize) - - /* We create the first of many possible time machines that could live at the Chart Space. */ - - let timeMachine = newTimeMachine() - - /* We make the time machine a little bit smaller than the current space. */ - - timeMachine.container.frame.position.x = thisObject.container.frame.width / 2 - timeMachine.container.frame.width / 2 - timeMachine.container.frame.position.y = thisObject.container.frame.height / 2 - timeMachine.container.frame.height / 2 - timeMachine.container.fitFunction = fitIntoVisibleArea - timeMachine.fitFunction = fitIntoVisibleArea - timeMachine.initialize(onTimeMachineInitialized) - - function onTimeMachineInitialized (err) { - initializedCounter++ - - if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) { - if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> Initialization Failed. -> Err ' + err.message) } - return - } - - thisObject.timeMachines.push(timeMachine) - - if (initializedCounter === toInitialize) { - viewPort.raiseEvents() // These events will impacts on objects just initialized. - } - } } function getContainer (point, purpose) { @@ -206,10 +180,74 @@ function newChartSpace () { } function physics () { + syncWithDesigner() thisObjectPhysics() childrenPhysics() } + function syncWithDesigner () { + syncWithDesignerLoop = syncWithDesignerLoop + 0.00000000001 + + let rootNodes = canvas.designerSpace.workspace.workspaceNode.rootNodes + for (let i = 0; i < rootNodes.length; i++) { + let rootNode = rootNodes[i] + if (rootNode.type === 'Charting System') { + let chartingSystem = rootNode + if (chartingSystem.timeMachines !== undefined) { + for (let j = 0; j < chartingSystem.timeMachines.length; j++) { + let node = chartingSystem.timeMachines[j] + let timeMachine = timeMachinesMap.get(node.id) + if (timeMachine === undefined) { + /* The time machine node is new, thus we need to initialize a new timeMachine */ + initializeTimeMachine(node, syncWithDesignerLoop) + } else { + /* The time machine already exists, we tag it as existing at the current loop. */ + timeMachine.syncWithDesignerLoop = syncWithDesignerLoop + } + } + } + } + } + /* We check all the timeMachines we have to see if we need to remove any of them */ + for (let i = 0; i < thisObject.timeMachines.length; i++) { + let timeMachine = thisObject.timeMachines[i] + if (timeMachine.syncWithDesignerLoop < syncWithDesignerLoop) { + /* Must be removed */ + timeMachine.finalize() + timeMachinesMap.delete(timeMachine.node.id) + timeMachine.node = undefined + thisObject.timeMachines.splice(i, 1) + /* We remove one at the time */ + return + } + } + + function initializeTimeMachine (node, syncWithDesignerLoop) { + let timeMachine = newTimeMachine() + timeMachine.syncWithDesignerLoop = syncWithDesignerLoop + timeMachine.node = node + timeMachinesMap.set(node.id, timeMachine) + + /* Setting up the new time machine. */ + timeMachine.container.frame.position.x = thisObject.container.frame.width / 2 - timeMachine.container.frame.width / 2 + timeMachine.container.frame.position.y = thisObject.container.frame.height / 2 - timeMachine.container.frame.height / 2 + timeMachine.container.fitFunction = fitIntoVisibleArea + timeMachine.fitFunction = fitIntoVisibleArea + timeMachine.initialize(onTimeMachineInitialized) + + function onTimeMachineInitialized (err) { + if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) { + if (ERROR_LOG === true) { logger.write('[ERROR] syncWithDesigner -> initializeTimeMachine -> Initialization Failed. -> Err ' + err.message) } + return + } + + thisObject.timeMachines.push(timeMachine) + + viewPort.raiseEvents() // These events will impacts on objects just initialized. + } + } + } + function thisObjectPhysics () { thisObject.container.frame.height = COCKPIT_SPACE_POSITION From afeedf0613914f093de6d298efbc248113256fff Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 7 Jan 2020 13:35:39 +0100 Subject: [PATCH 040/264] Timeline Chart Synced with Designer --- ChartsSpace/TimeMachine.js | 209 ++++++++++++++----------------------- FloatingSpace/UiObject.js | 4 +- Spaces/ChartSpace.js | 12 ++- 3 files changed, 90 insertions(+), 135 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 0ac35e528..6b2151936 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -4,8 +4,8 @@ Markets are a function of time. When watching them, end users must be positioned to position themselves at any time they like. In the future, it will be usefull to explore markets and compare them at different times simultaneously. Anticipating that future this module exists. -All the charts that depand on a datetime are children of this object Time Machine. In the future we will allow users to have more than one Time Machine, -each one with it own charts, and each one positioned at an especific point in titme. +All the timelineCharts that depand on a datetime are children of this object Time Machine. In the future we will allow users to have more than one Time Machine, +each one with it own timelineCharts, and each one positioned at an especific point in titme. */ @@ -19,7 +19,7 @@ function newTimeMachine () { timeScale: undefined, rateScale: undefined, fitFunction: undefined, - charts: [], + timelineCharts: [], physics: physics, drawBackground: drawBackground, draw: draw, @@ -39,6 +39,9 @@ function newTimeMachine () { } } + let syncWithDesignerLoop = 0 + let timelineChartsMap = new Map() + setupContainer() return thisObject @@ -56,12 +59,13 @@ function newTimeMachine () { } function finalize () { - for (let i = 0; i < thisObject.charts.length; i++) { - let chart = thisObject.charts[i] + for (let i = 0; i < thisObject.timelineCharts.length; i++) { + let chart = thisObject.timelineCharts[i] chart.finalize() } - thisObject.charts = [] + thisObject.timelineCharts = undefined + timelineChartsMap = undefined if (thisObject.timeScale !== undefined) { thisObject.timeScale.finalize() @@ -82,60 +86,35 @@ function newTimeMachine () { function initialize (callBackFunction) { recalculateScale() - /* First, we initialize the market that we are going to show first on screen. Later all the other markets will be initialized on the background. */ + /* Each Time Machine has a Time Scale and a Right Scale. */ - let position = 0 // This defines the position of each chart respect to each other. + thisObject.timeScale = newTimeScale() + thisObject.timeScale.fitFunction = thisObject.fitFunction - let timelineChart = newTimelineChart() + thisObject.timeScale.container.eventHandler.listenToEvent('Lenght Percentage Changed', function (event) { + thisObject.container.frame.width = TIME_MACHINE_WIDTH * event.lenghtPercentage / 100 + recalculateScale() + moveToUserPosition(thisObject.container, timeLineCoordinateSystem, false, true, event.mousePosition) + thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) + }) - timelineChart.container.connectToParent(thisObject.container, true, true, false, true, true, true) - timelineChart.container.frame.height = thisObject.container.frame.height + thisObject.timeScale.initialize() - timelineChart.container.frame.position.x = thisObject.container.frame.width / 2 - timelineChart.container.frame.width / 2 - timelineChart.container.frame.position.y = timelineChart.container.frame.height * SEPARATION_BETWEEN_TIMELINE_CHARTS * position + thisObject.rateScale = newRateScale() + thisObject.rateScale.fitFunction = thisObject.fitFunction - position++ + thisObject.rateScale.container.eventHandler.listenToEvent('Height Percentage Changed', function (event) { + thisObject.container.frame.height = TIME_MACHINE_HEIGHT * event.heightPercentage / 100 + recalculateScale() + moveToUserPosition(thisObject.container, timeLineCoordinateSystem, true, false, event.mousePosition) + thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) + }) - timelineChart.initialize(DEFAULT_EXCHANGE, DEFAULT_MARKET, timeLineCoordinateSystem, onDefaultInitialized) + thisObject.rateScale.initialize() - function onDefaultInitialized (err) { - if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) { - callBackFunction(err) - return - } + thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) - thisObject.charts.push(timelineChart) - - /* Each Time Machine has a Time Scale and a Right Scale. */ - - thisObject.timeScale = newTimeScale() - thisObject.timeScale.fitFunction = thisObject.fitFunction - - thisObject.timeScale.container.eventHandler.listenToEvent('Lenght Percentage Changed', function (event) { - thisObject.container.frame.width = TIME_MACHINE_WIDTH * event.lenghtPercentage / 100 - recalculateScale() - moveToUserPosition(thisObject.container, timeLineCoordinateSystem, false, true, event.mousePosition) - thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) - }) - - thisObject.timeScale.initialize() - - thisObject.rateScale = newRateScale() - thisObject.rateScale.fitFunction = thisObject.fitFunction - - thisObject.rateScale.container.eventHandler.listenToEvent('Height Percentage Changed', function (event) { - thisObject.container.frame.height = TIME_MACHINE_HEIGHT * event.heightPercentage / 100 - recalculateScale() - moveToUserPosition(thisObject.container, timeLineCoordinateSystem, true, false, event.mousePosition) - thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) - }) - - thisObject.rateScale.initialize() - - thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) - - initializeTheRest() - } + callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) function onMouseOver (event) { thisObject.timeScale.visible = true @@ -144,56 +123,6 @@ function newTimeMachine () { mouse.position.x = event.x mouse.position.y = event.y } - - function initializeTheRest () { - let leftToInitialize = SUPPORTED_EXCHANGES.length * SUPPORTED_MARKETS.length - 1 // The default exchange and market was already initialized. - let alreadyInitialized = 0 - - if (alreadyInitialized === leftToInitialize) { - callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) - return - } - - for (let i = 0; i < SUPPORTED_EXCHANGES.length; i++) { - for (let j = 0; j < SUPPORTED_MARKETS.length; j++) { - let exchange = SUPPORTED_EXCHANGES[i] - let market = SUPPORTED_MARKETS[j] - - if ( - exchange === DEFAULT_EXCHANGE && - market.baseAsset === DEFAULT_MARKET.baseAsset && - market.quotedAsset === DEFAULT_MARKET.quotedAsset - ) { continue } - - initializeTimelineChart(exchange, market) - } - } - - function initializeTimelineChart (exchange, market) { - let timelineChart = newTimelineChart() - - timelineChart.container.connectToParent(thisObject.container, true, true, false, true, true, true) - - timelineChart.container.frame.height = thisObject.container.frame.height - - timelineChart.container.frame.position.x = thisObject.container.frame.width / 2 - timelineChart.container.frame.width / 2 - timelineChart.container.frame.position.y = timelineChart.container.frame.height * SEPARATION_BETWEEN_TIMELINE_CHARTS * position - - position++ - - timelineChart.initialize(exchange, market, timeLineCoordinateSystem, finalSteps) - - function finalSteps () { - thisObject.charts.push(timelineChart) - - alreadyInitialized++ - - if (alreadyInitialized === leftToInitialize) { - callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) - } - } - } - } } function getContainer (point, purpose) { @@ -217,8 +146,8 @@ function newTimeMachine () { } } - for (let i = 0; i < this.charts.length; i++) { - container = this.charts[i].getContainer(point) + for (let i = 0; i < this.timelineCharts.length; i++) { + container = this.timelineCharts[i].getContainer(point) if (container !== undefined) { if (container.isForThisPurpose(purpose)) { if (thisObject.container.frame.isThisPointHere(point) === true) { @@ -247,39 +176,61 @@ function newTimeMachine () { function physics () { thisObjectPhysics() childrenPhysics() + syncWithDesigner() } function syncWithDesigner () { - let rootNodes = canvas.designerSpace.workspace.workspaceNode.rootNodes - for (let i = 0; i < rootNodes.length; i++) { - let rootNode = rootNodes[i] - if (rootNode.type === 'Charting System') { - let chartingSytemNode = rootNode - if (chartingSystem.timeMachines !== undefined) { - for (let j = 0; j < chartingSystem.timeMachines.length; j++) { + syncWithDesignerLoop = syncWithDesignerLoop + 0.00000000001 - } - } + for (let j = 0; j < thisObject.payload.node.timelineCharts.length; j++) { + let node = thisObject.payload.node.timelineCharts[j] + let timelineChart = timelineChartsMap.get(node.id) + if (timelineChart === undefined) { + /* The timeline chart node is new, thus we need to initialize a new timelineChart */ + initializeTimelineChart(node, syncWithDesignerLoop) + } else { + /* The time machine already exists, we tag it as existing at the current loop. */ + timelineChart.syncWithDesignerLoop = syncWithDesignerLoop } } - function initializeTimelineChart (exchange, market) { + /* We check all the timeMachines we have to see if we need to remove any of them */ + for (let i = 0; i < thisObject.timelineCharts.length; i++) { + let timelineChart = thisObject.timelineCharts[i] + if (timelineChart.syncWithDesignerLoop < syncWithDesignerLoop) { + /* Must be removed */ + timelineChart.finalize() + timelineChartsMap.delete(timelineChart.nodeId) + timelineChart.payload = undefined + thisObject.timelineCharts.splice(i, 1) + /* We remove one at the time */ + return + } + } + + function initializeTimelineChart (node, syncWithDesignerLoop) { let timelineChart = newTimelineChart() + timelineChart.syncWithDesignerLoop = syncWithDesignerLoop + timelineChart.payload = node.payload + timelineChart.nodeId = node.id + timelineChartsMap.set(node.id, timelineChart) + timelineChart.payload.uiObject.setValue('Loading...') + /* Setting up the new timeline chart. */ timelineChart.container.connectToParent(thisObject.container, true, true, false, true, true, true) - timelineChart.container.frame.height = thisObject.container.frame.height - timelineChart.container.frame.position.x = thisObject.container.frame.width / 2 - timelineChart.container.frame.width / 2 - timelineChart.container.frame.position.y = timelineChart.container.frame.height * SEPARATION_BETWEEN_TIMELINE_CHARTS * position + timelineChart.container.frame.position.y = 0 + timelineChart.initialize(DEFAULT_EXCHANGE, DEFAULT_MARKET, timeLineCoordinateSystem, onTimelineChartInitialized) - position++ + function onTimelineChartInitialized (err) { + if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) { + if (ERROR_LOG === true) { logger.write('[ERROR] syncWithDesigner -> initializeTimelineChart -> Initialization Failed. -> Err ' + err.message) } + return + } - timelineChart.initialize(exchange, market, timeLineCoordinateSystem, onTimelineChartInitialized) - - function onTimelineChartInitialized () { - thisObject.charts.push(timelineChart) - chartsMap.set() + thisObject.timelineCharts.push(timelineChart) + timelineChart.payload.uiObject.setValue('') } } } @@ -304,8 +255,8 @@ function newTimeMachine () { thisObject.timeScale.physics() thisObject.rateScale.physics() - for (let i = 0; i < thisObject.charts.length; i++) { - let chart = thisObject.charts[i] + for (let i = 0; i < thisObject.timelineCharts.length; i++) { + let chart = thisObject.timelineCharts[i] chart.physics() } @@ -364,8 +315,8 @@ function newTimeMachine () { thisBackground() if (thisObject.container.frame.isInViewPort()) { - for (let i = 0; i < this.charts.length; i++) { - let chart = this.charts[i] + for (let i = 0; i < this.timelineCharts.length; i++) { + let chart = this.timelineCharts[i] chart.drawBackground() } } @@ -373,8 +324,8 @@ function newTimeMachine () { function draw () { if (thisObject.container.frame.isInViewPort()) { - for (let i = 0; i < this.charts.length; i++) { - let chart = this.charts[i] + for (let i = 0; i < this.timelineCharts.length; i++) { + let chart = this.timelineCharts[i] chart.draw() } diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index 7d11245d1..37e832461 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -1062,7 +1062,9 @@ function newUiObject () { label = currentValue if (!isNaN(label)) { - label = currentValue.toFixed(2) + if (currentValue.toFixed !== undefined) { + label = currentValue.toFixed(2) + } } if (label !== undefined) { diff --git a/Spaces/ChartSpace.js b/Spaces/ChartSpace.js index 47b188569..117f09d14 100644 --- a/Spaces/ChartSpace.js +++ b/Spaces/ChartSpace.js @@ -180,9 +180,9 @@ function newChartSpace () { } function physics () { - syncWithDesigner() thisObjectPhysics() childrenPhysics() + syncWithDesigner() } function syncWithDesigner () { @@ -214,8 +214,8 @@ function newChartSpace () { if (timeMachine.syncWithDesignerLoop < syncWithDesignerLoop) { /* Must be removed */ timeMachine.finalize() - timeMachinesMap.delete(timeMachine.node.id) - timeMachine.node = undefined + timeMachinesMap.delete(timeMachine.nodeId) + timeMachine.payload = undefined thisObject.timeMachines.splice(i, 1) /* We remove one at the time */ return @@ -225,8 +225,10 @@ function newChartSpace () { function initializeTimeMachine (node, syncWithDesignerLoop) { let timeMachine = newTimeMachine() timeMachine.syncWithDesignerLoop = syncWithDesignerLoop - timeMachine.node = node + timeMachine.payload = node.payload + timeMachine.nodeId = node.id timeMachinesMap.set(node.id, timeMachine) + timeMachine.payload.uiObject.setValue('Loading...') /* Setting up the new time machine. */ timeMachine.container.frame.position.x = thisObject.container.frame.width / 2 - timeMachine.container.frame.width / 2 @@ -242,7 +244,7 @@ function newChartSpace () { } thisObject.timeMachines.push(timeMachine) - + timeMachine.payload.uiObject.setValue('') viewPort.raiseEvents() // These events will impacts on objects just initialized. } } From 57e58da67b0f9b4733d07d48ea8cfe1cfe0cfea1 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 7 Jan 2020 14:47:17 +0100 Subject: [PATCH 041/264] Bug Fixed while deleting Timeline Chart --- ChartsSpace/TimelineChart.js | 18 ++++++++++++++---- Scales/TimeFrameScale.js | 4 ++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 41423dda7..be4e435e7 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -46,6 +46,11 @@ function newTimelineChart () { let productsPanelHandle let timeFrameScale + let onOffsetChangedEventSuscriptionId + let onZoomChangedEventSuscriptionId + let onMouseOverEventSuscriptionId + let timeFrameScaleEventSuscriptionId + setupContainer() return thisObject @@ -56,6 +61,11 @@ function newTimelineChart () { } function finalize () { + viewPort.eventHandler.stopListening(onOffsetChangedEventSuscriptionId) + viewPort.eventHandler.stopListening(onZoomChangedEventSuscriptionId) + thisObject.container.eventHandler.stopListening(onMouseOverEventSuscriptionId) + timeFrameScale.container.eventHandler.stopListening(timeFrameScaleEventSuscriptionId) + plotterManager.finalize() plotterManager = undefined timeFrameScale.finalize() @@ -74,7 +84,7 @@ function newTimelineChart () { market = pMarket timeLineCoordinateSystem = pTimeLineCoordinateSystem - thisObject.container.eventHandler.listenToEvent('onMouseOver', function (event) { + onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', function (event) { saveUserPosition(thisObject.container, timeLineCoordinateSystem, event) }) @@ -123,8 +133,8 @@ function newTimelineChart () { /* Event Subscriptions - we need this events to be fired first here and then in active Plotters. */ - viewPort.eventHandler.listenToEvent('Offset Changed', onOffsetChanged) - viewPort.eventHandler.listenToEvent('Zoom Changed', onZoomChanged) + onOffsetChangedEventSuscriptionId = viewPort.eventHandler.listenToEvent('Offset Changed', onOffsetChanged) + onZoomChangedEventSuscriptionId = viewPort.eventHandler.listenToEvent('Zoom Changed', onZoomChanged) /* Initialize the Plotter Manager */ @@ -149,7 +159,7 @@ function newTimelineChart () { timeFrameScale = newTimeFrameScale() timeFrameScale.container.connectToParent(thisObject.container, false, false, false, true, true, true) - timeFrameScale.container.eventHandler.listenToEvent('Time Frame Changed', function (event) { + timeFrameScaleEventSuscriptionId = timeFrameScale.container.eventHandler.listenToEvent('Time Frame Changed', function (event) { let currentTimeFrame = timeFrame timeFrame = event.timeFrame if (timeFrame !== currentTimeFrame) { diff --git a/Scales/TimeFrameScale.js b/Scales/TimeFrameScale.js index df39d022d..a34e3df91 100644 --- a/Scales/TimeFrameScale.js +++ b/Scales/TimeFrameScale.js @@ -50,7 +50,7 @@ function newTimeFrameScale () { thisObject.container.eventHandler.stopListening(onMouseWheelEventSubscriptionId) thisObject.container.eventHandler.stopListening(onMouseOverEventSubscriptionId) thisObject.container.eventHandler.stopListening(onMouseNotOverEventSubscriptionId) - thisObject.container.eventHandler.stopListening(onZoomChangedEventSubscriptionId) + viewPort.eventHandler.stopListening(onZoomChangedEventSubscriptionId) timeLineCoordinateSystem = undefined objectStorage = undefined @@ -75,7 +75,7 @@ function newTimeFrameScale () { visible = true }) - onMouseWheelEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', function (event) { + onMouseNotOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', function (event) { visible = false }) From 9d8a6415c538a7b76dbca4858166413800b56535 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 7 Jan 2020 16:09:24 +0100 Subject: [PATCH 042/264] 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 From 32a0abfbe7828ca87ee87046403532a4f9ffad4b Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 7 Jan 2020 16:41:37 +0100 Subject: [PATCH 043/264] Cleaning --- ChartsSpace/TimeMachine.js | 3 --- Utilities.js | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 6b2151936..3c5f50b83 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -53,9 +53,6 @@ function newTimeMachine () { thisObject.container.frame.width = TIME_MACHINE_WIDTH thisObject.container.frame.height = TIME_MACHINE_HEIGHT - - thisObject.container.frame.position.x = browserCanvas.width / 2 - TIME_MACHINE_WIDTH / 2 - thisObject.container.frame.position.y = browserCanvas.height / 2 - TIME_MACHINE_HEIGHT / 2 } function finalize () { diff --git a/Utilities.js b/Utilities.js index c4991c43d..37ee16d97 100644 --- a/Utilities.js +++ b/Utilities.js @@ -14,7 +14,7 @@ function transformThisPoint (point, container) { point = container.frame.frameThisPoint(point) - /* We viewport Transformation. */ + /* We pass this point through the viewPort lends, meaning we apply the viewPort zoom and displacement. */ point = viewPort.zoomThisPoint(point) From 5c4876df351cc79478567415133c6737b698b55b Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 7 Jan 2020 17:50:43 +0100 Subject: [PATCH 044/264] Can have more than one time machine and drag it around --- Canvas.js | 42 +++++++++++++++++++++----------------- ChartsSpace/TimeMachine.js | 5 +++-- Container.js | 5 +++++ Globals.js | 3 ++- Spaces/ChartSpace.js | 8 +++++++- 5 files changed, 40 insertions(+), 23 deletions(-) diff --git a/Canvas.js b/Canvas.js index 9726c9d46..286cc81f5 100644 --- a/Canvas.js +++ b/Canvas.js @@ -850,30 +850,34 @@ function newCanvas () { thisObject.eventHandler.raiseEvent('Dragging', undefined) if (containerDragStarted || viewPortBeingDragged) { - /* The parameters received have been captured with zoom applied. We must remove the zoom in order to correctly modify the displacement. */ - - let downCopy = { - x: dragVector.downX, - y: dragVector.downY - } - - let downCopyNoTransf - downCopyNoTransf = viewPort.unzoomThisPoint(downCopy) - // downCopyNoTransf = containerBeingDragged.zoom.unzoomThisPoint(downCopyNoTransf); - - let upCopy = { - x: dragVector.upX, - y: dragVector.upY - } - - let upCopyNoTranf - upCopyNoTranf = viewPort.unzoomThisPoint(upCopy) - let displaceVector = { x: dragVector.upX - dragVector.downX, y: dragVector.upY - dragVector.downY } + if (containerBeingDragged !== undefined && containerBeingDragged.insideViewport === true) { + let downCopy = { + x: dragVector.downX, + y: dragVector.downY + } + + let downNoZoom + downNoZoom = viewPort.unzoomThisPoint(downCopy) + + let upCopy = { + x: dragVector.upX, + y: dragVector.upY + } + + let upNoZoom + upNoZoom = viewPort.unzoomThisPoint(upCopy) + + displaceVector = { + x: upNoZoom.x - downNoZoom.x, + y: upNoZoom.y - downNoZoom.y + } + } + if (viewPortBeingDragged) { viewPort.displace(displaceVector) } diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 3c5f50b83..37024081d 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -48,7 +48,8 @@ function newTimeMachine () { function setupContainer () { thisObject.container = newContainer() thisObject.container.initialize(MODULE_NAME) - thisObject.container.isDraggeable = false + thisObject.container.isDraggeable = true + thisObject.container.insideViewport = true thisObject.container.detectMouseOver = true thisObject.container.frame.width = TIME_MACHINE_WIDTH @@ -329,7 +330,7 @@ function newTimeMachine () { if (thisObject.timeScale !== undefined) { thisObject.timeScale.draw() } if (thisObject.rateScale !== undefined) { thisObject.rateScale.draw() } - // thisObject.container.frame.draw(false, true, false) + thisObject.container.frame.draw(false, true, false, thisObject.fitFunction) } } diff --git a/Container.js b/Container.js index d94375bdd..0816953fd 100644 --- a/Container.js +++ b/Container.js @@ -211,6 +211,11 @@ function newContainer () { return true } break + case GET_CONTAINER_PURPOSE.DRAGGING: + if (thisObject.isDraggeable === true) { + return true + } + break default: { return false } } diff --git a/Globals.js b/Globals.js index 281a3da9e..f6db156ae 100644 --- a/Globals.js +++ b/Globals.js @@ -48,7 +48,8 @@ const MIN_ZOOM_LEVEL = -28.25 const GET_CONTAINER_PURPOSE = { MOUSE_OVER: 1, MOUSE_WHEEL: 2, - MOUSE_CLICK: 3 + MOUSE_CLICK: 3, + DRAGGING: 4 } /* User Interface Panels */ diff --git a/Spaces/ChartSpace.js b/Spaces/ChartSpace.js index 117f09d14..57bc80994 100644 --- a/Spaces/ChartSpace.js +++ b/Spaces/ChartSpace.js @@ -76,7 +76,13 @@ function newChartSpace () { for (let i = 0; i < thisObject.timeMachines.length; i++) { container = thisObject.timeMachines[i].getContainer(point, purpose) if (container !== undefined) { - if (container.isForThisPurpose(purpose)) { + if (purpose !== undefined) { + if (container.isForThisPurpose(purpose)) { + if (thisObject.container.frame.isThisPointHere(point, true) === true) { + return container + } + } + } else { if (thisObject.container.frame.isThisPointHere(point, true) === true) { return container } From 082bacea3ae7da5fb35881f2c567ac57d1159013 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 8 Jan 2020 10:20:08 +0100 Subject: [PATCH 045/264] Time Scale working without displacing the view port --- ChartsSpace/TimeMachine.js | 2 +- Utilities.js | 50 ++++++++++++++++++++++++++++++-------- 2 files changed, 41 insertions(+), 11 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 37024081d..0f268f8b1 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -92,7 +92,7 @@ function newTimeMachine () { thisObject.timeScale.container.eventHandler.listenToEvent('Lenght Percentage Changed', function (event) { thisObject.container.frame.width = TIME_MACHINE_WIDTH * event.lenghtPercentage / 100 recalculateScale() - moveToUserPosition(thisObject.container, timeLineCoordinateSystem, false, true, event.mousePosition) + moveToUserPosition(thisObject.container, timeLineCoordinateSystem, false, true, event.mousePosition, false, true) thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) }) diff --git a/Utilities.js b/Utilities.js index 37ee16d97..52f02cbf4 100644 --- a/Utilities.js +++ b/Utilities.js @@ -105,7 +105,7 @@ function getUserPosition (timeLineCoordinateSystem) { return userPosition } -function moveToUserPosition (container, timeLineCoordinateSystem, ignoreX, ignoreY, center, considerZoom) { +function moveToUserPosition (container, timeLineCoordinateSystem, ignoreX, ignoreY, center, considerZoom, moveContainer) { let userPosition = getUserPosition(timeLineCoordinateSystem) if (considerZoom === true) { @@ -138,17 +138,47 @@ function moveToUserPosition (container, timeLineCoordinateSystem, ignoreX, ignor } } - /* Lets calculate the displace vector, from the point we want at the center, to the current center. */ + /* When we are moving the container, it needs to consider the zooming of the viewport */ + /* Lets calculate the displace vector, from the point we want at the center, to the current center. */ - let displaceVector = { - x: centerPoint.x - targetPoint.x, - y: centerPoint.y - targetPoint.y + let displaceVector + if (moveContainer === true) { + let targetCopy = { + x: targetPoint.x, + y: targetPoint.y + } + + let targetNoZoom + targetNoZoom = viewPort.unzoomThisPoint(targetCopy) + + let centerCopy = { + x: centerPoint.x, + y: centerPoint.y + } + + let centerNoZoom + centerNoZoom = viewPort.unzoomThisPoint(centerCopy) + + displaceVector = { + x: centerNoZoom.x - targetNoZoom.x, + y: centerNoZoom.y - targetNoZoom.y + } + + if (ignoreX) { displaceVector.x = 0 } + if (ignoreY) { displaceVector.y = 0 } + + container.displace(displaceVector) + } else { + displaceVector = { + x: centerPoint.x - targetPoint.x, + y: centerPoint.y - targetPoint.y + } + + if (ignoreX) { displaceVector.x = 0 } + if (ignoreY) { displaceVector.y = 0 } + + viewPort.displace(displaceVector) } - - if (ignoreX) { displaceVector.x = 0 } - if (ignoreY) { displaceVector.y = 0 } - - viewPort.displace(displaceVector) } function removeTime (datetime) { From 3c34df1383a949030292a8d3b70d639576f343a7 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 8 Jan 2020 10:31:51 +0100 Subject: [PATCH 046/264] Order of drawing now corrected --- Spaces/ChartSpace.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Spaces/ChartSpace.js b/Spaces/ChartSpace.js index 57bc80994..5f9932fa3 100644 --- a/Spaces/ChartSpace.js +++ b/Spaces/ChartSpace.js @@ -309,7 +309,7 @@ function newChartSpace () { if (thisObject.visible !== true) { return } for (let i = 0; i < thisObject.timeMachines.length; i++) { - let timeMachine = thisObject.timeMachines[i] + let timeMachine = thisObject.timeMachines[thisObject.timeMachines.length - i - 1] timeMachine.draw() } } From 6777cc1b98681756b1db03801ef3f793bc174345 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 8 Jan 2020 11:54:26 +0100 Subject: [PATCH 047/264] Rate Scale inside time machine --- ChartsSpace/TimeMachine.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 0f268f8b1..14d40fa77 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -299,7 +299,7 @@ function newTimeMachine () { thisObject.rateScale.container.frame.position.y = mouse.position.y - thisObject.rateScale.container.frame.height / 2 ratePoint = { - x: 10000000000000, + x: thisObject.container.frame.width, y: 0 } From f9d426de7d693eb743bfcdad85c7e2709f7a068e Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 8 Jan 2020 13:22:14 +0100 Subject: [PATCH 048/264] Time Frame Sclae upgraded --- ChartsSpace/TimeMachine.js | 4 +- ChartsSpace/TimelineChart.js | 65 +++++++++--- Scales/Commons.js | 4 +- Scales/RateScale.js | 2 +- Scales/TimeFrameScale.js | 194 ++++------------------------------- 5 files changed, 76 insertions(+), 193 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 14d40fa77..98241006c 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -78,7 +78,8 @@ function newTimeMachine () { thisObject.container.finalize() thisObject.container = undefined - setupContainer() + + mouse = undefined } function initialize (callBackFunction) { @@ -216,6 +217,7 @@ function newTimeMachine () { /* Setting up the new timeline chart. */ timelineChart.container.connectToParent(thisObject.container, true, true, false, true, true, true) + timelineChart.container.fitFunction = thisObject.container.fitFunction timelineChart.container.frame.height = thisObject.container.frame.height timelineChart.container.frame.position.x = thisObject.container.frame.width / 2 - timelineChart.container.frame.width / 2 timelineChart.container.frame.position.y = 0 diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index be4e435e7..9ee435e4c 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -14,6 +14,7 @@ function newTimelineChart () { let thisObject = { container: undefined, fitFunction: undefined, + timeFrameScale: undefined, physics: physics, setDatetime: setDatetime, drawBackground: drawBackground, @@ -44,13 +45,20 @@ function newTimelineChart () { let market let productsPanelHandle - let timeFrameScale let onOffsetChangedEventSuscriptionId let onZoomChangedEventSuscriptionId let onMouseOverEventSuscriptionId + let onMouseNotOverEventSuscriptionId let timeFrameScaleEventSuscriptionId + let mouse = { + position: { + x: 0, + y: 0 + } + } + setupContainer() return thisObject @@ -64,17 +72,19 @@ function newTimelineChart () { viewPort.eventHandler.stopListening(onOffsetChangedEventSuscriptionId) viewPort.eventHandler.stopListening(onZoomChangedEventSuscriptionId) thisObject.container.eventHandler.stopListening(onMouseOverEventSuscriptionId) - timeFrameScale.container.eventHandler.stopListening(timeFrameScaleEventSuscriptionId) + thisObject.container.eventHandler.stopListening(onMouseNotOverEventSuscriptionId) + thisObject.timeFrameScale.container.eventHandler.stopListening(timeFrameScaleEventSuscriptionId) plotterManager.finalize() plotterManager = undefined - timeFrameScale.finalize() - timeFrameScale = undefined + thisObject.timeFrameScale.finalize() + thisObject.timeFrameScale = undefined canvas.panelsSpace.destroyPanel(productsPanelHandle) thisObject.container.finalize() thisObject.container = undefined - setupContainer() + + mouse = undefined } function initialize (pExchange, pMarket, pTimeLineCoordinateSystem, callBackFunction) { @@ -84,9 +94,22 @@ function newTimelineChart () { market = pMarket timeLineCoordinateSystem = pTimeLineCoordinateSystem - onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', function (event) { + onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) + + function onMouseOver (event) { + thisObject.timeFrameScale.visible = true + + mouse.position.x = event.x + mouse.position.y = event.y + saveUserPosition(thisObject.container, timeLineCoordinateSystem, event) - }) + } + + onMouseNotOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) + + function onMouseNotOver (event) { + thisObject.timeFrameScale.visible = false + } let panelOwner = exchange + ' ' + market.quotedAsset + '/' + market.baseAsset productsPanelHandle = canvas.panelsSpace.createNewPanel('Products Panel', undefined, panelOwner) @@ -157,9 +180,9 @@ function newTimelineChart () { return } - timeFrameScale = newTimeFrameScale() - timeFrameScale.container.connectToParent(thisObject.container, false, false, false, true, true, true) - timeFrameScaleEventSuscriptionId = timeFrameScale.container.eventHandler.listenToEvent('Time Frame Changed', function (event) { + thisObject.timeFrameScale = newTimeFrameScale() + thisObject.timeFrameScale.fitFunction = thisObject.fitFunction + timeFrameScaleEventSuscriptionId = thisObject.timeFrameScale.container.eventHandler.listenToEvent('Time Frame Changed', function (event) { let currentTimeFrame = timeFrame timeFrame = event.timeFrame if (timeFrame !== currentTimeFrame) { @@ -167,7 +190,7 @@ function newTimelineChart () { } }) - timeFrameScale.initialize(timeLineCoordinateSystem) + thisObject.timeFrameScale.initialize() initializationReady = true callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) @@ -233,7 +256,7 @@ function newTimelineChart () { function getContainer (point) { let container - container = timeFrameScale.getContainer(point) + container = thisObject.timeFrameScale.getContainer(point) if (container !== undefined) { return container } @@ -250,7 +273,23 @@ function newTimelineChart () { } function childrenPhysics () { + if (thisObject.timeFrameScale === undefined) { return } + thisObject.timeFrameScale.physics() + + /* thisObject.timeFrameScale Positioning */ + + thisObject.timeFrameScale.container.frame.position.x = mouse.position.x - thisObject.timeFrameScale.container.frame.width / 2 + + timePoint = { + x: 0, + y: thisObject.container.frame.height + } + + timePoint = transformThisPoint(timePoint, thisObject.container.frame.container) + timePoint = thisObject.container.fitFunction(timePoint) + + thisObject.timeFrameScale.container.frame.position.y = timePoint.y - thisObject.timeFrameScale.container.frame.height } function tooTiny () { @@ -283,7 +322,7 @@ function newTimelineChart () { if (thisObject.container.frame.isInViewPort()) { drawChartsBackground() plotterManager.draw() - timeFrameScale.draw() + thisObject.timeFrameScale.draw() } } diff --git a/Scales/Commons.js b/Scales/Commons.js index 6e52c9c99..05808196d 100644 --- a/Scales/Commons.js +++ b/Scales/Commons.js @@ -3,11 +3,11 @@ function drawScaleDisplay (label1, label2, xExtraOffSet1, xExtraOffSet2, contain let fontSize1 = 20 let fontSize2 = 10 - const RED_LINE_HIGHT = 5 + const RED_LINE_HIGHT = 4 const OPACITY = 1 let params = { - cornerRadius: 3, + cornerRadius: 5, lineWidth: RED_LINE_HIGHT, container: container, borderColor: UI_COLOR.RUSTED_RED, diff --git a/Scales/RateScale.js b/Scales/RateScale.js index dc675d4db..33533b17e 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -26,7 +26,7 @@ function newRateScale () { thisObject.container.isWheelable = true thisObject.container.detectMouseOver = true - thisObject.container.frame.width = 110 + thisObject.container.frame.width = 190 thisObject.container.frame.height = 25 let isMouseOver diff --git a/Scales/TimeFrameScale.js b/Scales/TimeFrameScale.js index a34e3df91..130056f07 100644 --- a/Scales/TimeFrameScale.js +++ b/Scales/TimeFrameScale.js @@ -4,7 +4,9 @@ function newTimeFrameScale () { let thisObject = { timeFrame: undefined, container: undefined, + fitFunction: undefined, draw: draw, + physics: physics, getContainer: getContainer, initialize: initialize, finalize: finalize @@ -14,15 +16,7 @@ function newTimeFrameScale () { const TIME_PERIOD_DEFAULT_VALUE = 0 const MIN_HEIGHT = 50 - let mouse = { - position: { - x: 0, - y: 0 - } - } - let visible = true - let timeLineCoordinateSystem let objectStorage = {} let filePeriodIndex = FILES_PERIOD_DEFAULT_VALUE let timeFrameIndex = TIME_PERIOD_DEFAULT_VALUE @@ -30,8 +24,6 @@ function newTimeFrameScale () { let timeFrameLabel = '' let onMouseWheelEventSubscriptionId - let onMouseOverEventSubscriptionId - let onMouseNotOverEventSubscriptionId let onZoomChangedEventSubscriptionId setupContainer() @@ -44,44 +36,35 @@ function newTimeFrameScale () { thisObject.container.isDraggeable = false thisObject.container.isClickeable = false thisObject.container.isWheelable = true + + thisObject.container.frame.width = 190 + thisObject.container.frame.height = 25 } function finalize () { thisObject.container.eventHandler.stopListening(onMouseWheelEventSubscriptionId) - thisObject.container.eventHandler.stopListening(onMouseOverEventSubscriptionId) - thisObject.container.eventHandler.stopListening(onMouseNotOverEventSubscriptionId) viewPort.eventHandler.stopListening(onZoomChangedEventSubscriptionId) - timeLineCoordinateSystem = undefined objectStorage = undefined thisObject.container.finalize() thisObject.container = undefined - setupContainer() + thisObject.fitFunction = undefined } - function initialize (pTimeLineCoordinateSystem) { - timeLineCoordinateSystem = pTimeLineCoordinateSystem - + function initialize () { onMouseWheelEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) readObjectState() newTimeFrame() - onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', function (event) { - mouse.position.x = event.x - mouse.position.y = event.y - - visible = true - }) - - onMouseNotOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', function (event) { - visible = false - }) - onZoomChangedEventSubscriptionId = viewPort.eventHandler.listenToEvent('Zoom Changed', onZoomChanged) } + function physics () { + + } + function onZoomChanged (event) { if (event !== undefined) { // it is undefined when the level is just being animated. let currentTimeFrame = thisObject.timeFrame @@ -133,24 +116,9 @@ function newTimeFrameScale () { newTimeFrame() } - function getContainer (pPoint) { - let container - -/* In this case we manually frame this point since we do a very special treatment of the position of this scale. */ - let point = { - x: 0, - y: 0 - } - - point.x = pPoint.x - thisObject.container.frame.position.x - point.y = pPoint.y - thisObject.container.frame.position.y - - if (thisObject.container.frame.isThisPointHere(point, undefined, true) === true) { + function getContainer (point) { + if (thisObject.container.frame.isThisPointHere(point, true) === true) { return thisObject.container - } else { - /* This point does not belong to this space. */ - - return undefined } } @@ -183,142 +151,16 @@ function newTimeFrameScale () { function draw () { if (visible === false) { return } -/* We need this scale to match the shape of its parent when the parent is inside the viewPort, when it is not, we need the scale still -to be visible at the top of the viewPort. */ + drawTimeFrame() + } - let frame = thisObject.container.parentContainer.frame - let point1 - let point2 - let point3 - let point4 - - point1 = { - x: 0, - y: frame.height - frame.height * 2 / 100 - } - - point2 = { - x: frame.width, - y: frame.height - frame.height * 2 / 100 - } - - point3 = { - x: frame.width, - y: frame.height - } - - point4 = { - x: 0, - y: frame.height - } - - point5 = { - x: 0, - y: 0 - } - - /* Now the transformations. */ - - point1 = transformThisPoint(point1, frame.container) - point2 = transformThisPoint(point2, frame.container) - point3 = transformThisPoint(point3, frame.container) - point4 = transformThisPoint(point4, frame.container) - point5 = transformThisPoint(point5, frame.container) - - point1 = viewPort.fitIntoVisibleArea(point1) - point2 = viewPort.fitIntoVisibleArea(point2) - point3 = viewPort.fitIntoVisibleArea(point3) - point4 = viewPort.fitIntoVisibleArea(point4) - point5 = viewPort.fitIntoVisibleArea(point5) - - if (point3.y - point2.y < MIN_HEIGHT) { - point1.y = point3.y - MIN_HEIGHT - point2.y = point3.y - MIN_HEIGHT - } - - /* Lets start the drawing. */ - - let displacement = viewPort.margins.BOTTOM - COCKPIT_SPACE_HEIGHT - - /* - browserCanvasContext.beginPath() - browserCanvasContext.moveTo(point1.x, point1.y + displacement) - browserCanvasContext.lineTo(point2.x, point2.y + displacement) - browserCanvasContext.lineTo(point3.x, point3.y + displacement) - browserCanvasContext.lineTo(point4.x, point4.y + displacement) - browserCanvasContext.lineTo(point1.x, point1.y + displacement) - browserCanvasContext.closePath() - - browserCanvasContext.strokeStyle = 'rgba(150, 150, 150, 1)' - browserCanvasContext.lineWidth = 1 - browserCanvasContext.stroke() -*/ - - thisObject.container.frame.position.x = point1.x - thisObject.container.frame.position.y = point1.y + displacement - - thisObject.container.frame.width = point2.x - point1.x - thisObject.container.frame.height = point3.y - point2.y - - /* Common Variables */ + function drawTimeFrame () { + if (thisObject.visible === false || timeFrameLabel === undefined) { return } let label = timeFrameLabel.split('-') let label1 = label[0] let label2 = label[1].toUpperCase() - let fontSize1 = 20 - let fontSize2 = 10 - const RED_LINE_HIGHT = 5 - const OPACITY = 1 - - let centerPoint = { - x: mouse.position.x, - y: point1.y + viewPort.margins.BOTTOM - } - - let container = newContainer() - container.initialize('Visible Time Scale') - container.frame.width = 60 - container.frame.height = 25 - container.frame.position.x = centerPoint.x - container.frame.width / 2 - container.frame.position.y = centerPoint.y - container.frame.height / 2 - - let params = { - cornerRadius: 3, - lineWidth: RED_LINE_HIGHT, - container: container, - borderColor: UI_COLOR.RUSTED_RED, - castShadow: false, - backgroundColor: UI_COLOR.DARK, - opacity: OPACITY - } - - roundedCornersBackground(params) - - /* Place the Text */ - - let xOffset1 = label1.length * fontSize1 * FONT_ASPECT_RATIO - - let labelPoint1 = { - x: mouse.position.x - xOffset1 / 2 - 14, - y: point1.y + viewPort.margins.BOTTOM + 6 - } - - browserCanvasContext.font = fontSize1 + 'px ' + UI_FONT.PRIMARY - browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)' - - browserCanvasContext.fillText(label1, labelPoint1.x, labelPoint1.y) - - let xOffset2 = label2.length * fontSize2 * FONT_ASPECT_RATIO - - let labelPoint2 = { - x: mouse.position.x - xOffset2 / 2 - 3 + 14, - y: point1.y + viewPort.margins.BOTTOM + 6 - } - - browserCanvasContext.font = fontSize2 + 'px ' + UI_FONT.PRIMARY - browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)' - - browserCanvasContext.fillText(label2, labelPoint2.x, labelPoint2.y) + drawScaleDisplay(label1, label2, 10, 60, thisObject.container, thisObject.fitFunction) } } From ac3a0de589933a2b732170051bb057af6fa4892c Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 8 Jan 2020 16:21:48 +0100 Subject: [PATCH 049/264] rateScale wheeling ok --- ChartsSpace/TimeMachine.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 98241006c..1da32bf2a 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -105,7 +105,7 @@ function newTimeMachine () { thisObject.rateScale.container.eventHandler.listenToEvent('Height Percentage Changed', function (event) { thisObject.container.frame.height = TIME_MACHINE_HEIGHT * event.heightPercentage / 100 recalculateScale() - moveToUserPosition(thisObject.container, timeLineCoordinateSystem, true, false, event.mousePosition) + moveToUserPosition(thisObject.container, timeLineCoordinateSystem, true, false, event.mousePosition, false, true) thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) }) From 0f0cfd58ac62487ed8360cd158fc4931825524cb Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 8 Jan 2020 16:28:29 +0100 Subject: [PATCH 050/264] Finalizing Events at scales --- Scales/RateScale.js | 16 ++++++++++++---- Scales/TimeScale.js | 15 ++++++++++++--- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/Scales/RateScale.js b/Scales/RateScale.js index 33533b17e..9de0f83c7 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -30,18 +30,27 @@ function newRateScale () { thisObject.container.frame.height = 25 let isMouseOver + + let onMouseWheelEventSubscriptionId + let onMouseOverEventSubscriptionId + let onMouseNotOverEventSubscriptionId + return thisObject function finalize () { + thisObject.container.eventHandler.stopListening(onMouseWheelEventSubscriptionId) + thisObject.container.eventHandler.stopListening(onMouseOverEventSubscriptionId) + thisObject.container.eventHandler.stopListening(onMouseNotOverEventSubscriptionId) + thisObject.container.finalize() thisObject.container = undefined thisObject.fitFunction = undefined } function initialize () { - thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) - thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) - thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) + onMouseWheelEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) + onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) + onMouseNotOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) thisObject.heightPercentage = window.localStorage.getItem(MODULE_NAME) if (!thisObject.heightPercentage) { @@ -206,4 +215,3 @@ function newRateScale () { drawScaleDisplay(label1, label2, 10, 40, thisObject.container, thisObject.fitFunction) } } - diff --git a/Scales/TimeScale.js b/Scales/TimeScale.js index 154b4447f..eea2a89f3 100644 --- a/Scales/TimeScale.js +++ b/Scales/TimeScale.js @@ -30,18 +30,27 @@ function newTimeScale () { thisObject.container.frame.height = 25 let isMouseOver + + let onMouseWheelEventSubscriptionId + let onMouseOverEventSubscriptionId + let onMouseNotOverEventSubscriptionId + return thisObject function finalize () { + thisObject.container.eventHandler.stopListening(onMouseWheelEventSubscriptionId) + thisObject.container.eventHandler.stopListening(onMouseOverEventSubscriptionId) + thisObject.container.eventHandler.stopListening(onMouseNotOverEventSubscriptionId) + thisObject.container.finalize() thisObject.container = undefined thisObject.fitFunction = undefined } function initialize () { - thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) - thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) - thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) + onMouseWheelEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) + onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) + onMouseNotOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) thisObject.lenghtPercentage = window.localStorage.getItem(MODULE_NAME) if (!thisObject.lenghtPercentage) { From fbac0a5704bb5ba129ea9b9bbc3260882eea109c Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 8 Jan 2020 17:26:57 +0100 Subject: [PATCH 051/264] misssing stop listneinig --- ChartsSpace/TimeMachine.js | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 1da32bf2a..ecbc7e56d 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -42,6 +42,11 @@ function newTimeMachine () { let syncWithDesignerLoop = 0 let timelineChartsMap = new Map() + let onMouseOverEventSuscriptionId + let onMouseNotOverEventSuscriptionId + let timeScaleEventSuscriptionId + let rateScaleEventSuscriptionId + setupContainer() return thisObject @@ -57,6 +62,11 @@ function newTimeMachine () { } function finalize () { + thisObject.timeScale.container.eventHandler.stopListening(timeScaleEventSuscriptionId) + thisObject.rateScale.container.eventHandler.stopListening(rateScaleEventSuscriptionId) + thisObject.container.eventHandler.stopListening(onMouseOverEventSuscriptionId) + thisObject.container.eventHandler.stopListening(onMouseNotOverEventSuscriptionId) + for (let i = 0; i < thisObject.timelineCharts.length; i++) { let chart = thisObject.timelineCharts[i] chart.finalize() @@ -90,7 +100,7 @@ function newTimeMachine () { thisObject.timeScale = newTimeScale() thisObject.timeScale.fitFunction = thisObject.fitFunction - thisObject.timeScale.container.eventHandler.listenToEvent('Lenght Percentage Changed', function (event) { + timeScaleEventSuscriptionId = thisObject.timeScale.container.eventHandler.listenToEvent('Lenght Percentage Changed', function (event) { thisObject.container.frame.width = TIME_MACHINE_WIDTH * event.lenghtPercentage / 100 recalculateScale() moveToUserPosition(thisObject.container, timeLineCoordinateSystem, false, true, event.mousePosition, false, true) @@ -102,7 +112,7 @@ function newTimeMachine () { thisObject.rateScale = newRateScale() thisObject.rateScale.fitFunction = thisObject.fitFunction - thisObject.rateScale.container.eventHandler.listenToEvent('Height Percentage Changed', function (event) { + rateScaleEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('Height Percentage Changed', function (event) { thisObject.container.frame.height = TIME_MACHINE_HEIGHT * event.heightPercentage / 100 recalculateScale() moveToUserPosition(thisObject.container, timeLineCoordinateSystem, true, false, event.mousePosition, false, true) @@ -111,9 +121,7 @@ function newTimeMachine () { thisObject.rateScale.initialize() - thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) - - callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) + onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) function onMouseOver (event) { thisObject.timeScale.visible = true @@ -122,6 +130,15 @@ function newTimeMachine () { mouse.position.x = event.x mouse.position.y = event.y } + + onMouseNotOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) + + function onMouseNotOver (event) { + thisObject.timeScale.visible = false + thisObject.rateScale.visible = false + } + + callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) } function getContainer (point, purpose) { @@ -160,7 +177,7 @@ function newTimeMachine () { return thisObject.container } else { if (purpose === GET_CONTAINER_PURPOSE.MOUSE_OVER) { - thisObject.container.eventHandler.raiseEvent('onMouseNotOver') + thisObject.container.eventHandler.raiseEvent('onMouseNotOverMe') if (thisObject.timeScale !== undefined) { thisObject.timeScale.visible = false } From 4a384a0ff5cb418fd8381ba00db086ced3153aab Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 8 Jan 2020 17:48:55 +0100 Subject: [PATCH 052/264] Switching between Time Machines working on every scale --- ChartsSpace/TimeMachine.js | 2 +- Scales/RateScale.js | 1 + Scales/TimeFrameScale.js | 11 +++++++++-- Scales/TimeScale.js | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index ecbc7e56d..032e57669 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -177,7 +177,7 @@ function newTimeMachine () { return thisObject.container } else { if (purpose === GET_CONTAINER_PURPOSE.MOUSE_OVER) { - thisObject.container.eventHandler.raiseEvent('onMouseNotOverMe') + thisObject.container.eventHandler.raiseEvent('onMouseNotOver') if (thisObject.timeScale !== undefined) { thisObject.timeScale.visible = false } diff --git a/Scales/RateScale.js b/Scales/RateScale.js index 9de0f83c7..eb83d9d01 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -65,6 +65,7 @@ function newRateScale () { } function onMouseOver () { + thisObject.visible = true isMouseOver = true } diff --git a/Scales/TimeFrameScale.js b/Scales/TimeFrameScale.js index 130056f07..f9442c203 100644 --- a/Scales/TimeFrameScale.js +++ b/Scales/TimeFrameScale.js @@ -25,6 +25,7 @@ function newTimeFrameScale () { let onMouseWheelEventSubscriptionId let onZoomChangedEventSubscriptionId + let onMouseOverEventSubscriptionId setupContainer() return thisObject @@ -36,6 +37,7 @@ function newTimeFrameScale () { thisObject.container.isDraggeable = false thisObject.container.isClickeable = false thisObject.container.isWheelable = true + thisObject.container.detectMouseOver = true thisObject.container.frame.width = 190 thisObject.container.frame.height = 25 @@ -44,6 +46,7 @@ function newTimeFrameScale () { function finalize () { thisObject.container.eventHandler.stopListening(onMouseWheelEventSubscriptionId) viewPort.eventHandler.stopListening(onZoomChangedEventSubscriptionId) + thisObject.container.eventHandler.stopListening(onMouseOverEventSubscriptionId) objectStorage = undefined @@ -53,12 +56,16 @@ function newTimeFrameScale () { } function initialize () { - onMouseWheelEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) - readObjectState() newTimeFrame() + onMouseWheelEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) onZoomChangedEventSubscriptionId = viewPort.eventHandler.listenToEvent('Zoom Changed', onZoomChanged) + onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) + + function onMouseOver () { + thisObject.visible = true + } } function physics () { diff --git a/Scales/TimeScale.js b/Scales/TimeScale.js index eea2a89f3..f70cbcbe9 100644 --- a/Scales/TimeScale.js +++ b/Scales/TimeScale.js @@ -65,6 +65,7 @@ function newTimeScale () { } function onMouseOver () { + thisObject.visible = true isMouseOver = true } @@ -216,4 +217,3 @@ function newTimeScale () { drawScaleDisplay(label1, label2, 10, 60, thisObject.container, thisObject.fitFunction) } } - From f5fb6e462e8d3a7926a499c531540884c1f036b8 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 8 Jan 2020 18:27:13 +0100 Subject: [PATCH 053/264] Dragging drags also the scales --- Canvas.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Canvas.js b/Canvas.js index 286cc81f5..3ca616f1b 100644 --- a/Canvas.js +++ b/Canvas.js @@ -655,9 +655,8 @@ function newCanvas () { dragVector.upY = point.y checkDrag(event) - } else { - onMouseOver(event) } + onMouseOver(event) } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] onMouseMove -> err = ' + err.stack) } } From 0d70f64c5693e1a7923cf2e28f8d0a008840a507 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 8 Jan 2020 19:13:25 +0100 Subject: [PATCH 054/264] Scales do not leave visible area --- ChartsSpace/TimeMachine.js | 10 +++++----- ChartsSpace/TimelineChart.js | 6 +++--- Spaces/ChartSpace.js | 12 +++++++++--- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 032e57669..bc96d5c07 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -301,30 +301,30 @@ function newTimeMachine () { /* timeScale Positioning */ - thisObject.timeScale.container.frame.position.x = mouse.position.x - thisObject.timeScale.container.frame.width / 2 - timePoint = { x: 0, y: 0 } timePoint = transformThisPoint(timePoint, thisObject.container.frame.container) + timePoint.x = mouse.position.x - thisObject.timeScale.container.frame.width / 2 timePoint = thisObject.container.fitFunction(timePoint) + thisObject.timeScale.container.frame.position.x = timePoint.x thisObject.timeScale.container.frame.position.y = timePoint.y /* rateScale Positioning */ - thisObject.rateScale.container.frame.position.y = mouse.position.y - thisObject.rateScale.container.frame.height / 2 - ratePoint = { x: thisObject.container.frame.width, y: 0 } ratePoint = transformThisPoint(ratePoint, thisObject.container.frame.container) - ratePoint = thisObject.container.fitFunction(ratePoint) + ratePoint.y = mouse.position.y - thisObject.rateScale.container.frame.height / 2 + thisObject.rateScale.container.frame.height + ratePoint = thisObject.container.fitFunction(ratePoint, true) + thisObject.rateScale.container.frame.position.y = ratePoint.y - thisObject.rateScale.container.frame.height thisObject.rateScale.container.frame.position.x = ratePoint.x - thisObject.rateScale.container.frame.width } diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 9ee435e4c..21cb8b82e 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -279,16 +279,16 @@ function newTimelineChart () { /* thisObject.timeFrameScale Positioning */ - thisObject.timeFrameScale.container.frame.position.x = mouse.position.x - thisObject.timeFrameScale.container.frame.width / 2 - timePoint = { x: 0, y: thisObject.container.frame.height } timePoint = transformThisPoint(timePoint, thisObject.container.frame.container) - timePoint = thisObject.container.fitFunction(timePoint) + timePoint.x = mouse.position.x - thisObject.timeFrameScale.container.frame.width / 2 + timePoint = thisObject.container.fitFunction(timePoint, true) + thisObject.timeFrameScale.container.frame.position.x = timePoint.x thisObject.timeFrameScale.container.frame.position.y = timePoint.y - thisObject.timeFrameScale.container.frame.height } diff --git a/Spaces/ChartSpace.js b/Spaces/ChartSpace.js index 5f9932fa3..2879666d3 100644 --- a/Spaces/ChartSpace.js +++ b/Spaces/ChartSpace.js @@ -138,7 +138,7 @@ function newChartSpace () { viewPort.displace(displaceVector, true) } - function fitIntoVisibleArea (point) { + function fitIntoVisibleArea (point, fullVisible) { /* Here we check the boundaries of the resulting points, so they dont go out of the visible area. */ let returnPoint = { @@ -154,8 +154,14 @@ function newChartSpace () { returnPoint.x = 0 } - if (point.y > COCKPIT_SPACE_POSITION + COCKPIT_SPACE_HEIGHT / 2) { - returnPoint.y = COCKPIT_SPACE_POSITION + COCKPIT_SPACE_HEIGHT / 2 + if (fullVisible === true) { + if (point.y > COCKPIT_SPACE_POSITION) { + returnPoint.y = COCKPIT_SPACE_POSITION + } + } else { + if (point.y > COCKPIT_SPACE_POSITION + COCKPIT_SPACE_HEIGHT / 2) { + returnPoint.y = COCKPIT_SPACE_POSITION + COCKPIT_SPACE_HEIGHT / 2 + } } if (point.y < 0) { From 401077f99ccfa34bb5c091d78c13aa0c2c6dece7 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 8 Jan 2020 19:48:55 +0100 Subject: [PATCH 055/264] Scales moving smoothly while with mouse over --- ChartsSpace/TimeMachine.js | 27 ++++++++++++++++++---- ChartsSpace/TimelineChart.js | 43 ++++++++++++++++++++++-------------- 2 files changed, 49 insertions(+), 21 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index bc96d5c07..c1ab3487f 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -46,6 +46,8 @@ function newTimeMachine () { let onMouseNotOverEventSuscriptionId let timeScaleEventSuscriptionId let rateScaleEventSuscriptionId + let timeScaleMouseOverEventSuscriptionId + let rateScaleMouseOverEventSuscriptionId setupContainer() return thisObject @@ -66,6 +68,8 @@ function newTimeMachine () { thisObject.rateScale.container.eventHandler.stopListening(rateScaleEventSuscriptionId) thisObject.container.eventHandler.stopListening(onMouseOverEventSuscriptionId) thisObject.container.eventHandler.stopListening(onMouseNotOverEventSuscriptionId) + thisObject.timeScale.container.eventHandler.stopListening(timeScaleMouseOverEventSuscriptionId) + thisObject.rateScale.container.eventHandler.stopListening(rateScaleMouseOverEventSuscriptionId) for (let i = 0; i < thisObject.timelineCharts.length; i++) { let chart = thisObject.timelineCharts[i] @@ -138,14 +142,29 @@ function newTimeMachine () { thisObject.rateScale.visible = false } + timeScaleMouseOverEventSuscriptionId = thisObject.timeScale.container.eventHandler.listenToEvent('onMouseOver', timeScaleMouseOver) + + function timeScaleMouseOver (event) { + thisObject.rateScale.visible = false + mouse.position.x = event.x + mouse.position.y = event.y + } + + rateScaleMouseOverEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('onMouseOver', rateScaleMouseOver) + + function rateScaleMouseOver (event) { + thisObject.timeScale.visible = false + mouse.position.x = event.x + mouse.position.y = event.y + } callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) } function getContainer (point, purpose) { let container - if (thisObject.timeScale !== undefined) { - container = thisObject.timeScale.getContainer(point) + if (thisObject.rateScale !== undefined) { + container = thisObject.rateScale.getContainer(point) if (container !== undefined) { if (container.isForThisPurpose(purpose)) { return container @@ -153,8 +172,8 @@ function newTimeMachine () { } } - if (thisObject.rateScale !== undefined) { - container = thisObject.rateScale.getContainer(point) + if (thisObject.timeScale !== undefined) { + container = thisObject.timeScale.getContainer(point) if (container !== undefined) { if (container.isForThisPurpose(purpose)) { return container diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 21cb8b82e..5bbdeb563 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -51,6 +51,7 @@ function newTimelineChart () { let onMouseOverEventSuscriptionId let onMouseNotOverEventSuscriptionId let timeFrameScaleEventSuscriptionId + let timeFrameScaleMouseOverEventSuscriptionId let mouse = { position: { @@ -74,6 +75,7 @@ function newTimelineChart () { thisObject.container.eventHandler.stopListening(onMouseOverEventSuscriptionId) thisObject.container.eventHandler.stopListening(onMouseNotOverEventSuscriptionId) thisObject.timeFrameScale.container.eventHandler.stopListening(timeFrameScaleEventSuscriptionId) + thisObject.timeFrameScale.container.eventHandler.stopListening(timeFrameScaleMouseOverEventSuscriptionId) plotterManager.finalize() plotterManager = undefined @@ -94,23 +96,6 @@ function newTimelineChart () { market = pMarket timeLineCoordinateSystem = pTimeLineCoordinateSystem - onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) - - function onMouseOver (event) { - thisObject.timeFrameScale.visible = true - - mouse.position.x = event.x - mouse.position.y = event.y - - saveUserPosition(thisObject.container, timeLineCoordinateSystem, event) - } - - onMouseNotOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) - - function onMouseNotOver (event) { - thisObject.timeFrameScale.visible = false - } - let panelOwner = exchange + ' ' + market.quotedAsset + '/' + market.baseAsset productsPanelHandle = canvas.panelsSpace.createNewPanel('Products Panel', undefined, panelOwner) let productsPanel = canvas.panelsSpace.getPanel(productsPanelHandle, panelOwner) @@ -192,6 +177,30 @@ function newTimelineChart () { thisObject.timeFrameScale.initialize() + onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) + + function onMouseOver (event) { + thisObject.timeFrameScale.visible = true + + mouse.position.x = event.x + mouse.position.y = event.y + + saveUserPosition(thisObject.container, timeLineCoordinateSystem, event) + } + + onMouseNotOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) + + function onMouseNotOver (event) { + thisObject.timeFrameScale.visible = false + } + + timeFrameScaleMouseOverEventSuscriptionId = thisObject.timeFrameScale.container.eventHandler.listenToEvent('onMouseOver', timeFrameScaleMouseOver) + + function timeFrameScaleMouseOver (event) { + mouse.position.x = event.x + mouse.position.y = event.y + } + initializationReady = true callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) return From ef34ee96c928a563eab1d8a882be379a190aed0d Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 8 Jan 2020 20:36:07 +0100 Subject: [PATCH 056/264] Scales totally working within container --- ChartsSpace/TimeMachine.js | 27 +++++++++++++++++++++++++++ ChartsSpace/TimelineChart.js | 19 +++++++++++++++++++ Scales/RateScale.js | 2 +- Scales/TimeFrameScale.js | 2 +- Scales/TimeScale.js | 2 +- 5 files changed, 49 insertions(+), 3 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index c1ab3487f..977f587cd 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -296,6 +296,21 @@ function newTimeMachine () { chart.physics() } + /* Container Limits */ + + let upCorner = { + x: 0, + y: 0 + } + + let bottonCorner = { + x: thisObject.container.frame.width, + y: thisObject.container.frame.height + } + + upCorner = transformThisPoint(upCorner, thisObject.container) + bottonCorner = transformThisPoint(bottonCorner, thisObject.container) + /* Mouse Position Date Calculation */ let timePoint = { @@ -329,6 +344,12 @@ function newTimeMachine () { timePoint.x = mouse.position.x - thisObject.timeScale.container.frame.width / 2 timePoint = thisObject.container.fitFunction(timePoint) + /* Checking against the container limits. */ + if (timePoint.x < upCorner.x) { timePoint.x = upCorner.x } + if (timePoint.x + thisObject.timeScale.container.frame.width > bottonCorner.x) { timePoint.x = bottonCorner.x - thisObject.timeScale.container.frame.width } + if (timePoint.y < upCorner.y) { timePoint.y = upCorner.y } + if (timePoint.y + thisObject.timeScale.container.frame.height > bottonCorner.y) { timePoint.y = bottonCorner.y - thisObject.timeScale.container.frame.height } + thisObject.timeScale.container.frame.position.x = timePoint.x thisObject.timeScale.container.frame.position.y = timePoint.y @@ -343,6 +364,12 @@ function newTimeMachine () { ratePoint.y = mouse.position.y - thisObject.rateScale.container.frame.height / 2 + thisObject.rateScale.container.frame.height ratePoint = thisObject.container.fitFunction(ratePoint, true) + /* Checking against the container limits. */ + if (ratePoint.x < upCorner.x) { ratePoint.x = upCorner.x } + if (ratePoint.x + thisObject.rateScale.container.frame.width > bottonCorner.x) { ratePoint.x = bottonCorner.x } + if (ratePoint.y < upCorner.y + thisObject.rateScale.container.frame.height) { ratePoint.y = upCorner.y + thisObject.rateScale.container.frame.height } + if (ratePoint.y > bottonCorner.y) { ratePoint.y = bottonCorner.y } + thisObject.rateScale.container.frame.position.y = ratePoint.y - thisObject.rateScale.container.frame.height thisObject.rateScale.container.frame.position.x = ratePoint.x - thisObject.rateScale.container.frame.width } diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 5bbdeb563..717197973 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -286,6 +286,21 @@ function newTimelineChart () { thisObject.timeFrameScale.physics() + /* Container Limits */ + + let upCorner = { + x: 0, + y: 0 + } + + let bottonCorner = { + x: thisObject.container.frame.width, + y: thisObject.container.frame.height + } + + upCorner = transformThisPoint(upCorner, thisObject.container) + bottonCorner = transformThisPoint(bottonCorner, thisObject.container) + /* thisObject.timeFrameScale Positioning */ timePoint = { @@ -297,6 +312,10 @@ function newTimelineChart () { timePoint.x = mouse.position.x - thisObject.timeFrameScale.container.frame.width / 2 timePoint = thisObject.container.fitFunction(timePoint, true) + /* Checking against the container limits. */ + if (timePoint.x < upCorner.x) { timePoint.x = upCorner.x } + if (timePoint.x + thisObject.timeFrameScale.container.frame.width > bottonCorner.x) { timePoint.x = bottonCorner.x - thisObject.timeFrameScale.container.frame.width } + thisObject.timeFrameScale.container.frame.position.x = timePoint.x thisObject.timeFrameScale.container.frame.position.y = timePoint.y - thisObject.timeFrameScale.container.frame.height } diff --git a/Scales/RateScale.js b/Scales/RateScale.js index eb83d9d01..d2db7ffe5 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -27,7 +27,7 @@ function newRateScale () { thisObject.container.detectMouseOver = true thisObject.container.frame.width = 190 - thisObject.container.frame.height = 25 + thisObject.container.frame.height = 30 let isMouseOver diff --git a/Scales/TimeFrameScale.js b/Scales/TimeFrameScale.js index f9442c203..87d3cfde3 100644 --- a/Scales/TimeFrameScale.js +++ b/Scales/TimeFrameScale.js @@ -40,7 +40,7 @@ function newTimeFrameScale () { thisObject.container.detectMouseOver = true thisObject.container.frame.width = 190 - thisObject.container.frame.height = 25 + thisObject.container.frame.height = 30 } function finalize () { diff --git a/Scales/TimeScale.js b/Scales/TimeScale.js index f70cbcbe9..9bcae12e8 100644 --- a/Scales/TimeScale.js +++ b/Scales/TimeScale.js @@ -27,7 +27,7 @@ function newTimeScale () { thisObject.container.detectMouseOver = true thisObject.container.frame.width = 190 - thisObject.container.frame.height = 25 + thisObject.container.frame.height = 30 let isMouseOver From 26d996101f72d39773b8f49bdd47fa4fda50d00b Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 8 Jan 2020 21:01:46 +0100 Subject: [PATCH 057/264] Bug Fixed --- ChartsSpace/TimeMachine.js | 8 ++------ ChartsSpace/TimelineChart.js | 2 ++ ChartsSpace/ViewPort.js | 4 ++-- Scales/TimeScale.js | 3 +-- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 977f587cd..b081be5de 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -145,17 +145,13 @@ function newTimeMachine () { timeScaleMouseOverEventSuscriptionId = thisObject.timeScale.container.eventHandler.listenToEvent('onMouseOver', timeScaleMouseOver) function timeScaleMouseOver (event) { - thisObject.rateScale.visible = false - mouse.position.x = event.x - mouse.position.y = event.y + thisObject.container.eventHandler.raiseEvent('onMouseOver', event) } rateScaleMouseOverEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('onMouseOver', rateScaleMouseOver) function rateScaleMouseOver (event) { - thisObject.timeScale.visible = false - mouse.position.x = event.x - mouse.position.y = event.y + thisObject.container.eventHandler.raiseEvent('onMouseOver', event) } callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) } diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 717197973..e00652db6 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -199,6 +199,8 @@ function newTimelineChart () { function timeFrameScaleMouseOver (event) { mouse.position.x = event.x mouse.position.y = event.y + + saveUserPosition(thisObject.container, timeLineCoordinateSystem, event) } initializationReady = true diff --git a/ChartsSpace/ViewPort.js b/ChartsSpace/ViewPort.js index 1e14c8d18..e9738b66f 100644 --- a/ChartsSpace/ViewPort.js +++ b/ChartsSpace/ViewPort.js @@ -12,7 +12,7 @@ function newViewPort () { let ANIMATION_INCREMENT = 0.25 let TOP_MARGIN = 30 + TOP_SPACE_HEIGHT - let BOTTOM_MARGIN = 30 + COCKPIT_SPACE_HEIGHT + let BOTTOM_MARGIN = 32 + COCKPIT_SPACE_HEIGHT let LEFT_MARGIN = 50 let RIGHT_MARGIN = 50 let MARGINS = { @@ -83,7 +83,7 @@ function newViewPort () { function resize () { TOP_MARGIN = 30 + TOP_SPACE_HEIGHT - BOTTOM_MARGIN = 30 + browserCanvas.height - COCKPIT_SPACE_POSITION + BOTTOM_MARGIN = 32 + browserCanvas.height - COCKPIT_SPACE_POSITION LEFT_MARGIN = 0 RIGHT_MARGIN = 0 MARGINS = { diff --git a/Scales/TimeScale.js b/Scales/TimeScale.js index 9bcae12e8..fb7d75e33 100644 --- a/Scales/TimeScale.js +++ b/Scales/TimeScale.js @@ -15,8 +15,7 @@ function newTimeScale () { } const LENGHT_PERCENTAGE_DEFAULT_VALUE = 5 - const STEP_SIZE = 5 - const MIN_HEIGHT = 50 + const STEP_SIZE = 2.5 thisObject.container = newContainer() thisObject.container.initialize(MODULE_NAME) From 33a203f4c67fcfb724ba3905ab70d0f71fab2cf2 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 9 Jan 2020 11:10:14 +0100 Subject: [PATCH 058/264] Automatically ordering panels working --- Frame.js | 4 +- Spaces/PanelsSpace.js | 116 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+), 1 deletion(-) diff --git a/Frame.js b/Frame.js index ac1b216f8..943a18a25 100644 --- a/Frame.js +++ b/Frame.js @@ -201,7 +201,9 @@ function newFrame () { y: thisObject.position.y } - thisPoint = thisObject.parentFrame.frameThisPoint(thisPoint) + if (thisObject.parentFrame !== undefined) { + thisPoint = thisObject.parentFrame.frameThisPoint(thisPoint) + } /* Now we check if the resulting point is whin the current Frame. */ diff --git a/Spaces/PanelsSpace.js b/Spaces/PanelsSpace.js index f312770ee..f3a6f5c35 100644 --- a/Spaces/PanelsSpace.js +++ b/Spaces/PanelsSpace.js @@ -110,6 +110,11 @@ function newPanelsSpace () { function physics () { if (thisObject.visible !== true) { return } + childrenPhysics() + positioningPhysics() + } + + function childrenPhysics () { if (thisObject.panels !== undefined) { for (let i = 0; i < thisObject.panels.length; i++) { let panel = thisObject.panels[i] @@ -120,6 +125,117 @@ function newPanelsSpace () { } } + function positioningPhysics () { + const INCREMENT = 0.5 + if (thisObject.panels !== undefined) { + for (let i = 0; i < thisObject.panels.length; i++) { + let panel = thisObject.panels[i] + + let centerPoint = { + x: panel.container.frame.position.x, + y: panel.container.frame.position.y + } + centerPoint.x = centerPoint.x + panel.container.frame.width / 2 + centerPoint.y = centerPoint.y + panel.container.frame.height / 2 + + /* Lets see which quadrant the panel is at */ + let centerVertical = (viewPort.visibleArea.topRight.x - viewPort.visibleArea.topLeft.x) / 2 + viewPort.visibleArea.topLeft.x + let centerHorizontal = (viewPort.visibleArea.bottomRight.y - viewPort.visibleArea.topRight.y) / 2 + viewPort.visibleArea.topRight.y + + /* According to the quadrant we push the panels to the sides */ + if (centerPoint.x < centerVertical) { + panel.container.frame.position.x = panel.container.frame.position.x - INCREMENT + if (isOverlapping(i, panel.container) === true) { + panel.container.frame.position.x = panel.container.frame.position.x + INCREMENT * 2 + } + if (panel.container.frame.position.x < viewPort.visibleArea.topLeft.x) { + panel.container.frame.position.x = viewPort.visibleArea.topLeft.x + } + } else { + panel.container.frame.position.x = panel.container.frame.position.x + INCREMENT + if (isOverlapping(i, panel.container) === true) { + panel.container.frame.position.x = panel.container.frame.position.x - INCREMENT * 2 + } + if (panel.container.frame.position.x + panel.container.frame.width > viewPort.visibleArea.topRight.x) { + panel.container.frame.position.x = viewPort.visibleArea.topRight.x - panel.container.frame.width + } + } + if (panel.container.frame.height <= viewPort.visibleArea.bottomRight.y - viewPort.visibleArea.topRight.y) { + if (centerPoint.y < centerHorizontal) { + panel.container.frame.position.y = panel.container.frame.position.y - INCREMENT + if (isOverlapping(i, panel.container) === true) { + panel.container.frame.position.y = panel.container.frame.position.y + INCREMENT * 2 + } + if (panel.container.frame.position.y < viewPort.visibleArea.topLeft.y) { + panel.container.frame.position.y = viewPort.visibleArea.topLeft.y + } + } else { + panel.container.frame.position.y = panel.container.frame.position.y + INCREMENT + if (isOverlapping(i, panel.container) === true) { + panel.container.frame.position.y = panel.container.frame.position.y - INCREMENT * 2 + } + if (panel.container.frame.position.y + panel.container.frame.height > viewPort.visibleArea.bottomRight.y) { + panel.container.frame.position.y = viewPort.visibleArea.bottomRight.y - panel.container.frame.height + } + } + } + } + } + + function isOverlapping (currentIndex, currentContainer) { + let corner1 = { + x: currentContainer.frame.position.x, + y: currentContainer.frame.position.y + } + let corner2 = { + x: currentContainer.frame.position.x + currentContainer.frame.width, + y: currentContainer.frame.position.y + } + let corner3 = { + x: currentContainer.frame.position.x + currentContainer.frame.width, + y: currentContainer.frame.position.y + currentContainer.frame.height + } + let corner4 = { + x: currentContainer.frame.position.x, + y: currentContainer.frame.position.y + currentContainer.frame.height + } + + for (let i = 0; i < currentIndex; i++) { + let panel = thisObject.panels[i] + + if (isThisPointInsideThisFrame(corner1, panel.container.frame) === true) { return true } + if (isThisPointInsideThisFrame(corner2, panel.container.frame) === true) { return true } + if (isThisPointInsideThisFrame(corner3, panel.container.frame) === true) { return true } + if (isThisPointInsideThisFrame(corner4, panel.container.frame) === true) { return true } + } + + function isThisPointInsideThisFrame (point, frame) { + let corner1 = { + x: frame.position.x, + y: frame.position.y + } + let corner2 = { + x: frame.position.x + frame.width, + y: frame.position.y + } + let corner3 = { + x: frame.position.x + frame.width, + y: frame.position.y + frame.height + } + let corner4 = { + x: frame.position.x, + y: frame.position.y + frame.height + } + if (point.x >= corner1.x && point.y >= corner1.y && point.x <= corner3.x && point.y <= corner3.y) { + return true + } else { + return false + } + } + return false + } + } + function draw () { if (thisObject.visible !== true) { return } From 5b9f6105a16e28c6924665905b6e20978b39d82e Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 9 Jan 2020 12:19:39 +0100 Subject: [PATCH 059/264] Dragging charts with 2nd button --- Canvas.js | 2 +- Spaces/PanelsSpace.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Canvas.js b/Canvas.js index 3ca616f1b..5f7f1125e 100644 --- a/Canvas.js +++ b/Canvas.js @@ -501,7 +501,7 @@ function newCanvas () { container = thisObject.chartSpace.getContainer(point) if (container !== undefined) { - if (container.isDraggeable === true) { + if (container.isDraggeable === true && event.button === 2) { containerBeingDragged = container containerDragStarted = true containerBeingDragged.eventHandler.raiseEvent('onDragStarted', point) diff --git a/Spaces/PanelsSpace.js b/Spaces/PanelsSpace.js index f3a6f5c35..ce0aa8a59 100644 --- a/Spaces/PanelsSpace.js +++ b/Spaces/PanelsSpace.js @@ -139,11 +139,11 @@ function newPanelsSpace () { centerPoint.y = centerPoint.y + panel.container.frame.height / 2 /* Lets see which quadrant the panel is at */ - let centerVertical = (viewPort.visibleArea.topRight.x - viewPort.visibleArea.topLeft.x) / 2 + viewPort.visibleArea.topLeft.x - let centerHorizontal = (viewPort.visibleArea.bottomRight.y - viewPort.visibleArea.topRight.y) / 2 + viewPort.visibleArea.topRight.y + let verticalLine = (viewPort.visibleArea.topRight.x - viewPort.visibleArea.topLeft.x) / 2 + viewPort.visibleArea.topLeft.x + let horizontalLine = (viewPort.visibleArea.bottomRight.y - viewPort.visibleArea.topRight.y) * 2 / 3 + viewPort.visibleArea.topRight.y /* According to the quadrant we push the panels to the sides */ - if (centerPoint.x < centerVertical) { + if (centerPoint.x < verticalLine) { panel.container.frame.position.x = panel.container.frame.position.x - INCREMENT if (isOverlapping(i, panel.container) === true) { panel.container.frame.position.x = panel.container.frame.position.x + INCREMENT * 2 @@ -161,7 +161,7 @@ function newPanelsSpace () { } } if (panel.container.frame.height <= viewPort.visibleArea.bottomRight.y - viewPort.visibleArea.topRight.y) { - if (centerPoint.y < centerHorizontal) { + if (centerPoint.y < horizontalLine) { panel.container.frame.position.y = panel.container.frame.position.y - INCREMENT if (isOverlapping(i, panel.container) === true) { panel.container.frame.position.y = panel.container.frame.position.y + INCREMENT * 2 From 88990cec27fb6b17c5bbcec32a7432427de2a10c Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 9 Jan 2020 13:21:32 +0100 Subject: [PATCH 060/264] Fine Tunning Opacity --- ChartsSpace/TimelineChart.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index e00652db6..3c4d95821 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -343,7 +343,7 @@ function newTimelineChart () { if (window.CHART_ON_FOCUS === '') { window.CHART_ON_FOCUS = exchange + ' ' + market.quotedAsset + '/' + market.baseAsset - drawChartsBackgroundImages() + // drawChartsBackgroundImages() } } } @@ -359,7 +359,7 @@ function newTimelineChart () { function drawChartsBackground () { /* We will paint some transparent background here. */ - let opacity = '0.9' + let opacity = '0.5' let fromPoint = { x: 0, From 041f7c90e0836ca0bfd9feefa245ad7986b13dc0 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 9 Jan 2020 14:52:15 +0100 Subject: [PATCH 061/264] No scale overlapping --- ChartsSpace/TimelineChart.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 3c4d95821..0041d623b 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -345,13 +345,13 @@ function newTimelineChart () { // drawChartsBackgroundImages() } + drawChartsBackground() + plotterManager.draw() } } function draw () { if (thisObject.container.frame.isInViewPort()) { - drawChartsBackground() - plotterManager.draw() thisObject.timeFrameScale.draw() } } From 027dea3441660b19d33fd514cb7a8687d6f602e5 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 9 Jan 2020 15:01:42 +0100 Subject: [PATCH 062/264] Code cleaning --- Canvas.js | 1 - ChartsSpace/TimeMachine.js | 18 ------------------ Scales/RateScale.js | 2 +- Scales/TimeFrameScale.js | 2 +- Scales/TimeScale.js | 2 +- Spaces/ChartSpace.js | 21 +++++++++------------ 6 files changed, 12 insertions(+), 34 deletions(-) diff --git a/Canvas.js b/Canvas.js index 5f7f1125e..b7f51fbbc 100644 --- a/Canvas.js +++ b/Canvas.js @@ -128,7 +128,6 @@ function newCanvas () { /* Spcaces Drawing */ animation.addCallBackFunction('Floating Space Draw', thisObject.floatingSpace.draw) - animation.addCallBackFunction('Chart Space Background', thisObject.chartSpace.drawBackground) animation.addCallBackFunction('Chart Space Draw', thisObject.chartSpace.draw) animation.addCallBackFunction('Panels Space', thisObject.panelsSpace.draw) animation.addCallBackFunction('ViewPort Animate', viewPort.animate) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index b081be5de..7343385d7 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -371,8 +371,6 @@ function newTimeMachine () { } function drawBackground () { - thisBackground() - if (thisObject.container.frame.isInViewPort()) { for (let i = 0; i < this.timelineCharts.length; i++) { let chart = this.timelineCharts[i] @@ -395,22 +393,6 @@ function newTimeMachine () { } } - function thisBackground () { - return - let params = { - cornerRadius: 15, - lineWidth: 5, - opacity: 1, - container: thisObject.container, - borderColor: UI_COLOR.RUSTED_RED, - backgroundColor: UI_COLOR.WHITE, - fitFunction: thisObject.fitFunction, - coordinateSystem: timeLineCoordinateSystem - } - - roundedCornersBackground(params) - } - function recalculateScale () { let minValue = { x: MIN_PLOTABLE_DATE.valueOf(), diff --git a/Scales/RateScale.js b/Scales/RateScale.js index d2db7ffe5..5158fe3b7 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -26,7 +26,7 @@ function newRateScale () { thisObject.container.isWheelable = true thisObject.container.detectMouseOver = true - thisObject.container.frame.width = 190 + thisObject.container.frame.width = 250 thisObject.container.frame.height = 30 let isMouseOver diff --git a/Scales/TimeFrameScale.js b/Scales/TimeFrameScale.js index 87d3cfde3..8f4d63f14 100644 --- a/Scales/TimeFrameScale.js +++ b/Scales/TimeFrameScale.js @@ -39,7 +39,7 @@ function newTimeFrameScale () { thisObject.container.isWheelable = true thisObject.container.detectMouseOver = true - thisObject.container.frame.width = 190 + thisObject.container.frame.width = 250 thisObject.container.frame.height = 30 } diff --git a/Scales/TimeScale.js b/Scales/TimeScale.js index fb7d75e33..689185e49 100644 --- a/Scales/TimeScale.js +++ b/Scales/TimeScale.js @@ -25,7 +25,7 @@ function newTimeScale () { thisObject.container.isWheelable = true thisObject.container.detectMouseOver = true - thisObject.container.frame.width = 190 + thisObject.container.frame.width = 250 thisObject.container.frame.height = 30 let isMouseOver diff --git a/Spaces/ChartSpace.js b/Spaces/ChartSpace.js index 2879666d3..85daf0772 100644 --- a/Spaces/ChartSpace.js +++ b/Spaces/ChartSpace.js @@ -23,7 +23,6 @@ function newChartSpace () { fitIntoVisibleArea: fitIntoVisibleArea, isThisPointVisible: isThisPointVisible, physics: physics, - drawBackground: drawBackground, draw: draw, getContainer: getContainer, // returns the inner most container that holds the point received by parameter. initialize: initialize, @@ -281,9 +280,17 @@ function newChartSpace () { } } - function drawBackground () { + function draw () { if (thisObject.visible !== true) { return } + drawBackground() + for (let i = 0; i < thisObject.timeMachines.length; i++) { + let timeMachine = thisObject.timeMachines[thisObject.timeMachines.length - i - 1] + timeMachine.draw() + } + } + + function drawBackground () { drawSpaceBackground() for (let i = 0; i < thisObject.timeMachines.length; i++) { @@ -291,7 +298,6 @@ function newChartSpace () { timeMachine.drawBackground() } } - function drawSpaceBackground () { let opacity = '1' let fromPoint = { @@ -310,13 +316,4 @@ function newChartSpace () { browserCanvasContext.closePath() browserCanvasContext.fill() } - - function draw () { - if (thisObject.visible !== true) { return } - - for (let i = 0; i < thisObject.timeMachines.length; i++) { - let timeMachine = thisObject.timeMachines[thisObject.timeMachines.length - i - 1] - timeMachine.draw() - } - } } From 85d253ba5a2dd207b34581ce1acf67dbe21446c9 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 9 Jan 2020 15:21:30 +0100 Subject: [PATCH 063/264] scales exists if scale nodes exists --- ChartsSpace/TimeMachine.js | 189 ++++++++++++++++++++--------------- ChartsSpace/TimelineChart.js | 2 + Spaces/ChartSpace.js | 1 - 3 files changed, 110 insertions(+), 82 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 7343385d7..1c74723fd 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -19,6 +19,7 @@ function newTimeMachine () { timeScale: undefined, rateScale: undefined, fitFunction: undefined, + payload: undefined, timelineCharts: [], physics: physics, drawBackground: drawBackground, @@ -64,12 +65,18 @@ function newTimeMachine () { } function finalize () { - thisObject.timeScale.container.eventHandler.stopListening(timeScaleEventSuscriptionId) - thisObject.rateScale.container.eventHandler.stopListening(rateScaleEventSuscriptionId) + if (thisObject.timeScale !== undefined) { + thisObject.timeScale.container.eventHandler.stopListening(timeScaleEventSuscriptionId) + thisObject.timeScale.container.eventHandler.stopListening(timeScaleMouseOverEventSuscriptionId) + } + + if (thisObject.rateScale !== undefined) { + thisObject.rateScale.container.eventHandler.stopListening(rateScaleEventSuscriptionId) + thisObject.rateScale.container.eventHandler.stopListening(rateScaleMouseOverEventSuscriptionId) + } + thisObject.container.eventHandler.stopListening(onMouseOverEventSuscriptionId) thisObject.container.eventHandler.stopListening(onMouseNotOverEventSuscriptionId) - thisObject.timeScale.container.eventHandler.stopListening(timeScaleMouseOverEventSuscriptionId) - thisObject.rateScale.container.eventHandler.stopListening(rateScaleMouseOverEventSuscriptionId) for (let i = 0; i < thisObject.timelineCharts.length; i++) { let chart = thisObject.timelineCharts[i] @@ -93,6 +100,7 @@ function newTimeMachine () { thisObject.container.finalize() thisObject.container = undefined + thisObject.payload = undefined mouse = undefined } @@ -101,35 +109,43 @@ function newTimeMachine () { /* Each Time Machine has a Time Scale and a Right Scale. */ - thisObject.timeScale = newTimeScale() - thisObject.timeScale.fitFunction = thisObject.fitFunction + if (thisObject.payload.node.timeScale !== undefined) { + thisObject.timeScale = newTimeScale() + thisObject.timeScale.fitFunction = thisObject.fitFunction - timeScaleEventSuscriptionId = thisObject.timeScale.container.eventHandler.listenToEvent('Lenght Percentage Changed', function (event) { - thisObject.container.frame.width = TIME_MACHINE_WIDTH * event.lenghtPercentage / 100 - recalculateScale() - moveToUserPosition(thisObject.container, timeLineCoordinateSystem, false, true, event.mousePosition, false, true) - thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) - }) + timeScaleEventSuscriptionId = thisObject.timeScale.container.eventHandler.listenToEvent('Lenght Percentage Changed', function (event) { + thisObject.container.frame.width = TIME_MACHINE_WIDTH * event.lenghtPercentage / 100 + recalculateScale() + moveToUserPosition(thisObject.container, timeLineCoordinateSystem, false, true, event.mousePosition, false, true) + thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) + }) - thisObject.timeScale.initialize() + thisObject.timeScale.initialize() + } - thisObject.rateScale = newRateScale() - thisObject.rateScale.fitFunction = thisObject.fitFunction + if (thisObject.payload.node.rateScale !== undefined) { + thisObject.rateScale = newRateScale() + thisObject.rateScale.fitFunction = thisObject.fitFunction - rateScaleEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('Height Percentage Changed', function (event) { - thisObject.container.frame.height = TIME_MACHINE_HEIGHT * event.heightPercentage / 100 - recalculateScale() - moveToUserPosition(thisObject.container, timeLineCoordinateSystem, true, false, event.mousePosition, false, true) - thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) - }) + rateScaleEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('Height Percentage Changed', function (event) { + thisObject.container.frame.height = TIME_MACHINE_HEIGHT * event.heightPercentage / 100 + recalculateScale() + moveToUserPosition(thisObject.container, timeLineCoordinateSystem, true, false, event.mousePosition, false, true) + thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) + }) - thisObject.rateScale.initialize() + thisObject.rateScale.initialize() + } onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) function onMouseOver (event) { - thisObject.timeScale.visible = true - thisObject.rateScale.visible = true + if (thisObject.timeScale !== undefined) { + thisObject.timeScale.visible = true + } + if (thisObject.rateScale !== undefined) { + thisObject.rateScale.visible = true + } mouse.position.x = event.x mouse.position.y = event.y @@ -138,20 +154,28 @@ function newTimeMachine () { onMouseNotOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) function onMouseNotOver (event) { - thisObject.timeScale.visible = false - thisObject.rateScale.visible = false + if (thisObject.timeScale !== undefined) { + thisObject.timeScale.visible = false + } + if (thisObject.rateScale !== undefined) { + thisObject.rateScale.visible = false + } } - timeScaleMouseOverEventSuscriptionId = thisObject.timeScale.container.eventHandler.listenToEvent('onMouseOver', timeScaleMouseOver) + if (thisObject.timeScale !== undefined) { + timeScaleMouseOverEventSuscriptionId = thisObject.timeScale.container.eventHandler.listenToEvent('onMouseOver', timeScaleMouseOver) - function timeScaleMouseOver (event) { - thisObject.container.eventHandler.raiseEvent('onMouseOver', event) + function timeScaleMouseOver (event) { + thisObject.container.eventHandler.raiseEvent('onMouseOver', event) + } } - rateScaleMouseOverEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('onMouseOver', rateScaleMouseOver) + if (thisObject.rateScale !== undefined) { + rateScaleMouseOverEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('onMouseOver', rateScaleMouseOver) - function rateScaleMouseOver (event) { - thisObject.container.eventHandler.raiseEvent('onMouseOver', event) + function rateScaleMouseOver (event) { + thisObject.container.eventHandler.raiseEvent('onMouseOver', event) + } } callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) } @@ -232,7 +256,6 @@ function newTimeMachine () { /* Must be removed */ timelineChart.finalize() timelineChartsMap.delete(timelineChart.nodeId) - timelineChart.payload = undefined thisObject.timelineCharts.splice(i, 1) /* We remove one at the time */ return @@ -281,11 +304,12 @@ function newTimeMachine () { } function childrenPhysics () { - if (thisObject.timeScale === undefined) { return } - if (thisObject.rateScale === undefined) { return } - - thisObject.timeScale.physics() - thisObject.rateScale.physics() + if (thisObject.timeScale !== undefined) { + thisObject.timeScale.physics() + } + if (thisObject.rateScale === undefined) { + thisObject.rateScale.physics() + } for (let i = 0; i < thisObject.timelineCharts.length; i++) { let chart = thisObject.timelineCharts[i] @@ -308,66 +332,69 @@ function newTimeMachine () { bottonCorner = transformThisPoint(bottonCorner, thisObject.container) /* Mouse Position Date Calculation */ + if (thisObject.timeScale !== undefined) { + let timePoint = { + x: mouse.position.x, + y: 0 + } - let timePoint = { - x: mouse.position.x, - y: 0 + let mouseDate = getDateFromPoint(timePoint, thisObject.container, timeLineCoordinateSystem) + + thisObject.timeScale.date = new Date(mouseDate) } - let mouseDate = getDateFromPoint(timePoint, thisObject.container, timeLineCoordinateSystem) - - thisObject.timeScale.date = new Date(mouseDate) - /* Mouse Position Rate Calculation */ + if (thisObject.rateScale === undefined) { + let ratePoint = { + x: 0, + y: mouse.position.y + } - let ratePoint = { - x: 0, - y: mouse.position.y + let mouseRate = getRateFromPoint(ratePoint, thisObject.container, timeLineCoordinateSystem) + + thisObject.rateScale.rate = mouseRate } - let mouseRate = getRateFromPoint(ratePoint, thisObject.container, timeLineCoordinateSystem) - - thisObject.rateScale.rate = mouseRate - /* timeScale Positioning */ + if (thisObject.timeScale !== undefined) { + timePoint = { + x: 0, + y: 0 + } - timePoint = { - x: 0, - y: 0 - } - - timePoint = transformThisPoint(timePoint, thisObject.container.frame.container) - timePoint.x = mouse.position.x - thisObject.timeScale.container.frame.width / 2 - timePoint = thisObject.container.fitFunction(timePoint) + timePoint = transformThisPoint(timePoint, thisObject.container.frame.container) + timePoint.x = mouse.position.x - thisObject.timeScale.container.frame.width / 2 + timePoint = thisObject.container.fitFunction(timePoint) /* Checking against the container limits. */ - if (timePoint.x < upCorner.x) { timePoint.x = upCorner.x } - if (timePoint.x + thisObject.timeScale.container.frame.width > bottonCorner.x) { timePoint.x = bottonCorner.x - thisObject.timeScale.container.frame.width } - if (timePoint.y < upCorner.y) { timePoint.y = upCorner.y } - if (timePoint.y + thisObject.timeScale.container.frame.height > bottonCorner.y) { timePoint.y = bottonCorner.y - thisObject.timeScale.container.frame.height } - - thisObject.timeScale.container.frame.position.x = timePoint.x - thisObject.timeScale.container.frame.position.y = timePoint.y + if (timePoint.x < upCorner.x) { timePoint.x = upCorner.x } + if (timePoint.x + thisObject.timeScale.container.frame.width > bottonCorner.x) { timePoint.x = bottonCorner.x - thisObject.timeScale.container.frame.width } + if (timePoint.y < upCorner.y) { timePoint.y = upCorner.y } + if (timePoint.y + thisObject.timeScale.container.frame.height > bottonCorner.y) { timePoint.y = bottonCorner.y - thisObject.timeScale.container.frame.height } + thisObject.timeScale.container.frame.position.x = timePoint.x + thisObject.timeScale.container.frame.position.y = timePoint.y + } /* rateScale Positioning */ + if (thisObject.rateScale === undefined) { + ratePoint = { + x: thisObject.container.frame.width, + y: 0 + } - ratePoint = { - x: thisObject.container.frame.width, - y: 0 - } - - ratePoint = transformThisPoint(ratePoint, thisObject.container.frame.container) - ratePoint.y = mouse.position.y - thisObject.rateScale.container.frame.height / 2 + thisObject.rateScale.container.frame.height - ratePoint = thisObject.container.fitFunction(ratePoint, true) + ratePoint = transformThisPoint(ratePoint, thisObject.container.frame.container) + ratePoint.y = mouse.position.y - thisObject.rateScale.container.frame.height / 2 + thisObject.rateScale.container.frame.height + ratePoint = thisObject.container.fitFunction(ratePoint, true) /* Checking against the container limits. */ - if (ratePoint.x < upCorner.x) { ratePoint.x = upCorner.x } - if (ratePoint.x + thisObject.rateScale.container.frame.width > bottonCorner.x) { ratePoint.x = bottonCorner.x } - if (ratePoint.y < upCorner.y + thisObject.rateScale.container.frame.height) { ratePoint.y = upCorner.y + thisObject.rateScale.container.frame.height } - if (ratePoint.y > bottonCorner.y) { ratePoint.y = bottonCorner.y } + if (ratePoint.x < upCorner.x) { ratePoint.x = upCorner.x } + if (ratePoint.x + thisObject.rateScale.container.frame.width > bottonCorner.x) { ratePoint.x = bottonCorner.x } + if (ratePoint.y < upCorner.y + thisObject.rateScale.container.frame.height) { ratePoint.y = upCorner.y + thisObject.rateScale.container.frame.height } + if (ratePoint.y > bottonCorner.y) { ratePoint.y = bottonCorner.y } - thisObject.rateScale.container.frame.position.y = ratePoint.y - thisObject.rateScale.container.frame.height - thisObject.rateScale.container.frame.position.x = ratePoint.x - thisObject.rateScale.container.frame.width + thisObject.rateScale.container.frame.position.y = ratePoint.y - thisObject.rateScale.container.frame.height + thisObject.rateScale.container.frame.position.x = ratePoint.x - thisObject.rateScale.container.frame.width + } } function drawBackground () { diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 0041d623b..9484881e3 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -15,6 +15,7 @@ function newTimelineChart () { container: undefined, fitFunction: undefined, timeFrameScale: undefined, + payload: undefined, physics: physics, setDatetime: setDatetime, drawBackground: drawBackground, @@ -86,6 +87,7 @@ function newTimelineChart () { thisObject.container.finalize() thisObject.container = undefined + thisObject.payload = undefined mouse = undefined } diff --git a/Spaces/ChartSpace.js b/Spaces/ChartSpace.js index 85daf0772..77910bd17 100644 --- a/Spaces/ChartSpace.js +++ b/Spaces/ChartSpace.js @@ -226,7 +226,6 @@ function newChartSpace () { /* Must be removed */ timeMachine.finalize() timeMachinesMap.delete(timeMachine.nodeId) - timeMachine.payload = undefined thisObject.timeMachines.splice(i, 1) /* We remove one at the time */ return From 418375bfce728d5bc80fe8ddb01d48f1c1718e42 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 9 Jan 2020 15:56:04 +0100 Subject: [PATCH 064/264] attach detach timeScale and rateScale --- ChartsSpace/TimeMachine.js | 140 +++++++++++++++++++++---------------- 1 file changed, 79 insertions(+), 61 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 1c74723fd..31a68c6fa 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -66,13 +66,11 @@ function newTimeMachine () { function finalize () { if (thisObject.timeScale !== undefined) { - thisObject.timeScale.container.eventHandler.stopListening(timeScaleEventSuscriptionId) - thisObject.timeScale.container.eventHandler.stopListening(timeScaleMouseOverEventSuscriptionId) + finalizeTimeScale() } if (thisObject.rateScale !== undefined) { - thisObject.rateScale.container.eventHandler.stopListening(rateScaleEventSuscriptionId) - thisObject.rateScale.container.eventHandler.stopListening(rateScaleMouseOverEventSuscriptionId) + finalizeRateScale() } thisObject.container.eventHandler.stopListening(onMouseOverEventSuscriptionId) @@ -86,15 +84,6 @@ function newTimeMachine () { thisObject.timelineCharts = undefined timelineChartsMap = undefined - if (thisObject.timeScale !== undefined) { - thisObject.timeScale.finalize() - thisObject.timeScale = undefined - } - if (thisObject.rateScale !== undefined) { - thisObject.rateScale.finalize() - thisObject.rateScale = undefined - } - thisObject.fitFunction = undefined thisObject.container.finalize() @@ -104,39 +93,23 @@ function newTimeMachine () { mouse = undefined } + function finalizeTimeScale () { + thisObject.timeScale.container.eventHandler.stopListening(timeScaleEventSuscriptionId) + thisObject.timeScale.container.eventHandler.stopListening(timeScaleMouseOverEventSuscriptionId) + thisObject.timeScale.finalize() + thisObject.timeScale = undefined + } + + function finalizeRateScale () { + thisObject.rateScale.container.eventHandler.stopListening(rateScaleEventSuscriptionId) + thisObject.rateScale.container.eventHandler.stopListening(rateScaleMouseOverEventSuscriptionId) + thisObject.rateScale.finalize() + thisObject.rateScale = undefined + } + function initialize (callBackFunction) { recalculateScale() - /* Each Time Machine has a Time Scale and a Right Scale. */ - - if (thisObject.payload.node.timeScale !== undefined) { - thisObject.timeScale = newTimeScale() - thisObject.timeScale.fitFunction = thisObject.fitFunction - - timeScaleEventSuscriptionId = thisObject.timeScale.container.eventHandler.listenToEvent('Lenght Percentage Changed', function (event) { - thisObject.container.frame.width = TIME_MACHINE_WIDTH * event.lenghtPercentage / 100 - recalculateScale() - moveToUserPosition(thisObject.container, timeLineCoordinateSystem, false, true, event.mousePosition, false, true) - thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) - }) - - thisObject.timeScale.initialize() - } - - if (thisObject.payload.node.rateScale !== undefined) { - thisObject.rateScale = newRateScale() - thisObject.rateScale.fitFunction = thisObject.fitFunction - - rateScaleEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('Height Percentage Changed', function (event) { - thisObject.container.frame.height = TIME_MACHINE_HEIGHT * event.heightPercentage / 100 - recalculateScale() - moveToUserPosition(thisObject.container, timeLineCoordinateSystem, true, false, event.mousePosition, false, true) - thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) - }) - - thisObject.rateScale.initialize() - } - onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) function onMouseOver (event) { @@ -162,24 +135,49 @@ function newTimeMachine () { } } - if (thisObject.timeScale !== undefined) { - timeScaleMouseOverEventSuscriptionId = thisObject.timeScale.container.eventHandler.listenToEvent('onMouseOver', timeScaleMouseOver) - - function timeScaleMouseOver (event) { - thisObject.container.eventHandler.raiseEvent('onMouseOver', event) - } - } - - if (thisObject.rateScale !== undefined) { - rateScaleMouseOverEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('onMouseOver', rateScaleMouseOver) - - function rateScaleMouseOver (event) { - thisObject.container.eventHandler.raiseEvent('onMouseOver', event) - } - } callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) } + function initializeTimeScale () { + thisObject.timeScale = newTimeScale() + thisObject.timeScale.fitFunction = thisObject.fitFunction + + timeScaleEventSuscriptionId = thisObject.timeScale.container.eventHandler.listenToEvent('Lenght Percentage Changed', function (event) { + thisObject.container.frame.width = TIME_MACHINE_WIDTH * event.lenghtPercentage / 100 + recalculateScale() + moveToUserPosition(thisObject.container, timeLineCoordinateSystem, false, true, event.mousePosition, false, true) + thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) + }) + + thisObject.timeScale.initialize() + + timeScaleMouseOverEventSuscriptionId = thisObject.timeScale.container.eventHandler.listenToEvent('onMouseOver', timeScaleMouseOver) + + function timeScaleMouseOver (event) { + thisObject.container.eventHandler.raiseEvent('onMouseOver', event) + } + } + + function initializeRateScale () { + thisObject.rateScale = newRateScale() + thisObject.rateScale.fitFunction = thisObject.fitFunction + + rateScaleEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('Height Percentage Changed', function (event) { + thisObject.container.frame.height = TIME_MACHINE_HEIGHT * event.heightPercentage / 100 + recalculateScale() + moveToUserPosition(thisObject.container, timeLineCoordinateSystem, true, false, event.mousePosition, false, true) + thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) + }) + + thisObject.rateScale.initialize() + + rateScaleMouseOverEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('onMouseOver', rateScaleMouseOver) + + function rateScaleMouseOver (event) { + thisObject.container.eventHandler.raiseEvent('onMouseOver', event) + } + } + function getContainer (point, purpose) { let container @@ -235,6 +233,26 @@ function newTimeMachine () { } function syncWithDesigner () { + syncWithDesignerTimelineCharts() + syncWithDesignerScales() + } + + function syncWithDesignerScales () { + if (thisObject.payload.node.timeScale === undefined && thisObject.timeScale !== undefined) { + finalizeTimeScale() + } + if (thisObject.payload.node.timeScale !== undefined && thisObject.timeScale === undefined) { + initializeTimeScale() + } + if (thisObject.payload.node.rateScale === undefined && thisObject.rateScale !== undefined) { + finalizeRateScale() + } + if (thisObject.payload.node.rateScale !== undefined && thisObject.rateScale === undefined) { + initializeRateScale() + } + } + + function syncWithDesignerTimelineCharts () { syncWithDesignerLoop = syncWithDesignerLoop + 0.00000000001 for (let j = 0; j < thisObject.payload.node.timelineCharts.length; j++) { @@ -307,7 +325,7 @@ function newTimeMachine () { if (thisObject.timeScale !== undefined) { thisObject.timeScale.physics() } - if (thisObject.rateScale === undefined) { + if (thisObject.rateScale !== undefined) { thisObject.rateScale.physics() } @@ -344,7 +362,7 @@ function newTimeMachine () { } /* Mouse Position Rate Calculation */ - if (thisObject.rateScale === undefined) { + if (thisObject.rateScale !== undefined) { let ratePoint = { x: 0, y: mouse.position.y @@ -376,7 +394,7 @@ function newTimeMachine () { thisObject.timeScale.container.frame.position.y = timePoint.y } /* rateScale Positioning */ - if (thisObject.rateScale === undefined) { + if (thisObject.rateScale !== undefined) { ratePoint = { x: thisObject.container.frame.width, y: 0 From 39be1eaffa9083dffa0ea5d59b36bae0f40dae40 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 9 Jan 2020 20:18:25 +0100 Subject: [PATCH 065/264] payload ready at scales --- ChartsSpace/TimeMachine.js | 2 + ChartsSpace/TimelineChart.js | 328 ++++++++--------------------------- Scales/RateScale.js | 4 +- Scales/TimeFrameScale.js | 4 +- Scales/TimeScale.js | 4 +- 5 files changed, 86 insertions(+), 256 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 31a68c6fa..0993b62f2 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -141,6 +141,7 @@ function newTimeMachine () { function initializeTimeScale () { thisObject.timeScale = newTimeScale() thisObject.timeScale.fitFunction = thisObject.fitFunction + thisObject.timeScale.payload = thisObject.payload timeScaleEventSuscriptionId = thisObject.timeScale.container.eventHandler.listenToEvent('Lenght Percentage Changed', function (event) { thisObject.container.frame.width = TIME_MACHINE_WIDTH * event.lenghtPercentage / 100 @@ -161,6 +162,7 @@ function newTimeMachine () { function initializeRateScale () { thisObject.rateScale = newRateScale() thisObject.rateScale.fitFunction = thisObject.fitFunction + thisObject.rateScale.payload = thisObject.payload rateScaleEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('Height Percentage Changed', function (event) { thisObject.container.frame.height = TIME_MACHINE_HEIGHT * event.heightPercentage / 100 diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 9484881e3..8ded9eee4 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -71,17 +71,18 @@ function newTimelineChart () { } function finalize () { + if (thisObject.timeFrameScale !== undefined) { + finalizeTimeFrameScale() + } + viewPort.eventHandler.stopListening(onOffsetChangedEventSuscriptionId) viewPort.eventHandler.stopListening(onZoomChangedEventSuscriptionId) thisObject.container.eventHandler.stopListening(onMouseOverEventSuscriptionId) thisObject.container.eventHandler.stopListening(onMouseNotOverEventSuscriptionId) - thisObject.timeFrameScale.container.eventHandler.stopListening(timeFrameScaleEventSuscriptionId) - thisObject.timeFrameScale.container.eventHandler.stopListening(timeFrameScaleMouseOverEventSuscriptionId) plotterManager.finalize() plotterManager = undefined - thisObject.timeFrameScale.finalize() - thisObject.timeFrameScale = undefined + canvas.panelsSpace.destroyPanel(productsPanelHandle) thisObject.container.finalize() @@ -91,6 +92,13 @@ function newTimelineChart () { mouse = undefined } + function finalizeTimeFrameScale () { + thisObject.timeFrameScale.container.eventHandler.stopListening(timeFrameScaleEventSuscriptionId) + thisObject.timeFrameScale.container.eventHandler.stopListening(timeFrameScaleMouseOverEventSuscriptionId) + thisObject.timeFrameScale.finalize() + thisObject.timeFrameScale = undefined + } + function initialize (pExchange, pMarket, pTimeLineCoordinateSystem, callBackFunction) { try { /* We load the logow we will need for the background. */ @@ -167,22 +175,12 @@ function newTimelineChart () { return } - thisObject.timeFrameScale = newTimeFrameScale() - thisObject.timeFrameScale.fitFunction = thisObject.fitFunction - timeFrameScaleEventSuscriptionId = thisObject.timeFrameScale.container.eventHandler.listenToEvent('Time Frame Changed', function (event) { - let currentTimeFrame = timeFrame - timeFrame = event.timeFrame - if (timeFrame !== currentTimeFrame) { - plotterManager.setTimeFrame(timeFrame) - } - }) - - thisObject.timeFrameScale.initialize() - onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) function onMouseOver (event) { - thisObject.timeFrameScale.visible = true + if (thisObject.timeFrameScale !== undefined) { + thisObject.timeFrameScale.visible = true + } mouse.position.x = event.x mouse.position.y = event.y @@ -193,16 +191,9 @@ function newTimelineChart () { onMouseNotOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) function onMouseNotOver (event) { - thisObject.timeFrameScale.visible = false - } - - timeFrameScaleMouseOverEventSuscriptionId = thisObject.timeFrameScale.container.eventHandler.listenToEvent('onMouseOver', timeFrameScaleMouseOver) - - function timeFrameScaleMouseOver (event) { - mouse.position.x = event.x - mouse.position.y = event.y - - saveUserPosition(thisObject.container, timeLineCoordinateSystem, event) + if (thisObject.timeFrameScale !== undefined) { + thisObject.timeFrameScale.visible = false + } } initializationReady = true @@ -215,6 +206,31 @@ function newTimelineChart () { } } + function initializeTimeFrameScale () { + thisObject.timeFrameScale = newTimeFrameScale() + thisObject.timeFrameScale.fitFunction = thisObject.fitFunction + thisObject.timeFrameScale.payload = thisObject.payload + + timeFrameScaleEventSuscriptionId = thisObject.timeFrameScale.container.eventHandler.listenToEvent('Time Frame Changed', function (event) { + let currentTimeFrame = timeFrame + timeFrame = event.timeFrame + if (timeFrame !== currentTimeFrame) { + plotterManager.setTimeFrame(timeFrame) + } + }) + + thisObject.timeFrameScale.initialize() + + timeFrameScaleMouseOverEventSuscriptionId = thisObject.timeFrameScale.container.eventHandler.listenToEvent('onMouseOver', timeFrameScaleMouseOver) + + function timeFrameScaleMouseOver (event) { + mouse.position.x = event.x + mouse.position.y = event.y + + saveUserPosition(thisObject.container, timeLineCoordinateSystem, event) + } + } + function onZoomChanged (event) { if (initializationReady === true) { recalculateCurrentDatetime() @@ -269,9 +285,9 @@ function newTimelineChart () { function getContainer (point) { let container - container = thisObject.timeFrameScale.getContainer(point) - - if (container !== undefined) { return container } + if (thisObject.timeFrameScale !== undefined) { + container = thisObject.timeFrameScale.getContainer(point) + } return container } @@ -279,16 +295,26 @@ function newTimelineChart () { function physics () { thisObjectPhysics() childrenPhysics() + syncWithDesignerScales() } function thisObjectPhysics () { } - function childrenPhysics () { - if (thisObject.timeFrameScale === undefined) { return } + function syncWithDesignerScales () { + if (thisObject.payload.node.timeFrameScale === undefined && thisObject.timeFrameScale !== undefined) { + finalizeTimeFrameScale() + } + if (thisObject.payload.node.timeFrameScale !== undefined && thisObject.timeFrameScale === undefined) { + initializeTimeFrameScale() + } + } - thisObject.timeFrameScale.physics() + function childrenPhysics () { + if (thisObject.timeFrameScale !== undefined) { + thisObject.timeFrameScale.physics() + } /* Container Limits */ @@ -306,22 +332,23 @@ function newTimelineChart () { bottonCorner = transformThisPoint(bottonCorner, thisObject.container) /* thisObject.timeFrameScale Positioning */ + if (thisObject.timeFrameScale !== undefined) { + timePoint = { + x: 0, + y: thisObject.container.frame.height + } - timePoint = { - x: 0, - y: thisObject.container.frame.height - } - - timePoint = transformThisPoint(timePoint, thisObject.container.frame.container) - timePoint.x = mouse.position.x - thisObject.timeFrameScale.container.frame.width / 2 - timePoint = thisObject.container.fitFunction(timePoint, true) + timePoint = transformThisPoint(timePoint, thisObject.container.frame.container) + timePoint.x = mouse.position.x - thisObject.timeFrameScale.container.frame.width / 2 + timePoint = thisObject.container.fitFunction(timePoint, true) /* Checking against the container limits. */ - if (timePoint.x < upCorner.x) { timePoint.x = upCorner.x } - if (timePoint.x + thisObject.timeFrameScale.container.frame.width > bottonCorner.x) { timePoint.x = bottonCorner.x - thisObject.timeFrameScale.container.frame.width } + if (timePoint.x < upCorner.x) { timePoint.x = upCorner.x } + if (timePoint.x + thisObject.timeFrameScale.container.frame.width > bottonCorner.x) { timePoint.x = bottonCorner.x - thisObject.timeFrameScale.container.frame.width } - thisObject.timeFrameScale.container.frame.position.x = timePoint.x - thisObject.timeFrameScale.container.frame.position.y = timePoint.y - thisObject.timeFrameScale.container.frame.height + thisObject.timeFrameScale.container.frame.position.x = timePoint.x + thisObject.timeFrameScale.container.frame.position.y = timePoint.y - thisObject.timeFrameScale.container.frame.height + } } function tooTiny () { @@ -344,8 +371,6 @@ function newTimelineChart () { if (thisObject.container.frame.isInViewPort()) { if (window.CHART_ON_FOCUS === '') { window.CHART_ON_FOCUS = exchange + ' ' + market.quotedAsset + '/' + market.baseAsset - - // drawChartsBackgroundImages() } drawChartsBackground() plotterManager.draw() @@ -354,7 +379,9 @@ function newTimelineChart () { function draw () { if (thisObject.container.frame.isInViewPort()) { - thisObject.timeFrameScale.draw() + if (thisObject.timeFrameScale !== undefined) { + thisObject.timeFrameScale.draw() + } } } @@ -388,209 +415,4 @@ function newTimelineChart () { browserCanvasContext.fill() } - - function drawChartsBackgroundImages () { - if (canDrawLogoA === false || canDrawLogoB === false || canDrawLogoExchange === false || canDrawLogoAA === false) { return } - - /* Fist we calculate the corners of the current frame so as not to draw imaages ourside of it */ - - let fromPoint = { - x: 0, - y: 0 - } - - let toPoint = { - x: thisObject.container.frame.width, - y: thisObject.container.frame.height - } - - fromPoint = transformThisPoint(fromPoint, thisObject.container) - toPoint = transformThisPoint(toPoint, thisObject.container) - - /* Second we calculate the points for the images themselves */ - - let backgroundLogoPoint1 - let backgroundLogoPoint2 - - let imageHeight = 42 - let imageWidth = 150 - - const MAX_COLUMNS = 32 - const MAX_ROWS = 5 - const Y_TOP_MARGIN = 30 - const MIN_ROW_HIGHT = 100 - - let point1 = { - x: viewPort.visibleArea.topLeft.x, - y: viewPort.visibleArea.topLeft.y - } - - backgroundLogoPoint1 = { - x: getDateFromPoint(point1, thisObject.container, timeLineCoordinateSystem).valueOf(), - y: getRateFromPoint(point1, thisObject.container, timeLineCoordinateSystem) - } - - let point2 = { - x: viewPort.visibleArea.topLeft.x + imageWidth * 8, - y: viewPort.visibleArea.topLeft.y - } - - backgroundLogoPoint2 = { - x: getDateFromPoint(point2, thisObject.container, timeLineCoordinateSystem).valueOf(), - y: getRateFromPoint(point2, thisObject.container, timeLineCoordinateSystem) - } - - let currentCorner = { - x: getDateFromPoint(viewPort.visibleArea.topLeft, thisObject.container, timeLineCoordinateSystem).valueOf(), - y: getRateFromPoint(viewPort.visibleArea.topLeft, thisObject.container, timeLineCoordinateSystem) - } - - currentCorner.x = Math.trunc(currentCorner.x / (backgroundLogoPoint2.x - backgroundLogoPoint1.x)) * (backgroundLogoPoint2.x - backgroundLogoPoint1.x) - - let rowHight = (viewPort.visibleArea.bottomLeft.y - viewPort.visibleArea.topLeft.y) / 4.5 - if (rowHight < MIN_ROW_HIGHT) { rowHight = MIN_ROW_HIGHT } - - imagePoint = timeLineCoordinateSystem.transformThisPoint(currentCorner) - imagePoint = transformThisPoint(imagePoint, thisObject.container) - - let offSet = 0 - let imagePosition = { - x: 0, - y: 0 - } - - for (let j = 0; j < MAX_ROWS; j++) { - if (offSet === -imageWidth * 8) { - offSet = -imageWidth * 4 - imageWidth - } else { - offSet = -imageWidth * 8 - } - - for (let i = 0; i < MAX_COLUMNS; i = i + 4) { - let logo = logoA - - imagePosition.x = imagePoint.x + i * imageWidth * 2 + offSet - imagePosition.y = imagePoint.y + j * rowHight + Y_TOP_MARGIN - - if ( - imagePosition.x > fromPoint.x && - imagePosition.x + imageWidth < toPoint.x && - imagePosition.y > fromPoint.y && - imagePosition.y + imageHeight < toPoint.y - ) { - let checkPoint = { - x: imagePosition.x, - y: imagePosition.y + imageHeight - } - - checkPoint = thisObject.fitFunction(checkPoint) - if (checkPoint.y === imagePosition.y + imageHeight) { - browserCanvasContext.drawImage(logo, imagePosition.x, imagePosition.y, imageWidth, imageHeight) - } - } - } - } - - offSet = 0 - - for (let j = 0; j < MAX_ROWS; j++) { - if (offSet === -imageWidth * 8) { - offSet = -imageWidth * 4 - imageWidth - } else { - offSet = -imageWidth * 8 - } - - for (let i = 1; i < MAX_COLUMNS; i = i + 4) { - let logo = logoB - - imagePosition.x = imagePoint.x + i * imageWidth * 2 + offSet - imagePosition.y = imagePoint.y + j * rowHight + Y_TOP_MARGIN - - if ( - imagePosition.x > fromPoint.x && - imagePosition.x + imageWidth < toPoint.x && - imagePosition.y > fromPoint.y && - imagePosition.y + imageHeight < toPoint.y - ) { - let checkPoint = { - x: imagePosition.x, - y: imagePosition.y + imageHeight - } - - checkPoint = thisObject.fitFunction(checkPoint) - if (checkPoint.y === imagePosition.y + imageHeight) { - browserCanvasContext.drawImage(logo, imagePosition.x, imagePosition.y, imageWidth, imageHeight) - } - } - } - } - - offSet = 0 - - for (let j = 0; j < MAX_ROWS; j++) { - if (offSet === -imageWidth * 8) { - offSet = -imageWidth * 4 - imageWidth - } else { - offSet = -imageWidth * 8 - } - - for (let i = 2; i < MAX_COLUMNS; i = i + 4) { - let logo = logoExchange - - imagePosition.x = imagePoint.x + i * imageWidth * 2 + offSet - imagePosition.y = imagePoint.y + j * rowHight + Y_TOP_MARGIN - - if ( - imagePosition.x > fromPoint.x && - imagePosition.x + imageWidth < toPoint.x && - imagePosition.y > fromPoint.y && - imagePosition.y + imageHeight < toPoint.y - ) { - let checkPoint = { - x: imagePosition.x, - y: imagePosition.y + imageHeight - } - - checkPoint = thisObject.fitFunction(checkPoint) - if (checkPoint.y === imagePosition.y + imageHeight) { - browserCanvasContext.drawImage(logo, imagePosition.x, imagePosition.y, imageWidth, imageHeight) - } - } - } - } - - offSet = 0 - - for (let j = 0; j < MAX_ROWS; j++) { - if (offSet === -imageWidth * 8) { - offSet = -imageWidth * 4 - imageWidth - } else { - offSet = -imageWidth * 8 - } - - for (let i = 3; i < MAX_COLUMNS; i = i + 4) { - let logo = logoAA - - imagePosition.x = imagePoint.x + i * imageWidth * 2 + offSet - imagePosition.y = imagePoint.y + j * rowHight + Y_TOP_MARGIN - - if ( - imagePosition.x > fromPoint.x && - imagePosition.x + imageWidth < toPoint.x && - imagePosition.y > fromPoint.y && - imagePosition.y + imageHeight < toPoint.y - ) { - let checkPoint = { - x: imagePosition.x, - y: imagePosition.y + imageHeight - } - - checkPoint = thisObject.fitFunction(checkPoint) - if (checkPoint.y === imagePosition.y + imageHeight) { - browserCanvasContext.drawImage(logo, imagePosition.x, imagePosition.y, imageWidth, imageHeight) - } - } - } - } - } } diff --git a/Scales/RateScale.js b/Scales/RateScale.js index 5158fe3b7..11cdc65a5 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -5,6 +5,7 @@ function newRateScale () { container: undefined, rate: undefined, fitFunction: undefined, + payload: undefined, visible: true, heightPercentage: 150, physics: physics, @@ -26,7 +27,7 @@ function newRateScale () { thisObject.container.isWheelable = true thisObject.container.detectMouseOver = true - thisObject.container.frame.width = 250 + thisObject.container.frame.width = 300 thisObject.container.frame.height = 30 let isMouseOver @@ -45,6 +46,7 @@ function newRateScale () { thisObject.container.finalize() thisObject.container = undefined thisObject.fitFunction = undefined + thisObject.payload = undefined } function initialize () { diff --git a/Scales/TimeFrameScale.js b/Scales/TimeFrameScale.js index 8f4d63f14..417afa4da 100644 --- a/Scales/TimeFrameScale.js +++ b/Scales/TimeFrameScale.js @@ -5,6 +5,7 @@ function newTimeFrameScale () { timeFrame: undefined, container: undefined, fitFunction: undefined, + payload: undefined, draw: draw, physics: physics, getContainer: getContainer, @@ -39,7 +40,7 @@ function newTimeFrameScale () { thisObject.container.isWheelable = true thisObject.container.detectMouseOver = true - thisObject.container.frame.width = 250 + thisObject.container.frame.width = 300 thisObject.container.frame.height = 30 } @@ -53,6 +54,7 @@ function newTimeFrameScale () { thisObject.container.finalize() thisObject.container = undefined thisObject.fitFunction = undefined + thisObject.payload = undefined } function initialize () { diff --git a/Scales/TimeScale.js b/Scales/TimeScale.js index 689185e49..345ca041a 100644 --- a/Scales/TimeScale.js +++ b/Scales/TimeScale.js @@ -6,6 +6,7 @@ function newTimeScale () { container: undefined, date: undefined, fitFunction: undefined, + payload: undefined, visible: true, physics: physics, draw: draw, @@ -25,7 +26,7 @@ function newTimeScale () { thisObject.container.isWheelable = true thisObject.container.detectMouseOver = true - thisObject.container.frame.width = 250 + thisObject.container.frame.width = 300 thisObject.container.frame.height = 30 let isMouseOver @@ -44,6 +45,7 @@ function newTimeScale () { thisObject.container.finalize() thisObject.container = undefined thisObject.fitFunction = undefined + thisObject.payload = undefined } function initialize () { From 6f85f420580ba05881a71857dcd1cfd73e8abbfa Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 9 Jan 2020 21:12:35 +0100 Subject: [PATCH 066/264] Scales with icons and names --- ChartsSpace/TimeMachine.js | 4 +-- ChartsSpace/TimelineChart.js | 2 +- Scales/Commons.js | 69 ++++++++++++++++++++++++++++++++---- Scales/RateScale.js | 14 +++++--- Scales/TimeFrameScale.js | 14 +++++--- Scales/TimeScale.js | 14 +++++--- 6 files changed, 92 insertions(+), 25 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 0993b62f2..49b35acac 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -141,7 +141,7 @@ function newTimeMachine () { function initializeTimeScale () { thisObject.timeScale = newTimeScale() thisObject.timeScale.fitFunction = thisObject.fitFunction - thisObject.timeScale.payload = thisObject.payload + thisObject.timeScale.payload = thisObject.payload.node.timeScale.payload timeScaleEventSuscriptionId = thisObject.timeScale.container.eventHandler.listenToEvent('Lenght Percentage Changed', function (event) { thisObject.container.frame.width = TIME_MACHINE_WIDTH * event.lenghtPercentage / 100 @@ -162,7 +162,7 @@ function newTimeMachine () { function initializeRateScale () { thisObject.rateScale = newRateScale() thisObject.rateScale.fitFunction = thisObject.fitFunction - thisObject.rateScale.payload = thisObject.payload + thisObject.rateScale.payload = thisObject.payload.node.rateScale.payload rateScaleEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('Height Percentage Changed', function (event) { thisObject.container.frame.height = TIME_MACHINE_HEIGHT * event.heightPercentage / 100 diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 8ded9eee4..e29a2d183 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -209,7 +209,7 @@ function newTimelineChart () { function initializeTimeFrameScale () { thisObject.timeFrameScale = newTimeFrameScale() thisObject.timeFrameScale.fitFunction = thisObject.fitFunction - thisObject.timeFrameScale.payload = thisObject.payload + thisObject.timeFrameScale.payload = thisObject.payload.node.timeFrameScale.payload timeFrameScaleEventSuscriptionId = thisObject.timeFrameScale.container.eventHandler.listenToEvent('Time Frame Changed', function (event) { let currentTimeFrame = timeFrame diff --git a/Scales/Commons.js b/Scales/Commons.js index 05808196d..329a356cc 100644 --- a/Scales/Commons.js +++ b/Scales/Commons.js @@ -1,7 +1,8 @@ -function drawScaleDisplay (label1, label2, xExtraOffSet1, xExtraOffSet2, container, fitFunction) { - let fontSize1 = 20 - let fontSize2 = 10 +function drawScaleDisplay (label1, label2, label3, xExtraOffSet1, xExtraOffSet2, xExtraOffSet3, icon1, icon2, container, fitFunction) { + let fontSize1 = 10 + let fontSize2 = 20 + let fontSize3 = 10 const RED_LINE_HIGHT = 4 const OPACITY = 1 @@ -21,11 +22,12 @@ function drawScaleDisplay (label1, label2, xExtraOffSet1, xExtraOffSet2, contain /* Place the Text */ + label1 = label1.substring(0, 18) let xOffset1 = label1.length * fontSize1 * FONT_ASPECT_RATIO let labelPoint1 = { - x: container.frame.width / 2 - xOffset1 + xExtraOffSet1, - y: container.frame.height / 2 + 6 + x: container.frame.width * 1 / 2 - xOffset1 / 2 + xExtraOffSet1, + y: container.frame.height * 4 / 5 } labelPoint1 = container.frame.frameThisPoint(labelPoint1) @@ -38,11 +40,12 @@ function drawScaleDisplay (label1, label2, xExtraOffSet1, xExtraOffSet2, contain browserCanvasContext.fillText(label1, labelPoint1.x, labelPoint1.y) + label2 = label2.substring(0, 20) let xOffset2 = label2.length * fontSize2 * FONT_ASPECT_RATIO let labelPoint2 = { - x: container.frame.width / 2 - xOffset2 / 2 - 3 + xExtraOffSet2, - y: container.frame.height / 2 + 6 + x: container.frame.width * 1 / 2 - xOffset2 / 2 + xExtraOffSet2, + y: container.frame.height * 2 / 5 } labelPoint2 = container.frame.frameThisPoint(labelPoint2) @@ -52,5 +55,57 @@ function drawScaleDisplay (label1, label2, xExtraOffSet1, xExtraOffSet2, contain browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)' browserCanvasContext.fillText(label2, labelPoint2.x, labelPoint2.y) + + label3 = label3.substring(0, 20) + let xOffset3 = label3.length * fontSize3 * FONT_ASPECT_RATIO + + let labelPoint3 = { + x: container.frame.width * 1 / 2 - xOffset3 / 2 + xExtraOffSet3, + y: container.frame.height * 3 / 5 + } + + labelPoint3 = container.frame.frameThisPoint(labelPoint3) + labelPoint3 = fitFunction(labelPoint3) + + browserCanvasContext.font = fontSize3 + 'px ' + UI_FONT.PRIMARY + browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)' + + browserCanvasContext.fillText(label3, labelPoint3.x, labelPoint3.y) + + /* Images */ + + if (icon1 !== undefined) { + if (icon1.canDrawIcon === true) { + let imageSize = 40 + let imagePosition = { + x: container.frame.width * 1 / 8 - imageSize / 2, + y: container.frame.height / 2 - imageSize / 2 + } + + imagePosition = container.frame.frameThisPoint(imagePosition) + browserCanvasContext.drawImage( + icon1, imagePosition.x, + imagePosition.y, + imageSize, + imageSize) + } + } + + if (icon2 !== undefined) { + if (icon2.canDrawIcon === true) { + let imageSize = 40 + let imagePosition = { + x: container.frame.width * 7 / 8 - imageSize / 2, + y: container.frame.height / 2 - imageSize / 2 + } + + imagePosition = container.frame.frameThisPoint(imagePosition) + browserCanvasContext.drawImage( + icon2, imagePosition.x, + imagePosition.y, + imageSize, + imageSize) + } + } } diff --git a/Scales/RateScale.js b/Scales/RateScale.js index 11cdc65a5..19eb114c8 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -27,8 +27,8 @@ function newRateScale () { thisObject.container.isWheelable = true thisObject.container.detectMouseOver = true - thisObject.container.frame.width = 300 - thisObject.container.frame.height = 30 + thisObject.container.frame.width = 200 + thisObject.container.frame.height = 60 let isMouseOver @@ -212,9 +212,13 @@ function newRateScale () { let label = (thisObject.rate - Math.trunc(thisObject.rate)).toFixed(2) let labelArray = label.split('.') - let label1 = (Math.trunc(thisObject.rate)).toLocaleString() - let label2 = labelArray[1] + let label1 = thisObject.payload.node.payload.parentNode.name + let label2 = (Math.trunc(thisObject.rate)).toLocaleString() + let label3 = labelArray[1] - drawScaleDisplay(label1, label2, 10, 40, thisObject.container, thisObject.fitFunction) + let icon1 = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.payload.parentNode.type) + let icon2 = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.type) + + drawScaleDisplay(label1, label2, label3, 0, 0, 0, icon1, icon2, thisObject.container, thisObject.fitFunction) } } diff --git a/Scales/TimeFrameScale.js b/Scales/TimeFrameScale.js index 417afa4da..de053c656 100644 --- a/Scales/TimeFrameScale.js +++ b/Scales/TimeFrameScale.js @@ -40,8 +40,8 @@ function newTimeFrameScale () { thisObject.container.isWheelable = true thisObject.container.detectMouseOver = true - thisObject.container.frame.width = 300 - thisObject.container.frame.height = 30 + thisObject.container.frame.width = 200 + thisObject.container.frame.height = 60 } function finalize () { @@ -167,9 +167,13 @@ function newTimeFrameScale () { if (thisObject.visible === false || timeFrameLabel === undefined) { return } let label = timeFrameLabel.split('-') - let label1 = label[0] - let label2 = label[1].toUpperCase() + let label1 = thisObject.payload.node.payload.parentNode.name + let label2 = label[0] + let label3 = label[1].toUpperCase() - drawScaleDisplay(label1, label2, 10, 60, thisObject.container, thisObject.fitFunction) + let icon1 = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.payload.parentNode.type) + let icon2 = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.type) + + drawScaleDisplay(label1, label2, label3, 0, 0, 0, icon1, icon2, thisObject.container, thisObject.fitFunction) } } diff --git a/Scales/TimeScale.js b/Scales/TimeScale.js index 345ca041a..5022f64dd 100644 --- a/Scales/TimeScale.js +++ b/Scales/TimeScale.js @@ -26,8 +26,8 @@ function newTimeScale () { thisObject.container.isWheelable = true thisObject.container.detectMouseOver = true - thisObject.container.frame.width = 300 - thisObject.container.frame.height = 30 + thisObject.container.frame.width = 200 + thisObject.container.frame.height = 60 let isMouseOver @@ -212,9 +212,13 @@ function newTimeScale () { let label = thisObject.date.toUTCString() let labelArray = label.split(' ') - let label1 = labelArray[1] + ' ' + labelArray[2] + ' ' + labelArray[3] - let label2 = labelArray[4] + let label1 = thisObject.payload.node.payload.parentNode.name + let label2 = labelArray[1] + ' ' + labelArray[2] + ' ' + labelArray[3] + let label3 = labelArray[4] - drawScaleDisplay(label1, label2, 10, 60, thisObject.container, thisObject.fitFunction) + let icon1 = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.payload.parentNode.type) + let icon2 = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.type) + + drawScaleDisplay(label1, label2, label3, 0, 0, 0, icon1, icon2, thisObject.container, thisObject.fitFunction) } } From edb90b45e4cecdba6a0fd8f7d740550061b76134 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 9 Jan 2020 21:40:16 +0100 Subject: [PATCH 067/264] Final touch --- Scales/Commons.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scales/Commons.js b/Scales/Commons.js index 329a356cc..db22d6459 100644 --- a/Scales/Commons.js +++ b/Scales/Commons.js @@ -26,7 +26,7 @@ function drawScaleDisplay (label1, label2, label3, xExtraOffSet1, xExtraOffSet2, let xOffset1 = label1.length * fontSize1 * FONT_ASPECT_RATIO let labelPoint1 = { - x: container.frame.width * 1 / 2 - xOffset1 / 2 + xExtraOffSet1, + x: container.frame.width * 1 / 2 - xOffset1 / 2 + xExtraOffSet1 - 5, y: container.frame.height * 4 / 5 } From 09957fc96e966e97ce45138ca64d0c060f87e94d Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 10 Jan 2020 09:17:17 +0100 Subject: [PATCH 068/264] timeScale with its own physics --- ChartsSpace/TimeMachine.js | 41 +++------------------- Scales/TimeScale.js | 70 +++++++++++++++++++++++++++++++++++++- 2 files changed, 74 insertions(+), 37 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 49b35acac..e3e518cd8 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -113,15 +113,16 @@ function newTimeMachine () { onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) function onMouseOver (event) { + mouse.position.x = event.x + mouse.position.y = event.y + if (thisObject.timeScale !== undefined) { thisObject.timeScale.visible = true + thisObject.timeScale.onMouseOverSomeInnerContainer(event) } if (thisObject.rateScale !== undefined) { thisObject.rateScale.visible = true } - - mouse.position.x = event.x - mouse.position.y = event.y } onMouseNotOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) @@ -150,7 +151,7 @@ function newTimeMachine () { thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) }) - thisObject.timeScale.initialize() + thisObject.timeScale.initialize(timeLineCoordinateSystem, thisObject.container) timeScaleMouseOverEventSuscriptionId = thisObject.timeScale.container.eventHandler.listenToEvent('onMouseOver', timeScaleMouseOver) @@ -351,18 +352,6 @@ function newTimeMachine () { upCorner = transformThisPoint(upCorner, thisObject.container) bottonCorner = transformThisPoint(bottonCorner, thisObject.container) - /* Mouse Position Date Calculation */ - if (thisObject.timeScale !== undefined) { - let timePoint = { - x: mouse.position.x, - y: 0 - } - - let mouseDate = getDateFromPoint(timePoint, thisObject.container, timeLineCoordinateSystem) - - thisObject.timeScale.date = new Date(mouseDate) - } - /* Mouse Position Rate Calculation */ if (thisObject.rateScale !== undefined) { let ratePoint = { @@ -375,26 +364,6 @@ function newTimeMachine () { thisObject.rateScale.rate = mouseRate } - /* timeScale Positioning */ - if (thisObject.timeScale !== undefined) { - timePoint = { - x: 0, - y: 0 - } - - timePoint = transformThisPoint(timePoint, thisObject.container.frame.container) - timePoint.x = mouse.position.x - thisObject.timeScale.container.frame.width / 2 - timePoint = thisObject.container.fitFunction(timePoint) - - /* Checking against the container limits. */ - if (timePoint.x < upCorner.x) { timePoint.x = upCorner.x } - if (timePoint.x + thisObject.timeScale.container.frame.width > bottonCorner.x) { timePoint.x = bottonCorner.x - thisObject.timeScale.container.frame.width } - if (timePoint.y < upCorner.y) { timePoint.y = upCorner.y } - if (timePoint.y + thisObject.timeScale.container.frame.height > bottonCorner.y) { timePoint.y = bottonCorner.y - thisObject.timeScale.container.frame.height } - - thisObject.timeScale.container.frame.position.x = timePoint.x - thisObject.timeScale.container.frame.position.y = timePoint.y - } /* rateScale Positioning */ if (thisObject.rateScale !== undefined) { ratePoint = { diff --git a/Scales/TimeScale.js b/Scales/TimeScale.js index 5022f64dd..91ff265e7 100644 --- a/Scales/TimeScale.js +++ b/Scales/TimeScale.js @@ -8,6 +8,7 @@ function newTimeScale () { fitFunction: undefined, payload: undefined, visible: true, + onMouseOverSomeInnerContainer: onMouseOverSomeInnerContainer, physics: physics, draw: draw, getContainer: getContainer, @@ -35,6 +36,15 @@ function newTimeScale () { let onMouseOverEventSubscriptionId let onMouseNotOverEventSubscriptionId + let timeLineCoordinateSystem + let limitingContainer + + let mouse = { + position: { + x: 0, + y: 0 + } + } return thisObject function finalize () { @@ -46,9 +56,16 @@ function newTimeScale () { thisObject.container = undefined thisObject.fitFunction = undefined thisObject.payload = undefined + + timeLineCoordinateSystem = undefined + limitingContainer = undefined + mouse = undefined } - function initialize () { + function initialize (pTimeLineCoordinateSystem, pLimitingContainer) { + timeLineCoordinateSystem = pTimeLineCoordinateSystem + limitingContainer = pLimitingContainer + onMouseWheelEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) onMouseNotOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) @@ -65,6 +82,15 @@ function newTimeScale () { thisObject.container.eventHandler.raiseEvent('Lenght Percentage Changed', event) } + function onMouseOverSomeInnerContainer (event) { + mouse = { + position: { + x: event.x, + y: event.y + } + } + } + function onMouseOver () { thisObject.visible = true isMouseOver = true @@ -97,7 +123,49 @@ function newTimeScale () { } function physics () { + /* Container Limits */ + let upCorner = { + x: 0, + y: 0 + } + + let bottonCorner = { + x: limitingContainer.frame.width, + y: limitingContainer.frame.height + } + + upCorner = transformThisPoint(upCorner, limitingContainer) + bottonCorner = transformThisPoint(bottonCorner, limitingContainer) + + /* Mouse Position Date Calculation */ + let timePoint = { + x: mouse.position.x, + y: 0 + } + + let mouseDate = getDateFromPoint(timePoint, limitingContainer, timeLineCoordinateSystem) + + thisObject.date = new Date(mouseDate) + + /* timeScale Positioning */ + timePoint = { + x: 0, + y: 0 + } + + timePoint = transformThisPoint(timePoint, limitingContainer.frame.container) + timePoint.x = mouse.position.x - thisObject.container.frame.width / 2 + timePoint = limitingContainer.fitFunction(timePoint) + + /* Checking against the container limits. */ + if (timePoint.x < upCorner.x) { timePoint.x = upCorner.x } + if (timePoint.x + thisObject.container.frame.width > bottonCorner.x) { timePoint.x = bottonCorner.x - thisObject.container.frame.width } + if (timePoint.y < upCorner.y) { timePoint.y = upCorner.y } + if (timePoint.y + thisObject.container.frame.height > bottonCorner.y) { timePoint.y = bottonCorner.y - thisObject.container.frame.height } + + thisObject.container.frame.position.x = timePoint.x + thisObject.container.frame.position.y = timePoint.y } function draw () { From 2bfee8c2c74c13f534fb071038c88a68c9d9f436 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 10 Jan 2020 09:31:49 +0100 Subject: [PATCH 069/264] RateScale with its own physics --- ChartsSpace/TimeMachine.js | 53 ++--------------------------- Scales/RateScale.js | 70 +++++++++++++++++++++++++++++++++++++- Scales/TimeScale.js | 4 +-- 3 files changed, 74 insertions(+), 53 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index e3e518cd8..5ff5de51e 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -118,9 +118,10 @@ function newTimeMachine () { if (thisObject.timeScale !== undefined) { thisObject.timeScale.visible = true - thisObject.timeScale.onMouseOverSomeInnerContainer(event) + thisObject.timeScale.onMouseOverSomeTimeMachineContainer(event) } if (thisObject.rateScale !== undefined) { + thisObject.rateScale.onMouseOverSomeTimeMachineContainer(event) thisObject.rateScale.visible = true } } @@ -172,7 +173,7 @@ function newTimeMachine () { thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) }) - thisObject.rateScale.initialize() + thisObject.rateScale.initialize(timeLineCoordinateSystem, thisObject.container) rateScaleMouseOverEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('onMouseOver', rateScaleMouseOver) @@ -336,54 +337,6 @@ function newTimeMachine () { let chart = thisObject.timelineCharts[i] chart.physics() } - - /* Container Limits */ - - let upCorner = { - x: 0, - y: 0 - } - - let bottonCorner = { - x: thisObject.container.frame.width, - y: thisObject.container.frame.height - } - - upCorner = transformThisPoint(upCorner, thisObject.container) - bottonCorner = transformThisPoint(bottonCorner, thisObject.container) - - /* Mouse Position Rate Calculation */ - if (thisObject.rateScale !== undefined) { - let ratePoint = { - x: 0, - y: mouse.position.y - } - - let mouseRate = getRateFromPoint(ratePoint, thisObject.container, timeLineCoordinateSystem) - - thisObject.rateScale.rate = mouseRate - } - - /* rateScale Positioning */ - if (thisObject.rateScale !== undefined) { - ratePoint = { - x: thisObject.container.frame.width, - y: 0 - } - - ratePoint = transformThisPoint(ratePoint, thisObject.container.frame.container) - ratePoint.y = mouse.position.y - thisObject.rateScale.container.frame.height / 2 + thisObject.rateScale.container.frame.height - ratePoint = thisObject.container.fitFunction(ratePoint, true) - - /* Checking against the container limits. */ - if (ratePoint.x < upCorner.x) { ratePoint.x = upCorner.x } - if (ratePoint.x + thisObject.rateScale.container.frame.width > bottonCorner.x) { ratePoint.x = bottonCorner.x } - if (ratePoint.y < upCorner.y + thisObject.rateScale.container.frame.height) { ratePoint.y = upCorner.y + thisObject.rateScale.container.frame.height } - if (ratePoint.y > bottonCorner.y) { ratePoint.y = bottonCorner.y } - - thisObject.rateScale.container.frame.position.y = ratePoint.y - thisObject.rateScale.container.frame.height - thisObject.rateScale.container.frame.position.x = ratePoint.x - thisObject.rateScale.container.frame.width - } } function drawBackground () { diff --git a/Scales/RateScale.js b/Scales/RateScale.js index 19eb114c8..1d8ba85ca 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -8,6 +8,7 @@ function newRateScale () { payload: undefined, visible: true, heightPercentage: 150, + onMouseOverSomeTimeMachineContainer: onMouseOverSomeTimeMachineContainer, physics: physics, draw: draw, getContainer: getContainer, @@ -36,6 +37,15 @@ function newRateScale () { let onMouseOverEventSubscriptionId let onMouseNotOverEventSubscriptionId + let timeLineCoordinateSystem + let limitingContainer + + let mouse = { + position: { + x: 0, + y: 0 + } + } return thisObject function finalize () { @@ -47,9 +57,16 @@ function newRateScale () { thisObject.container = undefined thisObject.fitFunction = undefined thisObject.payload = undefined + + timeLineCoordinateSystem = undefined + limitingContainer = undefined + mouse = undefined } - function initialize () { + function initialize (pTimeLineCoordinateSystem, pLimitingContainer) { + timeLineCoordinateSystem = pTimeLineCoordinateSystem + limitingContainer = pLimitingContainer + onMouseWheelEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) onMouseNotOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) @@ -66,6 +83,15 @@ function newRateScale () { thisObject.container.eventHandler.raiseEvent('Height Percentage Changed', event) } + function onMouseOverSomeTimeMachineContainer (event) { + mouse = { + position: { + x: event.x, + y: event.y + } + } + } + function onMouseOver () { thisObject.visible = true isMouseOver = true @@ -97,7 +123,49 @@ function newRateScale () { } function physics () { + /* Container Limits */ + let upCorner = { + x: 0, + y: 0 + } + + let bottonCorner = { + x: limitingContainer.frame.width, + y: limitingContainer.frame.height + } + + upCorner = transformThisPoint(upCorner, limitingContainer) + bottonCorner = transformThisPoint(bottonCorner, limitingContainer) + + /* Mouse Position Rate Calculation */ + let ratePoint = { + x: 0, + y: mouse.position.y + } + + let mouseRate = getRateFromPoint(ratePoint, limitingContainer, timeLineCoordinateSystem) + + thisObject.rate = mouseRate + + /* rateScale Positioning */ + ratePoint = { + x: limitingContainer.frame.width, + y: 0 + } + + ratePoint = transformThisPoint(ratePoint, limitingContainer.frame.container) + ratePoint.y = mouse.position.y - thisObject.container.frame.height / 2 + thisObject.container.frame.height + ratePoint = limitingContainer.fitFunction(ratePoint, true) + + /* Checking against the container limits. */ + if (ratePoint.x < upCorner.x) { ratePoint.x = upCorner.x } + if (ratePoint.x + thisObject.container.frame.width > bottonCorner.x) { ratePoint.x = bottonCorner.x } + if (ratePoint.y < upCorner.y + thisObject.container.frame.height) { ratePoint.y = upCorner.y + thisObject.container.frame.height } + if (ratePoint.y > bottonCorner.y) { ratePoint.y = bottonCorner.y } + + thisObject.container.frame.position.y = ratePoint.y - thisObject.container.frame.height + thisObject.container.frame.position.x = ratePoint.x - thisObject.container.frame.width } function draw () { diff --git a/Scales/TimeScale.js b/Scales/TimeScale.js index 91ff265e7..4a1039573 100644 --- a/Scales/TimeScale.js +++ b/Scales/TimeScale.js @@ -8,7 +8,7 @@ function newTimeScale () { fitFunction: undefined, payload: undefined, visible: true, - onMouseOverSomeInnerContainer: onMouseOverSomeInnerContainer, + onMouseOverSomeTimeMachineContainer: onMouseOverSomeTimeMachineContainer, physics: physics, draw: draw, getContainer: getContainer, @@ -82,7 +82,7 @@ function newTimeScale () { thisObject.container.eventHandler.raiseEvent('Lenght Percentage Changed', event) } - function onMouseOverSomeInnerContainer (event) { + function onMouseOverSomeTimeMachineContainer (event) { mouse = { position: { x: event.x, From a6bf4e1cb86024640dfa41b6064c9cc64b36c9ba Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 10 Jan 2020 13:59:10 +0100 Subject: [PATCH 070/264] Time Frame Scale with its own physics --- ChartsSpace/TimelineChart.js | 37 ++---------------------- Scales/TimeFrameScale.js | 56 ++++++++++++++++++++++++++++++++++-- 2 files changed, 56 insertions(+), 37 deletions(-) diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index e29a2d183..0eb9022dd 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -180,6 +180,7 @@ function newTimelineChart () { function onMouseOver (event) { if (thisObject.timeFrameScale !== undefined) { thisObject.timeFrameScale.visible = true + thisObject.timeFrameScale.onMouseOverSomeTimeMachineContainer(event) } mouse.position.x = event.x @@ -219,7 +220,7 @@ function newTimelineChart () { } }) - thisObject.timeFrameScale.initialize() + thisObject.timeFrameScale.initialize(timeLineCoordinateSystem, thisObject.container) timeFrameScaleMouseOverEventSuscriptionId = thisObject.timeFrameScale.container.eventHandler.listenToEvent('onMouseOver', timeFrameScaleMouseOver) @@ -315,40 +316,6 @@ function newTimelineChart () { if (thisObject.timeFrameScale !== undefined) { thisObject.timeFrameScale.physics() } - - /* Container Limits */ - - let upCorner = { - x: 0, - y: 0 - } - - let bottonCorner = { - x: thisObject.container.frame.width, - y: thisObject.container.frame.height - } - - upCorner = transformThisPoint(upCorner, thisObject.container) - bottonCorner = transformThisPoint(bottonCorner, thisObject.container) - - /* thisObject.timeFrameScale Positioning */ - if (thisObject.timeFrameScale !== undefined) { - timePoint = { - x: 0, - y: thisObject.container.frame.height - } - - timePoint = transformThisPoint(timePoint, thisObject.container.frame.container) - timePoint.x = mouse.position.x - thisObject.timeFrameScale.container.frame.width / 2 - timePoint = thisObject.container.fitFunction(timePoint, true) - - /* Checking against the container limits. */ - if (timePoint.x < upCorner.x) { timePoint.x = upCorner.x } - if (timePoint.x + thisObject.timeFrameScale.container.frame.width > bottonCorner.x) { timePoint.x = bottonCorner.x - thisObject.timeFrameScale.container.frame.width } - - thisObject.timeFrameScale.container.frame.position.x = timePoint.x - thisObject.timeFrameScale.container.frame.position.y = timePoint.y - thisObject.timeFrameScale.container.frame.height - } } function tooTiny () { diff --git a/Scales/TimeFrameScale.js b/Scales/TimeFrameScale.js index de053c656..40b27b7cf 100644 --- a/Scales/TimeFrameScale.js +++ b/Scales/TimeFrameScale.js @@ -6,6 +6,7 @@ function newTimeFrameScale () { container: undefined, fitFunction: undefined, payload: undefined, + onMouseOverSomeTimeMachineContainer: onMouseOverSomeTimeMachineContainer, draw: draw, physics: physics, getContainer: getContainer, @@ -28,6 +29,15 @@ function newTimeFrameScale () { let onZoomChangedEventSubscriptionId let onMouseOverEventSubscriptionId + let timeLineCoordinateSystem + let limitingContainer + + let mouse = { + position: { + x: 0, + y: 0 + } + } setupContainer() return thisObject @@ -57,7 +67,10 @@ function newTimeFrameScale () { thisObject.payload = undefined } - function initialize () { + function initialize (pTimeLineCoordinateSystem, pLimitingContainer) { + timeLineCoordinateSystem = pTimeLineCoordinateSystem + limitingContainer = pLimitingContainer + readObjectState() newTimeFrame() @@ -70,8 +83,47 @@ function newTimeFrameScale () { } } - function physics () { + function onMouseOverSomeTimeMachineContainer (event) { + mouse = { + position: { + x: event.x, + y: event.y + } + } + } + function physics () { + /* Container Limits */ + + let upCorner = { + x: 0, + y: 0 + } + + let bottonCorner = { + x: limitingContainer.frame.width, + y: limitingContainer.frame.height + } + + upCorner = transformThisPoint(upCorner, limitingContainer) + bottonCorner = transformThisPoint(bottonCorner, limitingContainer) + + /* Positioning */ + timePoint = { + x: 0, + y: limitingContainer.frame.height + } + + timePoint = transformThisPoint(timePoint, limitingContainer.frame.container) + timePoint.x = mouse.position.x - thisObject.container.frame.width / 2 + timePoint = limitingContainer.fitFunction(timePoint, true) + + /* Checking against the container limits. */ + if (timePoint.x < upCorner.x) { timePoint.x = upCorner.x } + if (timePoint.x + thisObject.container.frame.width > bottonCorner.x) { timePoint.x = bottonCorner.x - thisObject.container.frame.width } + + thisObject.container.frame.position.x = timePoint.x + thisObject.container.frame.position.y = timePoint.y - thisObject.container.frame.height } function onZoomChanged (event) { From abb09e18d88387926d39cf829545b99c8fb85fd5 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 10 Jan 2020 14:10:28 +0100 Subject: [PATCH 071/264] Bug Fixed, scales well limited --- Scales/Commons.js | 9 ++------- Scales/RateScale.js | 6 ++++-- Scales/TimeFrameScale.js | 6 ++++-- Scales/TimeScale.js | 6 ++++-- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Scales/Commons.js b/Scales/Commons.js index db22d6459..b4259b9c2 100644 --- a/Scales/Commons.js +++ b/Scales/Commons.js @@ -1,5 +1,5 @@ -function drawScaleDisplay (label1, label2, label3, xExtraOffSet1, xExtraOffSet2, xExtraOffSet3, icon1, icon2, container, fitFunction) { +function drawScaleDisplay (label1, label2, label3, xExtraOffSet1, xExtraOffSet2, xExtraOffSet3, icon1, icon2, container) { let fontSize1 = 10 let fontSize2 = 20 let fontSize3 = 10 @@ -14,8 +14,7 @@ function drawScaleDisplay (label1, label2, label3, xExtraOffSet1, xExtraOffSet2, borderColor: UI_COLOR.RUSTED_RED, castShadow: false, backgroundColor: UI_COLOR.DARK, - opacity: OPACITY, - fitFunction: fitFunction + opacity: OPACITY } roundedCornersBackground(params) @@ -32,7 +31,6 @@ function drawScaleDisplay (label1, label2, label3, xExtraOffSet1, xExtraOffSet2, labelPoint1 = container.frame.frameThisPoint(labelPoint1) let x = labelPoint1.x - labelPoint1 = fitFunction(labelPoint1) labelPoint1.x = x browserCanvasContext.font = fontSize1 + 'px ' + UI_FONT.PRIMARY @@ -49,7 +47,6 @@ function drawScaleDisplay (label1, label2, label3, xExtraOffSet1, xExtraOffSet2, } labelPoint2 = container.frame.frameThisPoint(labelPoint2) - labelPoint2 = fitFunction(labelPoint2) browserCanvasContext.font = fontSize2 + 'px ' + UI_FONT.PRIMARY browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)' @@ -65,7 +62,6 @@ function drawScaleDisplay (label1, label2, label3, xExtraOffSet1, xExtraOffSet2, } labelPoint3 = container.frame.frameThisPoint(labelPoint3) - labelPoint3 = fitFunction(labelPoint3) browserCanvasContext.font = fontSize3 + 'px ' + UI_FONT.PRIMARY browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)' @@ -108,4 +104,3 @@ function drawScaleDisplay (label1, label2, label3, xExtraOffSet1, xExtraOffSet2, } } } - diff --git a/Scales/RateScale.js b/Scales/RateScale.js index 1d8ba85ca..5f81177b6 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -138,6 +138,9 @@ function newRateScale () { upCorner = transformThisPoint(upCorner, limitingContainer) bottonCorner = transformThisPoint(bottonCorner, limitingContainer) + upCorner = limitingContainer.fitFunction(upCorner, true) + bottonCorner = limitingContainer.fitFunction(bottonCorner, true) + /* Mouse Position Rate Calculation */ let ratePoint = { x: 0, @@ -156,7 +159,6 @@ function newRateScale () { ratePoint = transformThisPoint(ratePoint, limitingContainer.frame.container) ratePoint.y = mouse.position.y - thisObject.container.frame.height / 2 + thisObject.container.frame.height - ratePoint = limitingContainer.fitFunction(ratePoint, true) /* Checking against the container limits. */ if (ratePoint.x < upCorner.x) { ratePoint.x = upCorner.x } @@ -287,6 +289,6 @@ function newRateScale () { let icon1 = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.payload.parentNode.type) let icon2 = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.type) - drawScaleDisplay(label1, label2, label3, 0, 0, 0, icon1, icon2, thisObject.container, thisObject.fitFunction) + drawScaleDisplay(label1, label2, label3, 0, 0, 0, icon1, icon2, thisObject.container) } } diff --git a/Scales/TimeFrameScale.js b/Scales/TimeFrameScale.js index 40b27b7cf..ed3c6c5c6 100644 --- a/Scales/TimeFrameScale.js +++ b/Scales/TimeFrameScale.js @@ -108,6 +108,9 @@ function newTimeFrameScale () { upCorner = transformThisPoint(upCorner, limitingContainer) bottonCorner = transformThisPoint(bottonCorner, limitingContainer) + upCorner = limitingContainer.fitFunction(upCorner, true) + bottonCorner = limitingContainer.fitFunction(bottonCorner, true) + /* Positioning */ timePoint = { x: 0, @@ -116,7 +119,6 @@ function newTimeFrameScale () { timePoint = transformThisPoint(timePoint, limitingContainer.frame.container) timePoint.x = mouse.position.x - thisObject.container.frame.width / 2 - timePoint = limitingContainer.fitFunction(timePoint, true) /* Checking against the container limits. */ if (timePoint.x < upCorner.x) { timePoint.x = upCorner.x } @@ -226,6 +228,6 @@ function newTimeFrameScale () { let icon1 = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.payload.parentNode.type) let icon2 = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.type) - drawScaleDisplay(label1, label2, label3, 0, 0, 0, icon1, icon2, thisObject.container, thisObject.fitFunction) + drawScaleDisplay(label1, label2, label3, 0, 0, 0, icon1, icon2, thisObject.container) } } diff --git a/Scales/TimeScale.js b/Scales/TimeScale.js index 4a1039573..9bd8a5372 100644 --- a/Scales/TimeScale.js +++ b/Scales/TimeScale.js @@ -138,6 +138,9 @@ function newTimeScale () { upCorner = transformThisPoint(upCorner, limitingContainer) bottonCorner = transformThisPoint(bottonCorner, limitingContainer) + upCorner = limitingContainer.fitFunction(upCorner, true) + bottonCorner = limitingContainer.fitFunction(bottonCorner, true) + /* Mouse Position Date Calculation */ let timePoint = { x: mouse.position.x, @@ -156,7 +159,6 @@ function newTimeScale () { timePoint = transformThisPoint(timePoint, limitingContainer.frame.container) timePoint.x = mouse.position.x - thisObject.container.frame.width / 2 - timePoint = limitingContainer.fitFunction(timePoint) /* Checking against the container limits. */ if (timePoint.x < upCorner.x) { timePoint.x = upCorner.x } @@ -287,6 +289,6 @@ function newTimeScale () { let icon1 = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.payload.parentNode.type) let icon2 = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.type) - drawScaleDisplay(label1, label2, label3, 0, 0, 0, icon1, icon2, thisObject.container, thisObject.fitFunction) + drawScaleDisplay(label1, label2, label3, 0, 0, 0, icon1, icon2, thisObject.container) } } From d0c96d5b4b88f6af685e4f8067d99b8e9d30dbf1 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 10 Jan 2020 14:39:16 +0100 Subject: [PATCH 072/264] Events childrenMouseOver taken from timelineCharts --- ChartsSpace/TimeMachine.js | 13 +++++++++++-- ChartsSpace/TimelineChart.js | 4 ++-- Scales/TimeScale.js | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 5ff5de51e..107f09648 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -77,8 +77,9 @@ function newTimeMachine () { thisObject.container.eventHandler.stopListening(onMouseNotOverEventSuscriptionId) for (let i = 0; i < thisObject.timelineCharts.length; i++) { - let chart = thisObject.timelineCharts[i] - chart.finalize() + let timelineChart = thisObject.timelineCharts[i] + timelineChart.container.eventHandler.stopListening(timelineChart.onChildrenMouseOverEventSuscriptionId) + timelineChart.finalize() } thisObject.timelineCharts = undefined @@ -276,6 +277,7 @@ function newTimeMachine () { let timelineChart = thisObject.timelineCharts[i] if (timelineChart.syncWithDesignerLoop < syncWithDesignerLoop) { /* Must be removed */ + timelineChart.container.eventHandler.stopListening(timelineChart.onChildrenMouseOverEventSuscriptionId) timelineChart.finalize() timelineChartsMap.delete(timelineChart.nodeId) thisObject.timelineCharts.splice(i, 1) @@ -300,6 +302,13 @@ function newTimeMachine () { timelineChart.container.frame.position.y = 0 timelineChart.initialize(DEFAULT_EXCHANGE, DEFAULT_MARKET, timeLineCoordinateSystem, onTimelineChartInitialized) + /* we will store the event suscription id as a property of the timelineChart, to avoid keeping it an a separate array */ + timelineChart.onChildrenMouseOverEventSuscriptionId = timelineChart.container.eventHandler.listenToEvent('onChildrenMouseOver', onChildrenMouseOver) + + function onChildrenMouseOver (event) { + thisObject.container.eventHandler.raiseEvent('onMouseOver', event) + } + function onTimelineChartInitialized (err) { if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) { if (ERROR_LOG === true) { logger.write('[ERROR] syncWithDesigner -> initializeTimelineChart -> Initialization Failed. -> Err ' + err.message) } diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 0eb9022dd..7e68224e4 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -178,6 +178,7 @@ function newTimelineChart () { onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) function onMouseOver (event) { + /* This event gets to the timelinechart container because it inherits it from the time machine container, which is the one raising Mouse Over and Mouse not Over Events to its children. */ if (thisObject.timeFrameScale !== undefined) { thisObject.timeFrameScale.visible = true thisObject.timeFrameScale.onMouseOverSomeTimeMachineContainer(event) @@ -225,8 +226,7 @@ function newTimelineChart () { timeFrameScaleMouseOverEventSuscriptionId = thisObject.timeFrameScale.container.eventHandler.listenToEvent('onMouseOver', timeFrameScaleMouseOver) function timeFrameScaleMouseOver (event) { - mouse.position.x = event.x - mouse.position.y = event.y + thisObject.container.eventHandler.raiseEvent('onChildrenMouseOver', event) saveUserPosition(thisObject.container, timeLineCoordinateSystem, event) } diff --git a/Scales/TimeScale.js b/Scales/TimeScale.js index 9bd8a5372..30713d73c 100644 --- a/Scales/TimeScale.js +++ b/Scales/TimeScale.js @@ -17,7 +17,7 @@ function newTimeScale () { } const LENGHT_PERCENTAGE_DEFAULT_VALUE = 5 - const STEP_SIZE = 2.5 + const STEP_SIZE = 1 thisObject.container = newContainer() thisObject.container.initialize(MODULE_NAME) From 4c5662e50224c52213014cb945f6b76705decf71 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 10 Jan 2020 14:43:57 +0100 Subject: [PATCH 073/264] Background order fixed --- Spaces/ChartSpace.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Spaces/ChartSpace.js b/Spaces/ChartSpace.js index 77910bd17..6500bd1db 100644 --- a/Spaces/ChartSpace.js +++ b/Spaces/ChartSpace.js @@ -293,7 +293,7 @@ function newChartSpace () { drawSpaceBackground() for (let i = 0; i < thisObject.timeMachines.length; i++) { - let timeMachine = thisObject.timeMachines[i] + let timeMachine = thisObject.timeMachines[thisObject.timeMachines.length - i - 1] timeMachine.drawBackground() } } From 866691306551a322fabe60879cf16cea35d4e5cb Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 10 Jan 2020 15:00:35 +0100 Subject: [PATCH 074/264] Bug Fixed while dragging --- Canvas.js | 21 ++++++++++----------- Scales/RateScale.js | 2 +- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Canvas.js b/Canvas.js index b7f51fbbc..ac164db12 100644 --- a/Canvas.js +++ b/Canvas.js @@ -663,8 +663,12 @@ function newCanvas () { function onMouseOver (event) { try { - /* Then we check who is the current object underneeth the mounse. */ + if (containerDragStarted === true) { + containerBeingDragged.eventHandler.raiseEvent('onMouseOver', event) + return + } + /* Then we check who is the current object underneeth the mounse. */ let point = { x: event.pageX, y: event.pageY - CURRENT_TOP_MARGIN @@ -672,8 +676,7 @@ function newCanvas () { let container - /* We check if the mouse is over an element of the Strategy Space / */ - + /* We check if the mouse is over an element of the Strategy Space / */ if (thisObject.designerSpace !== undefined) { container = thisObject.designerSpace.getContainer(point) @@ -683,8 +686,7 @@ function newCanvas () { } } - /* We check if the mouse is over an element of the Top Space / */ - + /* We check if the mouse is over an element of the Top Space / */ if (thisObject.topSpace !== undefined) { container = thisObject.topSpace.getContainer(point) @@ -694,8 +696,7 @@ function newCanvas () { } } - /* We check if the mouse is over an element of the CockpitSpace / */ - + /* We check if the mouse is over an element of the CockpitSpace / */ if (thisObject.cockpitSpace !== undefined) { container = thisObject.cockpitSpace.getContainer(point) @@ -705,8 +706,7 @@ function newCanvas () { } } - /* We check if the mouse is over a panel/ */ - + /* We check if the mouse is over a panel/ */ if (thisObject.panelsSpace !== undefined) { container = thisObject.panelsSpace.getContainer(point) @@ -716,8 +716,7 @@ function newCanvas () { } } - /* If it is not, then we check if it is over any of the existing containers at the Chart Space. */ - + /* If it is not, then we check if it is over any of the existing containers at the Chart Space. */ if (thisObject.chartSpace !== undefined) { container = thisObject.chartSpace.getContainer(point, GET_CONTAINER_PURPOSE.MOUSE_OVER) diff --git a/Scales/RateScale.js b/Scales/RateScale.js index 5f81177b6..5be5a908d 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -105,7 +105,7 @@ function newRateScale () { delta = event.wheelDelta if (delta < 0) { thisObject.heightPercentage = thisObject.heightPercentage - STEP_SIZE - if (thisObject.heightPercentage < STEP_SIZE) { thisObject.heightPercentage = STEP_SIZE } + if (thisObject.heightPercentage < STEP_SIZE * 3) { thisObject.heightPercentage = STEP_SIZE } } else { thisObject.heightPercentage = thisObject.heightPercentage + STEP_SIZE if (thisObject.heightPercentage > 150) { thisObject.heightPercentage = 200 } From 6f1f85b1943e09eb61188f60bd7e6164ee660a5e Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 10 Jan 2020 15:17:05 +0100 Subject: [PATCH 075/264] bug fixed turning off scales when switching focus --- ChartsSpace/TimeMachine.js | 11 ----------- ChartsSpace/TimelineChart.js | 1 + Spaces/ChartSpace.js | 9 ++++++++- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 107f09648..e193efcab 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -217,17 +217,6 @@ function newTimeMachine () { if (thisObject.container.frame.isThisPointHere(point) === true) { return thisObject.container - } else { - if (purpose === GET_CONTAINER_PURPOSE.MOUSE_OVER) { - thisObject.container.eventHandler.raiseEvent('onMouseNotOver') - if (thisObject.timeScale !== undefined) { - thisObject.timeScale.visible = false - } - if (thisObject.rateScale !== undefined) { - thisObject.rateScale.visible = false - } - } - return } } diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 7e68224e4..7a7296485 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -193,6 +193,7 @@ function newTimelineChart () { onMouseNotOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) function onMouseNotOver (event) { + /* This event is inherited from the Time Machine */ if (thisObject.timeFrameScale !== undefined) { thisObject.timeFrameScale.visible = false } diff --git a/Spaces/ChartSpace.js b/Spaces/ChartSpace.js index 6500bd1db..7f4fcca26 100644 --- a/Spaces/ChartSpace.js +++ b/Spaces/ChartSpace.js @@ -70,8 +70,15 @@ function newChartSpace () { let container - /* Now we see which is the inner most container that has it */ + /* This first step is not actually to get the container but to allow things to be turned off in case there is a switch of focus from one time machine to another */ + for (let i = 0; i < thisObject.timeMachines.length; i++) { + container = thisObject.timeMachines[i].container + if (purpose === GET_CONTAINER_PURPOSE.MOUSE_OVER) { + container.eventHandler.raiseEvent('onMouseNotOver') + } + } + /* Now we see which is the inner most container that has it */ for (let i = 0; i < thisObject.timeMachines.length; i++) { container = thisObject.timeMachines[i].getContainer(point, purpose) if (container !== undefined) { From e570f889a62f3170f47d4d5ab0839b832e2eb8e1 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 10 Jan 2020 16:53:38 +0100 Subject: [PATCH 076/264] BUG in CANVAS!!! fixed --- Canvas.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Canvas.js b/Canvas.js index ac164db12..2304320a7 100644 --- a/Canvas.js +++ b/Canvas.js @@ -664,7 +664,11 @@ function newCanvas () { function onMouseOver (event) { try { if (containerDragStarted === true) { - containerBeingDragged.eventHandler.raiseEvent('onMouseOver', event) + let point = { + x: event.pageX, + y: event.pageY - CURRENT_TOP_MARGIN + } + containerBeingDragged.eventHandler.raiseEvent('onMouseOver', point) return } @@ -742,7 +746,6 @@ function newCanvas () { lastContainerMouseOver.eventHandler.raiseEvent('onMouseNotOver', point) } } - container.eventHandler.raiseEvent('onMouseOver', point) lastContainerMouseOver = container } From 283fcd9979ead78a914070fe2a5adaba0fd9b67b Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 10 Jan 2020 17:15:43 +0100 Subject: [PATCH 077/264] Bug Fixed, no scale coming into de designer --- Scales/Commons.js | 2 +- Scales/TimeFrameScale.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Scales/Commons.js b/Scales/Commons.js index b4259b9c2..8871558ff 100644 --- a/Scales/Commons.js +++ b/Scales/Commons.js @@ -13,7 +13,7 @@ function drawScaleDisplay (label1, label2, label3, xExtraOffSet1, xExtraOffSet2, container: container, borderColor: UI_COLOR.RUSTED_RED, castShadow: false, - backgroundColor: UI_COLOR.DARK, + backgroundColor: UI_COLOR.BLACK, opacity: OPACITY } diff --git a/Scales/TimeFrameScale.js b/Scales/TimeFrameScale.js index ed3c6c5c6..366a6edb7 100644 --- a/Scales/TimeFrameScale.js +++ b/Scales/TimeFrameScale.js @@ -123,6 +123,8 @@ function newTimeFrameScale () { /* Checking against the container limits. */ if (timePoint.x < upCorner.x) { timePoint.x = upCorner.x } if (timePoint.x + thisObject.container.frame.width > bottonCorner.x) { timePoint.x = bottonCorner.x - thisObject.container.frame.width } + if (timePoint.y < upCorner.y + thisObject.container.frame.height) { timePoint.y = upCorner.y + thisObject.container.frame.height } + if (timePoint.y > bottonCorner.y) { timePoint.y = bottonCorner.y } thisObject.container.frame.position.x = timePoint.x thisObject.container.frame.position.y = timePoint.y - thisObject.container.frame.height From d073e7497cd778d298b7e8b301f99b2796a9691c Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 10 Jan 2020 17:18:03 +0100 Subject: [PATCH 078/264] Bug Fixed with physics order --- Canvas.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Canvas.js b/Canvas.js index 2304320a7..b6c7cd525 100644 --- a/Canvas.js +++ b/Canvas.js @@ -120,9 +120,9 @@ function newCanvas () { animation.addCallBackFunction('System Event Handler Physics', systemEventHandler.physics) /* Spcaces Physics */ + animation.addCallBackFunction('CockpitSpace Physics', thisObject.cockpitSpace.physics) animation.addCallBackFunction('Floating Space Physics', thisObject.floatingSpace.physics) animation.addCallBackFunction('Chart Space Physics', thisObject.chartSpace.physics) - animation.addCallBackFunction('CockpitSpace Physics', thisObject.cockpitSpace.physics) animation.addCallBackFunction('Strategy Space Physics', thisObject.designerSpace.physics) animation.addCallBackFunction('Panels Space Physics', thisObject.panelsSpace.physics) From ec521be7c20d29a0323bec6b0b307c5ae5445925 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 10 Jan 2020 19:27:01 +0100 Subject: [PATCH 079/264] Stacking Time Frame Scales --- ChartsSpace/TimelineChart.js | 2 +- Scales/TimeFrameScale.js | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 7a7296485..08e78d287 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -356,7 +356,7 @@ function newTimelineChart () { function drawChartsBackground () { /* We will paint some transparent background here. */ - let opacity = '0.5' + let opacity = '0.1' let fromPoint = { x: 0, diff --git a/Scales/TimeFrameScale.js b/Scales/TimeFrameScale.js index 366a6edb7..28aa573e6 100644 --- a/Scales/TimeFrameScale.js +++ b/Scales/TimeFrameScale.js @@ -111,6 +111,24 @@ function newTimeFrameScale () { upCorner = limitingContainer.fitFunction(upCorner, true) bottonCorner = limitingContainer.fitFunction(bottonCorner, true) + /* We will check if we need to change the bottom because of being one of many scales of the same type */ + let levelsUp = 0 + if (thisObject.payload.parentNode === undefined) { return } // This happens when in the process of deleting the scale, timeline chart or time machine. + if (thisObject.payload.parentNode.type === 'Timeline Chart') { + if (thisObject.payload.parentNode.payload.parentNode.timeFrameScale !== undefined) { + levelsUp++ + } + for (let i = 0; i < thisObject.payload.parentNode.payload.parentNode.timelineCharts.length; i++) { + let timelineChart = thisObject.payload.parentNode.payload.parentNode.timelineCharts[i] + if (thisObject.payload.node.id !== timelineChart.timeFrameScale.id) { + levelsUp++ + } else { + break + } + } + } + bottonCorner.y = bottonCorner.y - thisObject.container.frame.height * levelsUp + /* Positioning */ timePoint = { x: 0, From 90314ffcf2177760af3002ca55d828744ae6d8d0 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 10 Jan 2020 19:54:34 +0100 Subject: [PATCH 080/264] Bug Fixed at Plotter when dragging Time Machine container --- ChartsSpace/PlottersManager.js | 2 +- ChartsSpace/TimeMachine.js | 2 +- ChartsSpace/TimelineChart.js | 2 +- Plotter.js | 31 +++++++++++++++++++------------ 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/ChartsSpace/PlottersManager.js b/ChartsSpace/PlottersManager.js index f1b5728f1..a221e16eb 100644 --- a/ChartsSpace/PlottersManager.js +++ b/ChartsSpace/PlottersManager.js @@ -199,7 +199,7 @@ function newPlottersManager () { plotter = getNewPlotter(pProductCard.product.plotter.dataMine, pProductCard.product.plotter.codeName, pProductCard.product.plotter.moduleName) } - plotter.container.connectToParent(thisObject.container, true, true, false, true, true, true) + plotter.container.connectToParent(thisObject.container, true, true, false, true, true, true, false, false, true) plotter.container.frame.position.x = thisObject.container.frame.width / 2 - plotter.container.frame.width / 2 plotter.container.frame.position.y = thisObject.container.frame.height / 2 - plotter.container.frame.height / 2 plotter.fitFunction = thisObject.fitFunction diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index e193efcab..1653d556e 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -284,7 +284,7 @@ function newTimeMachine () { timelineChart.payload.uiObject.setValue('Loading...') /* Setting up the new timeline chart. */ - timelineChart.container.connectToParent(thisObject.container, true, true, false, true, true, true) + timelineChart.container.connectToParent(thisObject.container, true, true, false, true, true, true, false, false, true) timelineChart.container.fitFunction = thisObject.container.fitFunction timelineChart.container.frame.height = thisObject.container.frame.height timelineChart.container.frame.position.x = thisObject.container.frame.width / 2 - timelineChart.container.frame.width / 2 diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 08e78d287..bbe6e5084 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -158,7 +158,7 @@ function newTimelineChart () { plotterManager = newPlottersManager() - plotterManager.container.connectToParent(thisObject.container, true, true, false, true, true, true) + plotterManager.container.connectToParent(thisObject.container, true, true, false, true, true, true, false, false, true) plotterManager.container.frame.position.x = 0 plotterManager.container.frame.position.y = 0 diff --git a/Plotter.js b/Plotter.js index 00fa2a607..a0cde53cc 100644 --- a/Plotter.js +++ b/Plotter.js @@ -58,6 +58,7 @@ function newPlotter () { let dimmensionsChangedEventSubscriptionId let marketFilesUpdatedEventSubscriptionId let dailyFilesUpdatedEventSubscriptionId + let onDisplaceEventSubscriptionId let logged = false return thisObject @@ -71,6 +72,7 @@ function newPlotter () { thisObject.container.eventHandler.stopListening(dimmensionsChangedEventSubscriptionId) marketFiles.eventHandler.stopListening(marketFilesUpdatedEventSubscriptionId) dailyFiles.eventHandler.stopListening(dailyFilesUpdatedEventSubscriptionId) + thisObject.container.eventHandler.stopListening(onDisplaceEventSubscriptionId) /* Clear References */ marketFiles = undefined @@ -120,6 +122,7 @@ function newPlotter () { dragFinishedEventSubscriptionId = canvas.eventHandler.listenToEvent('Drag Finished', onDragFinished) marketFilesUpdatedEventSubscriptionId = marketFiles.eventHandler.listenToEvent('Files Updated', onMarketFilesUpdated) dailyFilesUpdatedEventSubscriptionId = dailyFiles.eventHandler.listenToEvent('Files Updated', onDailyFilesUpdated) + onDisplaceEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onDisplace', onDisplace) /* Get ready for plotting. */ recalculate() @@ -783,20 +786,24 @@ function newPlotter () { } } + function onDisplace (event) { + recalculateAll(event) + } + function onOffsetChanged (event) { - try { - mustRecalculateDataPoints = true - if (event !== undefined) { - if (event.recalculate === true) { - recalculate() - return - } - } - if (Math.random() * 100 > 95) { + recalculateAll(event) + } + + function recalculateAll (event) { + mustRecalculateDataPoints = true + if (event !== undefined) { + if (event.recalculate === true) { recalculate() - }; - } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] onOffsetChanged -> err = ' + err.stack) } + return + } + } + if (Math.random() * 100 > 95) { + recalculate() } } } From 9e88c6f7a8de6ebc130033be71cb9157b85247ed Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 10 Jan 2020 20:14:35 +0100 Subject: [PATCH 081/264] Bug Fixed when plotters were not initialized --- ChartsSpace/PlottersManager.js | 12 +++++------- Scales/TimeScale.js | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/ChartsSpace/PlottersManager.js b/ChartsSpace/PlottersManager.js index a221e16eb..5c4e5d387 100644 --- a/ChartsSpace/PlottersManager.js +++ b/ChartsSpace/PlottersManager.js @@ -318,13 +318,11 @@ function newPlottersManager () { function setTimeFrame (pTimeFrame) { timeFrame = pTimeFrame - if (initializationReady === true) { - for (let i = 0; i < productPlotters.length; i++) { - let productPlotter = productPlotters[i] - productPlotter.productCard.setTimeFrame(timeFrame) - productPlotter.storage.setTimeFrame(timeFrame) - productPlotter.plotter.setTimeFrame(timeFrame) - } + for (let i = 0; i < productPlotters.length; i++) { + let productPlotter = productPlotters[i] + productPlotter.productCard.setTimeFrame(timeFrame) + productPlotter.storage.setTimeFrame(timeFrame) + productPlotter.plotter.setTimeFrame(timeFrame) } } diff --git a/Scales/TimeScale.js b/Scales/TimeScale.js index 30713d73c..9bd8a5372 100644 --- a/Scales/TimeScale.js +++ b/Scales/TimeScale.js @@ -17,7 +17,7 @@ function newTimeScale () { } const LENGHT_PERCENTAGE_DEFAULT_VALUE = 5 - const STEP_SIZE = 1 + const STEP_SIZE = 2.5 thisObject.container = newContainer() thisObject.container.initialize(MODULE_NAME) From 02b593e00ae495755b8fe06df3c14c1b59c79ae8 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 10 Jan 2020 20:27:06 +0100 Subject: [PATCH 082/264] more power to mouse wheel --- Scales/RateScale.js | 7 +++++-- Scales/TimeScale.js | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Scales/RateScale.js b/Scales/RateScale.js index 5be5a908d..527bfac82 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -102,12 +102,15 @@ function newRateScale () { } function onMouseWheel (event) { + let morePower = 1 + if (event.buttons === 4) { morePower = 5 } // Mouse wheel pressed. + delta = event.wheelDelta if (delta < 0) { - thisObject.heightPercentage = thisObject.heightPercentage - STEP_SIZE + thisObject.heightPercentage = thisObject.heightPercentage - STEP_SIZE * morePower if (thisObject.heightPercentage < STEP_SIZE * 3) { thisObject.heightPercentage = STEP_SIZE } } else { - thisObject.heightPercentage = thisObject.heightPercentage + STEP_SIZE + thisObject.heightPercentage = thisObject.heightPercentage + STEP_SIZE * morePower if (thisObject.heightPercentage > 150) { thisObject.heightPercentage = 200 } } event.heightPercentage = thisObject.heightPercentage diff --git a/Scales/TimeScale.js b/Scales/TimeScale.js index 9bd8a5372..086e45fa9 100644 --- a/Scales/TimeScale.js +++ b/Scales/TimeScale.js @@ -101,12 +101,15 @@ function newTimeScale () { } function onMouseWheel (event) { + let morePower = 1 + if (event.buttons === 4) { morePower = 5 } // Mouse wheel pressed. + delta = event.wheelDelta if (delta < 0) { - thisObject.lenghtPercentage = thisObject.lenghtPercentage - STEP_SIZE + thisObject.lenghtPercentage = thisObject.lenghtPercentage - STEP_SIZE * morePower if (thisObject.lenghtPercentage < STEP_SIZE) { thisObject.lenghtPercentage = STEP_SIZE } } else { - thisObject.lenghtPercentage = thisObject.lenghtPercentage + STEP_SIZE + thisObject.lenghtPercentage = thisObject.lenghtPercentage + STEP_SIZE * morePower if (thisObject.lenghtPercentage > 400) { thisObject.lenghtPercentage = 400 } } From 6014261a9876eff9ace5a1821470f5b6d74f6b42 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 10 Jan 2020 20:37:32 +0100 Subject: [PATCH 083/264] Code Cleaning --- ChartsSpace/TimelineChart.js | 34 ---------------------------------- 1 file changed, 34 deletions(-) diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index bbe6e5084..e87eabccd 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -111,40 +111,6 @@ function newTimelineChart () { let productsPanel = canvas.panelsSpace.getPanel(productsPanelHandle, panelOwner) productsPanel.initialize(exchange, market) - logoA = new Image() - logoB = new Image() - logoExchange = new Image() - logoAA = new Image() - - logoA.onload = onImageALoaded - - function onImageALoaded () { - canDrawLogoA = true - } - - logoB.onload = onImageBLoaded - - function onImageBLoaded () { - canDrawLogoB = true - } - - logoExchange.onload = onImageExchangeLoaded - - function onImageExchangeLoaded () { - canDrawLogoExchange = true - } - - logoAA.onload = onImageAALoaded - - function onImageAALoaded () { - canDrawLogoAA = true - } - - logoA.src = window.canvasApp.urlPrefix + 'Images/tether-logo-background.png' - logoB.src = window.canvasApp.urlPrefix + 'Images/bitcoin-logo-background.png' - logoExchange.src = window.canvasApp.urlPrefix + 'Images/' + exchange + '-logo-background.png' - logoAA.src = window.canvasApp.urlPrefix + 'Images/sa-logo-background.png' - // moveToUserPosition(thisObject.container, timeLineCoordinateSystem, undefined, undefined, undefined, true) timeFrame = INITIAL_TIME_PERIOD datetime = NEW_SESSION_INITIAL_DATE From 2b1ff19acef17135897fd5ba490cf2f7ac0ad660 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 11 Jan 2020 09:03:39 +0100 Subject: [PATCH 084/264] Cleaning --- ChartsSpace/TimelineChart.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index e87eabccd..e5c7b9de5 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -31,16 +31,6 @@ function newTimelineChart () { let productsPanel - /* Background */ - let logoBaseAsset - let logoQuotedAsset - let logoExchange - let logoAA - let canDrawLogoA = false - let canDrawLogoB = false - let canDrawLogoExchange = false - let canDrawLogoAA = false - let plotterManager let exchange let market From 6394fe261900c91a05f55123c9eddf25aa0ef427 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 11 Jan 2020 09:15:17 +0100 Subject: [PATCH 085/264] Cleaning unued code --- ChartsSpace/TimeMachine.js | 18 +++++++++++++++++- ChartsSpace/TimelineChart.js | 19 +++---------------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 1653d556e..db77c5505 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -14,6 +14,8 @@ function newTimeMachine () { const logger = newWebDebugLog() logger.fileName = MODULE_NAME + let timeFrame = INITIAL_TIME_PERIOD + let thisObject = { container: undefined, timeScale: undefined, @@ -46,9 +48,11 @@ function newTimeMachine () { let onMouseOverEventSuscriptionId let onMouseNotOverEventSuscriptionId let timeScaleEventSuscriptionId - let rateScaleEventSuscriptionId let timeScaleMouseOverEventSuscriptionId + let rateScaleEventSuscriptionId let rateScaleMouseOverEventSuscriptionId + let timeFrameScaleEventSuscriptionId + let timeFrameScaleMouseOverEventSuscriptionId setupContainer() return thisObject @@ -73,6 +77,10 @@ function newTimeMachine () { finalizeRateScale() } + if (thisObject.timeFrameScale !== undefined) { + finalizeTimeFrameScale() + } + thisObject.container.eventHandler.stopListening(onMouseOverEventSuscriptionId) thisObject.container.eventHandler.stopListening(onMouseNotOverEventSuscriptionId) @@ -108,7 +116,15 @@ function newTimeMachine () { thisObject.rateScale = undefined } + function finalizeTimeFrameScale () { + thisObject.timeFrameScale.container.eventHandler.stopListening(timeFrameScaleEventSuscriptionId) + thisObject.timeFrameScale.container.eventHandler.stopListening(timeFrameScaleMouseOverEventSuscriptionId) + thisObject.timeFrameScale.finalize() + thisObject.timeFrameScale = undefined + } + function initialize (callBackFunction) { + timeFrame = INITIAL_TIME_PERIOD recalculateScale() onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index e5c7b9de5..457f858c5 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -17,7 +17,6 @@ function newTimelineChart () { timeFrameScale: undefined, payload: undefined, physics: physics, - setDatetime: setDatetime, drawBackground: drawBackground, draw: draw, getContainer: getContainer, @@ -91,7 +90,7 @@ function newTimelineChart () { function initialize (pExchange, pMarket, pTimeLineCoordinateSystem, callBackFunction) { try { - /* We load the logow we will need for the background. */ + /* We load the logow we will need for the background. */ exchange = pExchange market = pMarket timeLineCoordinateSystem = pTimeLineCoordinateSystem @@ -105,13 +104,11 @@ function newTimelineChart () { timeFrame = INITIAL_TIME_PERIOD datetime = NEW_SESSION_INITIAL_DATE - /* Event Subscriptions - we need this events to be fired first here and then in active Plotters. */ - + /* Event Subscriptions - we need this events to be fired first here and then in active Plotters. */ onOffsetChangedEventSuscriptionId = viewPort.eventHandler.listenToEvent('Offset Changed', onOffsetChanged) onZoomChangedEventSuscriptionId = viewPort.eventHandler.listenToEvent('Zoom Changed', onZoomChanged) - /* Initialize the Plotter Manager */ - + /* Initialize the Plotter Manager */ plotterManager = newPlottersManager() plotterManager.container.connectToParent(thisObject.container, true, true, false, true, true, true, false, false, true) @@ -197,16 +194,6 @@ function newTimelineChart () { } } - function setDatetime (pDatetime) { - /* This function is used when the time is changed through the user interface, but without zooming or panning. */ - /* No matter if the day changed or not, we need to inform all visible Plotters. */ - - if (thisObject.container.frame.isInViewPort()) { - plotterManager.setDatetime(pDatetime) - plotterManager.positionAtDatetime(pDatetime) - } - } - function onOffsetChanged () { if (initializationReady === true) { if (thisObject.container.frame.isInViewPort()) { From 85707562b7707c2222dcf1edd723f3019b56bd64 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 11 Jan 2020 09:32:18 +0100 Subject: [PATCH 086/264] Porting timeframescale to the time machine and cleaning code --- ChartsSpace/TimeLineCoordinateSystem.js | 16 +++---- ChartsSpace/TimeMachine.js | 60 ++++++++++++++++++++----- ChartsSpace/TimelineChart.js | 24 +++++----- Plotter.js | 6 +-- SplashScreen.js | 4 +- 5 files changed, 73 insertions(+), 37 deletions(-) diff --git a/ChartsSpace/TimeLineCoordinateSystem.js b/ChartsSpace/TimeLineCoordinateSystem.js index 5cd0abfa5..2c906b81d 100644 --- a/ChartsSpace/TimeLineCoordinateSystem.js +++ b/ChartsSpace/TimeLineCoordinateSystem.js @@ -92,8 +92,8 @@ function newTimeLineCoordinateSystem () { */ point = { - x: (point.x - this.min.x) * this.scale.x, - y: maxHeight - (point.y - this.min.y) * this.scale.y + x: (point.x - thisObject.min.x) * thisObject.scale.x, + y: maxHeight - (point.y - thisObject.min.y) * thisObject.scale.y } return point @@ -101,8 +101,8 @@ function newTimeLineCoordinateSystem () { function transformThisPoint2 (point) { point = { - x: (point.x - this.min.x) * this.scale.x, - y: (maxHeight - point.y - this.min.y) * this.scale.y + x: (point.x - thisObject.min.x) * thisObject.scale.x, + y: (maxHeight - point.y - thisObject.min.y) * thisObject.scale.y } return point @@ -110,8 +110,8 @@ function newTimeLineCoordinateSystem () { function unInverseTransform (point, inverseY) { point = { - x: (point.x / this.scale.x) + this.min.x, - y: (inverseY - point.y) / this.scale.y + this.min.y + x: (point.x / thisObject.scale.x) + thisObject.min.x, + y: (inverseY - point.y) / thisObject.scale.y + thisObject.min.y } return point @@ -119,8 +119,8 @@ function newTimeLineCoordinateSystem () { function inverseTransformUncappedY (point, inverseY) { point = { - x: (point.x - this.min.x) * this.scale.x, - y: (inverseY - point.y) * this.scale.y + x: (point.x - thisObject.min.x) * thisObject.scale.x, + y: (inverseY - point.y) * thisObject.scale.y } return point diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index db77c5505..c8b11a9c2 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -199,6 +199,33 @@ function newTimeMachine () { } } + function initializeTimeFrameScale () { + thisObject.timeFrameScale = newTimeFrameScale() + thisObject.timeFrameScale.fitFunction = thisObject.fitFunction + thisObject.timeFrameScale.payload = thisObject.payload.node.timeFrameScale.payload + + timeFrameScaleEventSuscriptionId = thisObject.timeFrameScale.container.eventHandler.listenToEvent('Time Frame Changed', function (event) { + let currentTimeFrame = timeFrame + timeFrame = event.timeFrame + if (timeFrame !== currentTimeFrame) { + for (let i = 0; i < thisObject.timelineCharts.length; i++) { + let timelineChart = thisObject.timelineCharts[i] + if (timelineChart.timeFrameScale === undefined) { + timelineChart.plotterManager.setTimeFrame(timeFrame) + } + } + } + }) + + thisObject.timeFrameScale.initialize(timeLineCoordinateSystem, thisObject.container) + + timeFrameScaleMouseOverEventSuscriptionId = thisObject.timeFrameScale.container.eventHandler.listenToEvent('onMouseOver', timeFrameScaleMouseOver) + + function timeFrameScaleMouseOver (event) { + thisObject.container.eventHandler.raiseEvent('onMouseOver', event) + } + } + function getContainer (point, purpose) { let container @@ -220,8 +247,17 @@ function newTimeMachine () { } } - for (let i = 0; i < this.timelineCharts.length; i++) { - container = this.timelineCharts[i].getContainer(point) + if (thisObject.timeFrameScale !== undefined) { + container = thisObject.timeFrameScale.getContainer(point) + if (container !== undefined) { + if (container.isForThisPurpose(purpose)) { + return container + } + } + } + + for (let i = 0; i < thisObject.timelineCharts.length; i++) { + container = thisObject.timelineCharts[i].getContainer(point) if (container !== undefined) { if (container.isForThisPurpose(purpose)) { if (thisObject.container.frame.isThisPointHere(point) === true) { @@ -269,7 +305,7 @@ function newTimeMachine () { let node = thisObject.payload.node.timelineCharts[j] let timelineChart = timelineChartsMap.get(node.id) if (timelineChart === undefined) { - /* The timeline chart node is new, thus we need to initialize a new timelineChart */ + /* The timeline timelineChart node is new, thus we need to initialize a new timelineChart */ initializeTimelineChart(node, syncWithDesignerLoop) } else { /* The time machine already exists, we tag it as existing at the current loop. */ @@ -299,7 +335,7 @@ function newTimeMachine () { timelineChartsMap.set(node.id, timelineChart) timelineChart.payload.uiObject.setValue('Loading...') - /* Setting up the new timeline chart. */ + /* Setting up the new timeline timelineChart. */ timelineChart.container.connectToParent(thisObject.container, true, true, false, true, true, true, false, false, true) timelineChart.container.fitFunction = thisObject.container.fitFunction timelineChart.container.frame.height = thisObject.container.frame.height @@ -348,25 +384,25 @@ function newTimeMachine () { } for (let i = 0; i < thisObject.timelineCharts.length; i++) { - let chart = thisObject.timelineCharts[i] - chart.physics() + let timelineChart = thisObject.timelineCharts[i] + timelineChart.physics() } } function drawBackground () { if (thisObject.container.frame.isInViewPort()) { - for (let i = 0; i < this.timelineCharts.length; i++) { - let chart = this.timelineCharts[i] - chart.drawBackground() + for (let i = 0; i < thisObject.timelineCharts.length; i++) { + let timelineChart = thisObject.timelineCharts[i] + timelineChart.drawBackground() } } } function draw () { if (thisObject.container.frame.isInViewPort()) { - for (let i = 0; i < this.timelineCharts.length; i++) { - let chart = this.timelineCharts[i] - chart.draw() + for (let i = 0; i < thisObject.timelineCharts.length; i++) { + let timelineChart = thisObject.timelineCharts[i] + timelineChart.draw() } if (thisObject.timeScale !== undefined) { thisObject.timeScale.draw() } diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 457f858c5..993752e17 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -16,6 +16,7 @@ function newTimelineChart () { fitFunction: undefined, timeFrameScale: undefined, payload: undefined, + plotterManager: undefined, physics: physics, drawBackground: drawBackground, draw: draw, @@ -30,7 +31,6 @@ function newTimelineChart () { let productsPanel - let plotterManager let exchange let market @@ -69,8 +69,8 @@ function newTimelineChart () { thisObject.container.eventHandler.stopListening(onMouseOverEventSuscriptionId) thisObject.container.eventHandler.stopListening(onMouseNotOverEventSuscriptionId) - plotterManager.finalize() - plotterManager = undefined + thisObject.plotterManager.finalize() + thisObject.plotterManager = undefined canvas.panelsSpace.destroyPanel(productsPanelHandle) @@ -109,15 +109,15 @@ function newTimelineChart () { onZoomChangedEventSuscriptionId = viewPort.eventHandler.listenToEvent('Zoom Changed', onZoomChanged) /* Initialize the Plotter Manager */ - plotterManager = newPlottersManager() + thisObject.plotterManager = newPlottersManager() - plotterManager.container.connectToParent(thisObject.container, true, true, false, true, true, true, false, false, true) + thisObject.plotterManager.container.connectToParent(thisObject.container, true, true, false, true, true, true, false, false, true) - plotterManager.container.frame.position.x = 0 - plotterManager.container.frame.position.y = 0 + thisObject.plotterManager.container.frame.position.x = 0 + thisObject.plotterManager.container.frame.position.y = 0 - plotterManager.fitFunction = thisObject.fitFunction - plotterManager.initialize(productsPanel, pExchange, pMarket, onPlotterManagerReady) + thisObject.plotterManager.fitFunction = thisObject.fitFunction + thisObject.plotterManager.initialize(productsPanel, pExchange, pMarket, onPlotterManagerReady) function onPlotterManagerReady (err) { if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) { @@ -171,7 +171,7 @@ function newTimelineChart () { let currentTimeFrame = timeFrame timeFrame = event.timeFrame if (timeFrame !== currentTimeFrame) { - plotterManager.setTimeFrame(timeFrame) + thisObject.plotterManager.setTimeFrame(timeFrame) } }) @@ -224,7 +224,7 @@ function newTimelineChart () { datetime = newDate - plotterManager.setDatetime(datetime) + thisObject.plotterManager.setDatetime(datetime) } function getContainer (point) { @@ -284,7 +284,7 @@ function newTimelineChart () { window.CHART_ON_FOCUS = exchange + ' ' + market.quotedAsset + '/' + market.baseAsset } drawChartsBackground() - plotterManager.draw() + thisObject.plotterManager.draw() } } diff --git a/Plotter.js b/Plotter.js index a0cde53cc..52d0110d4 100644 --- a/Plotter.js +++ b/Plotter.js @@ -168,8 +168,8 @@ function newPlotter () { try { let container /* First we check if this point is inside this space. */ - if (this.container.frame.isThisPointHere(point) === true) { - return this.container + if (thisObject.container.frame.isThisPointHere(point) === true) { + return thisObject.container } else { /* This point does not belong to this space. */ return undefined @@ -222,7 +222,7 @@ function newPlotter () { function draw () { try { - this.container.frame.draw() + thisObject.container.frame.draw() plotChart() } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] draw -> err = ' + err.stack) } diff --git a/SplashScreen.js b/SplashScreen.js index 38f75d5ef..c73dcad85 100644 --- a/SplashScreen.js +++ b/SplashScreen.js @@ -143,14 +143,14 @@ function newSplashScreen () { /* First we check if this point is inside this space. */ - if (this.container.frame.isThisPointHere(point) === true) { + if (thisObject.container.frame.isThisPointHere(point) === true) { /* Now we see which is the inner most container that has it */ // add validation of inner most containers here. /* The point does not belong to any inner container, so we return the current container. */ - return this.container + return thisObject.container } else { /* This point does not belong to this space. */ From 46936d5e0c62945180c3fd45707229e87eec8447 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 11 Jan 2020 09:34:36 +0100 Subject: [PATCH 087/264] Bug Fixed: purpose --- ChartsSpace/TimeMachine.js | 2 +- ChartsSpace/TimelineChart.js | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index c8b11a9c2..ddbdfd7c2 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -257,7 +257,7 @@ function newTimeMachine () { } for (let i = 0; i < thisObject.timelineCharts.length; i++) { - container = thisObject.timelineCharts[i].getContainer(point) + container = thisObject.timelineCharts[i].getContainer(point, purpose) if (container !== undefined) { if (container.isForThisPurpose(purpose)) { if (thisObject.container.frame.isThisPointHere(point) === true) { diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 993752e17..12e6ad5a4 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -227,11 +227,16 @@ function newTimelineChart () { thisObject.plotterManager.setDatetime(datetime) } - function getContainer (point) { + function getContainer (point, purpose) { let container if (thisObject.timeFrameScale !== undefined) { container = thisObject.timeFrameScale.getContainer(point) + if (container !== undefined) { + if (container.isForThisPurpose(purpose)) { + return container + } + } } return container From 9ce6410ca0bf4a92375635e103f909f709b3dacb Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 11 Jan 2020 10:02:47 +0100 Subject: [PATCH 088/264] Time Frame Scale at Time Machine Finished --- ChartsSpace/TimeMachine.js | 18 ++++++++++++++++++ ChartsSpace/TimelineChart.js | 5 +++++ 2 files changed, 23 insertions(+) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index ddbdfd7c2..1f21cb7a2 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -141,6 +141,10 @@ function newTimeMachine () { thisObject.rateScale.onMouseOverSomeTimeMachineContainer(event) thisObject.rateScale.visible = true } + if (thisObject.timeFrameScale !== undefined) { + thisObject.timeFrameScale.onMouseOverSomeTimeMachineContainer(event) + thisObject.timeFrameScale.visible = true + } } onMouseNotOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) @@ -152,6 +156,9 @@ function newTimeMachine () { if (thisObject.rateScale !== undefined) { thisObject.rateScale.visible = false } + if (thisObject.timeFrameScale !== undefined) { + thisObject.timeFrameScale.visible = false + } } callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) @@ -210,6 +217,7 @@ function newTimeMachine () { if (timeFrame !== currentTimeFrame) { for (let i = 0; i < thisObject.timelineCharts.length; i++) { let timelineChart = thisObject.timelineCharts[i] + timelineChart.upstreamTimeFrame = timeFrame if (timelineChart.timeFrameScale === undefined) { timelineChart.plotterManager.setTimeFrame(timeFrame) } @@ -296,6 +304,12 @@ function newTimeMachine () { if (thisObject.payload.node.rateScale !== undefined && thisObject.rateScale === undefined) { initializeRateScale() } + if (thisObject.payload.node.timeFrameScale === undefined && thisObject.timeFrameScale !== undefined) { + finalizeTimeFrameScale() + } + if (thisObject.payload.node.timeFrameScale !== undefined && thisObject.timeFrameScale === undefined) { + initializeTimeFrameScale() + } } function syncWithDesignerTimelineCharts () { @@ -382,6 +396,9 @@ function newTimeMachine () { if (thisObject.rateScale !== undefined) { thisObject.rateScale.physics() } + if (thisObject.timeFrameScale !== undefined) { + thisObject.timeFrameScale.physics() + } for (let i = 0; i < thisObject.timelineCharts.length; i++) { let timelineChart = thisObject.timelineCharts[i] @@ -407,6 +424,7 @@ function newTimeMachine () { if (thisObject.timeScale !== undefined) { thisObject.timeScale.draw() } if (thisObject.rateScale !== undefined) { thisObject.rateScale.draw() } + if (thisObject.timeFrameScale !== undefined) { thisObject.timeFrameScale.draw() } thisObject.container.frame.draw(false, true, false, thisObject.fitFunction) } diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 12e6ad5a4..ad84e6998 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -17,6 +17,7 @@ function newTimelineChart () { timeFrameScale: undefined, payload: undefined, plotterManager: undefined, + upstreamTimeFrame: undefined, physics: physics, drawBackground: drawBackground, draw: draw, @@ -86,6 +87,10 @@ function newTimelineChart () { thisObject.timeFrameScale.container.eventHandler.stopListening(timeFrameScaleMouseOverEventSuscriptionId) thisObject.timeFrameScale.finalize() thisObject.timeFrameScale = undefined + if (thisObject.upstreamTimeFrame !== undefined) { + timeFrame = thisObject.upstreamTimeFrame + thisObject.plotterManager.setTimeFrame(timeFrame) + } } function initialize (pExchange, pMarket, pTimeLineCoordinateSystem, callBackFunction) { From f51155a84cff11f880c2bece6f7d0b768b394581 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 11 Jan 2020 11:43:49 +0100 Subject: [PATCH 089/264] rateScale at timelineChart ported --- ...oordinateSystem.js => CoordinateSystem.js} | 3 +- ChartsSpace/TimeMachine.js | 34 ++--- ChartsSpace/TimelineChart.js | 118 +++++++++++++++--- Plotter.js | 24 ++-- Scales/RateScale.js | 18 +++ Scales/TimeFrameScale.js | 8 +- 6 files changed, 158 insertions(+), 47 deletions(-) rename ChartsSpace/{TimeLineCoordinateSystem.js => CoordinateSystem.js} (98%) diff --git a/ChartsSpace/TimeLineCoordinateSystem.js b/ChartsSpace/CoordinateSystem.js similarity index 98% rename from ChartsSpace/TimeLineCoordinateSystem.js rename to ChartsSpace/CoordinateSystem.js index 2c906b81d..93e261fda 100644 --- a/ChartsSpace/TimeLineCoordinateSystem.js +++ b/ChartsSpace/CoordinateSystem.js @@ -7,7 +7,7 @@ The scale on the Y axis depends on the data that wants to be plotted. Usually we */ -function newTimeLineCoordinateSystem () { +function newCoordinateSystem () { let thisObject = { min: undefined, max: undefined, @@ -126,4 +126,3 @@ function newTimeLineCoordinateSystem () { return point } } - diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 1f21cb7a2..bbbae6a7c 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -31,9 +31,7 @@ function newTimeMachine () { finalize: finalize } - const SEPARATION_BETWEEN_TIMELINE_CHARTS = 1.5 - - let timeLineCoordinateSystem = newTimeLineCoordinateSystem() + let timeMachineCoordinateSystem = newCoordinateSystem() let mouse = { position: { @@ -125,7 +123,7 @@ function newTimeMachine () { function initialize (callBackFunction) { timeFrame = INITIAL_TIME_PERIOD - recalculateScale() + recalculateCoordinateSystem() onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) @@ -171,12 +169,12 @@ function newTimeMachine () { timeScaleEventSuscriptionId = thisObject.timeScale.container.eventHandler.listenToEvent('Lenght Percentage Changed', function (event) { thisObject.container.frame.width = TIME_MACHINE_WIDTH * event.lenghtPercentage / 100 - recalculateScale() - moveToUserPosition(thisObject.container, timeLineCoordinateSystem, false, true, event.mousePosition, false, true) + recalculateCoordinateSystem() + moveToUserPosition(thisObject.container, timeMachineCoordinateSystem, false, true, event.mousePosition, false, true) thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) }) - thisObject.timeScale.initialize(timeLineCoordinateSystem, thisObject.container) + thisObject.timeScale.initialize(timeMachineCoordinateSystem, thisObject.container) timeScaleMouseOverEventSuscriptionId = thisObject.timeScale.container.eventHandler.listenToEvent('onMouseOver', timeScaleMouseOver) @@ -192,12 +190,12 @@ function newTimeMachine () { rateScaleEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('Height Percentage Changed', function (event) { thisObject.container.frame.height = TIME_MACHINE_HEIGHT * event.heightPercentage / 100 - recalculateScale() - moveToUserPosition(thisObject.container, timeLineCoordinateSystem, true, false, event.mousePosition, false, true) + recalculateCoordinateSystem() + moveToUserPosition(thisObject.container, timeMachineCoordinateSystem, true, false, event.mousePosition, false, true) thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) }) - thisObject.rateScale.initialize(timeLineCoordinateSystem, thisObject.container) + thisObject.rateScale.initialize(timeMachineCoordinateSystem, thisObject.container) rateScaleMouseOverEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('onMouseOver', rateScaleMouseOver) @@ -225,7 +223,7 @@ function newTimeMachine () { } }) - thisObject.timeFrameScale.initialize(timeLineCoordinateSystem, thisObject.container) + thisObject.timeFrameScale.initialize(timeMachineCoordinateSystem, thisObject.container) timeFrameScaleMouseOverEventSuscriptionId = thisObject.timeFrameScale.container.eventHandler.listenToEvent('onMouseOver', timeFrameScaleMouseOver) @@ -292,6 +290,12 @@ function newTimeMachine () { } function syncWithDesignerScales () { + if (thisObject.payload.node === undefined) { + finalizeTimeScale() + finalizeRateScale() + finalizeTimeFrameScale() + return + } if (thisObject.payload.node.timeScale === undefined && thisObject.timeScale !== undefined) { finalizeTimeScale() } @@ -355,7 +359,7 @@ function newTimeMachine () { timelineChart.container.frame.height = thisObject.container.frame.height timelineChart.container.frame.position.x = thisObject.container.frame.width / 2 - timelineChart.container.frame.width / 2 timelineChart.container.frame.position.y = 0 - timelineChart.initialize(DEFAULT_EXCHANGE, DEFAULT_MARKET, timeLineCoordinateSystem, onTimelineChartInitialized) + timelineChart.initialize(DEFAULT_EXCHANGE, DEFAULT_MARKET, timeMachineCoordinateSystem, onTimelineChartInitialized) /* we will store the event suscription id as a property of the timelineChart, to avoid keeping it an a separate array */ timelineChart.onChildrenMouseOverEventSuscriptionId = timelineChart.container.eventHandler.listenToEvent('onChildrenMouseOver', onChildrenMouseOver) @@ -384,7 +388,7 @@ function newTimeMachine () { y: 0 } - let cornerDate = getDateFromPoint(point, thisObject.container, timeLineCoordinateSystem) + let cornerDate = getDateFromPoint(point, thisObject.container, timeMachineCoordinateSystem) cornerDate = new Date(cornerDate) window.localStorage.setItem('Date @ Screen Corner', cornerDate.toUTCString()) } @@ -430,7 +434,7 @@ function newTimeMachine () { } } - function recalculateScale () { + function recalculateCoordinateSystem () { let minValue = { x: MIN_PLOTABLE_DATE.valueOf(), y: 0 @@ -441,7 +445,7 @@ function newTimeMachine () { y: nextPorwerOf10(USDT_BTC_HTH) / 4 } - timeLineCoordinateSystem.initialize( + timeMachineCoordinateSystem.initialize( minValue, maxValue, thisObject.container.frame.width, diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index ad84e6998..76f6e3ecb 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -6,14 +6,13 @@ function newTimelineChart () { const logger = newWebDebugLog() logger.fileName = MODULE_NAME - let timeLineCoordinateSystem - let timeFrame = INITIAL_TIME_PERIOD let datetime = NEW_SESSION_INITIAL_DATE let thisObject = { container: undefined, fitFunction: undefined, + rateScale: undefined, timeFrameScale: undefined, payload: undefined, plotterManager: undefined, @@ -28,6 +27,9 @@ function newTimelineChart () { thisObject.fitFunction = canvas.chartSpace.fitIntoVisibleArea + let timeMachineCoordinateSystem + let timelineChartCoordinateSystem = newCoordinateSystem() + let initializationReady = false let productsPanel @@ -61,6 +63,10 @@ function newTimelineChart () { } function finalize () { + if (thisObject.rateScale !== undefined) { + finalizeRateScale() + } + if (thisObject.timeFrameScale !== undefined) { finalizeTimeFrameScale() } @@ -93,19 +99,29 @@ function newTimelineChart () { } } - function initialize (pExchange, pMarket, pTimeLineCoordinateSystem, callBackFunction) { + function finalizeRateScale () { + thisObject.rateScale.container.eventHandler.stopListening(rateScaleEventSuscriptionId) + thisObject.rateScale.container.eventHandler.stopListening(rateScaleMouseOverEventSuscriptionId) + thisObject.rateScale.finalize() + thisObject.rateScale = undefined + + /* Resets the local container with the dimessions of its parent, the Time Machine */ + thisObject.container.frame.position.position.y = 0 + thisObject.container.frame.position.height = thisObject.container.parentContainer.frame.height + } + + function initialize (pExchange, pMarket, pTimeMachineCoordinateSystem, callBackFunction) { try { /* We load the logow we will need for the background. */ exchange = pExchange market = pMarket - timeLineCoordinateSystem = pTimeLineCoordinateSystem + timeMachineCoordinateSystem = pTimeMachineCoordinateSystem let panelOwner = exchange + ' ' + market.quotedAsset + '/' + market.baseAsset productsPanelHandle = canvas.panelsSpace.createNewPanel('Products Panel', undefined, panelOwner) let productsPanel = canvas.panelsSpace.getPanel(productsPanelHandle, panelOwner) productsPanel.initialize(exchange, market) - // moveToUserPosition(thisObject.container, timeLineCoordinateSystem, undefined, undefined, undefined, true) timeFrame = INITIAL_TIME_PERIOD datetime = NEW_SESSION_INITIAL_DATE @@ -137,6 +153,11 @@ function newTimelineChart () { function onMouseOver (event) { /* This event gets to the timelinechart container because it inherits it from the time machine container, which is the one raising Mouse Over and Mouse not Over Events to its children. */ + if (thisObject.rateScale !== undefined) { + thisObject.rateScale.onMouseOverSomeTimeMachineContainer(event) + thisObject.rateScale.visible = true + } + if (thisObject.timeFrameScale !== undefined) { thisObject.timeFrameScale.visible = true thisObject.timeFrameScale.onMouseOverSomeTimeMachineContainer(event) @@ -145,13 +166,16 @@ function newTimelineChart () { mouse.position.x = event.x mouse.position.y = event.y - saveUserPosition(thisObject.container, timeLineCoordinateSystem, event) + saveUserPosition(thisObject.container, timeMachineCoordinateSystem, event) } onMouseNotOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) function onMouseNotOver (event) { /* This event is inherited from the Time Machine */ + if (thisObject.rateScale !== undefined) { + thisObject.rateScale.visible = false + } if (thisObject.timeFrameScale !== undefined) { thisObject.timeFrameScale.visible = false } @@ -167,6 +191,27 @@ function newTimelineChart () { } } + function initializeRateScale () { + thisObject.rateScale = newRateScale() + thisObject.rateScale.fitFunction = thisObject.fitFunction + thisObject.rateScale.payload = thisObject.payload.node.rateScale.payload + + rateScaleEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('Height Percentage Changed', function (event) { + thisObject.container.frame.height = TIME_MACHINE_HEIGHT * event.heightPercentage / 100 + recalculateCoordinateSystem() + moveToUserPosition(thisObject.container, timelineChartCoordinateSystem, true, false, event.mousePosition, false, true) + thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) + }) + + thisObject.rateScale.initialize(timelineChartCoordinateSystem, thisObject.container) + + rateScaleMouseOverEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('onMouseOver', rateScaleMouseOver) + + function rateScaleMouseOver (event) { + thisObject.container.eventHandler.raiseEvent('onChildrenMouseOver', event) + } + } + function initializeTimeFrameScale () { thisObject.timeFrameScale = newTimeFrameScale() thisObject.timeFrameScale.fitFunction = thisObject.fitFunction @@ -180,14 +225,14 @@ function newTimelineChart () { } }) - thisObject.timeFrameScale.initialize(timeLineCoordinateSystem, thisObject.container) + thisObject.timeFrameScale.initialize(timeMachineCoordinateSystem, thisObject.container) timeFrameScaleMouseOverEventSuscriptionId = thisObject.timeFrameScale.container.eventHandler.listenToEvent('onMouseOver', timeFrameScaleMouseOver) function timeFrameScaleMouseOver (event) { thisObject.container.eventHandler.raiseEvent('onChildrenMouseOver', event) - saveUserPosition(thisObject.container, timeLineCoordinateSystem, event) + saveUserPosition(thisObject.container, timeMachineCoordinateSystem, event) } } @@ -195,7 +240,7 @@ function newTimelineChart () { if (initializationReady === true) { recalculateCurrentDatetime() - // saveUserPosition(thisObject.container, timeLineCoordinateSystem) + // saveUserPosition(thisObject.container, timeMachineCoordinateSystem) } } @@ -203,7 +248,7 @@ function newTimelineChart () { if (initializationReady === true) { if (thisObject.container.frame.isInViewPort()) { recalculateCurrentDatetime() - // saveUserPosition(thisObject.container, timeLineCoordinateSystem) + // saveUserPosition(thisObject.container, timeMachineCoordinateSystem) } } } @@ -222,7 +267,11 @@ function newTimelineChart () { } center = unTransformThisPoint(center, thisObject.container) - center = timeLineCoordinateSystem.unInverseTransform(center, thisObject.container.frame.height) + if (thisObject.rateScale === undefined) { + center = timeMachineCoordinateSystem.unInverseTransform(center, thisObject.container.frame.height) + } else { + center = timelineChartCoordinateSystem.unInverseTransform(center, thisObject.container.frame.height) + } let newDate = new Date(0) newDate.setUTCSeconds(center.x / 1000) @@ -235,6 +284,15 @@ function newTimelineChart () { function getContainer (point, purpose) { let container + if (thisObject.rateScale !== undefined) { + container = thisObject.rateScale.getContainer(point) + if (container !== undefined) { + if (container.isForThisPurpose(purpose)) { + return container + } + } + } + if (thisObject.timeFrameScale !== undefined) { container = thisObject.timeFrameScale.getContainer(point) if (container !== undefined) { @@ -258,6 +316,17 @@ function newTimelineChart () { } function syncWithDesignerScales () { + if (thisObject.payload.node === undefined) { + finalizeRateScale() + finalizeTimeFrameScale() + return + } + if (thisObject.payload.node.rateScale === undefined && thisObject.rateScale !== undefined) { + finalizeRateScale() + } + if (thisObject.payload.node.rateScale !== undefined && thisObject.rateScale === undefined) { + initializeRateScale() + } if (thisObject.payload.node.timeFrameScale === undefined && thisObject.timeFrameScale !== undefined) { finalizeTimeFrameScale() } @@ -267,6 +336,9 @@ function newTimelineChart () { } function childrenPhysics () { + if (thisObject.rateScale !== undefined) { + thisObject.rateScale.physics() + } if (thisObject.timeFrameScale !== undefined) { thisObject.timeFrameScale.physics() } @@ -300,9 +372,8 @@ function newTimelineChart () { function draw () { if (thisObject.container.frame.isInViewPort()) { - if (thisObject.timeFrameScale !== undefined) { - thisObject.timeFrameScale.draw() - } + if (thisObject.rateScale !== undefined) { thisObject.rateScale.draw() } + if (thisObject.timeFrameScale !== undefined) { thisObject.timeFrameScale.draw() } } } @@ -336,4 +407,23 @@ function newTimelineChart () { browserCanvasContext.fill() } + + function recalculateCoordinateSystem () { + let minValue = { + x: MIN_PLOTABLE_DATE.valueOf(), + y: 0 + } + + let maxValue = { + x: MAX_PLOTABLE_DATE.valueOf(), + y: nextPorwerOf10(USDT_BTC_HTH) / 4 + } + + timelineChartCoordinateSystem.initialize( + minValue, + maxValue, + thisObject.container.frame.width, + thisObject.container.frame.height + ) + } } diff --git a/Plotter.js b/Plotter.js index 52d0110d4..986d26bc9 100644 --- a/Plotter.js +++ b/Plotter.js @@ -31,7 +31,7 @@ function newPlotter () { container.initialize() thisObject.container = container - let timeLineCoordinateSystem = newTimeLineCoordinateSystem() // Needed to be able to plot on the timeline. + let coordinateSystem = newCoordinateSystem() // Needed to be able to plot on the timeline. let slotCoordinateSystem // Needed to be able to plot on a slot over the timeline. let plotterModuleConfig let slotHeight = (viewPort.visibleArea.bottomRight.y - viewPort.visibleArea.topLeft.y) / 10 // This is the amount of slots available @@ -84,7 +84,7 @@ function newPlotter () { marketFile = undefined fileCursor = undefined - timeLineCoordinateSystem = undefined + coordinateSystem = undefined slotCoordinateSystem = undefined plotterModuleConfig = undefined slotHeight = undefined @@ -353,8 +353,8 @@ function newPlotter () { let daysOnSides = getSideDays(timeFrame) - let leftDate = getDateFromPoint(viewPort.visibleArea.topLeft, thisObject.container, timeLineCoordinateSystem) - let rightDate = getDateFromPoint(viewPort.visibleArea.topRight, thisObject.container, timeLineCoordinateSystem) + let leftDate = getDateFromPoint(viewPort.visibleArea.topLeft, thisObject.container, coordinateSystem) + let rightDate = getDateFromPoint(viewPort.visibleArea.topRight, thisObject.container, coordinateSystem) let dateDiff = rightDate.valueOf() - leftDate.valueOf() @@ -406,8 +406,8 @@ function newPlotter () { let daysOnSides = getSideDays(timeFrame) - let leftDate = getDateFromPoint(viewPort.visibleArea.topLeft, thisObject.container, timeLineCoordinateSystem) - let rightDate = getDateFromPoint(viewPort.visibleArea.topRight, thisObject.container, timeLineCoordinateSystem) + let leftDate = getDateFromPoint(viewPort.visibleArea.topLeft, thisObject.container, coordinateSystem) + let rightDate = getDateFromPoint(viewPort.visibleArea.topRight, thisObject.container, coordinateSystem) let dateDiff = rightDate.valueOf() - leftDate.valueOf() @@ -441,7 +441,7 @@ function newPlotter () { function recalculateScale () { try { - if (timeLineCoordinateSystem.maxValue > 0) { return } // Already calculated. + if (coordinateSystem.maxValue > 0) { return } // Already calculated. /* First we calculate the default scale */ let minValue = { x: MIN_PLOTABLE_DATE.valueOf(), @@ -453,7 +453,7 @@ function newPlotter () { y: nextPorwerOf10(USDT_BTC_HTH) / 4 // TODO: This 4 is temporary } - timeLineCoordinateSystem.initialize( + coordinateSystem.initialize( minValue, maxValue, thisObject.container.frame.width, @@ -465,7 +465,7 @@ function newPlotter () { plotterModuleConfig = productDefinition.referenceParent.code if (plotterModuleConfig.slot === undefined) { return } - slotCoordinateSystem = newTimeLineCoordinateSystem() + slotCoordinateSystem = newCoordinateSystem() minValue.y = plotterModuleConfig.slot.minValue maxValue.y = plotterModuleConfig.slot.maxValue @@ -511,8 +511,8 @@ function newPlotter () { y: 0 } - beginPoint = timeLineCoordinateSystem.transformThisPoint(beginPoint) - endPoint = timeLineCoordinateSystem.transformThisPoint(endPoint) + beginPoint = coordinateSystem.transformThisPoint(beginPoint) + endPoint = coordinateSystem.transformThisPoint(endPoint) beginPoint = transformThisPoint(beginPoint, thisObject.container) endPoint = transformThisPoint(endPoint, thisObject.container) @@ -565,7 +565,7 @@ function newPlotter () { The information we store in files is independent from the charing system and its coordinate systems. That means that the first thing we allways need to do is to trasform these points to the coordinate system of the timeline. */ - dataPoint = timeLineCoordinateSystem.transformThisPoint(dataPoint) + dataPoint = coordinateSystem.transformThisPoint(dataPoint) /* The browser canvas object does not care about our timeline and its coordinate system. In order to draw on a html canvas we diff --git a/Scales/RateScale.js b/Scales/RateScale.js index 527bfac82..ddab988fa 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -144,6 +144,24 @@ function newRateScale () { upCorner = limitingContainer.fitFunction(upCorner, true) bottonCorner = limitingContainer.fitFunction(bottonCorner, true) + /* We will check if we need to change the bottom because of being one of many scales of the same type */ + let displaceFactor = 0 + if (thisObject.payload.parentNode === undefined) { return } // This happens when in the process of deleting the scale, timeline chart or time machine. + if (thisObject.payload.parentNode.type === 'Timeline Chart') { + if (thisObject.payload.parentNode.payload.parentNode.rateScale !== undefined) { + displaceFactor++ + } + for (let i = 0; i < thisObject.payload.parentNode.payload.parentNode.timelineCharts.length; i++) { + let timelineChart = thisObject.payload.parentNode.payload.parentNode.timelineCharts[i] + if (thisObject.payload.node.id !== timelineChart.rateScale.id) { + displaceFactor++ + } else { + break + } + } + } + bottonCorner.x = bottonCorner.x - thisObject.container.frame.width * displaceFactor + /* Mouse Position Rate Calculation */ let ratePoint = { x: 0, diff --git a/Scales/TimeFrameScale.js b/Scales/TimeFrameScale.js index 28aa573e6..b9a9c2937 100644 --- a/Scales/TimeFrameScale.js +++ b/Scales/TimeFrameScale.js @@ -112,22 +112,22 @@ function newTimeFrameScale () { bottonCorner = limitingContainer.fitFunction(bottonCorner, true) /* We will check if we need to change the bottom because of being one of many scales of the same type */ - let levelsUp = 0 + let displaceFactor = 0 if (thisObject.payload.parentNode === undefined) { return } // This happens when in the process of deleting the scale, timeline chart or time machine. if (thisObject.payload.parentNode.type === 'Timeline Chart') { if (thisObject.payload.parentNode.payload.parentNode.timeFrameScale !== undefined) { - levelsUp++ + displaceFactor++ } for (let i = 0; i < thisObject.payload.parentNode.payload.parentNode.timelineCharts.length; i++) { let timelineChart = thisObject.payload.parentNode.payload.parentNode.timelineCharts[i] if (thisObject.payload.node.id !== timelineChart.timeFrameScale.id) { - levelsUp++ + displaceFactor++ } else { break } } } - bottonCorner.y = bottonCorner.y - thisObject.container.frame.height * levelsUp + bottonCorner.y = bottonCorner.y - thisObject.container.frame.height * displaceFactor /* Positioning */ timePoint = { From 82c78b40d0d6060348ec217144151c34f646bd8f Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 11 Jan 2020 14:08:08 +0100 Subject: [PATCH 090/264] bug fixed, scale not moving --- ChartsSpace/TimelineChart.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 76f6e3ecb..89d423f35 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -203,7 +203,7 @@ function newTimelineChart () { thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) }) - thisObject.rateScale.initialize(timelineChartCoordinateSystem, thisObject.container) + thisObject.rateScale.initialize(timelineChartCoordinateSystem, thisObject.container.parentContainer) rateScaleMouseOverEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('onMouseOver', rateScaleMouseOver) @@ -225,7 +225,7 @@ function newTimelineChart () { } }) - thisObject.timeFrameScale.initialize(timeMachineCoordinateSystem, thisObject.container) + thisObject.timeFrameScale.initialize(timeMachineCoordinateSystem, thisObject.container.parentContainer) timeFrameScaleMouseOverEventSuscriptionId = thisObject.timeFrameScale.container.eventHandler.listenToEvent('onMouseOver', timeFrameScaleMouseOver) From c507ca6d73b1214c18c6e58423c01c5ed23b03ff Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 11 Jan 2020 14:13:45 +0100 Subject: [PATCH 091/264] order of drawing scales --- ChartsSpace/TimeMachine.js | 2 +- ChartsSpace/TimelineChart.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index bbbae6a7c..d6ec178ca 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -427,8 +427,8 @@ function newTimeMachine () { } if (thisObject.timeScale !== undefined) { thisObject.timeScale.draw() } - if (thisObject.rateScale !== undefined) { thisObject.rateScale.draw() } if (thisObject.timeFrameScale !== undefined) { thisObject.timeFrameScale.draw() } + if (thisObject.rateScale !== undefined) { thisObject.rateScale.draw() } thisObject.container.frame.draw(false, true, false, thisObject.fitFunction) } diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 89d423f35..b50187041 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -372,8 +372,8 @@ function newTimelineChart () { function draw () { if (thisObject.container.frame.isInViewPort()) { - if (thisObject.rateScale !== undefined) { thisObject.rateScale.draw() } if (thisObject.timeFrameScale !== undefined) { thisObject.timeFrameScale.draw() } + if (thisObject.rateScale !== undefined) { thisObject.rateScale.draw() } } } From 6f57ee93926f19257b942ad210f6e05189fd4354 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 11 Jan 2020 14:52:41 +0100 Subject: [PATCH 092/264] Not visible working on all scales --- ChartsSpace/TimeMachine.js | 9 +++------ ChartsSpace/TimelineChart.js | 6 ++---- Scales/RateScale.js | 22 +++++++++++++++++----- Scales/TimeFrameScale.js | 16 ++++++++++++++-- Scales/TimeScale.js | 20 ++++++++++++++++---- 5 files changed, 52 insertions(+), 21 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index d6ec178ca..028e39908 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -132,16 +132,13 @@ function newTimeMachine () { mouse.position.y = event.y if (thisObject.timeScale !== undefined) { - thisObject.timeScale.visible = true thisObject.timeScale.onMouseOverSomeTimeMachineContainer(event) } if (thisObject.rateScale !== undefined) { thisObject.rateScale.onMouseOverSomeTimeMachineContainer(event) - thisObject.rateScale.visible = true } if (thisObject.timeFrameScale !== undefined) { thisObject.timeFrameScale.onMouseOverSomeTimeMachineContainer(event) - thisObject.timeFrameScale.visible = true } } @@ -176,7 +173,7 @@ function newTimeMachine () { thisObject.timeScale.initialize(timeMachineCoordinateSystem, thisObject.container) - timeScaleMouseOverEventSuscriptionId = thisObject.timeScale.container.eventHandler.listenToEvent('onMouseOver', timeScaleMouseOver) + timeScaleMouseOverEventSuscriptionId = thisObject.timeScale.container.eventHandler.listenToEvent('onMouseOverScale', timeScaleMouseOver) function timeScaleMouseOver (event) { thisObject.container.eventHandler.raiseEvent('onMouseOver', event) @@ -197,7 +194,7 @@ function newTimeMachine () { thisObject.rateScale.initialize(timeMachineCoordinateSystem, thisObject.container) - rateScaleMouseOverEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('onMouseOver', rateScaleMouseOver) + rateScaleMouseOverEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('onMouseOverScale', rateScaleMouseOver) function rateScaleMouseOver (event) { thisObject.container.eventHandler.raiseEvent('onMouseOver', event) @@ -225,7 +222,7 @@ function newTimeMachine () { thisObject.timeFrameScale.initialize(timeMachineCoordinateSystem, thisObject.container) - timeFrameScaleMouseOverEventSuscriptionId = thisObject.timeFrameScale.container.eventHandler.listenToEvent('onMouseOver', timeFrameScaleMouseOver) + timeFrameScaleMouseOverEventSuscriptionId = thisObject.timeFrameScale.container.eventHandler.listenToEvent('onMouseOverScale', timeFrameScaleMouseOver) function timeFrameScaleMouseOver (event) { thisObject.container.eventHandler.raiseEvent('onMouseOver', event) diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index b50187041..278295272 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -155,11 +155,9 @@ function newTimelineChart () { /* This event gets to the timelinechart container because it inherits it from the time machine container, which is the one raising Mouse Over and Mouse not Over Events to its children. */ if (thisObject.rateScale !== undefined) { thisObject.rateScale.onMouseOverSomeTimeMachineContainer(event) - thisObject.rateScale.visible = true } if (thisObject.timeFrameScale !== undefined) { - thisObject.timeFrameScale.visible = true thisObject.timeFrameScale.onMouseOverSomeTimeMachineContainer(event) } @@ -205,7 +203,7 @@ function newTimelineChart () { thisObject.rateScale.initialize(timelineChartCoordinateSystem, thisObject.container.parentContainer) - rateScaleMouseOverEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('onMouseOver', rateScaleMouseOver) + rateScaleMouseOverEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('onMouseOverScale', rateScaleMouseOver) function rateScaleMouseOver (event) { thisObject.container.eventHandler.raiseEvent('onChildrenMouseOver', event) @@ -227,7 +225,7 @@ function newTimelineChart () { thisObject.timeFrameScale.initialize(timeMachineCoordinateSystem, thisObject.container.parentContainer) - timeFrameScaleMouseOverEventSuscriptionId = thisObject.timeFrameScale.container.eventHandler.listenToEvent('onMouseOver', timeFrameScaleMouseOver) + timeFrameScaleMouseOverEventSuscriptionId = thisObject.timeFrameScale.container.eventHandler.listenToEvent('onMouseOverScale', timeFrameScaleMouseOver) function timeFrameScaleMouseOver (event) { thisObject.container.eventHandler.raiseEvent('onChildrenMouseOver', event) diff --git a/Scales/RateScale.js b/Scales/RateScale.js index ddab988fa..1b3214baf 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -6,7 +6,6 @@ function newRateScale () { rate: undefined, fitFunction: undefined, payload: undefined, - visible: true, heightPercentage: 150, onMouseOverSomeTimeMachineContainer: onMouseOverSomeTimeMachineContainer, physics: physics, @@ -31,6 +30,7 @@ function newRateScale () { thisObject.container.frame.width = 200 thisObject.container.frame.height = 60 + let visible = true let isMouseOver let onMouseWheelEventSubscriptionId @@ -84,6 +84,16 @@ function newRateScale () { } function onMouseOverSomeTimeMachineContainer (event) { + if (event.containerId === undefined) { + /* This happens when the mouse over was not at the instance of a certain scale, but anywhere else. */ + visible = true + } else { + if (event.containerId === thisObject.container.id) { + visible = true + } else { + visible = false + } + } mouse = { position: { x: event.x, @@ -92,9 +102,10 @@ function newRateScale () { } } - function onMouseOver () { - thisObject.visible = true + function onMouseOver (event) { isMouseOver = true + event.containerId = thisObject.container.id + thisObject.container.eventHandler.raiseEvent('onMouseOverScale', event) } function onMouseNotOver () { @@ -120,6 +131,7 @@ function newRateScale () { } function getContainer (point) { + if (visible !== true) { return } if (thisObject.container.frame.isThisPointHere(point, true) === true) { return thisObject.container } @@ -198,7 +210,7 @@ function newRateScale () { function drawArrows () { if (isMouseOver !== true) { return } - if (thisObject.visible === false || thisObject.rate === undefined) { return } + if (visible === false || thisObject.rate === undefined) { return } const X_OFFSET = thisObject.container.frame.width / 2 const Y_OFFSET = thisObject.container.frame.height / 2 @@ -299,7 +311,7 @@ function newRateScale () { } function drawRate () { - if (thisObject.visible === false || thisObject.rate === undefined) { return } + if (visible === false || thisObject.rate === undefined) { return } let label = (thisObject.rate - Math.trunc(thisObject.rate)).toFixed(2) let labelArray = label.split('.') diff --git a/Scales/TimeFrameScale.js b/Scales/TimeFrameScale.js index b9a9c2937..8b3d8f9e5 100644 --- a/Scales/TimeFrameScale.js +++ b/Scales/TimeFrameScale.js @@ -79,11 +79,22 @@ function newTimeFrameScale () { onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) function onMouseOver () { - thisObject.visible = true + event.containerId = thisObject.container.id + thisObject.container.eventHandler.raiseEvent('onMouseOverScale', event) } } function onMouseOverSomeTimeMachineContainer (event) { + if (event.containerId === undefined) { + /* This happens when the mouse over was not at the instance of a certain scale, but anywhere else. */ + visible = true + } else { + if (event.containerId === thisObject.container.id) { + visible = true + } else { + visible = false + } + } mouse = { position: { x: event.x, @@ -200,6 +211,7 @@ function newTimeFrameScale () { } function getContainer (point) { + if (visible !== true) { return } if (thisObject.container.frame.isThisPointHere(point, true) === true) { return thisObject.container } @@ -238,7 +250,7 @@ function newTimeFrameScale () { } function drawTimeFrame () { - if (thisObject.visible === false || timeFrameLabel === undefined) { return } + if (visible === false || timeFrameLabel === undefined) { return } let label = timeFrameLabel.split('-') let label1 = thisObject.payload.node.payload.parentNode.name diff --git a/Scales/TimeScale.js b/Scales/TimeScale.js index 086e45fa9..d5ed2497e 100644 --- a/Scales/TimeScale.js +++ b/Scales/TimeScale.js @@ -7,7 +7,6 @@ function newTimeScale () { date: undefined, fitFunction: undefined, payload: undefined, - visible: true, onMouseOverSomeTimeMachineContainer: onMouseOverSomeTimeMachineContainer, physics: physics, draw: draw, @@ -30,6 +29,7 @@ function newTimeScale () { thisObject.container.frame.width = 200 thisObject.container.frame.height = 60 + let visible = true let isMouseOver let onMouseWheelEventSubscriptionId @@ -83,6 +83,16 @@ function newTimeScale () { } function onMouseOverSomeTimeMachineContainer (event) { + if (event.containerId === undefined) { + /* This happens when the mouse over was not at the instance of a certain scale, but anywhere else. */ + visible = true + } else { + if (event.containerId === thisObject.container.id) { + visible = true + } else { + visible = false + } + } mouse = { position: { x: event.x, @@ -92,8 +102,9 @@ function newTimeScale () { } function onMouseOver () { - thisObject.visible = true isMouseOver = true + event.containerId = thisObject.container.id + thisObject.container.eventHandler.raiseEvent('onMouseOverScale', event) } function onMouseNotOver () { @@ -120,6 +131,7 @@ function newTimeScale () { } function getContainer (point) { + if (visible !== true) { return } if (thisObject.container.frame.isThisPointHere(point, true) === true) { return thisObject.container } @@ -180,7 +192,7 @@ function newTimeScale () { function drawArrows () { if (isMouseOver !== true) { return } - if (thisObject.visible === false || thisObject.date === undefined) { return } + if (visible === false || thisObject.date === undefined) { return } const X_OFFSET = thisObject.container.frame.width / 2 const Y_OFFSET = thisObject.container.frame.height / 2 - 10 @@ -281,7 +293,7 @@ function newTimeScale () { } function drawTime () { - if (thisObject.visible === false || thisObject.date === undefined) { return } + if (visible === false || thisObject.date === undefined) { return } let label = thisObject.date.toUTCString() let labelArray = label.split(' ') From bbbffe0e4a05f04ca8613f32e120172763790a26 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 11 Jan 2020 15:59:51 +0100 Subject: [PATCH 093/264] Scales not visible grayed out --- ChartsSpace/TimeMachine.js | 34 +++++++++++++++++------- ChartsSpace/TimelineChart.js | 16 ++++++++--- Scales/Commons.js | 22 +++++++++++++--- Scales/RateScale.js | 51 +++++++++++++++++++++++------------- Scales/TimeFrameScale.js | 46 ++++++++++++++++++++++++-------- Scales/TimeScale.js | 51 +++++++++++++++++++++++------------- Spaces/ChartSpace.js | 10 +++++++ 7 files changed, 165 insertions(+), 65 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 028e39908..ed0bd74a1 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -24,8 +24,9 @@ function newTimeMachine () { payload: undefined, timelineCharts: [], physics: physics, - drawBackground: drawBackground, draw: draw, + drawBackground: drawBackground, + drawForeground: drawForeground, getContainer: getContainer, // returns the inner most container that holds the point received by parameter. initialize: initialize, finalize: finalize @@ -407,15 +408,6 @@ function newTimeMachine () { } } - function drawBackground () { - if (thisObject.container.frame.isInViewPort()) { - for (let i = 0; i < thisObject.timelineCharts.length; i++) { - let timelineChart = thisObject.timelineCharts[i] - timelineChart.drawBackground() - } - } - } - function draw () { if (thisObject.container.frame.isInViewPort()) { for (let i = 0; i < thisObject.timelineCharts.length; i++) { @@ -431,6 +423,28 @@ function newTimeMachine () { } } + function drawBackground () { + if (thisObject.container.frame.isInViewPort()) { + for (let i = 0; i < thisObject.timelineCharts.length; i++) { + let timelineChart = thisObject.timelineCharts[i] + timelineChart.drawBackground() + } + } + } + + function drawForeground () { + if (thisObject.container.frame.isInViewPort()) { + for (let i = 0; i < thisObject.timelineCharts.length; i++) { + let timelineChart = thisObject.timelineCharts[i] + timelineChart.drawForeground() + } + + if (thisObject.timeScale !== undefined) { thisObject.timeScale.drawForeground() } + if (thisObject.timeFrameScale !== undefined) { thisObject.timeFrameScale.drawForeground() } + if (thisObject.rateScale !== undefined) { thisObject.rateScale.drawForeground() } + } + } + function recalculateCoordinateSystem () { let minValue = { x: MIN_PLOTABLE_DATE.valueOf(), diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 278295272..8fdd77296 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -18,8 +18,9 @@ function newTimelineChart () { plotterManager: undefined, upstreamTimeFrame: undefined, physics: physics, - drawBackground: drawBackground, draw: draw, + drawBackground: drawBackground, + drawForeground: drawForeground, getContainer: getContainer, initialize: initialize, finalize: finalize @@ -358,6 +359,13 @@ function newTimelineChart () { } } + function draw () { + if (thisObject.container.frame.isInViewPort()) { + if (thisObject.timeFrameScale !== undefined) { thisObject.timeFrameScale.draw() } + if (thisObject.rateScale !== undefined) { thisObject.rateScale.draw() } + } + } + function drawBackground () { if (thisObject.container.frame.isInViewPort()) { if (window.CHART_ON_FOCUS === '') { @@ -368,10 +376,10 @@ function newTimelineChart () { } } - function draw () { + function drawForeground () { if (thisObject.container.frame.isInViewPort()) { - if (thisObject.timeFrameScale !== undefined) { thisObject.timeFrameScale.draw() } - if (thisObject.rateScale !== undefined) { thisObject.rateScale.draw() } + if (thisObject.timeFrameScale !== undefined) { thisObject.timeFrameScale.drawForeground() } + if (thisObject.rateScale !== undefined) { thisObject.rateScale.drawForeground() } } } diff --git a/Scales/Commons.js b/Scales/Commons.js index 8871558ff..db0bb567e 100644 --- a/Scales/Commons.js +++ b/Scales/Commons.js @@ -1,5 +1,5 @@ -function drawScaleDisplay (label1, label2, label3, xExtraOffSet1, xExtraOffSet2, xExtraOffSet3, icon1, icon2, container) { +function drawScaleDisplay (label1, label2, label3, xExtraOffSet1, xExtraOffSet2, xExtraOffSet3, icon1, icon2, container, backgroundColor) { let fontSize1 = 10 let fontSize2 = 20 let fontSize3 = 10 @@ -8,12 +8,12 @@ function drawScaleDisplay (label1, label2, label3, xExtraOffSet1, xExtraOffSet2, const OPACITY = 1 let params = { - cornerRadius: 5, - lineWidth: RED_LINE_HIGHT, + cornerRadius: 15, + lineWidth: 2, container: container, borderColor: UI_COLOR.RUSTED_RED, castShadow: false, - backgroundColor: UI_COLOR.BLACK, + backgroundColor: backgroundColor, opacity: OPACITY } @@ -104,3 +104,17 @@ function drawScaleDisplay (label1, label2, label3, xExtraOffSet1, xExtraOffSet2, } } } + +function drawScaleDisplayCover (container) { + let params = { + cornerRadius: 15, + lineWidth: 2, + container: container, + borderColor: UI_COLOR.WHITE, + castShadow: false, + backgroundColor: UI_COLOR.WHITE, + opacity: '0.75' + } + + roundedCornersBackground(params) +} diff --git a/Scales/RateScale.js b/Scales/RateScale.js index 1b3214baf..08deeee63 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -10,6 +10,7 @@ function newRateScale () { onMouseOverSomeTimeMachineContainer: onMouseOverSomeTimeMachineContainer, physics: physics, draw: draw, + drawForeground: drawForeground, getContainer: getContainer, initialize: initialize, finalize: finalize @@ -204,12 +205,41 @@ function newRateScale () { } function draw () { - drawRate() - drawArrows() + drawScaleBox() + if (visible === false) { + drawScaleDisplayCover(thisObject.container) + } + } + + function drawForeground () { + if (isMouseOver === true) { + drawScaleBox() + drawArrows() + } + } + + function drawScaleBox () { + if (thisObject.rate === undefined) { return } + + let label = (thisObject.rate - Math.trunc(thisObject.rate)).toFixed(2) + let labelArray = label.split('.') + let label1 = thisObject.payload.node.payload.parentNode.name + let label2 = (Math.trunc(thisObject.rate)).toLocaleString() + let label3 = labelArray[1] + + let icon1 = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.payload.parentNode.type) + let icon2 = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.type) + + let backgroundColor + if (visible === true) { + backgroundColor = UI_COLOR.BLACK + } else { + backgroundColor = UI_COLOR.DARK + } + drawScaleDisplay(label1, label2, label3, 0, 0, 0, icon1, icon2, thisObject.container, backgroundColor) } function drawArrows () { - if (isMouseOver !== true) { return } if (visible === false || thisObject.rate === undefined) { return } const X_OFFSET = thisObject.container.frame.width / 2 @@ -309,19 +339,4 @@ function newRateScale () { browserCanvasContext.stroke() } } - - function drawRate () { - if (visible === false || thisObject.rate === undefined) { return } - - let label = (thisObject.rate - Math.trunc(thisObject.rate)).toFixed(2) - let labelArray = label.split('.') - let label1 = thisObject.payload.node.payload.parentNode.name - let label2 = (Math.trunc(thisObject.rate)).toLocaleString() - let label3 = labelArray[1] - - let icon1 = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.payload.parentNode.type) - let icon2 = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.type) - - drawScaleDisplay(label1, label2, label3, 0, 0, 0, icon1, icon2, thisObject.container) - } } diff --git a/Scales/TimeFrameScale.js b/Scales/TimeFrameScale.js index 8b3d8f9e5..0fc5e9f93 100644 --- a/Scales/TimeFrameScale.js +++ b/Scales/TimeFrameScale.js @@ -8,6 +8,7 @@ function newTimeFrameScale () { payload: undefined, onMouseOverSomeTimeMachineContainer: onMouseOverSomeTimeMachineContainer, draw: draw, + drawForeground: drawForeground, physics: physics, getContainer: getContainer, initialize: initialize, @@ -19,6 +20,8 @@ function newTimeFrameScale () { const MIN_HEIGHT = 50 let visible = true + let isMouseOver + let objectStorage = {} let filePeriodIndex = FILES_PERIOD_DEFAULT_VALUE let timeFrameIndex = TIME_PERIOD_DEFAULT_VALUE @@ -28,6 +31,7 @@ function newTimeFrameScale () { let onMouseWheelEventSubscriptionId let onZoomChangedEventSubscriptionId let onMouseOverEventSubscriptionId + let onMouseNotOverEventSubscriptionId let timeLineCoordinateSystem let limitingContainer @@ -58,6 +62,7 @@ function newTimeFrameScale () { thisObject.container.eventHandler.stopListening(onMouseWheelEventSubscriptionId) viewPort.eventHandler.stopListening(onZoomChangedEventSubscriptionId) thisObject.container.eventHandler.stopListening(onMouseOverEventSubscriptionId) + thisObject.container.eventHandler.stopListening(onMouseNotOverEventSubscriptionId) objectStorage = undefined @@ -77,11 +82,7 @@ function newTimeFrameScale () { onMouseWheelEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) onZoomChangedEventSubscriptionId = viewPort.eventHandler.listenToEvent('Zoom Changed', onZoomChanged) onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) - - function onMouseOver () { - event.containerId = thisObject.container.id - thisObject.container.eventHandler.raiseEvent('onMouseOverScale', event) - } + onMouseNotOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) } function onMouseOverSomeTimeMachineContainer (event) { @@ -103,6 +104,16 @@ function newTimeFrameScale () { } } + function onMouseOver () { + isMouseOver = true + event.containerId = thisObject.container.id + thisObject.container.eventHandler.raiseEvent('onMouseOverScale', event) + } + + function onMouseNotOver () { + isMouseOver = false + } + function physics () { /* Container Limits */ @@ -244,13 +255,20 @@ function newTimeFrameScale () { } function draw () { - if (visible === false) { return } - - drawTimeFrame() + drawScaleBox() + if (visible === false) { + drawScaleDisplayCover(thisObject.container) + } } - function drawTimeFrame () { - if (visible === false || timeFrameLabel === undefined) { return } + function drawForeground () { + if (isMouseOver === true) { + drawScaleBox() + } + } + + function drawScaleBox () { + if (timeFrameLabel === undefined) { return } let label = timeFrameLabel.split('-') let label1 = thisObject.payload.node.payload.parentNode.name @@ -260,6 +278,12 @@ function newTimeFrameScale () { let icon1 = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.payload.parentNode.type) let icon2 = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.type) - drawScaleDisplay(label1, label2, label3, 0, 0, 0, icon1, icon2, thisObject.container) + let backgroundColor + if (visible === true) { + backgroundColor = UI_COLOR.BLACK + } else { + backgroundColor = UI_COLOR.DARK + } + drawScaleDisplay(label1, label2, label3, 0, 0, 0, icon1, icon2, thisObject.container, backgroundColor) } } diff --git a/Scales/TimeScale.js b/Scales/TimeScale.js index d5ed2497e..55842cdc6 100644 --- a/Scales/TimeScale.js +++ b/Scales/TimeScale.js @@ -10,6 +10,7 @@ function newTimeScale () { onMouseOverSomeTimeMachineContainer: onMouseOverSomeTimeMachineContainer, physics: physics, draw: draw, + drawForeground: drawForeground, getContainer: getContainer, initialize: initialize, finalize: finalize @@ -186,12 +187,41 @@ function newTimeScale () { } function draw () { - drawTime() - drawArrows() + drawScaleBox() + if (visible === false) { + drawScaleDisplayCover(thisObject.container) + } + } + + function drawForeground () { + if (isMouseOver === true) { + drawScaleBox() + drawArrows() + } + } + + function drawScaleBox () { + if (thisObject.date === undefined) { return } + + let label = thisObject.date.toUTCString() + let labelArray = label.split(' ') + let label1 = thisObject.payload.node.payload.parentNode.name + let label2 = labelArray[1] + ' ' + labelArray[2] + ' ' + labelArray[3] + let label3 = labelArray[4] + + let icon1 = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.payload.parentNode.type) + let icon2 = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.type) + + let backgroundColor + if (visible === true) { + backgroundColor = UI_COLOR.BLACK + } else { + backgroundColor = UI_COLOR.DARK + } + drawScaleDisplay(label1, label2, label3, 0, 0, 0, icon1, icon2, thisObject.container, backgroundColor) } function drawArrows () { - if (isMouseOver !== true) { return } if (visible === false || thisObject.date === undefined) { return } const X_OFFSET = thisObject.container.frame.width / 2 @@ -291,19 +321,4 @@ function newTimeScale () { browserCanvasContext.stroke() } } - - function drawTime () { - if (visible === false || thisObject.date === undefined) { return } - - let label = thisObject.date.toUTCString() - let labelArray = label.split(' ') - let label1 = thisObject.payload.node.payload.parentNode.name - let label2 = labelArray[1] + ' ' + labelArray[2] + ' ' + labelArray[3] - let label3 = labelArray[4] - - let icon1 = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.payload.parentNode.type) - let icon2 = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.type) - - drawScaleDisplay(label1, label2, label3, 0, 0, 0, icon1, icon2, thisObject.container) - } } diff --git a/Spaces/ChartSpace.js b/Spaces/ChartSpace.js index 7f4fcca26..ada3eb8b5 100644 --- a/Spaces/ChartSpace.js +++ b/Spaces/ChartSpace.js @@ -294,6 +294,8 @@ function newChartSpace () { let timeMachine = thisObject.timeMachines[thisObject.timeMachines.length - i - 1] timeMachine.draw() } + + drawForeground() } function drawBackground () { @@ -304,6 +306,14 @@ function newChartSpace () { timeMachine.drawBackground() } } + + function drawForeground () { + for (let i = 0; i < thisObject.timeMachines.length; i++) { + let timeMachine = thisObject.timeMachines[thisObject.timeMachines.length - i - 1] + timeMachine.drawForeground() + } + } + function drawSpaceBackground () { let opacity = '1' let fromPoint = { From b85806f19b7e8f4f58378a7250fefcea80a250c0 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 11 Jan 2020 16:54:31 +0100 Subject: [PATCH 094/264] Bug Fixed on mouse over --- Scales/Commons.js | 2 +- Scales/RateScale.js | 10 +++------- Scales/TimeFrameScale.js | 12 ++++-------- Scales/TimeScale.js | 12 ++++-------- 4 files changed, 12 insertions(+), 24 deletions(-) diff --git a/Scales/Commons.js b/Scales/Commons.js index db0bb567e..c935a38a2 100644 --- a/Scales/Commons.js +++ b/Scales/Commons.js @@ -5,7 +5,7 @@ function drawScaleDisplay (label1, label2, label3, xExtraOffSet1, xExtraOffSet2, let fontSize3 = 10 const RED_LINE_HIGHT = 4 - const OPACITY = 1 + const OPACITY = 0.75 let params = { cornerRadius: 15, diff --git a/Scales/RateScale.js b/Scales/RateScale.js index 08deeee63..8df57a2ed 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -93,6 +93,7 @@ function newRateScale () { visible = true } else { visible = false + turnOnCounter = 0 } } mouse = { @@ -132,7 +133,6 @@ function newRateScale () { } function getContainer (point) { - if (visible !== true) { return } if (thisObject.container.frame.isThisPointHere(point, true) === true) { return thisObject.container } @@ -230,12 +230,8 @@ function newRateScale () { let icon1 = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.payload.parentNode.type) let icon2 = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.type) - let backgroundColor - if (visible === true) { - backgroundColor = UI_COLOR.BLACK - } else { - backgroundColor = UI_COLOR.DARK - } + let backgroundColor = UI_COLOR.BLACK + drawScaleDisplay(label1, label2, label3, 0, 0, 0, icon1, icon2, thisObject.container, backgroundColor) } diff --git a/Scales/TimeFrameScale.js b/Scales/TimeFrameScale.js index 0fc5e9f93..7674b52a9 100644 --- a/Scales/TimeFrameScale.js +++ b/Scales/TimeFrameScale.js @@ -94,6 +94,7 @@ function newTimeFrameScale () { visible = true } else { visible = false + turnOnCounter = 0 } } mouse = { @@ -104,7 +105,7 @@ function newTimeFrameScale () { } } - function onMouseOver () { + function onMouseOver (event) { isMouseOver = true event.containerId = thisObject.container.id thisObject.container.eventHandler.raiseEvent('onMouseOverScale', event) @@ -222,7 +223,6 @@ function newTimeFrameScale () { } function getContainer (point) { - if (visible !== true) { return } if (thisObject.container.frame.isThisPointHere(point, true) === true) { return thisObject.container } @@ -278,12 +278,8 @@ function newTimeFrameScale () { let icon1 = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.payload.parentNode.type) let icon2 = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.type) - let backgroundColor - if (visible === true) { - backgroundColor = UI_COLOR.BLACK - } else { - backgroundColor = UI_COLOR.DARK - } + let backgroundColor = UI_COLOR.BLACK + drawScaleDisplay(label1, label2, label3, 0, 0, 0, icon1, icon2, thisObject.container, backgroundColor) } } diff --git a/Scales/TimeScale.js b/Scales/TimeScale.js index 55842cdc6..88260326e 100644 --- a/Scales/TimeScale.js +++ b/Scales/TimeScale.js @@ -92,6 +92,7 @@ function newTimeScale () { visible = true } else { visible = false + turnOnCounter = 0 } } mouse = { @@ -102,7 +103,7 @@ function newTimeScale () { } } - function onMouseOver () { + function onMouseOver (event) { isMouseOver = true event.containerId = thisObject.container.id thisObject.container.eventHandler.raiseEvent('onMouseOverScale', event) @@ -132,7 +133,6 @@ function newTimeScale () { } function getContainer (point) { - if (visible !== true) { return } if (thisObject.container.frame.isThisPointHere(point, true) === true) { return thisObject.container } @@ -212,12 +212,8 @@ function newTimeScale () { let icon1 = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.payload.parentNode.type) let icon2 = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.type) - let backgroundColor - if (visible === true) { - backgroundColor = UI_COLOR.BLACK - } else { - backgroundColor = UI_COLOR.DARK - } + let backgroundColor = UI_COLOR.BLACK + drawScaleDisplay(label1, label2, label3, 0, 0, 0, icon1, icon2, thisObject.container, backgroundColor) } From ed2361112d3133806d3c8556bfbb04a07fa43200 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 11 Jan 2020 17:06:32 +0100 Subject: [PATCH 095/264] Bug Fixed, wired overlapping --- ChartsSpace/TimeMachine.js | 18 +++++++++--------- ChartsSpace/TimelineChart.js | 14 +++++++------- Scales/Commons.js | 2 +- Spaces/ChartSpace.js | 18 +++++++++--------- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index ed0bd74a1..1645d2827 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -408,6 +408,15 @@ function newTimeMachine () { } } + function drawBackground () { + if (thisObject.container.frame.isInViewPort()) { + for (let i = 0; i < thisObject.timelineCharts.length; i++) { + let timelineChart = thisObject.timelineCharts[i] + timelineChart.drawBackground() + } + } + } + function draw () { if (thisObject.container.frame.isInViewPort()) { for (let i = 0; i < thisObject.timelineCharts.length; i++) { @@ -423,15 +432,6 @@ function newTimeMachine () { } } - function drawBackground () { - if (thisObject.container.frame.isInViewPort()) { - for (let i = 0; i < thisObject.timelineCharts.length; i++) { - let timelineChart = thisObject.timelineCharts[i] - timelineChart.drawBackground() - } - } - } - function drawForeground () { if (thisObject.container.frame.isInViewPort()) { for (let i = 0; i < thisObject.timelineCharts.length; i++) { diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 8fdd77296..287792ef6 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -359,13 +359,6 @@ function newTimelineChart () { } } - function draw () { - if (thisObject.container.frame.isInViewPort()) { - if (thisObject.timeFrameScale !== undefined) { thisObject.timeFrameScale.draw() } - if (thisObject.rateScale !== undefined) { thisObject.rateScale.draw() } - } - } - function drawBackground () { if (thisObject.container.frame.isInViewPort()) { if (window.CHART_ON_FOCUS === '') { @@ -376,6 +369,13 @@ function newTimelineChart () { } } + function draw () { + if (thisObject.container.frame.isInViewPort()) { + if (thisObject.timeFrameScale !== undefined) { thisObject.timeFrameScale.draw() } + if (thisObject.rateScale !== undefined) { thisObject.rateScale.draw() } + } + } + function drawForeground () { if (thisObject.container.frame.isInViewPort()) { if (thisObject.timeFrameScale !== undefined) { thisObject.timeFrameScale.drawForeground() } diff --git a/Scales/Commons.js b/Scales/Commons.js index c935a38a2..db0bb567e 100644 --- a/Scales/Commons.js +++ b/Scales/Commons.js @@ -5,7 +5,7 @@ function drawScaleDisplay (label1, label2, label3, xExtraOffSet1, xExtraOffSet2, let fontSize3 = 10 const RED_LINE_HIGHT = 4 - const OPACITY = 0.75 + const OPACITY = 1 let params = { cornerRadius: 15, diff --git a/Spaces/ChartSpace.js b/Spaces/ChartSpace.js index ada3eb8b5..a4ba0f45b 100644 --- a/Spaces/ChartSpace.js +++ b/Spaces/ChartSpace.js @@ -286,6 +286,15 @@ function newChartSpace () { } } + function drawBackground () { + drawSpaceBackground() + + for (let i = 0; i < thisObject.timeMachines.length; i++) { + let timeMachine = thisObject.timeMachines[thisObject.timeMachines.length - i - 1] + timeMachine.drawBackground() + } + } + function draw () { if (thisObject.visible !== true) { return } drawBackground() @@ -298,15 +307,6 @@ function newChartSpace () { drawForeground() } - function drawBackground () { - drawSpaceBackground() - - for (let i = 0; i < thisObject.timeMachines.length; i++) { - let timeMachine = thisObject.timeMachines[thisObject.timeMachines.length - i - 1] - timeMachine.drawBackground() - } - } - function drawForeground () { for (let i = 0; i < thisObject.timeMachines.length; i++) { let timeMachine = thisObject.timeMachines[thisObject.timeMachines.length - i - 1] From 728cb260172f494831aa1edd1aa36013ef3143a9 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 11 Jan 2020 17:13:27 +0100 Subject: [PATCH 096/264] Bug Fixed scales allways drawing --- ChartsSpace/TimeMachine.js | 21 +++++++++++++++------ ChartsSpace/TimelineChart.js | 17 +++++++++++++---- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 1645d2827..d30d1a737 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -41,6 +41,7 @@ function newTimeMachine () { } } + let drawScales = false let syncWithDesignerLoop = 0 let timelineChartsMap = new Map() @@ -129,6 +130,8 @@ function newTimeMachine () { onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) function onMouseOver (event) { + drawScales = true + mouse.position.x = event.x mouse.position.y = event.y @@ -146,6 +149,8 @@ function newTimeMachine () { onMouseNotOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) function onMouseNotOver (event) { + drawScales = false + if (thisObject.timeScale !== undefined) { thisObject.timeScale.visible = false } @@ -424,9 +429,11 @@ function newTimeMachine () { timelineChart.draw() } - if (thisObject.timeScale !== undefined) { thisObject.timeScale.draw() } - if (thisObject.timeFrameScale !== undefined) { thisObject.timeFrameScale.draw() } - if (thisObject.rateScale !== undefined) { thisObject.rateScale.draw() } + if (drawScales === true) { + if (thisObject.timeScale !== undefined) { thisObject.timeScale.draw() } + if (thisObject.timeFrameScale !== undefined) { thisObject.timeFrameScale.draw() } + if (thisObject.rateScale !== undefined) { thisObject.rateScale.draw() } + } thisObject.container.frame.draw(false, true, false, thisObject.fitFunction) } @@ -439,9 +446,11 @@ function newTimeMachine () { timelineChart.drawForeground() } - if (thisObject.timeScale !== undefined) { thisObject.timeScale.drawForeground() } - if (thisObject.timeFrameScale !== undefined) { thisObject.timeFrameScale.drawForeground() } - if (thisObject.rateScale !== undefined) { thisObject.rateScale.drawForeground() } + if (drawScales === true) { + if (thisObject.timeScale !== undefined) { thisObject.timeScale.drawForeground() } + if (thisObject.timeFrameScale !== undefined) { thisObject.timeFrameScale.drawForeground() } + if (thisObject.rateScale !== undefined) { thisObject.rateScale.drawForeground() } + } } } diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 287792ef6..3f9fcc83d 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -47,6 +47,7 @@ function newTimelineChart () { let timeFrameScaleEventSuscriptionId let timeFrameScaleMouseOverEventSuscriptionId + let drawScales = false let mouse = { position: { x: 0, @@ -154,6 +155,8 @@ function newTimelineChart () { function onMouseOver (event) { /* This event gets to the timelinechart container because it inherits it from the time machine container, which is the one raising Mouse Over and Mouse not Over Events to its children. */ + drawScales = true + if (thisObject.rateScale !== undefined) { thisObject.rateScale.onMouseOverSomeTimeMachineContainer(event) } @@ -172,6 +175,8 @@ function newTimelineChart () { function onMouseNotOver (event) { /* This event is inherited from the Time Machine */ + drawScales = false + if (thisObject.rateScale !== undefined) { thisObject.rateScale.visible = false } @@ -371,15 +376,19 @@ function newTimelineChart () { function draw () { if (thisObject.container.frame.isInViewPort()) { - if (thisObject.timeFrameScale !== undefined) { thisObject.timeFrameScale.draw() } - if (thisObject.rateScale !== undefined) { thisObject.rateScale.draw() } + if (drawScales === true) { + if (thisObject.timeFrameScale !== undefined) { thisObject.timeFrameScale.draw() } + if (thisObject.rateScale !== undefined) { thisObject.rateScale.draw() } + } } } function drawForeground () { if (thisObject.container.frame.isInViewPort()) { - if (thisObject.timeFrameScale !== undefined) { thisObject.timeFrameScale.drawForeground() } - if (thisObject.rateScale !== undefined) { thisObject.rateScale.drawForeground() } + if (drawScales === true) { + if (thisObject.timeFrameScale !== undefined) { thisObject.timeFrameScale.drawForeground() } + if (thisObject.rateScale !== undefined) { thisObject.rateScale.drawForeground() } + } } } From 504afdc89a758cb6da6a6b6e1369934d9196780b Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 11 Jan 2020 18:38:02 +0100 Subject: [PATCH 097/264] fit function at time machine --- ChartsSpace/TimeMachine.js | 36 +++++++++++++++++++++++++++++++++++- ChartsSpace/TimelineChart.js | 6 ++---- Spaces/ChartSpace.js | 6 ++---- Spaces/PanelsSpace.js | 6 +++--- 4 files changed, 42 insertions(+), 12 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index d30d1a737..9e32904fd 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -20,9 +20,9 @@ function newTimeMachine () { container: undefined, timeScale: undefined, rateScale: undefined, - fitFunction: undefined, payload: undefined, timelineCharts: [], + fitFunction: fitFunction, physics: physics, draw: draw, drawBackground: drawBackground, @@ -60,6 +60,7 @@ function newTimeMachine () { function setupContainer () { thisObject.container = newContainer() thisObject.container.initialize(MODULE_NAME) + thisObject.container.fitFunction = thisObject.fitFunction thisObject.container.isDraggeable = true thisObject.container.insideViewport = true thisObject.container.detectMouseOver = true @@ -281,6 +282,38 @@ function newTimeMachine () { } } + function fitFunction (point, fullVisible) { + /* We prevent a point to be out of the container AND out of the Chart Space in general */ + + let returnPoint = { + x: point.x, + y: point.y + } + + let upCorner = { + x: 0, + y: 0 + } + + let bottonCorner = { + x: thisObject.container.frame.width, + y: thisObject.container.frame.height + } + + upCorner = transformThisPoint(upCorner, thisObject.container) + bottonCorner = transformThisPoint(bottonCorner, thisObject.container) + + /* Checking against the container limits. */ + if (returnPoint.x < upCorner.x) { returnPoint.x = upCorner.x } + if (returnPoint.x > bottonCorner.x) { returnPoint.x = bottonCorner.x } + if (returnPoint.y < upCorner.y) { returnPoint.y = upCorner.y } + if (returnPoint.y > bottonCorner.y) { returnPoint.y = bottonCorner.y } + + returnPoint = canvas.chartSpace.fitFunction(returnPoint, fullVisible) + + return returnPoint + } + function physics () { thisObjectPhysics() childrenPhysics() @@ -359,6 +392,7 @@ function newTimeMachine () { /* Setting up the new timeline timelineChart. */ timelineChart.container.connectToParent(thisObject.container, true, true, false, true, true, true, false, false, true) timelineChart.container.fitFunction = thisObject.container.fitFunction + timelineChart.fitFunction = thisObject.fitFunction timelineChart.container.frame.height = thisObject.container.frame.height timelineChart.container.frame.position.x = thisObject.container.frame.width / 2 - timelineChart.container.frame.width / 2 timelineChart.container.frame.position.y = 0 diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 3f9fcc83d..2e823c21c 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -26,8 +26,6 @@ function newTimelineChart () { finalize: finalize } - thisObject.fitFunction = canvas.chartSpace.fitIntoVisibleArea - let timeMachineCoordinateSystem let timelineChartCoordinateSystem = newCoordinateSystem() @@ -410,8 +408,8 @@ function newTimelineChart () { fromPoint = transformThisPoint(fromPoint, thisObject.container) toPoint = transformThisPoint(toPoint, thisObject.container) - fromPoint = canvas.chartSpace.fitIntoVisibleArea(fromPoint) - toPoint = canvas.chartSpace.fitIntoVisibleArea(toPoint) + fromPoint = thisObject.fitFunction(fromPoint) + toPoint = thisObject.fitFunction(toPoint) browserCanvasContext.beginPath() diff --git a/Spaces/ChartSpace.js b/Spaces/ChartSpace.js index a4ba0f45b..789e36d45 100644 --- a/Spaces/ChartSpace.js +++ b/Spaces/ChartSpace.js @@ -20,7 +20,7 @@ function newChartSpace () { oneScreenDown: oneScreenDown, oneScreenLeft: oneScreenLeft, oneScreenRight: oneScreenRight, - fitIntoVisibleArea: fitIntoVisibleArea, + fitFunction: fitFunction, isThisPointVisible: isThisPointVisible, physics: physics, draw: draw, @@ -144,7 +144,7 @@ function newChartSpace () { viewPort.displace(displaceVector, true) } - function fitIntoVisibleArea (point, fullVisible) { + function fitFunction (point, fullVisible) { /* Here we check the boundaries of the resulting points, so they dont go out of the visible area. */ let returnPoint = { @@ -250,8 +250,6 @@ function newChartSpace () { /* Setting up the new time machine. */ timeMachine.container.frame.position.x = thisObject.container.frame.width / 2 - timeMachine.container.frame.width / 2 timeMachine.container.frame.position.y = thisObject.container.frame.height / 2 - timeMachine.container.frame.height / 2 - timeMachine.container.fitFunction = fitIntoVisibleArea - timeMachine.fitFunction = fitIntoVisibleArea timeMachine.initialize(onTimeMachineInitialized) function onTimeMachineInitialized (err) { diff --git a/Spaces/PanelsSpace.js b/Spaces/PanelsSpace.js index ce0aa8a59..1539238e4 100644 --- a/Spaces/PanelsSpace.js +++ b/Spaces/PanelsSpace.js @@ -42,7 +42,7 @@ function newPanelsSpace () { case 'Products Panel': { panel = newProductsPanel() - panel.fitFunction = canvas.chartSpace.fitIntoVisibleArea + panel.fitFunction = canvas.chartSpace.fitFunction panel.container.isVisibleFunction = canvas.chartSpace.isThisPointVisible break } @@ -50,13 +50,13 @@ function newPanelsSpace () { { if (pPanelCode !== undefined) { panel = newPlotterPanel() - panel.fitFunction = canvas.chartSpace.fitIntoVisibleArea + panel.fitFunction = canvas.chartSpace.fitFunction panel.container.isVisibleFunction = canvas.chartSpace.isThisPointVisible panel.session = pSession panel.initialize(pPanelCode) } else { panel = getNewPlotterPanel(pParameters.dataMine, pParameters.plotterCodeName, pParameters.moduleCodeName, pParameters.panelCodeName) - panel.fitFunction = canvas.chartSpace.fitIntoVisibleArea + panel.fitFunction = canvas.chartSpace.fitFunction panel.container.isVisibleFunction = canvas.chartSpace.isThisPointVisible panel.session = pSession panel.initialize() From 27deede44c4c1fe822b4f23116015a8a17781880 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 11 Jan 2020 19:55:40 +0100 Subject: [PATCH 098/264] Margin at fitfunction --- ChartsSpace/TimeMachine.js | 20 +++++++++++++++----- ChartsSpace/TimelineChart.js | 4 ++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 9e32904fd..0e9ac7b6a 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -104,6 +104,8 @@ function newTimeMachine () { } function finalizeTimeScale () { + if (thisObject.timeScale === undefined) { return } + thisObject.timeScale.container.eventHandler.stopListening(timeScaleEventSuscriptionId) thisObject.timeScale.container.eventHandler.stopListening(timeScaleMouseOverEventSuscriptionId) thisObject.timeScale.finalize() @@ -111,6 +113,8 @@ function newTimeMachine () { } function finalizeRateScale () { + if (thisObject.rateScale === undefined) { return } + thisObject.rateScale.container.eventHandler.stopListening(rateScaleEventSuscriptionId) thisObject.rateScale.container.eventHandler.stopListening(rateScaleMouseOverEventSuscriptionId) thisObject.rateScale.finalize() @@ -118,6 +122,8 @@ function newTimeMachine () { } function finalizeTimeFrameScale () { + if (thisObject.timeFrameScale === undefined) { return } + thisObject.timeFrameScale.container.eventHandler.stopListening(timeFrameScaleEventSuscriptionId) thisObject.timeFrameScale.container.eventHandler.stopListening(timeFrameScaleMouseOverEventSuscriptionId) thisObject.timeFrameScale.finalize() @@ -282,7 +288,7 @@ function newTimeMachine () { } } - function fitFunction (point, fullVisible) { + function fitFunction (point, fullVisible, margin, topMargin, bottomMargin) { /* We prevent a point to be out of the container AND out of the Chart Space in general */ let returnPoint = { @@ -304,10 +310,14 @@ function newTimeMachine () { bottonCorner = transformThisPoint(bottonCorner, thisObject.container) /* Checking against the container limits. */ - if (returnPoint.x < upCorner.x) { returnPoint.x = upCorner.x } - if (returnPoint.x > bottonCorner.x) { returnPoint.x = bottonCorner.x } - if (returnPoint.y < upCorner.y) { returnPoint.y = upCorner.y } - if (returnPoint.y > bottonCorner.y) { returnPoint.y = bottonCorner.y } + if (margin === undefined) { margin = 0 } + if (topMargin === undefined) { topMargin = 0 } + if (bottomMargin === undefined) { bottomMargin = 0 } + + if (returnPoint.x - margin < upCorner.x) { returnPoint.x = upCorner.x + margin } + if (returnPoint.x + margin > bottonCorner.x) { returnPoint.x = bottonCorner.x - margin } + if (returnPoint.y - margin - topMargin < upCorner.y) { returnPoint.y = upCorner.y + margin + topMargin } + if (returnPoint.y + margin + bottomMargin > bottonCorner.y) { returnPoint.y = bottonCorner.y - margin - bottomMargin } returnPoint = canvas.chartSpace.fitFunction(returnPoint, fullVisible) diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 2e823c21c..a6fa21b33 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -89,6 +89,8 @@ function newTimelineChart () { } function finalizeTimeFrameScale () { + if (thisObject.timeFrameScale === undefined) { return } + thisObject.timeFrameScale.container.eventHandler.stopListening(timeFrameScaleEventSuscriptionId) thisObject.timeFrameScale.container.eventHandler.stopListening(timeFrameScaleMouseOverEventSuscriptionId) thisObject.timeFrameScale.finalize() @@ -100,6 +102,8 @@ function newTimelineChart () { } function finalizeRateScale () { + if (thisObject.rateScale === undefined) { return } + thisObject.rateScale.container.eventHandler.stopListening(rateScaleEventSuscriptionId) thisObject.rateScale.container.eventHandler.stopListening(rateScaleMouseOverEventSuscriptionId) thisObject.rateScale.finalize() From 257abd0110c01aa2a29d7d725de414ecd12f45aa Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 13 Jan 2020 13:20:19 +0100 Subject: [PATCH 099/264] cleaning Product Card --- Panels/ProductCard.js | 358 ++-------------------------------------- Spaces/DesignerSpace.js | 7 +- 2 files changed, 16 insertions(+), 349 deletions(-) diff --git a/Panels/ProductCard.js b/Panels/ProductCard.js index 539aab0bd..bad36ba6a 100644 --- a/Panels/ProductCard.js +++ b/Panels/ProductCard.js @@ -69,40 +69,11 @@ function newProductCard () { let timeFrame = INITIAL_TIME_PERIOD let datetime = NEW_SESSION_INITIAL_DATE - /* TODO We are in a transition period in which bots and dataMines images might be located at different places. - What we are going to do then is to try to load them from both places and use the variable that finally gets an - image. */ - - /* This is the legacy image storage. */ - - let legacyDataMineAvatar - let legacyDataMineAvatarLoaded = false - - /* TODO Temporary code */ - let legacyBotAvatar - let legacyBotAvatarLoaded = false - - /* Now the plotters images */ - - let legacyPlotterBanner - let legacyPlotterBannerLoaded = false - - /* We are transitioning towards this */ - - let dataMineAvatar // stores the avatar image of the dataMine the bot portrayed at this card belongs to. - let dataMineAvatarLoaded = false - - /* TODO Temporary code */ - let botAvatar // stores the avatar image of the dataMine the bot portrayed at this card belongs to. - let botAvatarLoaded = false - /* Add an Event Handler */ thisObject.eventHandler = newEventHandler() let imagesLoaded = 0 - let lastMouseOver = 0 // This variable is used to animate what happens while we are having a mounse over. - return thisObject function finalize () { @@ -117,11 +88,6 @@ function newProductCard () { thisObject.code = undefined thisObject.fitFunction = undefined - legacyDataMineAvatar = undefined - legacyDataMineAvatarLoaded = undefined - legacyBotAvatar = undefined - legacyBotAvatarLoaded = undefined - legacyPlotterBanner = undefined timeFrame = undefined datetime = undefined @@ -144,7 +110,6 @@ function newProductCard () { try { thisObject.container = newContainer() thisObject.container.initialize(MODULE_NAME + thisObject.code) - thisObject.container.detectMouseOver = true thisObject.container.isDraggeable = false thisObject.container.isClickeable = true @@ -158,8 +123,6 @@ function newProductCard () { if (plotter !== undefined) { let plotterModule = ecosystem.getPlotterModule(plotter, thisObject.product.plotter.moduleName) - - thisObject.product.plotter.profilePicture = plotterModule.profilePicture thisObject.product.plotter.module = plotterModule } @@ -208,93 +171,6 @@ function newProductCard () { /* Lets listen to our own events to react when we have a Mouse Click */ thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick) - thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) - - /* WARNING THIS IS TEMPORARY CODE */ - - const LEGACY_DATA_MINE = thisObject.dataMine.codeName - const REPO = thisObject.bot.repo - const PROFILE_PIC = thisObject.bot.profilePicture - - /* The plotter banner, comes from the Legacy Location so far, no matter if the Data Mine is at the DataMines Modules or not. */ - - const PLOTTER_DATA_MINE = thisObject.product.plotter.dataMine - const PLOTTER_REPO = thisObject.product.plotter.codeName - const PLOTTER_PROFILE_PIC = thisObject.product.plotter.profilePicture - - legacyPlotterBanner = new Image() - legacyPlotterBanner.onload = onLegacyPlotterBanner - - function onLegacyPlotterBanner () { - legacyPlotterBannerLoaded = true - } - - if (PLOTTER_PROFILE_PIC !== undefined) { - legacyPlotterBanner.src = window.canvasApp.urlPrefix + 'Images/' + PLOTTER_DATA_MINE + '/' + PLOTTER_REPO + '/' + PLOTTER_PROFILE_PIC - } else { - if (thisObject.product.plotter.banner !== undefined) { - legacyPlotterBanner.src = window.canvasApp.urlPrefix + 'Images/' + thisObject.product.plotter.banner + '-Banner.PNG' - } else { - legacyPlotterBanner.src = window.canvasApp.urlPrefix + 'Images/' + 'Default-Banner.PNG' - } - } - - const DATA_MINE = thisObject.dataMine.codeName.toLowerCase() - const BOT = thisObject.bot.codeName.toLowerCase() - - if (window.canvasApp.context.dataMineProfileImages.get(DATA_MINE) === undefined) { - // This means this Data Mine is a Lecay Data Mine, still not at any Module. - - /* - Here we will download the images still at the legacy storage. - */ - - legacyDataMineAvatar = new Image() - - legacyDataMineAvatar.onload = onLegacyImageLoad - - function onLegacyImageLoad () { - legacyDataMineAvatarLoaded = true - } - - legacyDataMineAvatar.src = window.canvasApp.urlPrefix + 'Images/' + LEGACY_DATA_MINE + '/' + LEGACY_DATA_MINE + '.png' - - legacyBotAvatar = new Image() - legacyBotAvatar.onload = onLegacyImageLoadBot - - function onLegacyImageLoadBot () { - legacyBotAvatarLoaded = true - thisObject.bot.avatar = legacyBotAvatar - } - - legacyBotAvatar.src = window.canvasApp.urlPrefix + 'Images/' + LEGACY_DATA_MINE + '/' + REPO + '/' + PROFILE_PIC - } else { - /* - Here we will download the images of dataMines shareed at the DataMines Module. - There might be Product Cards of bots beloging to dataMines not present currently at the DataMines Module, in those cases - nothing should happen. - */ - - dataMineAvatar = new Image() - - dataMineAvatar.onload = onImageLoad - - function onImageLoad () { - dataMineAvatarLoaded = true - } - - dataMineAvatar.src = window.canvasApp.context.dataMineProfileImages.get(DATA_MINE) - - botAvatar = new Image() - botAvatar.onload = onImageLoadBot - - function onImageLoadBot () { - botAvatarLoaded = true - thisObject.bot.avatar = botAvatar - } - - botAvatar.src = window.canvasApp.context.fbProfileImages.get(DATA_MINE + '-' + BOT) - } } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err.stack) } } @@ -433,10 +309,6 @@ function newProductCard () { fileSequenceProgressBar.strokeStyle = UNLOADED_STROKE_STYLE } - function onMouseOver (event) { - lastMouseOver = 25 - } - function changeStatusTo (pNewStatus) { if (thisObject.status !== pNewStatus) { thisObject.status = pNewStatus @@ -451,215 +323,19 @@ function newProductCard () { } function drawProductCard () { - /* - Put images on the card. - */ + switch (thisObject.status) { + case PRODUCT_CARD_STATUS.ON: - let fitImagePoint = { - x: 0, - y: 0 + break + case PRODUCT_CARD_STATUS.OFF: + + break + case PRODUCT_CARD_STATUS.LOADING: + + break } - const dataMineImageSize = 20 - const botImageSize = 20 - const plotterImageSize = { - width: 180, - height: 50 - } - - lastMouseOver-- // Animating the mouse onMouseOver - - if (lastMouseOver > 0) { - /* First the Dev Data Mine Profile Picture. */ - let dataMineImagePoint = { - x: 2, - y: thisObject.container.frame.height / 2 - dataMineImageSize / 2 - } - - dataMineImagePoint = thisObject.container.frame.frameThisPoint(dataMineImagePoint) - fitImagePoint = thisObject.fitFunction(dataMineImagePoint) - let dataMineImage - if (legacyDataMineAvatarLoaded === true) { - dataMineImage = legacyDataMineAvatar - } - if (dataMineAvatarLoaded === true) { - dataMineImage = dataMineAvatar - } - if (dataMineImage !== undefined && dataMineImagePoint.y === fitImagePoint.y) { - if (dataMineImage.naturalHeight !== 0) { - /* The image is rounded before being displayed. */ - browserCanvasContext.save() - browserCanvasContext.beginPath() - browserCanvasContext.arc(dataMineImagePoint.x + dataMineImageSize / 2, dataMineImagePoint.y + dataMineImageSize / 2, dataMineImageSize / 2, 0, Math.PI * 2, true) - browserCanvasContext.closePath() - browserCanvasContext.clip() - browserCanvasContext.drawImage(dataMineImage, dataMineImagePoint.x, dataMineImagePoint.y, dataMineImageSize, dataMineImageSize) - browserCanvasContext.beginPath() - browserCanvasContext.arc(dataMineImagePoint.x, dataMineImagePoint.y, dataMineImageSize / 2, 0, Math.PI * 2, true) - browserCanvasContext.clip() - browserCanvasContext.closePath() - browserCanvasContext.restore() - } - } - - /* Second the Bot's Profile Picture. */ - if (thisObject.bot.profilePicture !== undefined) { - let botImagePoint = { - x: thisObject.container.frame.width - botImageSize / 2 - 8, - y: thisObject.container.frame.height / 2 - botImageSize / 2 - } - botImagePoint = thisObject.container.frame.frameThisPoint(botImagePoint) - fitImagePoint = thisObject.fitFunction(botImagePoint) - - let imageId = thisObject.bot.dataMine + '.' + thisObject.bot.profilePicture - /* TODO Temporary code */ - let botImage - botImage = thisObject.bot.avatar - if (botImage !== undefined && botImagePoint.y === fitImagePoint.y) { - if (botImage.naturalHeight !== 0) { - /* The image is rounded before being displayed. */ - browserCanvasContext.save() - browserCanvasContext.beginPath() - browserCanvasContext.arc(botImagePoint.x + botImageSize / 2, botImagePoint.y + botImageSize / 2, botImageSize / 2, 0, Math.PI * 2, true) - browserCanvasContext.closePath() - browserCanvasContext.clip() - browserCanvasContext.drawImage(botImage, botImagePoint.x, botImagePoint.y, botImageSize, botImageSize) - browserCanvasContext.beginPath() - browserCanvasContext.arc(botImagePoint.x, botImagePoint.y, botImageSize / 2, 0, Math.PI * 2, true) - browserCanvasContext.clip() - browserCanvasContext.closePath() - browserCanvasContext.restore() - } - } - } - } - /* Third the Plotter's Profile Picture. */ - if (thisObject.product.plotter.profilePicture !== undefined || thisObject.product.plotter.legacy === false) { - let plotterImagePoint = { - x: thisObject.container.frame.width / 2 - plotterImageSize.width / 2, - y: thisObject.container.frame.height / 2 - plotterImageSize.height / 2 - } - plotterImagePoint = thisObject.container.frame.frameThisPoint(plotterImagePoint) - fitImagePoint = { - x: 0, - y: plotterImagePoint.y + plotterImageSize.height - } - fitImagePoint = thisObject.fitFunction(fitImagePoint) - let imageId = thisObject.product.plotter.dataMine + '.' + thisObject.product.plotter.codeName + '.' + thisObject.product.plotter.moduleName + '.' + thisObject.product.plotter.profilePicture - let plotterImage = legacyPlotterBanner - if (plotterImage !== undefined && plotterImagePoint.y + plotterImageSize.height === fitImagePoint.y) { - if (plotterImage.naturalHeight !== 0) { - browserCanvasContext.drawImage(plotterImage, plotterImagePoint.x, plotterImagePoint.y, plotterImageSize.width, plotterImageSize.height) - } - } - } - drawProductLoadStatus() - - function drawProductLoadStatus () { - let offFillStyle = 'rgba(' + UI_COLOR.RED + ', 0.20)' - let onFillStyle = 'rgba(' + UI_COLOR.GREEN + ', 0.20)' - let loadingFillStyle = 'rgba(' + UI_COLOR.TITANIUM_YELLOW + ', 0.40)' - - switch (thisObject.status) { - case PRODUCT_CARD_STATUS.ON: - browserCanvasContext.fillStyle = onFillStyle - break - case PRODUCT_CARD_STATUS.OFF: - browserCanvasContext.fillStyle = offFillStyle - break - case PRODUCT_CARD_STATUS.LOADING: - browserCanvasContext.fillStyle = loadingFillStyle - break - } - - let centerPoint = { - x: thisObject.container.frame.width / 2, - y: thisObject.container.frame.height / 2 - 13 - } - - let point1 = { - x: centerPoint.x - plotterImageSize.width / 2, - y: centerPoint.y - plotterImageSize.height / 2 - 7 - } - - let point2 = { - x: centerPoint.x + plotterImageSize.width / 2, - y: centerPoint.y - plotterImageSize.height / 2 - 7 - } - - let point3 = { - x: centerPoint.x + plotterImageSize.width / 2, - y: centerPoint.y - plotterImageSize.height / 2 + 7 - } - - let point4 = { - x: centerPoint.x - plotterImageSize.width / 2, - y: centerPoint.y - plotterImageSize.height / 2 + 7 - } - /* Now the transformations. */ - point1 = thisObject.container.frame.frameThisPoint(point1) - point2 = thisObject.container.frame.frameThisPoint(point2) - point3 = thisObject.container.frame.frameThisPoint(point3) - point4 = thisObject.container.frame.frameThisPoint(point4) - - point1 = thisObject.fitFunction(point1) - point2 = thisObject.fitFunction(point2) - point3 = thisObject.fitFunction(point3) - point4 = thisObject.fitFunction(point4) - - browserCanvasContext.beginPath() - browserCanvasContext.moveTo(point1.x, point1.y) - browserCanvasContext.lineTo(point2.x, point2.y) - browserCanvasContext.lineTo(point3.x, point3.y) - browserCanvasContext.lineTo(point4.x, point4.y) - browserCanvasContext.closePath() - browserCanvasContext.fill() - browserCanvasContext.strokeStyle = 'rgba(150, 150, 150, 1)' - browserCanvasContext.lineWidth = 0.1 - browserCanvasContext.stroke() - } - /* - print the text - */ - let labelPoint - let fontSize = 10 - - browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY - let label - if (lastMouseOver > 0) { - /* dataMine */ - label = thisObject.dataMine.displayName - if (label.length > 10) { label = label.substring(1, 8) + '...' } - - labelPoint = { - x: 2 + dataMineImageSize / 2 - label.length / 2 * fontSize * FONT_ASPECT_RATIO, - y: thisObject.container.frame.height / 2 + dataMineImageSize / 2 + fontSize * FONT_ASPECT_RATIO + 5 - } - - labelPoint = thisObject.container.frame.frameThisPoint(labelPoint) - labelPoint = thisObject.fitFunction(labelPoint) - browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY - browserCanvasContext.fillStyle = 'rgba(60, 60, 60, 0.50)' - browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y) - /* bot */ - label = thisObject.bot.displayName - if (label.length > 10) { label = label.substring(1, 8) + '...' } - - labelPoint = { - x: thisObject.container.frame.width - 8 - label.length / 2 * fontSize * FONT_ASPECT_RATIO, - y: thisObject.container.frame.height / 2 + dataMineImageSize / 2 + fontSize * FONT_ASPECT_RATIO + 5 - } - - labelPoint = thisObject.container.frame.frameThisPoint(labelPoint) - labelPoint = thisObject.fitFunction(labelPoint) - - browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY - browserCanvasContext.fillStyle = 'rgba(60, 60, 60, 0.50)' - browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y) - } - /* product */ - fontSize = 10 - label = thisObject.product.displayName + let label = thisObject.product.displayName if (thisObject.session !== undefined) { const MAX_LABEL_LENGTH = 20 @@ -669,20 +345,6 @@ function newProductCard () { label = thisObject.session.name + ' - ' + label } } - labelPoint = { - x: 65, - y: thisObject.container.frame.height / 2 + 15 - } - labelPoint = { - x: thisObject.container.frame.width / 2 - label.length / 2 * fontSize * FONT_ASPECT_RATIO, - y: thisObject.container.frame.height / 2 - dataMineImageSize / 2 - fontSize * FONT_ASPECT_RATIO - 20 - } - labelPoint = thisObject.container.frame.frameThisPoint(labelPoint) - labelPoint = thisObject.fitFunction(labelPoint) - - browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY - browserCanvasContext.fillStyle = 'rgba(60, 60, 60, 1)' - browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y) /* ------------------- Progress Bars -------------------------- */ diff --git a/Spaces/DesignerSpace.js b/Spaces/DesignerSpace.js index cf64de32d..130df5dc3 100644 --- a/Spaces/DesignerSpace.js +++ b/Spaces/DesignerSpace.js @@ -210,7 +210,12 @@ function newDesignerSpace () { 'cardano', 'bitcoin-cash', 'bitcoin', - 'binance-coin' + 'binance-coin', + 'trend', + 'oscillator', + 'moving-average', + 'histogram', + 'band' ] for (let i = 0; i < iconsNames.length; i++) { From c930c9af0570699960ac9218246dc569f2d0e07f Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 13 Jan 2020 13:50:04 +0100 Subject: [PATCH 100/264] Products Panel usable --- Panels/ProductCard.js | 13 ++++++++++++- Panels/ProductsPanel.js | 2 +- Spaces/DesignerSpace.js | 4 +++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Panels/ProductCard.js b/Panels/ProductCard.js index bad36ba6a..136b2e449 100644 --- a/Panels/ProductCard.js +++ b/Panels/ProductCard.js @@ -134,7 +134,7 @@ function newProductCard () { } thisObject.container.frame.position = position - thisObject.container.frame.width = UI_PANEL.WIDTH.LARGE - 20 + thisObject.container.frame.width = UI_PANEL.WIDTH.LARGE thisObject.container.frame.height = 100 /* We retrieve the locally stored status of the Product */ @@ -346,6 +346,17 @@ function newProductCard () { } } + let label1 = label + let label2 = 'ON' + let label3 = '' + + let icon1 = canvas.designerSpace.iconCollection.get('oscillator') + let icon2 = canvas.designerSpace.iconCollection.get('poloniex') // canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.type) + + let backgroundColor = UI_COLOR.BLACK + + drawScaleDisplay(label1, label2, label3, 0, 0, 0, icon1, icon2, thisObject.container, backgroundColor) + /* ------------------- Progress Bars -------------------------- */ const ANIMATED_INCREMENT = 5 diff --git a/Panels/ProductsPanel.js b/Panels/ProductsPanel.js index d106d7327..b8a479578 100644 --- a/Panels/ProductsPanel.js +++ b/Panels/ProductsPanel.js @@ -494,7 +494,7 @@ function newProductsPanel () { function draw () { if (isInitialized === false) { return } - thisObject.container.frame.draw(false, false, true, thisObject.fitFunction) + thisObject.container.frame.draw(false, false, false, thisObject.fitFunction) for (let i = 0; i < visibleProductCards.length; i++) { visibleProductCards[i].draw() diff --git a/Spaces/DesignerSpace.js b/Spaces/DesignerSpace.js index 130df5dc3..b2aaedc46 100644 --- a/Spaces/DesignerSpace.js +++ b/Spaces/DesignerSpace.js @@ -215,7 +215,9 @@ function newDesignerSpace () { 'oscillator', 'moving-average', 'histogram', - 'band' + 'band', + 'volume', + 'candles' ] for (let i = 0; i < iconsNames.length; i++) { From 9719b6df33f577303ee28708b5863a65aef3d5e4 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 13 Jan 2020 17:44:47 +0100 Subject: [PATCH 101/264] Reorg inside Timeline Chart, Layers Manager and Plotter Manager --- ChartsSpace/PlottersManager.js | 204 ++++++++++++--------------------- ChartsSpace/TimeMachine.js | 17 +-- ChartsSpace/TimelineChart.js | 200 +++++++++++++++++--------------- 3 files changed, 187 insertions(+), 234 deletions(-) diff --git a/ChartsSpace/PlottersManager.js b/ChartsSpace/PlottersManager.js index 5c4e5d387..3cfd57279 100644 --- a/ChartsSpace/PlottersManager.js +++ b/ChartsSpace/PlottersManager.js @@ -65,7 +65,7 @@ function newPlottersManager () { setupContainer() } - function initialize (pProductsPanel, pExchange, pMarket, callBackFunction) { + function initialize (pProductsPanel, pExchange, pMarket) { try { /* Remember the Products Panel */ productsPanel = pProductsPanel @@ -76,51 +76,14 @@ function newPlottersManager () { /* Lets get all the cards that needs to be loaded. */ - let initializationCounter = 0 let loadingProductCards = productsPanel.getLoadingProductCards() - let okCounter = 0 - let failCounter = 0 - if (loadingProductCards.length === 0) { - callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) - return - } for (let i = 0; i < loadingProductCards.length; i++) { /* For each one, we will initialize the associated plotter. */ - initializeProductPlotter(loadingProductCards[i], onProductPlotterInitialized) - - function onProductPlotterInitialized (err) { - initializationCounter++ - - switch (err.result) { - case GLOBAL.DEFAULT_OK_RESPONSE.result: { - okCounter++ - break - } - case GLOBAL.DEFAULT_FAIL_RESPONSE.result: { - failCounter++ - break - } - default: { - failCounter++ - break - } - } - if (initializationCounter === loadingProductCards.length) { - // This was the last one. - /* If less than 50% of plotters are initialized then we return FAIL. */ - if (okCounter >= 1) { - initializationReady = true - callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) - } else { - callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) - } - } - } + initializeProductPlotter(loadingProductCards[i]) } } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err.stack) } - callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) } } @@ -162,119 +125,104 @@ function newPlottersManager () { function onProductStorageInitialized (err) { try { - switch (err.result) { - case GLOBAL.DEFAULT_OK_RESPONSE.result: { - break + if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result) { + /* Now we have all the initial data loaded and ready to be delivered to the new instance of the plotter. */ + let plotter + let productDefinition + + if (pProductCard.product.plotter.legacy === false) { + plotter = newPlotter() + + /* We take a snapwhot of the current product definition to be used by the plotter. */ + let functionLibraryProtocolNode = newProtocolNode() + let lightingPath = '->Product Definition->' + + 'Record Definition->Record Property->Formula->' + + 'Data Building Procedure->Procedure Loop->Javascript Code->Procedure Initialization->Javascript Code->' + + 'Calculations Procedure->Procedure Loop->Javascript Code->Procedure Initialization->Javascript Code->' + + 'Plotter Module->Shapes->' + + 'Chart Points->Point->Point Formula->' + + 'Polygon->Polygon Body->Style->Style Condition->Style->' + + 'Polygon Border->Style->Style Condition->Style->' + + 'Polygon Vertex->Point->' + + 'Plotter Panel->Javascript Code->Panel Data->Data Formula->' + productDefinition = functionLibraryProtocolNode.getProtocolNode(pProductCard.product.node, false, true, true, false, false, lightingPath) + } else { + plotter = getNewPlotter(pProductCard.product.plotter.dataMine, pProductCard.product.plotter.codeName, pProductCard.product.plotter.moduleName) } - case GLOBAL.DEFAULT_FAIL_RESPONSE.result: { - callBack(GLOBAL.DEFAULT_FAIL_RESPONSE) - return - } - default: { - callBack(GLOBAL.DEFAULT_FAIL_RESPONSE) - return - } - } - /* Now we have all the initial data loaded and ready to be delivered to the new instance of the plotter. */ - let plotter - let productDefinition - if (pProductCard.product.plotter.legacy === false) { - plotter = newPlotter() + plotter.container.connectToParent(thisObject.container, true, true, false, true, true, true, false, false, true) + plotter.container.frame.position.x = thisObject.container.frame.width / 2 - plotter.container.frame.width / 2 + plotter.container.frame.position.y = thisObject.container.frame.height / 2 - plotter.container.frame.height / 2 + plotter.fitFunction = thisObject.fitFunction + plotter.initialize(storage, exchange, market, datetime, timeFrame, onPlotterInizialized, productDefinition) - /* We take a snapwhot of the current product definition to be used by the plotter. */ - let functionLibraryProtocolNode = newProtocolNode() - let lightingPath = '->Product Definition->' + - 'Record Definition->Record Property->Formula->' + - 'Data Building Procedure->Procedure Loop->Javascript Code->Procedure Initialization->Javascript Code->' + - 'Calculations Procedure->Procedure Loop->Javascript Code->Procedure Initialization->Javascript Code->' + - 'Plotter Module->Shapes->' + - 'Chart Points->Point->Point Formula->' + - 'Polygon->Polygon Body->Style->Style Condition->Style->' + - 'Polygon Border->Style->Style Condition->Style->' + - 'Polygon Vertex->Point->' + - 'Plotter Panel->Javascript Code->Panel Data->Data Formula->' - productDefinition = functionLibraryProtocolNode.getProtocolNode(pProductCard.product.node, false, true, true, false, false, lightingPath) - } else { - plotter = getNewPlotter(pProductCard.product.plotter.dataMine, pProductCard.product.plotter.codeName, pProductCard.product.plotter.moduleName) - } - - plotter.container.connectToParent(thisObject.container, true, true, false, true, true, true, false, false, true) - plotter.container.frame.position.x = thisObject.container.frame.width / 2 - plotter.container.frame.width / 2 - plotter.container.frame.position.y = thisObject.container.frame.height / 2 - plotter.container.frame.height / 2 - plotter.fitFunction = thisObject.fitFunction - plotter.initialize(storage, exchange, market, datetime, timeFrame, onPlotterInizialized, productDefinition) - - function onPlotterInizialized () { - try { - let productPlotter = { - productCard: pProductCard, - plotter: plotter, - storage: storage, - profile: undefined, - notes: undefined - } - /* Let the Plotter listen to the event of Cursor Files loaded, so that it can react recalculating if needed. */ - storage.eventHandler.listenToEvent('Daily File Loaded', plotter.onDailyFileLoaded) - /* Lets load now this plotter panels. */ - productPlotter.panels = [] - - /* Here is where we instantiate the legacy panels */ - for (let i = 0; i < pProductCard.product.plotter.module.panels.length; i++) { - let panelConfig = pProductCard.product.plotter.module.panels[i] - - let parameters = { - dataMine: pProductCard.product.plotter.dataMine, - plotterCodeName: pProductCard.product.plotter.codeName, - moduleCodeName: pProductCard.product.plotter.moduleName, - panelCodeName: panelConfig.codeName + function onPlotterInizialized () { + try { + let productPlotter = { + productCard: pProductCard, + plotter: plotter, + storage: storage, + profile: undefined, + notes: undefined } - let panelOwner = exchange + ' ' + market.quotedAsset + '/' + market.baseAsset - let plotterPanelHandle = canvas.panelsSpace.createNewPanel('Plotter Panel', parameters, panelOwner, pProductCard.session) - let plotterPanel = canvas.panelsSpace.getPanel(plotterPanelHandle, panelOwner) - /* Connect Panel to the Plotter via an Event. */ - if (panelConfig.event !== undefined) { - productPlotter.plotter.container.eventHandler.listenToEvent(panelConfig.event, plotterPanel.onEventRaised) - } - productPlotter.panels.push(plotterPanelHandle) - } + /* Let the Plotter listen to the event of Cursor Files loaded, so that it can react recalculating if needed. */ + storage.eventHandler.listenToEvent('Daily File Loaded', plotter.onDailyFileLoaded) + /* Lets load now this plotter panels. */ + productPlotter.panels = [] - /* Here we instantiate the UI Defined Panels. */ - if (productDefinition !== undefined) { - for (let i = 0; i < productDefinition.referenceParent.panels.length; i++) { - let panel = productDefinition.referenceParent.panels[i] + /* Here is where we instantiate the legacy panels */ + for (let i = 0; i < pProductCard.product.plotter.module.panels.length; i++) { + let panelConfig = pProductCard.product.plotter.module.panels[i] let parameters = { dataMine: pProductCard.product.plotter.dataMine, plotterCodeName: pProductCard.product.plotter.codeName, moduleCodeName: pProductCard.product.plotter.moduleName, - panelCodeName: panel.id + panelCodeName: panelConfig.codeName } let panelOwner = exchange + ' ' + market.quotedAsset + '/' + market.baseAsset - let plotterPanelHandle = canvas.panelsSpace.createNewPanel('Plotter Panel', parameters, panelOwner, pProductCard.session, panel) + let plotterPanelHandle = canvas.panelsSpace.createNewPanel('Plotter Panel', parameters, panelOwner, pProductCard.session) let plotterPanel = canvas.panelsSpace.getPanel(plotterPanelHandle, panelOwner) - - /* Connect Panel to the Plotter via an Event. */ - productPlotter.plotter.container.eventHandler.listenToEvent('Current Record Changed', plotterPanel.onRecordChange) + /* Connect Panel to the Plotter via an Event. */ + if (panelConfig.event !== undefined) { + productPlotter.plotter.container.eventHandler.listenToEvent(panelConfig.event, plotterPanel.onEventRaised) + } productPlotter.panels.push(plotterPanelHandle) } - } - productPlotters.push(productPlotter) - callBack(GLOBAL.DEFAULT_OK_RESPONSE) - } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] initializeProductPlotter -> onProductStorageInitialized -> onPlotterInizialized -> err = ' + err.stack) } - callBack(GLOBAL.DEFAULT_FAIL_RESPONSE) + /* Here we instantiate the UI Defined Panels. */ + if (productDefinition !== undefined) { + for (let i = 0; i < productDefinition.referenceParent.panels.length; i++) { + let panel = productDefinition.referenceParent.panels[i] + + let parameters = { + dataMine: pProductCard.product.plotter.dataMine, + plotterCodeName: pProductCard.product.plotter.codeName, + moduleCodeName: pProductCard.product.plotter.moduleName, + panelCodeName: panel.id + } + let panelOwner = exchange + ' ' + market.quotedAsset + '/' + market.baseAsset + let plotterPanelHandle = canvas.panelsSpace.createNewPanel('Plotter Panel', parameters, panelOwner, pProductCard.session, panel) + let plotterPanel = canvas.panelsSpace.getPanel(plotterPanelHandle, panelOwner) + + /* Connect Panel to the Plotter via an Event. */ + productPlotter.plotter.container.eventHandler.listenToEvent('Current Record Changed', plotterPanel.onRecordChange) + productPlotter.panels.push(plotterPanelHandle) + } + } + + productPlotters.push(productPlotter) + } catch (err) { + if (ERROR_LOG === true) { logger.write('[ERROR] initializeProductPlotter -> onProductStorageInitialized -> onPlotterInizialized -> err = ' + err.stack) } + } } } } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] initializeProductPlotter -> onProductStorageInitialized -> err = ' + err.stack) } - callBack(GLOBAL.DEFAULT_FAIL_RESPONSE) } } } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] initializeProductPlotter -> err = ' + err.stack) } - callBack(GLOBAL.DEFAULT_FAIL_RESPONSE) } } diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 0e9ac7b6a..f3fef4cba 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -227,7 +227,7 @@ function newTimeMachine () { let timelineChart = thisObject.timelineCharts[i] timelineChart.upstreamTimeFrame = timeFrame if (timelineChart.timeFrameScale === undefined) { - timelineChart.plotterManager.setTimeFrame(timeFrame) + timelineChart.setTimeFrame(timeFrame) } } } @@ -406,24 +406,17 @@ function newTimeMachine () { timelineChart.container.frame.height = thisObject.container.frame.height timelineChart.container.frame.position.x = thisObject.container.frame.width / 2 - timelineChart.container.frame.width / 2 timelineChart.container.frame.position.y = 0 - timelineChart.initialize(DEFAULT_EXCHANGE, DEFAULT_MARKET, timeMachineCoordinateSystem, onTimelineChartInitialized) + timelineChart.initialize(timeMachineCoordinateSystem) /* we will store the event suscription id as a property of the timelineChart, to avoid keeping it an a separate array */ timelineChart.onChildrenMouseOverEventSuscriptionId = timelineChart.container.eventHandler.listenToEvent('onChildrenMouseOver', onChildrenMouseOver) + thisObject.timelineCharts.push(timelineChart) + timelineChart.payload.uiObject.setValue('') + function onChildrenMouseOver (event) { thisObject.container.eventHandler.raiseEvent('onMouseOver', event) } - - function onTimelineChartInitialized (err) { - if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) { - if (ERROR_LOG === true) { logger.write('[ERROR] syncWithDesigner -> initializeTimelineChart -> Initialization Failed. -> Err ' + err.message) } - return - } - - thisObject.timelineCharts.push(timelineChart) - timelineChart.payload.uiObject.setValue('') - } } } diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index a6fa21b33..942c70b86 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -17,6 +17,7 @@ function newTimelineChart () { payload: undefined, plotterManager: undefined, upstreamTimeFrame: undefined, + setTimeFrame: setTimeFrame, physics: physics, draw: draw, drawBackground: drawBackground, @@ -29,12 +30,10 @@ function newTimelineChart () { let timeMachineCoordinateSystem let timelineChartCoordinateSystem = newCoordinateSystem() - let initializationReady = false - let productsPanel - let exchange - let market + let exchange = DEFAULT_EXCHANGE + let market = DEFAULT_MARKET let productsPanelHandle @@ -63,6 +62,10 @@ function newTimelineChart () { } function finalize () { + if (thisObject.layersManager !== undefined) { + finalizeLayersManager() + } + if (thisObject.rateScale !== undefined) { finalizeRateScale() } @@ -76,11 +79,6 @@ function newTimelineChart () { thisObject.container.eventHandler.stopListening(onMouseOverEventSuscriptionId) thisObject.container.eventHandler.stopListening(onMouseNotOverEventSuscriptionId) - thisObject.plotterManager.finalize() - thisObject.plotterManager = undefined - - canvas.panelsSpace.destroyPanel(productsPanelHandle) - thisObject.container.finalize() thisObject.container = undefined @@ -88,6 +86,16 @@ function newTimelineChart () { mouse = undefined } + function finalizeLayersManager () { + if (thisObject.plotterManager !== undefined) { + thisObject.plotterManager.finalize() + } + thisObject.plotterManager = undefined + thisObject.layersManager = undefined + + canvas.panelsSpace.destroyPanel(productsPanelHandle) + } + function finalizeTimeFrameScale () { if (thisObject.timeFrameScale === undefined) { return } @@ -97,7 +105,9 @@ function newTimelineChart () { thisObject.timeFrameScale = undefined if (thisObject.upstreamTimeFrame !== undefined) { timeFrame = thisObject.upstreamTimeFrame - thisObject.plotterManager.setTimeFrame(timeFrame) + if (thisObject.plotterManager !== undefined) { + thisObject.plotterManager.setTimeFrame(timeFrame) + } } } @@ -114,87 +124,40 @@ function newTimelineChart () { thisObject.container.frame.position.height = thisObject.container.parentContainer.frame.height } - function initialize (pExchange, pMarket, pTimeMachineCoordinateSystem, callBackFunction) { - try { - /* We load the logow we will need for the background. */ - exchange = pExchange - market = pMarket - timeMachineCoordinateSystem = pTimeMachineCoordinateSystem + function initialize (pTimeMachineCoordinateSystem) { + /* We load the logow we will need for the background. */ - let panelOwner = exchange + ' ' + market.quotedAsset + '/' + market.baseAsset - productsPanelHandle = canvas.panelsSpace.createNewPanel('Products Panel', undefined, panelOwner) - let productsPanel = canvas.panelsSpace.getPanel(productsPanelHandle, panelOwner) - productsPanel.initialize(exchange, market) + timeMachineCoordinateSystem = pTimeMachineCoordinateSystem - timeFrame = INITIAL_TIME_PERIOD - datetime = NEW_SESSION_INITIAL_DATE + timeFrame = INITIAL_TIME_PERIOD + datetime = NEW_SESSION_INITIAL_DATE - /* Event Subscriptions - we need this events to be fired first here and then in active Plotters. */ - onOffsetChangedEventSuscriptionId = viewPort.eventHandler.listenToEvent('Offset Changed', onOffsetChanged) - onZoomChangedEventSuscriptionId = viewPort.eventHandler.listenToEvent('Zoom Changed', onZoomChanged) + /* Event Subscriptions - we need this events to be fired first here and then in active Plotters. */ + onOffsetChangedEventSuscriptionId = viewPort.eventHandler.listenToEvent('Offset Changed', onOffsetChanged) + onZoomChangedEventSuscriptionId = viewPort.eventHandler.listenToEvent('Zoom Changed', onZoomChanged) - /* Initialize the Plotter Manager */ - thisObject.plotterManager = newPlottersManager() + onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) + onMouseNotOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) + } - thisObject.plotterManager.container.connectToParent(thisObject.container, true, true, false, true, true, true, false, false, true) + function initializeLayersManager () { + let panelOwner = exchange + ' ' + market.quotedAsset + '/' + market.baseAsset + productsPanelHandle = canvas.panelsSpace.createNewPanel('Products Panel', undefined, panelOwner) + thisObject.layersManager = canvas.panelsSpace.getPanel(productsPanelHandle, panelOwner) + thisObject.layersManager.initialize(exchange, market) + thisObject.layersManager.payload = thisObject.payload.node.layersManager.payload - thisObject.plotterManager.container.frame.position.x = 0 - thisObject.plotterManager.container.frame.position.y = 0 + /* Initialize the Plotter Manager */ + thisObject.plotterManager = newPlottersManager() - thisObject.plotterManager.fitFunction = thisObject.fitFunction - thisObject.plotterManager.initialize(productsPanel, pExchange, pMarket, onPlotterManagerReady) + thisObject.plotterManager.container.connectToParent(thisObject.container, true, true, false, true, true, true, false, false, true) - function onPlotterManagerReady (err) { - if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) { - if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> onPlotterManagerReady -> Plotter Manager Initialization Failed. ') } - if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> onPlotterManagerReady -> err= ' + err.stack) } + thisObject.plotterManager.container.frame.position.x = 0 + thisObject.plotterManager.container.frame.position.y = 0 - callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) - return - } - - onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) - - function onMouseOver (event) { - /* This event gets to the timelinechart container because it inherits it from the time machine container, which is the one raising Mouse Over and Mouse not Over Events to its children. */ - drawScales = true - - if (thisObject.rateScale !== undefined) { - thisObject.rateScale.onMouseOverSomeTimeMachineContainer(event) - } - - if (thisObject.timeFrameScale !== undefined) { - thisObject.timeFrameScale.onMouseOverSomeTimeMachineContainer(event) - } - - mouse.position.x = event.x - mouse.position.y = event.y - - saveUserPosition(thisObject.container, timeMachineCoordinateSystem, event) - } - - onMouseNotOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) - - function onMouseNotOver (event) { - /* This event is inherited from the Time Machine */ - drawScales = false - - if (thisObject.rateScale !== undefined) { - thisObject.rateScale.visible = false - } - if (thisObject.timeFrameScale !== undefined) { - thisObject.timeFrameScale.visible = false - } - } - - initializationReady = true - callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) - return - } - } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err.stack) } - callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) - } + thisObject.plotterManager.fitFunction = thisObject.fitFunction + thisObject.plotterManager.initialize(thisObject.layersManager, DEFAULT_EXCHANGE, DEFAULT_MARKET) + thisObject.plotterManager.setTimeFrame(timeFrame) } function initializeRateScale () { @@ -227,7 +190,9 @@ function newTimelineChart () { let currentTimeFrame = timeFrame timeFrame = event.timeFrame if (timeFrame !== currentTimeFrame) { - thisObject.plotterManager.setTimeFrame(timeFrame) + if (thisObject.plotterManager !== undefined) { + thisObject.plotterManager.setTimeFrame(timeFrame) + } } }) @@ -242,20 +207,50 @@ function newTimelineChart () { } } - function onZoomChanged (event) { - if (initializationReady === true) { - recalculateCurrentDatetime() - - // saveUserPosition(thisObject.container, timeMachineCoordinateSystem) + function setTimeFrame (pTimeFrame) { + timeFrame = pTimeFrame + if (thisObject.plotterManager !== undefined) { + thisObject.plotterManager.setTimeFrame(timeFrame) } } + function onMouseOver (event) { + /* This event gets to the timelinechart container because it inherits it from the time machine container, which is the one raising Mouse Over and Mouse not Over Events to its children. */ + drawScales = true + + if (thisObject.rateScale !== undefined) { + thisObject.rateScale.onMouseOverSomeTimeMachineContainer(event) + } + + if (thisObject.timeFrameScale !== undefined) { + thisObject.timeFrameScale.onMouseOverSomeTimeMachineContainer(event) + } + + mouse.position.x = event.x + mouse.position.y = event.y + + saveUserPosition(thisObject.container, timeMachineCoordinateSystem, event) + } + + function onMouseNotOver (event) { + /* This event is inherited from the Time Machine */ + drawScales = false + + if (thisObject.rateScale !== undefined) { + thisObject.rateScale.visible = false + } + if (thisObject.timeFrameScale !== undefined) { + thisObject.timeFrameScale.visible = false + } + } + + function onZoomChanged (event) { + recalculateCurrentDatetime() + } + function onOffsetChanged () { - if (initializationReady === true) { - if (thisObject.container.frame.isInViewPort()) { - recalculateCurrentDatetime() - // saveUserPosition(thisObject.container, timeMachineCoordinateSystem) - } + if (thisObject.container.frame.isInViewPort()) { + recalculateCurrentDatetime() } } @@ -315,12 +310,27 @@ function newTimelineChart () { thisObjectPhysics() childrenPhysics() syncWithDesignerScales() + syncWithDesignerLayersManager() } function thisObjectPhysics () { } + function syncWithDesignerLayersManager () { + if (thisObject.payload.node === undefined) { + finalizeLayersManager() + return + } + + if (thisObject.payload.node.layersManager === undefined && thisObject.layersManager !== undefined) { + finalizeLayersManager() + } + if (thisObject.payload.node.layersManager !== undefined && thisObject.layersManager === undefined) { + initializeLayersManager() + } + } + function syncWithDesignerScales () { if (thisObject.payload.node === undefined) { finalizeRateScale() @@ -372,7 +382,9 @@ function newTimelineChart () { window.CHART_ON_FOCUS = exchange + ' ' + market.quotedAsset + '/' + market.baseAsset } drawChartsBackground() - thisObject.plotterManager.draw() + if (thisObject.plotterManager !== undefined) { + thisObject.plotterManager.draw() + } } } From 3c76d4f6547b73a0b061168b7cce0dfcb2fd06ed Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 14 Jan 2020 10:19:42 +0100 Subject: [PATCH 102/264] refactoring producsPanels for layersPanel --- ChartsSpace/PlottersManager.js | 12 ++++++------ ChartsSpace/TimelineChart.js | 11 ++++++----- Panels/{ProductsPanel.js => LayersPanel.js} | 2 +- Project.njsproj | 2 +- Spaces/PanelsSpace.js | 2 +- 5 files changed, 15 insertions(+), 14 deletions(-) rename Panels/{ProductsPanel.js => LayersPanel.js} (99%) diff --git a/ChartsSpace/PlottersManager.js b/ChartsSpace/PlottersManager.js index 3cfd57279..740a59a34 100644 --- a/ChartsSpace/PlottersManager.js +++ b/ChartsSpace/PlottersManager.js @@ -23,7 +23,7 @@ function newPlottersManager () { let initializationReady = false - let productsPanel + let layersPanel let exchange let market @@ -58,7 +58,7 @@ function newPlottersManager () { } productPlotters = [] - productsPanel = undefined + layersPanel = undefined thisObject.container.finalize() thisObject.container = undefined @@ -67,16 +67,16 @@ function newPlottersManager () { function initialize (pProductsPanel, pExchange, pMarket) { try { - /* Remember the Products Panel */ - productsPanel = pProductsPanel + /* Remember the Layers Panel */ + layersPanel = pProductsPanel exchange = pExchange market = pMarket /* Listen to the event of change of status */ - productsPanel.container.eventHandler.listenToEvent('Product Card Status Changed', onProductCardStatusChanged) + layersPanel.container.eventHandler.listenToEvent('Product Card Status Changed', onProductCardStatusChanged) /* Lets get all the cards that needs to be loaded. */ - let loadingProductCards = productsPanel.getLoadingProductCards() + let loadingProductCards = layersPanel.getLoadingProductCards() for (let i = 0; i < loadingProductCards.length; i++) { /* For each one, we will initialize the associated plotter. */ diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 942c70b86..e66d99ef7 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -15,6 +15,7 @@ function newTimelineChart () { rateScale: undefined, timeFrameScale: undefined, payload: undefined, + layersManager: undefined, plotterManager: undefined, upstreamTimeFrame: undefined, setTimeFrame: setTimeFrame, @@ -30,12 +31,12 @@ function newTimelineChart () { let timeMachineCoordinateSystem let timelineChartCoordinateSystem = newCoordinateSystem() - let productsPanel + let layersPanel let exchange = DEFAULT_EXCHANGE let market = DEFAULT_MARKET - let productsPanelHandle + let layersPanelHandle let onOffsetChangedEventSuscriptionId let onZoomChangedEventSuscriptionId @@ -93,7 +94,7 @@ function newTimelineChart () { thisObject.plotterManager = undefined thisObject.layersManager = undefined - canvas.panelsSpace.destroyPanel(productsPanelHandle) + canvas.panelsSpace.destroyPanel(layersPanelHandle) } function finalizeTimeFrameScale () { @@ -142,8 +143,8 @@ function newTimelineChart () { function initializeLayersManager () { let panelOwner = exchange + ' ' + market.quotedAsset + '/' + market.baseAsset - productsPanelHandle = canvas.panelsSpace.createNewPanel('Products Panel', undefined, panelOwner) - thisObject.layersManager = canvas.panelsSpace.getPanel(productsPanelHandle, panelOwner) + layersPanelHandle = canvas.panelsSpace.createNewPanel('Layers Panel', undefined, panelOwner) + thisObject.layersManager = canvas.panelsSpace.getPanel(layersPanelHandle, panelOwner) thisObject.layersManager.initialize(exchange, market) thisObject.layersManager.payload = thisObject.payload.node.layersManager.payload diff --git a/Panels/ProductsPanel.js b/Panels/LayersPanel.js similarity index 99% rename from Panels/ProductsPanel.js rename to Panels/LayersPanel.js index b8a479578..0d8e657df 100644 --- a/Panels/ProductsPanel.js +++ b/Panels/LayersPanel.js @@ -1,6 +1,6 @@ function newProductsPanel () { let thisObject = { - name: 'Products Panel', + name: 'Layers Panel', fitFunction: undefined, container: undefined, productCards: [], diff --git a/Project.njsproj b/Project.njsproj index b45882cef..2023bf304 100644 --- a/Project.njsproj +++ b/Project.njsproj @@ -156,7 +156,7 @@ - + diff --git a/Spaces/PanelsSpace.js b/Spaces/PanelsSpace.js index 1539238e4..77cb064b7 100644 --- a/Spaces/PanelsSpace.js +++ b/Spaces/PanelsSpace.js @@ -39,7 +39,7 @@ function newPanelsSpace () { switch (pType) { - case 'Products Panel': + case 'Layers Panel': { panel = newProductsPanel() panel.fitFunction = canvas.chartSpace.fitFunction From 5fc114b2f464a31e2ccf424a13006cde982eb232 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 14 Jan 2020 12:09:57 +0100 Subject: [PATCH 103/264] IMprovements on panels physics --- Scales/RateScale.js | 18 +++++---- Scales/TimeFrameScale.js | 18 +++++---- Spaces/PanelsSpace.js | 87 +++++++++++++++++++++++++++++++++++----- 3 files changed, 98 insertions(+), 25 deletions(-) diff --git a/Scales/RateScale.js b/Scales/RateScale.js index 8df57a2ed..71c1b9a23 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -161,15 +161,17 @@ function newRateScale () { let displaceFactor = 0 if (thisObject.payload.parentNode === undefined) { return } // This happens when in the process of deleting the scale, timeline chart or time machine. if (thisObject.payload.parentNode.type === 'Timeline Chart') { - if (thisObject.payload.parentNode.payload.parentNode.rateScale !== undefined) { - displaceFactor++ - } - for (let i = 0; i < thisObject.payload.parentNode.payload.parentNode.timelineCharts.length; i++) { - let timelineChart = thisObject.payload.parentNode.payload.parentNode.timelineCharts[i] - if (thisObject.payload.node.id !== timelineChart.rateScale.id) { + if (thisObject.payload.parentNode.payload.parentNode !== undefined) { + if (thisObject.payload.parentNode.payload.parentNode.rateScale !== undefined) { displaceFactor++ - } else { - break + } + for (let i = 0; i < thisObject.payload.parentNode.payload.parentNode.timelineCharts.length; i++) { + let timelineChart = thisObject.payload.parentNode.payload.parentNode.timelineCharts[i] + if (thisObject.payload.node.id !== timelineChart.rateScale.id) { + displaceFactor++ + } else { + break + } } } } diff --git a/Scales/TimeFrameScale.js b/Scales/TimeFrameScale.js index 7674b52a9..c4b438ded 100644 --- a/Scales/TimeFrameScale.js +++ b/Scales/TimeFrameScale.js @@ -138,15 +138,17 @@ function newTimeFrameScale () { let displaceFactor = 0 if (thisObject.payload.parentNode === undefined) { return } // This happens when in the process of deleting the scale, timeline chart or time machine. if (thisObject.payload.parentNode.type === 'Timeline Chart') { - if (thisObject.payload.parentNode.payload.parentNode.timeFrameScale !== undefined) { - displaceFactor++ - } - for (let i = 0; i < thisObject.payload.parentNode.payload.parentNode.timelineCharts.length; i++) { - let timelineChart = thisObject.payload.parentNode.payload.parentNode.timelineCharts[i] - if (thisObject.payload.node.id !== timelineChart.timeFrameScale.id) { + if (thisObject.payload.parentNode.payload.parentNode !== undefined) { + if (thisObject.payload.parentNode.payload.parentNode.timeFrameScale !== undefined) { displaceFactor++ - } else { - break + } + for (let i = 0; i < thisObject.payload.parentNode.payload.parentNode.timelineCharts.length; i++) { + let timelineChart = thisObject.payload.parentNode.payload.parentNode.timelineCharts[i] + if (thisObject.payload.node.id !== timelineChart.timeFrameScale.id) { + displaceFactor++ + } else { + break + } } } } diff --git a/Spaces/PanelsSpace.js b/Spaces/PanelsSpace.js index 77cb064b7..bd8361114 100644 --- a/Spaces/PanelsSpace.js +++ b/Spaces/PanelsSpace.js @@ -126,11 +126,24 @@ function newPanelsSpace () { } function positioningPhysics () { - const INCREMENT = 0.5 if (thisObject.panels !== undefined) { for (let i = 0; i < thisObject.panels.length; i++) { let panel = thisObject.panels[i] + /* setting the speed of the panel */ + let ACCELERATION = 0.1 // This is resting speed. + if (panel.container.speed === undefined) { + panel.container.speed = { + x: 1, + y: 1 + } + panel.container.resistance = { + x: 0, + y: 0 + } + } + + /* Trying to move the panel and see if it is possible */ let centerPoint = { x: panel.container.frame.position.x, y: panel.container.frame.position.y @@ -144,17 +157,23 @@ function newPanelsSpace () { /* According to the quadrant we push the panels to the sides */ if (centerPoint.x < verticalLine) { - panel.container.frame.position.x = panel.container.frame.position.x - INCREMENT + panel.container.frame.position.x = panel.container.frame.position.x - panel.container.speed.x if (isOverlapping(i, panel.container) === true) { - panel.container.frame.position.x = panel.container.frame.position.x + INCREMENT * 2 + panel.container.frame.position.x = panel.container.frame.position.x + panel.container.speed.x * 3 + accelerateOnX() + } else { + desAccelerateOnX() } if (panel.container.frame.position.x < viewPort.visibleArea.topLeft.x) { panel.container.frame.position.x = viewPort.visibleArea.topLeft.x } } else { - panel.container.frame.position.x = panel.container.frame.position.x + INCREMENT + panel.container.frame.position.x = panel.container.frame.position.x + panel.container.speed.x if (isOverlapping(i, panel.container) === true) { - panel.container.frame.position.x = panel.container.frame.position.x - INCREMENT * 2 + panel.container.frame.position.x = panel.container.frame.position.x - panel.container.speed.x * 3 + accelerateOnX() + } else { + desAccelerateOnX() } if (panel.container.frame.position.x + panel.container.frame.width > viewPort.visibleArea.topRight.x) { panel.container.frame.position.x = viewPort.visibleArea.topRight.x - panel.container.frame.width @@ -162,23 +181,73 @@ function newPanelsSpace () { } if (panel.container.frame.height <= viewPort.visibleArea.bottomRight.y - viewPort.visibleArea.topRight.y) { if (centerPoint.y < horizontalLine) { - panel.container.frame.position.y = panel.container.frame.position.y - INCREMENT + panel.container.frame.position.y = panel.container.frame.position.y - panel.container.speed.y if (isOverlapping(i, panel.container) === true) { - panel.container.frame.position.y = panel.container.frame.position.y + INCREMENT * 2 + panel.container.frame.position.y = panel.container.frame.position.y + panel.container.speed.y * 3 + accelerateOnY() + } else { + desAccelerateOnY() } if (panel.container.frame.position.y < viewPort.visibleArea.topLeft.y) { panel.container.frame.position.y = viewPort.visibleArea.topLeft.y } } else { - panel.container.frame.position.y = panel.container.frame.position.y + INCREMENT + panel.container.frame.position.y = panel.container.frame.position.y + panel.container.speed.y if (isOverlapping(i, panel.container) === true) { - panel.container.frame.position.y = panel.container.frame.position.y - INCREMENT * 2 + panel.container.frame.position.y = panel.container.frame.position.y - panel.container.speed.y * 3 + accelerateOnY() + } else { + desAccelerateOnY() } if (panel.container.frame.position.y + panel.container.frame.height > viewPort.visibleArea.bottomRight.y) { panel.container.frame.position.y = viewPort.visibleArea.bottomRight.y - panel.container.frame.height } } } + + function accelerateOnX () { + panel.container.speed.x = panel.container.speed.x + ACCELERATION + if (panel.container.speed.x > ACCELERATION * 10) { + panel.container.speed.x = ACCELERATION * 10 + } + panel.container.resistance.x = panel.container.resistance.x + 1 + } + function desAccelerateOnX () { + if (panel.container.resistance.x < -3) { + panel.container.resistance.x = 0 + panel.container.speed.x = ACCELERATION * 5 + console.log('desAccelerateOnX Invertido', panel.container.speed.x) + return + } + panel.container.speed.x = panel.container.speed.x - ACCELERATION + if (panel.container.speed.x < ACCELERATION) { + panel.container.speed.x = ACCELERATION * 1 + } + panel.container.resistance.x = panel.container.resistance.x - 1 + } + function accelerateOnY () { + if (panel.container.resistance.y > 5) { + panel.container.resistance.y = 0 + return + } + panel.container.speed.y = panel.container.speed.y + ACCELERATION + if (panel.container.speed.y > ACCELERATION * 10) { + panel.container.speed.y = ACCELERATION * 5 + } + panel.container.resistance.y = panel.container.resistance.y + 1 + } + function desAccelerateOnY () { + if (panel.container.resistance.y < -3) { + panel.container.resistance.y = 0 + panel.container.speed.y = ACCELERATION * 10 + return + } + panel.container.speed.y = panel.container.speed.y - ACCELERATION + if (panel.container.speed.y < ACCELERATION) { + panel.container.speed.y = ACCELERATION * 1 + } + panel.container.resistance.y = panel.container.resistance.y - 1 + } } } From 51794bff78885c787cd257deef2f1277c8687736 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 14 Jan 2020 12:40:45 +0100 Subject: [PATCH 104/264] Progress bar improvements --- Panels/ProductCard.js | 103 +++++++----------------------------------- Spaces/PanelsSpace.js | 1 - 2 files changed, 17 insertions(+), 87 deletions(-) diff --git a/Panels/ProductCard.js b/Panels/ProductCard.js index 136b2e449..45580da75 100644 --- a/Panels/ProductCard.js +++ b/Panels/ProductCard.js @@ -31,7 +31,7 @@ function newProductCard () { let UNLOADED_FILL_STYLE = 'rgba(226, 226, 226, @Opacity)' let LOADING_STROKE_STYLE = 'rgba(234, 143, 23, @Opacity)' - let LOADED_STROKE_STYLE = 'rgba(150, 150, 150, @Opacity)' + let LOADED_STROKE_STYLE = 'rgba(45, 232, 28, @Opacity)' let UNLOADED_STROKE_STYLE = 'rgba(226, 226, 226, @Opacity)' let marketFileProgressBar = { @@ -361,12 +361,10 @@ function newProductCard () { const ANIMATED_INCREMENT = 5 const OPACITY_INCREMENT = 0.05 - const OPACITY_MIN = 0.1 + const OPACITY_MIN = 1 let point1 let point2 - let point3 - let point4 /* We draw here the Market Progress Bar. */ @@ -391,48 +389,32 @@ function newProductCard () { point1 = { x: 0, - y: thisObject.container.frame.height - 1 + y: thisObject.container.frame.height - 15 } point2 = { x: thisObject.container.frame.width * marketFileProgressBar.animatedValue / 100, - y: thisObject.container.frame.height - 1 - } - - point3 = { - x: thisObject.container.frame.width * marketFileProgressBar.animatedValue / 100, - y: thisObject.container.frame.height - 3 - } - - point4 = { - x: 0, - y: thisObject.container.frame.height - 3 + y: thisObject.container.frame.height - 15 } /* Now the transformations. */ point1 = thisObject.container.frame.frameThisPoint(point1) point2 = thisObject.container.frame.frameThisPoint(point2) - point3 = thisObject.container.frame.frameThisPoint(point3) - point4 = thisObject.container.frame.frameThisPoint(point4) point1 = thisObject.fitFunction(point1) point2 = thisObject.fitFunction(point2) - point3 = thisObject.fitFunction(point3) - point4 = thisObject.fitFunction(point4) browserCanvasContext.beginPath() browserCanvasContext.moveTo(point1.x, point1.y) browserCanvasContext.lineTo(point2.x, point2.y) - browserCanvasContext.lineTo(point3.x, point3.y) - browserCanvasContext.lineTo(point4.x, point4.y) + browserCanvasContext.closePath() - browserCanvasContext.fillStyle = marketFileProgressBar.fillStyle.replace('@Opacity', marketFileProgressBar.opacity.toString()) browserCanvasContext.strokeStyle = marketFileProgressBar.strokeStyle.replace('@Opacity', marketFileProgressBar.opacity.toString()) - browserCanvasContext.fill() - browserCanvasContext.lineWidth = 0.1 + browserCanvasContext.setLineDash([2, 5]) + browserCanvasContext.lineWidth = 10 browserCanvasContext.stroke() /* We draw here the Daily Progress Bar. */ @@ -458,48 +440,32 @@ function newProductCard () { point1 = { x: 0, - y: thisObject.container.frame.height - 4 + y: thisObject.container.frame.height - 25 } point2 = { x: thisObject.container.frame.width * dailyFileProgressBar.animatedValue / 100, - y: thisObject.container.frame.height - 4 - } - - point3 = { - x: thisObject.container.frame.width * dailyFileProgressBar.animatedValue / 100, - y: thisObject.container.frame.height - 6 - } - - point4 = { - x: 0, - y: thisObject.container.frame.height - 6 + y: thisObject.container.frame.height - 25 } /* Now the transformations. */ point1 = thisObject.container.frame.frameThisPoint(point1) point2 = thisObject.container.frame.frameThisPoint(point2) - point3 = thisObject.container.frame.frameThisPoint(point3) - point4 = thisObject.container.frame.frameThisPoint(point4) point1 = thisObject.fitFunction(point1) point2 = thisObject.fitFunction(point2) - point3 = thisObject.fitFunction(point3) - point4 = thisObject.fitFunction(point4) browserCanvasContext.beginPath() browserCanvasContext.moveTo(point1.x, point1.y) browserCanvasContext.lineTo(point2.x, point2.y) - browserCanvasContext.lineTo(point3.x, point3.y) - browserCanvasContext.lineTo(point4.x, point4.y) + browserCanvasContext.closePath() - browserCanvasContext.fillStyle = dailyFileProgressBar.fillStyle.replace('@Opacity', dailyFileProgressBar.opacity.toString()) browserCanvasContext.strokeStyle = dailyFileProgressBar.strokeStyle.replace('@Opacity', dailyFileProgressBar.opacity.toString()) - browserCanvasContext.fill() - browserCanvasContext.lineWidth = 0.1 + browserCanvasContext.setLineDash([2, 5]) + browserCanvasContext.lineWidth = 10 browserCanvasContext.stroke() /* We draw here the Single File Progress Bar. */ @@ -533,41 +499,23 @@ function newProductCard () { y: thisObject.container.frame.height - 7 } - point3 = { - x: thisObject.container.frame.width * singleFileProgressBar.animatedValue / 100, - y: thisObject.container.frame.height - 9 - } - - point4 = { - x: 0, - y: thisObject.container.frame.height - 9 - } - /* Now the transformations. */ point1 = thisObject.container.frame.frameThisPoint(point1) point2 = thisObject.container.frame.frameThisPoint(point2) - point3 = thisObject.container.frame.frameThisPoint(point3) - point4 = thisObject.container.frame.frameThisPoint(point4) point1 = thisObject.fitFunction(point1) point2 = thisObject.fitFunction(point2) - point3 = thisObject.fitFunction(point3) - point4 = thisObject.fitFunction(point4) browserCanvasContext.beginPath() browserCanvasContext.moveTo(point1.x, point1.y) browserCanvasContext.lineTo(point2.x, point2.y) - browserCanvasContext.lineTo(point3.x, point3.y) - browserCanvasContext.lineTo(point4.x, point4.y) browserCanvasContext.closePath() - browserCanvasContext.fillStyle = singleFileProgressBar.fillStyle.replace('@Opacity', singleFileProgressBar.opacity.toString()) browserCanvasContext.strokeStyle = singleFileProgressBar.strokeStyle.replace('@Opacity', singleFileProgressBar.opacity.toString()) - browserCanvasContext.fill() - browserCanvasContext.lineWidth = 0.1 - browserCanvasContext.stroke() + browserCanvasContext.setLineDash([2, 5]) + browserCanvasContext.lineWidth = 10 /* We draw here the File Sequence Progress Bar. */ @@ -600,41 +548,24 @@ function newProductCard () { y: thisObject.container.frame.height - 10 } - point3 = { - x: thisObject.container.frame.width * fileSequenceProgressBar.animatedValue / 100, - y: thisObject.container.frame.height - 11 - } - - point4 = { - x: 0, - y: thisObject.container.frame.height - 11 - } - /* Now the transformations. */ point1 = thisObject.container.frame.frameThisPoint(point1) point2 = thisObject.container.frame.frameThisPoint(point2) - point3 = thisObject.container.frame.frameThisPoint(point3) - point4 = thisObject.container.frame.frameThisPoint(point4) point1 = thisObject.fitFunction(point1) point2 = thisObject.fitFunction(point2) - point3 = thisObject.fitFunction(point3) - point4 = thisObject.fitFunction(point4) browserCanvasContext.beginPath() browserCanvasContext.moveTo(point1.x, point1.y) browserCanvasContext.lineTo(point2.x, point2.y) - browserCanvasContext.lineTo(point3.x, point3.y) - browserCanvasContext.lineTo(point4.x, point4.y) + browserCanvasContext.closePath() - browserCanvasContext.fillStyle = fileSequenceProgressBar.fillStyle.replace('@Opacity', fileSequenceProgressBar.opacity.toString()) browserCanvasContext.strokeStyle = fileSequenceProgressBar.strokeStyle.replace('@Opacity', fileSequenceProgressBar.opacity.toString()) - browserCanvasContext.fill() - browserCanvasContext.lineWidth = 0.1 - browserCanvasContext.stroke() + browserCanvasContext.setLineDash([2, 5]) + browserCanvasContext.lineWidth = 10 } } diff --git a/Spaces/PanelsSpace.js b/Spaces/PanelsSpace.js index bd8361114..938af67ed 100644 --- a/Spaces/PanelsSpace.js +++ b/Spaces/PanelsSpace.js @@ -216,7 +216,6 @@ function newPanelsSpace () { if (panel.container.resistance.x < -3) { panel.container.resistance.x = 0 panel.container.speed.x = ACCELERATION * 5 - console.log('desAccelerateOnX Invertido', panel.container.speed.x) return } panel.container.speed.x = panel.container.speed.x - ACCELERATION From d9d434ec581c9243aaff115282f9491fe1a0f485 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 14 Jan 2020 12:52:17 +0100 Subject: [PATCH 105/264] Products Panel refactoring done --- ChartsSpace/PlottersManager.js | 70 ++++++------- CockpitSpace/FullScreen.js | 2 +- Panels/{ProductCard.js => Layer.js} | 7 +- Panels/LayersPanel.js | 156 ++++++++++++++-------------- Project.njsproj | 2 +- 5 files changed, 118 insertions(+), 119 deletions(-) rename Panels/{ProductCard.js => Layer.js} (99%) diff --git a/ChartsSpace/PlottersManager.js b/ChartsSpace/PlottersManager.js index 740a59a34..91bf7b67b 100644 --- a/ChartsSpace/PlottersManager.js +++ b/ChartsSpace/PlottersManager.js @@ -72,25 +72,25 @@ function newPlottersManager () { exchange = pExchange market = pMarket /* Listen to the event of change of status */ - layersPanel.container.eventHandler.listenToEvent('Product Card Status Changed', onProductCardStatusChanged) + layersPanel.container.eventHandler.listenToEvent('Product Card Status Changed', onLayerStatusChanged) /* Lets get all the cards that needs to be loaded. */ - let loadingProductCards = layersPanel.getLoadingProductCards() + let loadingLayers = layersPanel.getLoadingLayers() - for (let i = 0; i < loadingProductCards.length; i++) { + for (let i = 0; i < loadingLayers.length; i++) { /* For each one, we will initialize the associated plotter. */ - initializeProductPlotter(loadingProductCards[i]) + initializeProductPlotter(loadingLayers[i]) } } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err.stack) } } } - function initializeProductPlotter (pProductCard, callBack) { + function initializeProductPlotter (pLayer, callBack) { try { /* Before Initializing a Plotter, we need the Storage it will use, loaded with the files it will initially need. */ - let objName = pProductCard.dataMine.codeName + '-' + pProductCard.bot.codeName + '-' + pProductCard.product.codeName + let objName = pLayer.dataMine.codeName + '-' + pLayer.bot.codeName + '-' + pLayer.product.codeName let storage = newProductStorage(objName) /* @@ -98,30 +98,30 @@ function newPlottersManager () { so that the UI can somehow show this. There are different types of events. */ - for (let i = 0; i < pProductCard.product.dataSets.length; i++) { - let thisSet = pProductCard.product.dataSets[i] + for (let i = 0; i < pLayer.product.dataSets.length; i++) { + let thisSet = pLayer.product.dataSets[i] switch (thisSet.type) { case 'Market Files': { - storage.eventHandler.listenToEvent('Market File Loaded', pProductCard.onMarketFileLoaded) + storage.eventHandler.listenToEvent('Market File Loaded', pLayer.onMarketFileLoaded) } break case 'Daily Files': { - storage.eventHandler.listenToEvent('Daily File Loaded', pProductCard.onDailyFileLoaded) + storage.eventHandler.listenToEvent('Daily File Loaded', pLayer.onDailyFileLoaded) } break case 'Single File': { - storage.eventHandler.listenToEvent('Single File Loaded', pProductCard.onSingleFileLoaded) + storage.eventHandler.listenToEvent('Single File Loaded', pLayer.onSingleFileLoaded) } break case 'File Sequence': { - storage.eventHandler.listenToEvent('File Sequence Loaded', pProductCard.onFileSequenceLoaded) + storage.eventHandler.listenToEvent('File Sequence Loaded', pLayer.onFileSequenceLoaded) } break } } - storage.initialize(pProductCard.dataMine, pProductCard.bot, pProductCard.session, pProductCard.product, exchange, market, datetime, timeFrame, onProductStorageInitialized) + storage.initialize(pLayer.dataMine, pLayer.bot, pLayer.session, pLayer.product, exchange, market, datetime, timeFrame, onProductStorageInitialized) function onProductStorageInitialized (err) { try { @@ -130,7 +130,7 @@ function newPlottersManager () { let plotter let productDefinition - if (pProductCard.product.plotter.legacy === false) { + if (pLayer.product.plotter.legacy === false) { plotter = newPlotter() /* We take a snapwhot of the current product definition to be used by the plotter. */ @@ -145,9 +145,9 @@ function newPlottersManager () { 'Polygon Border->Style->Style Condition->Style->' + 'Polygon Vertex->Point->' + 'Plotter Panel->Javascript Code->Panel Data->Data Formula->' - productDefinition = functionLibraryProtocolNode.getProtocolNode(pProductCard.product.node, false, true, true, false, false, lightingPath) + productDefinition = functionLibraryProtocolNode.getProtocolNode(pLayer.product.node, false, true, true, false, false, lightingPath) } else { - plotter = getNewPlotter(pProductCard.product.plotter.dataMine, pProductCard.product.plotter.codeName, pProductCard.product.plotter.moduleName) + plotter = getNewPlotter(pLayer.product.plotter.dataMine, pLayer.product.plotter.codeName, pLayer.product.plotter.moduleName) } plotter.container.connectToParent(thisObject.container, true, true, false, true, true, true, false, false, true) @@ -159,7 +159,7 @@ function newPlottersManager () { function onPlotterInizialized () { try { let productPlotter = { - productCard: pProductCard, + layer: pLayer, plotter: plotter, storage: storage, profile: undefined, @@ -171,17 +171,17 @@ function newPlottersManager () { productPlotter.panels = [] /* Here is where we instantiate the legacy panels */ - for (let i = 0; i < pProductCard.product.plotter.module.panels.length; i++) { - let panelConfig = pProductCard.product.plotter.module.panels[i] + for (let i = 0; i < pLayer.product.plotter.module.panels.length; i++) { + let panelConfig = pLayer.product.plotter.module.panels[i] let parameters = { - dataMine: pProductCard.product.plotter.dataMine, - plotterCodeName: pProductCard.product.plotter.codeName, - moduleCodeName: pProductCard.product.plotter.moduleName, + dataMine: pLayer.product.plotter.dataMine, + plotterCodeName: pLayer.product.plotter.codeName, + moduleCodeName: pLayer.product.plotter.moduleName, panelCodeName: panelConfig.codeName } let panelOwner = exchange + ' ' + market.quotedAsset + '/' + market.baseAsset - let plotterPanelHandle = canvas.panelsSpace.createNewPanel('Plotter Panel', parameters, panelOwner, pProductCard.session) + let plotterPanelHandle = canvas.panelsSpace.createNewPanel('Plotter Panel', parameters, panelOwner, pLayer.session) let plotterPanel = canvas.panelsSpace.getPanel(plotterPanelHandle, panelOwner) /* Connect Panel to the Plotter via an Event. */ if (panelConfig.event !== undefined) { @@ -196,13 +196,13 @@ function newPlottersManager () { let panel = productDefinition.referenceParent.panels[i] let parameters = { - dataMine: pProductCard.product.plotter.dataMine, - plotterCodeName: pProductCard.product.plotter.codeName, - moduleCodeName: pProductCard.product.plotter.moduleName, + dataMine: pLayer.product.plotter.dataMine, + plotterCodeName: pLayer.product.plotter.codeName, + moduleCodeName: pLayer.product.plotter.moduleName, panelCodeName: panel.id } let panelOwner = exchange + ' ' + market.quotedAsset + '/' + market.baseAsset - let plotterPanelHandle = canvas.panelsSpace.createNewPanel('Plotter Panel', parameters, panelOwner, pProductCard.session, panel) + let plotterPanelHandle = canvas.panelsSpace.createNewPanel('Plotter Panel', parameters, panelOwner, pLayer.session, panel) let plotterPanel = canvas.panelsSpace.getPanel(plotterPanelHandle, panelOwner) /* Connect Panel to the Plotter via an Event. */ @@ -226,26 +226,26 @@ function newPlottersManager () { } } - function onProductCardStatusChanged (pProductCard) { - if (pProductCard.status === PRODUCT_CARD_STATUS.LOADING) { + function onLayerStatusChanged (pLayer) { + if (pLayer.status === PRODUCT_CARD_STATUS.LOADING) { /* Lets see if we can find the Plotter of this card on our Active Plotters list, other wise we will initialize it */ let found = false for (let i = 0; i < productPlotters.length; i++) { - if (productPlotters[i].productCard.code === pProductCard.code) { + if (productPlotters[i].layer.code === pLayer.code) { found = true } } if (found === false) { - initializeProductPlotter(pProductCard, onProductPlotterInitialized) + initializeProductPlotter(pLayer, onProductPlotterInitialized) function onProductPlotterInitialized (err) { /* There is no policy yet of what to do if this fails. */ } } } - if (pProductCard.status === PRODUCT_CARD_STATUS.OFF) { + if (pLayer.status === PRODUCT_CARD_STATUS.OFF) { /* If the plotter of this card is not on our Active Plotters list, then we remove it. */ for (let i = 0; i < productPlotters.length; i++) { - if (productPlotters[i].productCard.code === pProductCard.code) { + if (productPlotters[i].layer.code === pLayer.code) { /* Then the panels. */ for (let j = 0; j < productPlotters[i].panels.length; j++) { canvas.panelsSpace.destroyPanel(productPlotters[i].panels[j]) @@ -268,7 +268,7 @@ function newPlottersManager () { timeFrame = pTimeFrame for (let i = 0; i < productPlotters.length; i++) { let productPlotter = productPlotters[i] - productPlotter.productCard.setTimeFrame(timeFrame) + productPlotter.layer.setTimeFrame(timeFrame) productPlotter.storage.setTimeFrame(timeFrame) productPlotter.plotter.setTimeFrame(timeFrame) } @@ -278,7 +278,7 @@ function newPlottersManager () { datetime = pDatetime for (let i = 0; i < productPlotters.length; i++) { let productPlotter = productPlotters[i] - productPlotter.productCard.setDatetime(pDatetime) + productPlotter.layer.setDatetime(pDatetime) productPlotter.storage.setDatetime(pDatetime) productPlotter.plotter.setDatetime(pDatetime) } diff --git a/CockpitSpace/FullScreen.js b/CockpitSpace/FullScreen.js index 8f204e3b7..12951403f 100644 --- a/CockpitSpace/FullScreen.js +++ b/CockpitSpace/FullScreen.js @@ -28,7 +28,7 @@ function newFullScreen () { let isMouseOver = false let counterTillNextState = 0 - let productCardsToTurnOn = [] + let layersToTurnOn = [] return thisObject function finalize () { diff --git a/Panels/ProductCard.js b/Panels/Layer.js similarity index 99% rename from Panels/ProductCard.js rename to Panels/Layer.js index 45580da75..03c724f46 100644 --- a/Panels/ProductCard.js +++ b/Panels/Layer.js @@ -1,4 +1,4 @@ -function newProductCard () { +function newLayer () { const MODULE_NAME = 'Product Card' const ERROR_LOG = true const logger = newWebDebugLog() @@ -319,10 +319,10 @@ function newProductCard () { } function draw () { - drawProductCard() + drawLayer() } - function drawProductCard () { + function drawLayer () { switch (thisObject.status) { case PRODUCT_CARD_STATUS.ON: @@ -568,4 +568,3 @@ function newProductCard () { browserCanvasContext.lineWidth = 10 } } - diff --git a/Panels/LayersPanel.js b/Panels/LayersPanel.js index 0d8e657df..995688ca4 100644 --- a/Panels/LayersPanel.js +++ b/Panels/LayersPanel.js @@ -3,8 +3,8 @@ function newProductsPanel () { name: 'Layers Panel', fitFunction: undefined, container: undefined, - productCards: [], - getLoadingProductCards: getLoadingProductCards, + layers: [], + getLoadingLayers: getLoadingLayers, physics: physics, draw: draw, getContainer: getContainer, // returns the inner most container that holds the point received by parameter. @@ -24,8 +24,8 @@ function newProductsPanel () { let isInitialized = false - let cardsMap = new Map() - let visibleProductCards = [] + let layersMap = new Map() + let visibleLayers = [] let firstVisibleCard = 1 /* Needed Variables */ @@ -60,7 +60,7 @@ function newProductsPanel () { panelTabButton.fitFunction = thisObject.fitFunction panelTabButton.initialize() - /* First thing is to build the thisObject.productCards array */ + /* First thing is to build the thisObject.layers array */ let ecosystem = JSON.parse(window.localStorage.getItem('ecosystem')) if (ecosystem === null || ecosystem === undefined) { ecosystem = getUserEcosystem() @@ -78,7 +78,7 @@ function newProductsPanel () { for (let k = 0; k < bot.products.length; k++) { let product = bot.products[k] - addProductCard(dataMine, bot, product) + addLayer(dataMine, bot, product) } } } @@ -187,7 +187,7 @@ function newProductsPanel () { } } - addProductCard(dataMine, bot, product) + addLayer(dataMine, bot, product) } } } @@ -197,36 +197,36 @@ function newProductsPanel () { isInitialized = true } - function removeProductCard (code) { - let productCard = cardsMap.get(code) - cardsMap.delete(code) - productCard.turnOff() - productCard.finalize() + function removeLayer (code) { + let layer = layersMap.get(code) + layersMap.delete(code) + layer.turnOff() + layer.finalize() } - function addProductCard (dataMine, bot, product, session) { + function addLayer (dataMine, bot, product, session) { /* Now we create Product objects */ - let productCard = newProductCard() + let layer = newLayer() - productCard.dataMine = dataMine - productCard.bot = bot - productCard.product = product - productCard.fitFunction = thisObject.fitFunction - productCard.code = exchange + '-' + market.quotedAsset + '/' + market.baseAsset + '-' + dataMine.codeName + '-' + bot.codeName + '-' + product.codeName + layer.dataMine = dataMine + layer.bot = bot + layer.product = product + layer.fitFunction = thisObject.fitFunction + layer.code = exchange + '-' + market.quotedAsset + '/' + market.baseAsset + '-' + dataMine.codeName + '-' + bot.codeName + '-' + product.codeName if (session !== undefined) { - productCard.code = productCard.code + '-' + session.id + layer.code = layer.code + '-' + session.id } - productCard.session = session + layer.session = session /* Initialize it */ - productCard.initialize() - cardsMap.set(productCard.code, productCard) + layer.initialize() + layersMap.set(layer.code, layer) /* Container Stuff */ - productCard.container.frame.parentFrame = thisObject.container.frame - productCard.container.parentContainer = thisObject.container - productCard.container.isWheelable = true + layer.container.frame.parentFrame = thisObject.container.frame + layer.container.parentContainer = thisObject.container + layer.container.isWheelable = true /* Positioning within thisObject Panel */ let position = { @@ -234,22 +234,22 @@ function newProductsPanel () { y: thisObject.container.frame.height - thisObject.container.frame.getBodyHeight() } - productCard.container.frame.position.x = position.x - productCard.container.frame.position.y = position.y + productCard.container.frame.height * thisObject.productCards.length + CANRD_SEPARATION + layer.container.frame.position.x = position.x + layer.container.frame.position.y = position.y + layer.container.frame.height * thisObject.layers.length + CANRD_SEPARATION /* Add to the Product Array */ - thisObject.productCards.push(productCard) + thisObject.layers.push(layer) /* Add to Visible Product Array */ - if (productCard.container.frame.position.y + productCard.container.frame.height < thisObject.container.frame.height) { - visibleProductCards.push(productCard) + if (layer.container.frame.position.y + layer.container.frame.height < thisObject.container.frame.height) { + visibleLayers.push(layer) } /* Listen to Status Changes Events */ - productCard.container.eventHandler.listenToEvent('Status Changed', onProductCardStatusChanged) - productCard.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) + layer.container.eventHandler.listenToEvent('Status Changed', onLayerStatusChanged) + layer.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) - return productCard + return layer } function onMouseWheel (event) { @@ -262,20 +262,20 @@ function newProductsPanel () { firstVisibleCard = firstVisibleCard + delta - calculateVisbleProductCards() + calculateVisbleLayers() } - function calculateVisbleProductCards () { - let availableSlots = visibleProductCards.length + function calculateVisbleLayers () { + let availableSlots = visibleLayers.length if (firstVisibleCard < 1) { firstVisibleCard = 1 } - if (firstVisibleCard > (thisObject.productCards.length - availableSlots + 1)) { firstVisibleCard = thisObject.productCards.length - availableSlots + 1 } + if (firstVisibleCard > (thisObject.layers.length - availableSlots + 1)) { firstVisibleCard = thisObject.layers.length - availableSlots + 1 } - visibleProductCards = [] + visibleLayers = [] - for (let i = 0; i < thisObject.productCards.length; i++) { + for (let i = 0; i < thisObject.layers.length; i++) { if (i + 1 >= firstVisibleCard && i + 1 < firstVisibleCard + availableSlots) { - let productCard = thisObject.productCards[i] + let layer = thisObject.layers[i] /* Positioning within thisObject Panel */ @@ -283,28 +283,28 @@ function newProductsPanel () { x: 10, y: thisObject.container.frame.height - thisObject.container.frame.getBodyHeight() } - productCard.container.frame.position.x = position.x - productCard.container.frame.position.y = position.y + productCard.container.frame.height * visibleProductCards.length + CANRD_SEPARATION + layer.container.frame.position.x = position.x + layer.container.frame.position.y = position.y + layer.container.frame.height * visibleLayers.length + CANRD_SEPARATION /* Add to Visible Product Array */ - visibleProductCards.push(productCard) + visibleLayers.push(layer) } } } - function onProductCardStatusChanged (pProductCard) { - thisObject.container.eventHandler.raiseEvent('Product Card Status Changed', pProductCard) + function onLayerStatusChanged (pLayer) { + thisObject.container.eventHandler.raiseEvent('Product Card Status Changed', pLayer) } - function getLoadingProductCards () { - /* Returns all thisObject.productCards which status is LOADING */ + function getLoadingLayers () { + /* Returns all thisObject.layers which status is LOADING */ let onProducts = [] - for (let i = 0; i < thisObject.productCards.length; i++) { - if (thisObject.productCards[i].status === PRODUCT_CARD_STATUS.LOADING) { - onProducts.push(thisObject.productCards[i]) + for (let i = 0; i < thisObject.layers.length; i++) { + if (thisObject.layers[i].status === PRODUCT_CARD_STATUS.LOADING) { + onProducts.push(thisObject.layers[i]) } } @@ -322,8 +322,8 @@ function newProductsPanel () { if (thisObject.container.frame.isThisPointHere(point, true) === true) { /* Now we see which is the inner most container that has it */ - for (let i = 0; i < visibleProductCards.length; i++) { - container = visibleProductCards[i].getContainer(point) + for (let i = 0; i < visibleLayers.length; i++) { + container = visibleLayers[i].getContainer(point) if (container !== undefined) { let checkPoint = { @@ -371,15 +371,15 @@ function newProductsPanel () { local array after all the layers at the designer have been processed, are turned off and discarded. */ - let localProductCards = [] - moveToLocalProductCards() - synchronizeLayersAndProductCards() + let localLayers = [] + moveToLocalLayers() + synchronizeLayersAndLayers() /* At this poins all the cards still at the local array need to be removed from the panel. */ turnOffUnusedProducCards() - calculateVisbleProductCards() + calculateVisbleLayers() - function synchronizeLayersAndProductCards () { + function synchronizeLayersAndLayers () { /* We will look into the ecosystem to know which Trading bots are defined there. */ let ecosystem = JSON.parse(window.localStorage.getItem('ecosystem')) if (ecosystem === null || ecosystem === undefined) { @@ -439,10 +439,10 @@ function newProductsPanel () { if (product.codeName === layerCode.product) { /* We have a layer that is matching the current product */ let cardCode = exchange + '-' + market.quotedAsset + '/' + market.baseAsset + '-' + dataMine.codeName + '-' + bot.codeName + '-' + product.codeName + '-' + process.session.id - let cardFound = removeFromLocalProductCards(cardCode) + let cardFound = removeFromLocalLayers(cardCode) if (cardFound !== true) { - productCard = addProductCard(dataMine, bot, product, process.session) - onProductCardStatusChanged(productCard) + layer = addLayer(dataMine, bot, product, process.session) + onLayerStatusChanged(layer) } } } @@ -458,36 +458,36 @@ function newProductsPanel () { } } - function moveToLocalProductCards () { + function moveToLocalLayers () { removeNext() function removeNext () { - for (let i = 0; i < thisObject.productCards.length; i++) { - let productCard = thisObject.productCards[i] - if (productCard.session !== undefined) { - thisObject.productCards.splice(i, 1) - localProductCards.push(productCard) + for (let i = 0; i < thisObject.layers.length; i++) { + let layer = thisObject.layers[i] + if (layer.session !== undefined) { + thisObject.layers.splice(i, 1) + localLayers.push(layer) removeNext() } } } } - function removeFromLocalProductCards (code) { - for (let i = 0; i < localProductCards.length; i++) { - let productCard = localProductCards[i] - if (productCard.code === code) { - thisObject.productCards.push(productCard) - localProductCards.splice(i, 1) + function removeFromLocalLayers (code) { + for (let i = 0; i < localLayers.length; i++) { + let layer = localLayers[i] + if (layer.code === code) { + thisObject.layers.push(layer) + localLayers.splice(i, 1) return true } } } function turnOffUnusedProducCards () { - for (let i = 0; i < localProductCards.length; i++) { - let productCard = localProductCards[i] - removeProductCard(productCard.code) + for (let i = 0; i < localLayers.length; i++) { + let layer = localLayers[i] + removeLayer(layer.code) } } } @@ -496,8 +496,8 @@ function newProductsPanel () { thisObject.container.frame.draw(false, false, false, thisObject.fitFunction) - for (let i = 0; i < visibleProductCards.length; i++) { - visibleProductCards[i].draw() + for (let i = 0; i < visibleLayers.length; i++) { + visibleLayers[i].draw() } panelTabButton.draw() diff --git a/Project.njsproj b/Project.njsproj index 2023bf304..99fe110d0 100644 --- a/Project.njsproj +++ b/Project.njsproj @@ -127,7 +127,7 @@ Code - + Code From aa4f4c735408fe303bc40a69dd56e20d57d25226 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 14 Jan 2020 13:47:25 +0100 Subject: [PATCH 106/264] Refactoring that was missing --- ChartsSpace/PlottersManager.js | 4 +-- ChartsSpace/TimelineChart.js | 3 +- Panels/Layer.js | 2 +- Panels/LayersPanel.js | 58 +++++++++++++++++++--------------- 4 files changed, 38 insertions(+), 29 deletions(-) diff --git a/ChartsSpace/PlottersManager.js b/ChartsSpace/PlottersManager.js index 91bf7b67b..1ed5ae6a4 100644 --- a/ChartsSpace/PlottersManager.js +++ b/ChartsSpace/PlottersManager.js @@ -72,7 +72,7 @@ function newPlottersManager () { exchange = pExchange market = pMarket /* Listen to the event of change of status */ - layersPanel.container.eventHandler.listenToEvent('Product Card Status Changed', onLayerStatusChanged) + layersPanel.container.eventHandler.listenToEvent('Layer Status Changed', onLayerStatusChanged) /* Lets get all the cards that needs to be loaded. */ @@ -94,7 +94,7 @@ function newPlottersManager () { let storage = newProductStorage(objName) /* - Before Initializing the Storage, we will put the Product Card to listen to the events the storage will raise every time a file is loaded, + Before Initializing the Storage, we will put the Layer to listen to the events the storage will raise every time a file is loaded, so that the UI can somehow show this. There are different types of events. */ diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index e66d99ef7..788aae461 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -3,7 +3,7 @@ function newTimelineChart () { const INFO_LOG = false const INTENSIVE_LOG = false const ERROR_LOG = true - const logger = newWebDebugLog() + let logger = newWebDebugLog() logger.fileName = MODULE_NAME let timeFrame = INITIAL_TIME_PERIOD @@ -85,6 +85,7 @@ function newTimelineChart () { thisObject.payload = undefined mouse = undefined + logger = undefined } function finalizeLayersManager () { diff --git a/Panels/Layer.js b/Panels/Layer.js index 03c724f46..691e4f490 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -1,5 +1,5 @@ function newLayer () { - const MODULE_NAME = 'Product Card' + const MODULE_NAME = 'Layer' const ERROR_LOG = true const logger = newWebDebugLog() logger.fileName = MODULE_NAME diff --git a/Panels/LayersPanel.js b/Panels/LayersPanel.js index 995688ca4..ba01ee7cd 100644 --- a/Panels/LayersPanel.js +++ b/Panels/LayersPanel.js @@ -4,33 +4,29 @@ function newProductsPanel () { fitFunction: undefined, container: undefined, layers: [], + payload: undefined, getLoadingLayers: getLoadingLayers, physics: physics, draw: draw, getContainer: getContainer, // returns the inner most container that holds the point received by parameter. - initialize: initialize + initialize: initialize, + finalize: finalize } - /* Cointainer stuff */ - - let container = newContainer() - - container.initialize() - - container.isDraggeable = true - container.isWheelable = true - - thisObject.container = container + thisObject.container = newContainer() + thisObject.container.initialize() + thisObject.container.isDraggeable = true + thisObject.container.isWheelable = true let isInitialized = false let layersMap = new Map() let visibleLayers = [] - let firstVisibleCard = 1 + let firstVisibleLayer = 1 /* Needed Variables */ - const CANRD_SEPARATION = 5 + const LAYER_SEPARATION = 5 let panelTabButton let exchange @@ -38,6 +34,18 @@ function newProductsPanel () { return thisObject + function finalize () { + panelTabButton = undefined + layersMap = undefined + visibleLayers = undefined + + thisObject.container.finalize() + thisObject.container = undefined + + thisObject.payload = undefined + thisObject = undefined + } + function initialize (pExchange, pMarket) { exchange = pExchange market = pMarket @@ -235,7 +243,7 @@ function newProductsPanel () { } layer.container.frame.position.x = position.x - layer.container.frame.position.y = position.y + layer.container.frame.height * thisObject.layers.length + CANRD_SEPARATION + layer.container.frame.position.y = position.y + layer.container.frame.height * thisObject.layers.length + LAYER_SEPARATION /* Add to the Product Array */ thisObject.layers.push(layer) @@ -260,7 +268,7 @@ function newProductsPanel () { delta = 1 } - firstVisibleCard = firstVisibleCard + delta + firstVisibleLayer = firstVisibleLayer + delta calculateVisbleLayers() } @@ -268,13 +276,13 @@ function newProductsPanel () { function calculateVisbleLayers () { let availableSlots = visibleLayers.length - if (firstVisibleCard < 1) { firstVisibleCard = 1 } - if (firstVisibleCard > (thisObject.layers.length - availableSlots + 1)) { firstVisibleCard = thisObject.layers.length - availableSlots + 1 } + if (firstVisibleLayer < 1) { firstVisibleLayer = 1 } + if (firstVisibleLayer > (thisObject.layers.length - availableSlots + 1)) { firstVisibleLayer = thisObject.layers.length - availableSlots + 1 } visibleLayers = [] for (let i = 0; i < thisObject.layers.length; i++) { - if (i + 1 >= firstVisibleCard && i + 1 < firstVisibleCard + availableSlots) { + if (i + 1 >= firstVisibleLayer && i + 1 < firstVisibleLayer + availableSlots) { let layer = thisObject.layers[i] /* Positioning within thisObject Panel */ @@ -284,7 +292,7 @@ function newProductsPanel () { y: thisObject.container.frame.height - thisObject.container.frame.getBodyHeight() } layer.container.frame.position.x = position.x - layer.container.frame.position.y = position.y + layer.container.frame.height * visibleLayers.length + CANRD_SEPARATION + layer.container.frame.position.y = position.y + layer.container.frame.height * visibleLayers.length + LAYER_SEPARATION /* Add to Visible Product Array */ @@ -294,7 +302,7 @@ function newProductsPanel () { } function onLayerStatusChanged (pLayer) { - thisObject.container.eventHandler.raiseEvent('Product Card Status Changed', pLayer) + thisObject.container.eventHandler.raiseEvent('Layer Status Changed', pLayer) } function getLoadingLayers () { @@ -361,7 +369,7 @@ function newProductsPanel () { The overall idea here is that we need to keep syncronized the panel with the layers that are defined at the Designer. Users can connect or disconnect any objext resulting in changes in which are valid layers and which not at any point in time. So what we do here is trying to keep the panel - only with the layers that are connected to each Definition structure. + only with the layers that are connected to the Charting System hiriarcy. To achieve this, first we are going to move all session related cards to a local array. Then we are going to check for layers at the designer, and will move back the cards which still have layers well @@ -373,13 +381,13 @@ function newProductsPanel () { let localLayers = [] moveToLocalLayers() - synchronizeLayersAndLayers() + syncWithDesignerLayers() /* At this poins all the cards still at the local array need to be removed from the panel. */ - turnOffUnusedProducCards() + turnOffUnusedLayers() calculateVisbleLayers() - function synchronizeLayersAndLayers () { + function syncWithDesignerLayers () { /* We will look into the ecosystem to know which Trading bots are defined there. */ let ecosystem = JSON.parse(window.localStorage.getItem('ecosystem')) if (ecosystem === null || ecosystem === undefined) { @@ -484,7 +492,7 @@ function newProductsPanel () { } } - function turnOffUnusedProducCards () { + function turnOffUnusedLayers () { for (let i = 0; i < localLayers.length; i++) { let layer = localLayers[i] removeLayer(layer.code) From 89efd12f506c473e591b3e79596a387e75b6ebc1 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 14 Jan 2020 14:25:02 +0100 Subject: [PATCH 107/264] Layers Panel rewritten --- DesignerSpace/Workspace/Workspace.js | 29 --- Panels/Layer.js | 2 + Panels/LayersPanel.js | 272 +++------------------------ 3 files changed, 33 insertions(+), 270 deletions(-) diff --git a/DesignerSpace/Workspace/Workspace.js b/DesignerSpace/Workspace/Workspace.js index c5e2afcfe..34d758b20 100644 --- a/DesignerSpace/Workspace/Workspace.js +++ b/DesignerSpace/Workspace/Workspace.js @@ -13,7 +13,6 @@ function newWorkspace () { nodeChildren: undefined, getNodeThatIsOnFocus: getNodeThatIsOnFocus, getNodeByShortcutKey: getNodeByShortcutKey, - getAllTradingBotInstances: getAllTradingBotInstances, stopAllRunningTasks: stopAllRunningTasks, onMenuItemClick: onMenuItemClick, physics: physics, @@ -191,34 +190,6 @@ function newWorkspace () { } } - function getAllTradingBotInstances () { - let tradingBotInstances = [] - for (let i = 0; i < thisObject.workspaceNode.rootNodes.length; i++) { - let rootNode = thisObject.workspaceNode.rootNodes[i] - if (rootNode.type === 'Network') { - if (rootNode.networkNodes !== undefined) { - for (let j = 0; j < rootNode.networkNodes.length; j++) { - let networkNode = rootNode.networkNodes[j] - for (let i = 0; i < networkNode.taskManagers.length; i++) { - let taskManager = networkNode.taskManagers[i] - for (let k = 0; k < taskManager.tasks.length; k++) { - let task = taskManager.tasks[k] - if (task.bot !== undefined) { - if (task.bot.type === 'Trading Bot Instance') { - if (task.bot.payload.floatingObject.isCollapsed !== true) { - tradingBotInstances.push(task.bot) - } - } - } - } - } - } - } - } - } - return tradingBotInstances - } - function getNodeByShortcutKey (searchingKey) { for (let i = 0; i < thisObject.workspaceNode.rootNodes.length; i++) { let rootNode = thisObject.workspaceNode.rootNodes[i] diff --git a/Panels/Layer.js b/Panels/Layer.js index 691e4f490..b43fafc9f 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -12,6 +12,7 @@ function newLayer () { product: undefined, code: undefined, fitFunction: undefined, + payload: undefined, draw: draw, turnOff: turnOff, turnOn: turnOn, @@ -87,6 +88,7 @@ function newLayer () { thisObject.product = undefined thisObject.code = undefined thisObject.fitFunction = undefined + thisObject.payload = undefined timeFrame = undefined datetime = undefined diff --git a/Panels/LayersPanel.js b/Panels/LayersPanel.js index ba01ee7cd..87794650d 100644 --- a/Panels/LayersPanel.js +++ b/Panels/LayersPanel.js @@ -8,7 +8,7 @@ function newProductsPanel () { getLoadingLayers: getLoadingLayers, physics: physics, draw: draw, - getContainer: getContainer, // returns the inner most container that holds the point received by parameter. + getContainer: getContainer, initialize: initialize, finalize: finalize } @@ -24,17 +24,18 @@ function newProductsPanel () { let visibleLayers = [] let firstVisibleLayer = 1 - /* Needed Variables */ - const LAYER_SEPARATION = 5 let panelTabButton let exchange let market + let onMouseWheelEventSuscriptionId return thisObject function finalize () { + thisObject.container.eventHandler.stopListening(onMouseWheelEventSuscriptionId) + panelTabButton = undefined layersMap = undefined visibleLayers = undefined @@ -68,168 +69,28 @@ function newProductsPanel () { panelTabButton.fitFunction = thisObject.fitFunction panelTabButton.initialize() - /* First thing is to build the thisObject.layers array */ - let ecosystem = JSON.parse(window.localStorage.getItem('ecosystem')) - if (ecosystem === null || ecosystem === undefined) { - ecosystem = getUserEcosystem() - } - - /* For legacy plotters, we will add product cards based on the old ecosystem file */ - for (let i = 0; i < ecosystem.dataMines.length; i++) { - let dataMine = ecosystem.dataMines[i] - - for (let j = 0; j < dataMine.bots.length; j++) { - let bot = dataMine.bots[j] - if (bot.type !== 'Indicator Bot Instance') { continue } - - if (bot.products !== undefined) { - for (let k = 0; k < bot.products.length; k++) { - let product = bot.products[k] - - addLayer(dataMine, bot, product) - } - } - } - } - - /* For new plotters defined at the UI, we will add product cards based on what we find at the workspace */ - let workspaceNode = canvas.designerSpace.workspace.workspaceNode - for (let i = 0; i < workspaceNode.rootNodes.length; i++) { - let rootNode = workspaceNode.rootNodes[i] - if (rootNode.type === 'Data Mine') { - let dataMineNode = rootNode - - let dataMine = {} - if (dataMineNode.code === undefined) { continue } - try { - let code = JSON.parse(dataMineNode.code) - dataMine.codeName = code.codeName - } catch (err) { - continue - } - for (let j = 0; j < dataMineNode.indicatorBots.length; j++) { - let botNode = dataMineNode.indicatorBots[j] - - let bot = {} - if (botNode.code === undefined) { continue } - try { - let code = JSON.parse(botNode.code) - bot.codeName = code.codeName - } catch (err) { - continue - } - - for (let k = 0; k < botNode.products.length; k++) { - let productNode = botNode.products[k] - - let product = {} - if (productNode.code === undefined) { continue } - try { - let code = JSON.parse(productNode.code) - product.codeName = code.codeName - } catch (err) { - continue - } - - if (productNode.payload.referenceParent === undefined) { continue } - let plotterModuleNode = productNode.payload.referenceParent - - let plotterModule = {} - if (plotterModuleNode.code === undefined) { continue } - try { - let code = JSON.parse(plotterModuleNode.code) - plotterModule.codeName = code.codeName - plotterModule.banner = code.banner - } catch (err) { - continue - } - - if (plotterModuleNode.payload.parentNode === undefined) { continue } - let plotterNode = plotterModuleNode.payload.parentNode - - let plotter = {} - if (plotterNode.code === undefined) { continue } - try { - let code = JSON.parse(plotterNode.code) - plotter.codeName = code.codeName - } catch (err) { - continue - } - - if (plotterNode.payload.parentNode === undefined) { continue } - let plotterDataMineNode = plotterNode.payload.parentNode - - let plotterDataMine = {} - if (plotterDataMineNode.code === undefined) { continue } - try { - let code = JSON.parse(plotterDataMineNode.code) - plotterDataMine.codeName = code.codeName - } catch (err) { - continue - } - - /* Conversion to fit old format */ - product.plotter = plotter - product.plotter.dataMine = plotterDataMine.codeName - product.plotter.moduleName = plotterModule.codeName - product.plotter.banner = plotterModule.banner - product.plotter.legacy = false - product.plotter.module = { panels: [] } - product.displayName = productNode.name - product.dataSets = [] - product.exchangeList = [{'name': 'Poloniex'}] - product.node = productNode - dataMine.displayName = dataMineNode.name - dataMine.host = {'url': 'localhost'} - bot.displayName = botNode.name - - for (let m = 0; m < productNode.datasets.length; m++) { - let dataset = productNode.datasets[m] - - if (dataset.code === undefined) { continue } - try { - let code = JSON.parse(dataset.code) - product.dataSets.push(code) - } catch (err) { - continue - } - } - - addLayer(dataMine, bot, product) - } - } - } - } - - thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) + onMouseWheelEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) isInitialized = true } - function removeLayer (code) { - let layer = layersMap.get(code) - layersMap.delete(code) + function removeLayer (id) { + let layer = layersMap.get(id) + layersMap.delete(id) layer.turnOff() + layer.container.eventHandler.stopListening(layer.onLayerStatusChangedEventSuscriptionId) + layer.container.eventHandler.stopListening(layer.onMouseWheelEventSuscriptionId) layer.finalize() } - function addLayer (dataMine, bot, product, session) { + function addLayer (layerNode) { /* Now we create Product objects */ let layer = newLayer() - - layer.dataMine = dataMine - layer.bot = bot - layer.product = product + layer.payload = layerNode.payload layer.fitFunction = thisObject.fitFunction - layer.code = exchange + '-' + market.quotedAsset + '/' + market.baseAsset + '-' + dataMine.codeName + '-' + bot.codeName + '-' + product.codeName - - if (session !== undefined) { - layer.code = layer.code + '-' + session.id - } - layer.session = session /* Initialize it */ layer.initialize() - layersMap.set(layer.code, layer) + layersMap.set(layerNode.id, layer) /* Container Stuff */ layer.container.frame.parentFrame = thisObject.container.frame @@ -238,7 +99,7 @@ function newProductsPanel () { /* Positioning within thisObject Panel */ let position = { - x: 10, + x: 0, y: thisObject.container.frame.height - thisObject.container.frame.getBodyHeight() } @@ -254,8 +115,8 @@ function newProductsPanel () { } /* Listen to Status Changes Events */ - layer.container.eventHandler.listenToEvent('Status Changed', onLayerStatusChanged) - layer.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) + layer.onLayerStatusChangedEventSuscriptionId = layer.container.eventHandler.listenToEvent('Status Changed', onLayerStatusChanged) + layer.onMouseWheelEventSuscriptionId = layer.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) return layer } @@ -285,17 +146,15 @@ function newProductsPanel () { if (i + 1 >= firstVisibleLayer && i + 1 < firstVisibleLayer + availableSlots) { let layer = thisObject.layers[i] - /* Positioning within thisObject Panel */ - + /* Positioning within thisObject Panel */ let position = { - x: 10, + x: 0, y: thisObject.container.frame.height - thisObject.container.frame.getBodyHeight() } layer.container.frame.position.x = position.x layer.container.frame.position.y = position.y + layer.container.frame.height * visibleLayers.length + LAYER_SEPARATION - /* Add to Visible Product Array */ - + /* Add to Visible Product Array */ visibleLayers.push(layer) } } @@ -306,8 +165,7 @@ function newProductsPanel () { } function getLoadingLayers () { - /* Returns all thisObject.layers which status is LOADING */ - + /* Returns all thisObject.layers which status is LOADING */ let onProducts = [] for (let i = 0; i < thisObject.layers.length; i++) { @@ -325,11 +183,9 @@ function newProductsPanel () { container = panelTabButton.getContainer(point) if (container !== undefined) { return container } - /* First we check if thisObject point is inside thisObject space. */ - + /* First we check if thisObject point is inside thisObject space. */ if (thisObject.container.frame.isThisPointHere(point, true) === true) { - /* Now we see which is the inner most container that has it */ - + /* Now we see which is the inner most container that has it */ for (let i = 0; i < visibleLayers.length; i++) { container = visibleLayers[i].getContainer(point) @@ -347,8 +203,7 @@ function newProductsPanel () { } } - /* The point does not belong to any inner container, so we return the current container. */ - + /* The point does not belong to any inner container, so we return the current container. */ let checkPoint = { x: point.x, y: point.y @@ -388,80 +243,14 @@ function newProductsPanel () { calculateVisbleLayers() function syncWithDesignerLayers () { - /* We will look into the ecosystem to know which Trading bots are defined there. */ - let ecosystem = JSON.parse(window.localStorage.getItem('ecosystem')) - if (ecosystem === null || ecosystem === undefined) { - ecosystem = getUserEcosystem() - } + let layerManager = thisObject.payload.node + for (let p = 0; p < layerManager.layers.length; p++) { + let layerNode = layerManager.layers[p] - /* Then we get an Array of all instances of this bot placed at Definitions on the Workspace. */ - let tradingBotInstances = canvas.designerSpace.workspace.getAllTradingBotInstances() - - /* Here we will go through all the instances of trading engines and see their layers, to see - if we can find a matching layer. */ - - for (let n = 0; n < tradingBotInstances.length; n++) { - let tradingBotInstance = tradingBotInstances[n] - let code - let instanceBot - let instanceDataMine - - for (let m = 0; m < tradingBotInstance.processes.length; m++) { - let process = tradingBotInstance.processes[m] - try { - code = JSON.parse(process.payload.referenceParent.payload.parentNode.code) - instanceBot = code.codeName - code = JSON.parse(process.payload.referenceParent.payload.parentNode.payload.parentNode.code) - instanceDataMine = code.codeName - } catch (err) { - continue - } - for (let i = 0; i < ecosystem.dataMines.length; i++) { - let dataMine = ecosystem.dataMines[i] - - for (let j = 0; j < dataMine.bots.length; j++) { - let bot = dataMine.bots[j] - if (bot.type !== 'Trading Bot Instance') { continue } - - if (dataMine.codeName === instanceDataMine && bot.codeName === instanceBot) { - /* We found an instance of the same Trading we are currently looking at. - Next thing to do is to see its layers to see if we can match it with the current product. */ - - if (process.session !== undefined) { - if (process.session.layerManager !== undefined) { - let layerManager = process.session.layerManager - if (layerManager.payload.floatingObject.isCollapsed !== true) { - if (bot.products !== undefined) { - for (let k = 0; k < bot.products.length; k++) { - let product = bot.products[k] - - for (let p = 0; p < layerManager.layers.length; p++) { - let layer = layerManager.layers[p] - let layerCode - try { - layerCode = JSON.parse(layer.code) - } catch (err) { - // if we can not parse this, then we ignore this trading engine. - } - - if (product.codeName === layerCode.product) { - /* We have a layer that is matching the current product */ - let cardCode = exchange + '-' + market.quotedAsset + '/' + market.baseAsset + '-' + dataMine.codeName + '-' + bot.codeName + '-' + product.codeName + '-' + process.session.id - let cardFound = removeFromLocalLayers(cardCode) - if (cardFound !== true) { - layer = addLayer(dataMine, bot, product, process.session) - onLayerStatusChanged(layer) - } - } - } - } - } - } - } - } - } - } - } + let found = removeFromLocalLayers(layerNode.id) + if (found !== true) { + layer = addLayer(layerNode.id) + onLayerStatusChanged(layer) } } } @@ -499,6 +288,7 @@ function newProductsPanel () { } } } + function draw () { if (isInitialized === false) { return } From 182be1fc218aea11d12bd11ed5af8793f6aed7a9 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 14 Jan 2020 19:57:43 +0100 Subject: [PATCH 108/264] Barelly Running Again with massive changes --- ChartsSpace/PlottersManager.js | 275 ++++++++++++++++++--------------- ChartsSpace/TimelineChart.js | 12 +- FloatingSpace/UiObjectTitle.js | 2 +- Globals.js | 1 - Panels/Layer.js | 264 ++++++++++++++++++++----------- Panels/LayersPanel.js | 18 +-- Plotter.js | 2 +- ProductStorage.js | 22 +-- 8 files changed, 347 insertions(+), 249 deletions(-) diff --git a/ChartsSpace/PlottersManager.js b/ChartsSpace/PlottersManager.js index 1ed5ae6a4..1f0b5e082 100644 --- a/ChartsSpace/PlottersManager.js +++ b/ChartsSpace/PlottersManager.js @@ -4,7 +4,7 @@ function newPlottersManager () { const logger = newWebDebugLog() logger.fileName = MODULE_NAME - let productPlotters = [] + let connectors = [] let timeFrame = INITIAL_TIME_PERIOD let datetime = NEW_SESSION_INITIAL_DATE @@ -24,8 +24,8 @@ function newPlottersManager () { let initializationReady = false let layersPanel - let exchange - let market + + let onLayerStatusChangedEventSuscriptionId setupContainer() return thisObject @@ -36,27 +36,31 @@ function newPlottersManager () { } function finalize () { - for (let i = 0; i < productPlotters.length; i++) { + layersPanel.container.eventHandler.stopListening(onLayerStatusChangedEventSuscriptionId) + + for (let i = 0; i < connectors.length; i++) { + let connector = connectors[i] /* Then the panels. */ - for (let j = 0; j < productPlotters[i].panels.length; j++) { - canvas.panelsSpace.destroyPanel(productPlotters[i].panels[j]) - productPlotters[i].panels[j] = undefined + for (let j = 0; j < connector.panels.length; j++) { + canvas.panelsSpace.destroyPanel(connector.panels[j]) + connector.panels[j] = undefined } - productPlotters[i].panels = undefined + connector.panels = undefined /* Finalize the plotters */ - if (productPlotters[i].plotter.finalize !== undefined) { - productPlotters[i].plotter.finalize() + if (connector.plotter.finalize !== undefined) { + connector.plotter.container.eventHandler.stopListening(connector.plotter.onRecordChangeEventsSubscriptionId) + connector.plotter.finalize() } - productPlotters[i].plotter = undefined + connector.plotter = undefined /* Finally the Storage Objects */ - productPlotters[i].storage.finalize() - productPlotters[i].storage = undefined + finalizeStorage(connector.storage) + connector.storage = undefined - productPlotters[i] = undefined + connector = undefined } - productPlotters = [] + connectors = [] layersPanel = undefined @@ -65,199 +69,216 @@ function newPlottersManager () { setupContainer() } - function initialize (pProductsPanel, pExchange, pMarket) { + function finalizeStorage (storage) { + storage.eventHandler.stopListening(storage.onMarketFileLoadedLayerEventsSubscriptionId) + storage.eventHandler.stopListening(storage.onDailyFileLoadedLayerEventsSubscriptionId) + storage.eventHandler.stopListening(storage.onSingleFileLoadedLayerEventsSubscriptionId) + storage.eventHandler.stopListening(storage.onFileSequenceLoadedLayerEventsSubscriptionId) + storage.eventHandler.stopListening(storage.onDailyFileLoadedPlotterEventsSubscriptionId) + storage.finalize() + } + + function initialize (pLayersPanel) { try { - /* Remember the Layers Panel */ - layersPanel = pProductsPanel - exchange = pExchange - market = pMarket - /* Listen to the event of change of status */ - layersPanel.container.eventHandler.listenToEvent('Layer Status Changed', onLayerStatusChanged) + /* Remember the Layers Panel */ + layersPanel = pLayersPanel + + /* Listen to the event of change of status */ + onLayerStatusChangedEventSuscriptionId = layersPanel.container.eventHandler.listenToEvent('Layer Status Changed', onLayerStatusChanged) /* Lets get all the cards that needs to be loaded. */ - let loadingLayers = layersPanel.getLoadingLayers() for (let i = 0; i < loadingLayers.length; i++) { - /* For each one, we will initialize the associated plotter. */ - initializeProductPlotter(loadingLayers[i]) + /* For each one, we will initialize the associated plotter. */ + initializePlotter(loadingLayers[i]) } } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err.stack) } } } - function initializeProductPlotter (pLayer, callBack) { + function initializePlotter (layer) { try { - /* Before Initializing a Plotter, we need the Storage it will use, loaded with the files it will initially need. */ - let objName = pLayer.dataMine.codeName + '-' + pLayer.bot.codeName + '-' + pLayer.product.codeName - let storage = newProductStorage(objName) - /* + /* Before Initializing a Plotter, we need the Storage it will use, loaded with the files it will initially need. */ + let storage = newProductStorage(layer.payload.node.id) - Before Initializing the Storage, we will put the Layer to listen to the events the storage will raise every time a file is loaded, - so that the UI can somehow show this. There are different types of events. + /* + Before Initializing the Storage, we will put the Layer to listen to the events the storage will raise every time a file is loaded, + so that the UI can somehow show this. There are different types of events. + */ + for (let i = 0; i < layer.definition.referenceParent.referenceParent.datasets.length; i++) { + let dataset = layer.definition.referenceParent.referenceParent.datasets[i] - */ - for (let i = 0; i < pLayer.product.dataSets.length; i++) { - let thisSet = pLayer.product.dataSets[i] - - switch (thisSet.type) { + switch (dataset.type) { case 'Market Files': { - storage.eventHandler.listenToEvent('Market File Loaded', pLayer.onMarketFileLoaded) + storage.onMarketFileLoadedLayerEventsSubscriptionId = storage.eventHandler.listenToEvent('Market File Loaded', layer.onMarketFileLoaded) } break case 'Daily Files': { - storage.eventHandler.listenToEvent('Daily File Loaded', pLayer.onDailyFileLoaded) + storage.onDailyFileLoadedLayerEventsSubscriptionId = storage.eventHandler.listenToEvent('Daily File Loaded', layer.onDailyFileLoaded) } break case 'Single File': { - storage.eventHandler.listenToEvent('Single File Loaded', pLayer.onSingleFileLoaded) + storage.onSingleFileLoadedLayerEventsSubscriptionId = storage.eventHandler.listenToEvent('Single File Loaded', layer.onSingleFileLoaded) } break case 'File Sequence': { - storage.eventHandler.listenToEvent('File Sequence Loaded', pLayer.onFileSequenceLoaded) + storage.onFileSequenceLoadedLayerEventsSubscriptionId = storage.eventHandler.listenToEvent('File Sequence Loaded', layer.onFileSequenceLoaded) } break + default: { + if (ERROR_LOG === true) { + logger.write('[ERROR] initializePlotter -> Dataset Type Incorrect or Undefined -> dataset.type = ' + dataset.type) + } + return + } } } - storage.initialize(pLayer.dataMine, pLayer.bot, pLayer.session, pLayer.product, exchange, market, datetime, timeFrame, onProductStorageInitialized) + let baseAsset = layer.definition.referenceParent.parentNode.referenceParent.baseAsset.referenceParent.code.codeName + let quotedAsset = layer.definition.referenceParent.parentNode.referenceParent.quotedAsset.referenceParent.code.codeName + let market = baseAsset + '/' + quotedAsset + let product = layer.definition.referenceParent.referenceParent + let bot = layer.definition.referenceParent.referenceParent.parentNode + let dataMine = layer.definition.referenceParent.referenceParent.parentNode.parentNode + let exchange = layer.definition.referenceParent.parentNode.referenceParent.parentNode.parentNode + let plotterModule = layer.definition.referenceParent.referenceParent.referenceParent + let session + + storage.initialize( + dataMine, + bot, + session, + product, + exchange, + market, + datetime, + timeFrame, + onProductStorageInitialized + ) function onProductStorageInitialized (err) { try { if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result) { /* Now we have all the initial data loaded and ready to be delivered to the new instance of the plotter. */ let plotter - let productDefinition - if (pLayer.product.plotter.legacy === false) { + if (plotterModule.code.isLegacy !== true) { plotter = newPlotter() - - /* We take a snapwhot of the current product definition to be used by the plotter. */ - let functionLibraryProtocolNode = newProtocolNode() - let lightingPath = '->Product Definition->' + - 'Record Definition->Record Property->Formula->' + - 'Data Building Procedure->Procedure Loop->Javascript Code->Procedure Initialization->Javascript Code->' + - 'Calculations Procedure->Procedure Loop->Javascript Code->Procedure Initialization->Javascript Code->' + - 'Plotter Module->Shapes->' + - 'Chart Points->Point->Point Formula->' + - 'Polygon->Polygon Body->Style->Style Condition->Style->' + - 'Polygon Border->Style->Style Condition->Style->' + - 'Polygon Vertex->Point->' + - 'Plotter Panel->Javascript Code->Panel Data->Data Formula->' - productDefinition = functionLibraryProtocolNode.getProtocolNode(pLayer.product.node, false, true, true, false, false, lightingPath) } else { - plotter = getNewPlotter(pLayer.product.plotter.dataMine, pLayer.product.plotter.codeName, pLayer.product.plotter.moduleName) + plotter = getNewPlotter(dataMine.code.codeName, plotterModule.parentNode.code.codeName, plotterModule.code.codeName) } plotter.container.connectToParent(thisObject.container, true, true, false, true, true, true, false, false, true) plotter.container.frame.position.x = thisObject.container.frame.width / 2 - plotter.container.frame.width / 2 plotter.container.frame.position.y = thisObject.container.frame.height / 2 - plotter.container.frame.height / 2 plotter.fitFunction = thisObject.fitFunction - plotter.initialize(storage, exchange, market, datetime, timeFrame, onPlotterInizialized, productDefinition) + plotter.initialize(storage, datetime, timeFrame, onPlotterInizialized, product) function onPlotterInizialized () { try { - let productPlotter = { - layer: pLayer, + let connector = { + layer: layer, plotter: plotter, - storage: storage, - profile: undefined, - notes: undefined + storage: storage } - /* Let the Plotter listen to the event of Cursor Files loaded, so that it can react recalculating if needed. */ - storage.eventHandler.listenToEvent('Daily File Loaded', plotter.onDailyFileLoaded) - /* Lets load now this plotter panels. */ - productPlotter.panels = [] + /* Let the Plotter listen to the event of Cursor Files loaded, so that it can react recalculating if needed. */ + plotter.onDailyFileLoadedPlotterEventsSubscriptionId = storage.eventHandler.listenToEvent('Daily File Loaded', plotter.onDailyFileLoaded) + /* Lets load now this plotter panels. */ + connector.panels = [] /* Here is where we instantiate the legacy panels */ - for (let i = 0; i < pLayer.product.plotter.module.panels.length; i++) { - let panelConfig = pLayer.product.plotter.module.panels[i] + for (let i = 0; i < plotterModule.panels.length; i++) { + let panelConfig = plotterModule.panels[i] let parameters = { - dataMine: pLayer.product.plotter.dataMine, - plotterCodeName: pLayer.product.plotter.codeName, - moduleCodeName: pLayer.product.plotter.moduleName, + dataMine: layer.product.plotter.dataMine, + plotterCodeName: layer.product.plotter.codeName, + moduleCodeName: layer.product.plotter.moduleName, panelCodeName: panelConfig.codeName } - let panelOwner = exchange + ' ' + market.quotedAsset + '/' + market.baseAsset - let plotterPanelHandle = canvas.panelsSpace.createNewPanel('Plotter Panel', parameters, panelOwner, pLayer.session) - let plotterPanel = canvas.panelsSpace.getPanel(plotterPanelHandle, panelOwner) + + let plotterPanelHandle = canvas.panelsSpace.createNewPanel('Plotter Panel', parameters, layer.payload.node.id, layer.session) + let plotterPanel = canvas.panelsSpace.getPanel(plotterPanelHandle, layer.payload.node.id) /* Connect Panel to the Plotter via an Event. */ if (panelConfig.event !== undefined) { - productPlotter.plotter.container.eventHandler.listenToEvent(panelConfig.event, plotterPanel.onEventRaised) + connector.plotter.onRecordChangeEventsSubscriptionId = connector.plotter.container.eventHandler.listenToEvent(panelConfig.event, plotterPanel.onEventRaised) } - productPlotter.panels.push(plotterPanelHandle) + connector.panels.push(plotterPanelHandle) } /* Here we instantiate the UI Defined Panels. */ - if (productDefinition !== undefined) { - for (let i = 0; i < productDefinition.referenceParent.panels.length; i++) { - let panel = productDefinition.referenceParent.panels[i] + if (product !== undefined) { + for (let i = 0; i < product.referenceParent.panels.length; i++) { + let panel = product.referenceParent.panels[i] let parameters = { - dataMine: pLayer.product.plotter.dataMine, - plotterCodeName: pLayer.product.plotter.codeName, - moduleCodeName: pLayer.product.plotter.moduleName, + dataMine: layer.product.plotter.dataMine, + plotterCodeName: layer.product.plotter.codeName, + moduleCodeName: layer.product.plotter.moduleName, panelCodeName: panel.id } - let panelOwner = exchange + ' ' + market.quotedAsset + '/' + market.baseAsset - let plotterPanelHandle = canvas.panelsSpace.createNewPanel('Plotter Panel', parameters, panelOwner, pLayer.session, panel) - let plotterPanel = canvas.panelsSpace.getPanel(plotterPanelHandle, panelOwner) + + let plotterPanelHandle = canvas.panelsSpace.createNewPanel('Plotter Panel', parameters, layer.payload.node.id, layer.session, panel) + let plotterPanel = canvas.panelsSpace.getPanel(plotterPanelHandle, layer.payload.node.id) /* Connect Panel to the Plotter via an Event. */ - productPlotter.plotter.container.eventHandler.listenToEvent('Current Record Changed', plotterPanel.onRecordChange) - productPlotter.panels.push(plotterPanelHandle) + connector.plotter.onRecordChangeEventsSubscriptionId = connector.plotter.container.eventHandler.listenToEvent('Current Record Changed', plotterPanel.onRecordChange) + connector.panels.push(plotterPanelHandle) } } - productPlotters.push(productPlotter) + connectors.push(connector) } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] initializeProductPlotter -> onProductStorageInitialized -> onPlotterInizialized -> err = ' + err.stack) } + if (ERROR_LOG === true) { logger.write('[ERROR] initializePlotter -> onProductStorageInitialized -> onPlotterInizialized -> err = ' + err.stack) } } } } } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] initializeProductPlotter -> onProductStorageInitialized -> err = ' + err.stack) } + if (ERROR_LOG === true) { logger.write('[ERROR] initializePlotter -> onProductStorageInitialized -> err = ' + err.stack) } } } } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] initializeProductPlotter -> err = ' + err.stack) } + if (ERROR_LOG === true) { logger.write('[ERROR] initializePlotter -> err = ' + err.stack) } } } - function onLayerStatusChanged (pLayer) { - if (pLayer.status === PRODUCT_CARD_STATUS.LOADING) { + function onLayerStatusChanged (layer) { + if (layer.status === PRODUCT_CARD_STATUS.LOADING) { /* Lets see if we can find the Plotter of this card on our Active Plotters list, other wise we will initialize it */ let found = false - for (let i = 0; i < productPlotters.length; i++) { - if (productPlotters[i].layer.code === pLayer.code) { + for (let i = 0; i < connectors.length; i++) { + let connector = connectors[i] + if (connector.layer.code === layer.code) { found = true } } if (found === false) { - initializeProductPlotter(pLayer, onProductPlotterInitialized) + initializePlotter(layer, onProductPlotterInitialized) function onProductPlotterInitialized (err) { /* There is no policy yet of what to do if this fails. */ } } } - if (pLayer.status === PRODUCT_CARD_STATUS.OFF) { + if (layer.status === PRODUCT_CARD_STATUS.OFF) { /* If the plotter of this card is not on our Active Plotters list, then we remove it. */ - for (let i = 0; i < productPlotters.length; i++) { - if (productPlotters[i].layer.code === pLayer.code) { + for (let i = 0; i < connectors.length; i++) { + let connector = connectors[i] + if (connector.layer.code === layer.code) { /* Then the panels. */ - for (let j = 0; j < productPlotters[i].panels.length; j++) { - canvas.panelsSpace.destroyPanel(productPlotters[i].panels[j]) + for (let j = 0; j < connector.panels.length; j++) { + canvas.panelsSpace.destroyPanel(connector.panels[j]) } /* Finally the Storage Objects */ - if (productPlotters[i].plotter.finalize !== undefined) { - productPlotters[i].plotter.container.finalize() - productPlotters[i].plotter.finalize() + if (connector.plotter.finalize !== undefined) { + connector.plotter.container.eventHandler.stopListening(connector.plotter.onRecordChangeEventsSubscriptionId) + connector.plotter.container.finalize() + connector.plotter.finalize() } - productPlotters[i].storage.finalize() - productPlotters.splice(i, 1) // Delete item from array. + finalizeStorage(connector.storage) + connectors.splice(i, 1) // Delete item from array. return // We already found the product woth changes and processed it. } } @@ -266,29 +287,29 @@ function newPlottersManager () { function setTimeFrame (pTimeFrame) { timeFrame = pTimeFrame - for (let i = 0; i < productPlotters.length; i++) { - let productPlotter = productPlotters[i] - productPlotter.layer.setTimeFrame(timeFrame) - productPlotter.storage.setTimeFrame(timeFrame) - productPlotter.plotter.setTimeFrame(timeFrame) + for (let i = 0; i < connectors.length; i++) { + let connector = connectors[i] + connector.layer.setTimeFrame(timeFrame) + connector.storage.setTimeFrame(timeFrame) + connector.plotter.setTimeFrame(timeFrame) } } function setDatetime (pDatetime) { datetime = pDatetime - for (let i = 0; i < productPlotters.length; i++) { - let productPlotter = productPlotters[i] - productPlotter.layer.setDatetime(pDatetime) - productPlotter.storage.setDatetime(pDatetime) - productPlotter.plotter.setDatetime(pDatetime) + for (let i = 0; i < connectors.length; i++) { + let connector = connectors[i] + connector.layer.setDatetime(pDatetime) + connector.storage.setDatetime(pDatetime) + connector.plotter.setDatetime(pDatetime) } } function positionAtDatetime (pDatetime) { - for (let i = 0; i < productPlotters.length; i++) { - let productPlotter = productPlotters[i] - if (productPlotter.plotter.positionAtDatetime !== undefined) { - productPlotter.plotter.positionAtDatetime(pDatetime) + for (let i = 0; i < connectors.length; i++) { + let connector = connectors[i] + if (connector.plotter.positionAtDatetime !== undefined) { + connector.plotter.positionAtDatetime(pDatetime) } } } @@ -297,11 +318,11 @@ function newPlottersManager () { } function draw () { - if (productPlotters === undefined) { return } // We need to wait + if (connectors === undefined) { return } // We need to wait /* First the Product Plotters. */ - for (let i = 0; i < productPlotters.length; i++) { - let productPlotter = productPlotters[i] - productPlotter.plotter.draw() + for (let i = 0; i < connectors.length; i++) { + let connector = connectors[i] + connector.plotter.draw() } } } diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 788aae461..4bd027f1e 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -33,9 +33,6 @@ function newTimelineChart () { let layersPanel - let exchange = DEFAULT_EXCHANGE - let market = DEFAULT_MARKET - let layersPanelHandle let onOffsetChangedEventSuscriptionId @@ -143,11 +140,10 @@ function newTimelineChart () { } function initializeLayersManager () { - let panelOwner = exchange + ' ' + market.quotedAsset + '/' + market.baseAsset - layersPanelHandle = canvas.panelsSpace.createNewPanel('Layers Panel', undefined, panelOwner) - thisObject.layersManager = canvas.panelsSpace.getPanel(layersPanelHandle, panelOwner) - thisObject.layersManager.initialize(exchange, market) + layersPanelHandle = canvas.panelsSpace.createNewPanel('Layers Panel', undefined, thisObject.payload.node.id) + thisObject.layersManager = canvas.panelsSpace.getPanel(layersPanelHandle, thisObject.payload.node.id) thisObject.layersManager.payload = thisObject.payload.node.layersManager.payload + thisObject.layersManager.initialize() /* Initialize the Plotter Manager */ thisObject.plotterManager = newPlottersManager() @@ -381,7 +377,7 @@ function newTimelineChart () { function drawBackground () { if (thisObject.container.frame.isInViewPort()) { if (window.CHART_ON_FOCUS === '') { - window.CHART_ON_FOCUS = exchange + ' ' + market.quotedAsset + '/' + market.baseAsset + window.CHART_ON_FOCUS = thisObject.payload.node.id } drawChartsBackground() if (thisObject.plotterManager !== undefined) { diff --git a/FloatingSpace/UiObjectTitle.js b/FloatingSpace/UiObjectTitle.js index 6841ad5de..49e4c153c 100644 --- a/FloatingSpace/UiObjectTitle.js +++ b/FloatingSpace/UiObjectTitle.js @@ -101,7 +101,7 @@ function newUiObjectTitle () { } } thisObject.payload.title = nodeToUse.payload.title - thisObject.payload.name = thisObject.payload.node.name + thisObject.payload.node.name = nodeToUse.payload.node.name title = trimTitle(thisObject.payload.title) } diff --git a/Globals.js b/Globals.js index f6db156ae..dcb2e5ddf 100644 --- a/Globals.js +++ b/Globals.js @@ -1,7 +1,6 @@ /* User Interface Colors */ -const STORAGE_PROVIDER = 'AAWeb'; const CANVAS_APP_NAME = 'Canvas App' const SUPPORTED_EXCHANGES = ["Poloniex"]; diff --git a/Panels/Layer.js b/Panels/Layer.js index b43fafc9f..60e67e3dd 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -7,12 +7,9 @@ function newLayer () { let thisObject = { container: undefined, status: PRODUCT_CARD_STATUS.OFF, - dataMine: undefined, - bot: undefined, - product: undefined, - code: undefined, fitFunction: undefined, payload: undefined, + definition: undefined, draw: draw, turnOff: turnOff, turnOn: turnOn, @@ -74,6 +71,7 @@ function newLayer () { thisObject.eventHandler = newEventHandler() let imagesLoaded = 0 + let onMouseClickEventSuscriptionId return thisObject @@ -83,12 +81,9 @@ function newLayer () { thisObject.container = undefined thisObject.eventHandler = undefined thisObject.status = undefined - thisObject.dataMine = undefined - thisObject.bot = undefined - thisObject.product = undefined - thisObject.code = undefined thisObject.fitFunction = undefined thisObject.payload = undefined + thisObject.definition = undefined timeFrame = undefined datetime = undefined @@ -105,32 +100,21 @@ function newLayer () { dailyFileProgressBar = undefined singleFileProgressBar = undefined fileSequenceProgressBar = undefined + + thisObject.container.eventHandler.stopListening(onMouseClickEventSuscriptionId) } function initialize () { /* Create this objects continer */ try { thisObject.container = newContainer() - thisObject.container.initialize(MODULE_NAME + thisObject.code) + thisObject.container.initialize(MODULE_NAME + ' ' + thisObject.payload.node.id) thisObject.container.isDraggeable = false thisObject.container.isClickeable = true - /* Add information that will later be needed. */ - - let dataMine = ecosystem.getDataMine(thisObject.product.plotter.dataMine) - let plotter - if (dataMine !== undefined) { - plotter = ecosystem.getPlotter(dataMine, thisObject.product.plotter.codeName) - } - - if (plotter !== undefined) { - let plotterModule = ecosystem.getPlotterModule(plotter, thisObject.product.plotter.moduleName) - thisObject.product.plotter.module = plotterModule - } - /* Lets set the basic dimensions of this thisObject. */ - var position = { + let position = { x: 0, y: 0 } @@ -139,9 +123,44 @@ function newLayer () { thisObject.container.frame.width = UI_PANEL.WIDTH.LARGE thisObject.container.frame.height = 100 - /* We retrieve the locally stored status of the Product */ + let functionLibraryProtocolNode = newProtocolNode() + let lightingPath = + '->Layer->' + + 'Data Product->Single Market Data->Market->' + + 'Market Base Asset->Asset->' + + 'Market Quoted Asset->Asset->' + + 'Exchange Markets->Crypto Exchange->' + + 'Product Definition->' + + 'Sensor Bot->Indicator Bot->Trading Bot->' + + 'Data Mine->' + + 'Dataset Definition->' + + 'Record Definition->Record Property->Formula->' + + 'Data Building Procedure->Procedure Loop->Javascript Code->Procedure Initialization->Javascript Code->' + + 'Calculations Procedure->Procedure Loop->Javascript Code->Procedure Initialization->Javascript Code->' + + 'Plotter Module->Shapes->' + + 'Chart Points->Point->Point Formula->' + + 'Polygon->Polygon Body->Style->Style Condition->Style->' + + 'Polygon Border->Style->Style Condition->Style->' + + 'Polygon Vertex->Point->' + + 'Plotter Panel->Javascript Code->Panel Data->Data Formula->' + thisObject.definition = functionLibraryProtocolNode.getProtocolNode(thisObject.payload.node, false, true, true, false, false, lightingPath) - let storedValue = window.localStorage.getItem(thisObject.code) + /* Here we validate that we have all the needed information */ + if (thisObject.definition.referenceParent === undefined) { return } + if (thisObject.definition.referenceParent.parentNode === undefined) { return } + if (thisObject.definition.referenceParent.parentNode.referenceParent === undefined) { return } + if (thisObject.definition.referenceParent.parentNode.referenceParent.referenceParent === undefined) { return } + if (thisObject.definition.referenceParent.parentNode.referenceParent.referenceParent.referenceParent === undefined) { return } + if (thisObject.definition.referenceParent.parentNode.referenceParent.baseAsset === undefined) { return } + if (thisObject.definition.referenceParent.parentNode.referenceParent.baseAsset.referenceParent === undefined) { return } + if (thisObject.definition.referenceParent.parentNode.referenceParent.quotedAsset === undefined) { return } + if (thisObject.definition.referenceParent.parentNode.referenceParent.quotedAsset.referenceParent === undefined) { return } + if (thisObject.definition.referenceParent.referenceParent === undefined) { return } + if (thisObject.definition.referenceParent.referenceParent.parentNode === undefined) { return } + if (thisObject.definition.referenceParent.referenceParent.parentNode.parentNode === undefined) { return } + + /* We retrieve the locally stored status of the Product */ + let storedValue = window.localStorage.getItem(thisObject.payload.node.id) if (storedValue !== null) { thisObject.status = storedValue @@ -150,56 +169,27 @@ function newLayer () { changeStatusTo(PRODUCT_CARD_STATUS.LOADING) } } else { - /* - - This happens the first time the app is run on a new browser. - - We will start with all product off, except for the candles chart, since something needs to be shown and allow the user to position themselves - on the timeline. - - For the time being, we will hard-code the name of the bot we will turn on by default, since we dont see that change in the near future. - - */ - - const DEFAULT_ON_PRODUCT = 'Poloniex-BTC/USDT-AAMasters-AAOlivia-Candles' - - if (thisObject.code === DEFAULT_ON_PRODUCT) { - changeStatusTo(PRODUCT_CARD_STATUS.LOADING) - } else { - changeStatusTo(PRODUCT_CARD_STATUS.OFF) - } + changeStatusTo(PRODUCT_CARD_STATUS.OFF) } /* Lets listen to our own events to react when we have a Mouse Click */ - - thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick) + onMouseClickEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick) } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err.stack) } } } function getContainer (point) { - var container - - /* First we check if this point is inside this space. */ - if (thisObject.container.frame.isThisPointHere(point, true) === true) { return thisObject.container - } else { - /* This point does not belong to this space. */ - - return undefined } } function setDatetime (pDatetime) { - /* - - When the datetime changes from one day to another, this forces cursors to potentially load more files, thus we reset this counter and - get ready to receive events on files loaded. - - */ - + /* + When the datetime changes from one day to another, this forces cursors to potentially load more files, thus we reset this counter and + get ready to receive events on files loaded. + */ let currentDate = Math.trunc(datetime.valueOf() / ONE_DAY_IN_MILISECONDS) let newDate = Math.trunc(pDatetime.valueOf() / ONE_DAY_IN_MILISECONDS) @@ -213,13 +203,10 @@ function newLayer () { } function setTimeFrame (pTimeFrame) { - /* - - When the time period below or equal to 1 hour changes, this forces cursors to potentially load more files, thus we reset this counter and - get ready to receive events on files loaded. - - */ - + /* + When the time period below or equal to 1 hour changes, this forces cursors to potentially load more files, thus we reset this counter and + get ready to receive events on files loaded. + */ if (timeFrame !== pTimeFrame) { timeFrame = pTimeFrame @@ -337,27 +324,7 @@ function newLayer () { break } - let label = thisObject.product.displayName - - if (thisObject.session !== undefined) { - const MAX_LABEL_LENGTH = 20 - if (thisObject.session.name.length > MAX_LABEL_LENGTH) { - label = thisObject.session.name.substring(0, MAX_LABEL_LENGTH) + '...' + ' - ' + label - } else { - label = thisObject.session.name + ' - ' + label - } - } - - let label1 = label - let label2 = 'ON' - let label3 = '' - - let icon1 = canvas.designerSpace.iconCollection.get('oscillator') - let icon2 = canvas.designerSpace.iconCollection.get('poloniex') // canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.type) - - let backgroundColor = UI_COLOR.BLACK - - drawScaleDisplay(label1, label2, label3, 0, 0, 0, icon1, icon2, thisObject.container, backgroundColor) + drawLayerDisplay() /* ------------------- Progress Bars -------------------------- */ @@ -569,4 +536,125 @@ function newLayer () { browserCanvasContext.setLineDash([2, 5]) browserCanvasContext.lineWidth = 10 } + + function drawLayerDisplay () { + const MAX_LABEL_LENGTH = 20 + let label = thisObject.payload.node.name + if (label > MAX_LABEL_LENGTH) { + label = label.substring(0, MAX_LABEL_LENGTH) + } + + let label1 = label + let label2 = thisObject.status + let label3 = '' + + let icon1 = canvas.designerSpace.iconCollection.get('oscillator') + let icon2 = canvas.designerSpace.iconCollection.get('poloniex') // canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.type) + + let backgroundColor = UI_COLOR.BLACK + + let fontSize1 = 10 + let fontSize2 = 20 + let fontSize3 = 10 + + const RED_LINE_HIGHT = 4 + const OPACITY = 1 + + let params = { + cornerRadius: 15, + lineWidth: 2, + container: thisObject.container, + borderColor: UI_COLOR.RUSTED_RED, + castShadow: false, + backgroundColor: backgroundColor, + opacity: OPACITY + } + + roundedCornersBackground(params) + + /* Place the Text */ + + label1 = label1.substring(0, 18) + let xOffset1 = label1.length * fontSize1 * FONT_ASPECT_RATIO + + let labelPoint1 = { + x: thisObject.container.frame.width * 1 / 2 - xOffset1 / 2 - 5, + y: thisObject.container.frame.height * 4 / 5 + } + + labelPoint1 = thisObject.container.frame.frameThisPoint(labelPoint1) + let x = labelPoint1.x + labelPoint1.x = x + + browserCanvasContext.font = fontSize1 + 'px ' + UI_FONT.PRIMARY + browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)' + + browserCanvasContext.fillText(label1, labelPoint1.x, labelPoint1.y) + + label2 = label2.substring(0, 20) + let xOffset2 = label2.length * fontSize2 * FONT_ASPECT_RATIO + + let labelPoint2 = { + x: thisObject.container.frame.width * 1 / 2 - xOffset2 / 2, + y: thisObject.container.frame.height * 2 / 5 + } + + labelPoint2 = thisObject.container.frame.frameThisPoint(labelPoint2) + + browserCanvasContext.font = fontSize2 + 'px ' + UI_FONT.PRIMARY + browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)' + + browserCanvasContext.fillText(label2, labelPoint2.x, labelPoint2.y) + + label3 = label3.substring(0, 20) + let xOffset3 = label3.length * fontSize3 * FONT_ASPECT_RATIO + + let labelPoint3 = { + x: thisObject.container.frame.width * 1 / 2 - xOffset3 / 2, + y: thisObject.container.frame.height * 3 / 5 + } + + labelPoint3 = thisObject.container.frame.frameThisPoint(labelPoint3) + + browserCanvasContext.font = fontSize3 + 'px ' + UI_FONT.PRIMARY + browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)' + + browserCanvasContext.fillText(label3, labelPoint3.x, labelPoint3.y) + + /* Images */ + + if (icon1 !== undefined) { + if (icon1.canDrawIcon === true) { + let imageSize = 40 + let imagePosition = { + x: thisObject.container.frame.width * 1 / 8 - imageSize / 2, + y: thisObject.container.frame.height / 2 - imageSize / 2 + } + + imagePosition = thisObject.container.frame.frameThisPoint(imagePosition) + browserCanvasContext.drawImage( + icon1, imagePosition.x, + imagePosition.y, + imageSize, + imageSize) + } + } + + if (icon2 !== undefined) { + if (icon2.canDrawIcon === true) { + let imageSize = 40 + let imagePosition = { + x: thisObject.container.frame.width * 7 / 8 - imageSize / 2, + y: thisObject.container.frame.height / 2 - imageSize / 2 + } + + imagePosition = thisObject.container.frame.frameThisPoint(imagePosition) + browserCanvasContext.drawImage( + icon2, imagePosition.x, + imagePosition.y, + imageSize, + imageSize) + } + } + } } diff --git a/Panels/LayersPanel.js b/Panels/LayersPanel.js index 87794650d..2f3f45098 100644 --- a/Panels/LayersPanel.js +++ b/Panels/LayersPanel.js @@ -27,9 +27,6 @@ function newProductsPanel () { const LAYER_SEPARATION = 5 let panelTabButton - let exchange - let market - let onMouseWheelEventSuscriptionId return thisObject @@ -47,11 +44,8 @@ function newProductsPanel () { thisObject = undefined } - function initialize (pExchange, pMarket) { - exchange = pExchange - market = pMarket - - thisObject.container.name = 'Layers @ ' + exchange + ' ' + market.quotedAsset + '/' + market.baseAsset + function initialize () { + thisObject.container.name = thisObject.payload.node.name thisObject.container.frame.containerName = thisObject.container.name thisObject.container.frame.width = UI_PANEL.WIDTH.LARGE thisObject.container.frame.height = UI_PANEL.HEIGHT.LARGE * 1.5 // viewPort.visibleArea.bottomLeft.y - viewPort.visibleArea.topLeft.y // UI_PANEL.HEIGHT.LARGE; @@ -249,7 +243,7 @@ function newProductsPanel () { let found = removeFromLocalLayers(layerNode.id) if (found !== true) { - layer = addLayer(layerNode.id) + layer = addLayer(layerNode) onLayerStatusChanged(layer) } } @@ -270,10 +264,10 @@ function newProductsPanel () { } } - function removeFromLocalLayers (code) { + function removeFromLocalLayers (id) { for (let i = 0; i < localLayers.length; i++) { let layer = localLayers[i] - if (layer.code === code) { + if (layer.payload.node.id === id) { thisObject.layers.push(layer) localLayers.splice(i, 1) return true @@ -284,7 +278,7 @@ function newProductsPanel () { function turnOffUnusedLayers () { for (let i = 0; i < localLayers.length; i++) { let layer = localLayers[i] - removeLayer(layer.code) + removeLayer(layer.payload.node.id) } } } diff --git a/Plotter.js b/Plotter.js index 986d26bc9..cb4dfb45d 100644 --- a/Plotter.js +++ b/Plotter.js @@ -96,7 +96,7 @@ function newPlotter () { } } - function initialize (pStorage, pExchange, pMarket, pDatetime, pTimeFrame, callBackFunction, pProductDefinition) { + function initialize (pStorage, pDatetime, pTimeFrame, callBackFunction, pProductDefinition) { try { /* Store the information received. */ marketFiles = pStorage.marketFiles[0] diff --git a/ProductStorage.js b/ProductStorage.js index 1b3323738..3feff668b 100644 --- a/ProductStorage.js +++ b/ProductStorage.js @@ -1,5 +1,5 @@  -function newProductStorage (pName) { +function newProductStorage (name) { const MODULE_NAME = 'Product Storage' const ERROR_LOG = true const logger = newWebDebugLog() @@ -40,7 +40,7 @@ function newProductStorage (pName) { /* We name the event Handler to easy debugging. */ - thisObject.eventHandler.name = 'Storage-' + pName + thisObject.eventHandler.name = 'Storage-' + name let datetime let timeFrame @@ -74,7 +74,7 @@ function newProductStorage (pName) { } } - function initialize (pdataMine, pBot, pSession, pProduct, pExchange, pMarket, pDatetime, pTimeFrame, callBackFunction) { + function initialize (dataMine, bot, session, product, exchange, market, pDatetime, pTimeFrame, callBackFunction) { try { datetime = pDatetime timeFrame = pTimeFrame @@ -82,15 +82,15 @@ function newProductStorage (pName) { let dataSetsToLoad = 0 let dataSetsLoaded = 0 - for (let i = 0; i < pProduct.dataSets.length; i++) { - let thisSet = pProduct.dataSets[i] + for (let i = 0; i < product.datasets.length; i++) { + let dataset = product.datasets[i] - switch (thisSet.type) { + switch (dataset.type) { case 'Market Files': { dataSetsToLoad++ let marketFiles = newMarketFiles() - marketFiles.initialize(pdataMine, pBot, pSession, pProduct, thisSet, pExchange, pMarket, onMarketFileReady) + marketFiles.initialize(dataMine, bot, session, product, dataset, exchange, market, onMarketFileReady) thisObject.marketFiles.push(marketFiles) } break @@ -99,7 +99,7 @@ function newProductStorage (pName) { dataSetsToLoad++ let dailyFiles = newDailyFiles() - dailyFiles.initialize(pdataMine, pBot, pSession, pProduct, thisSet, pExchange, pMarket, pDatetime, pTimeFrame, onDailyFileReady) + dailyFiles.initialize(dataMine, bot, session, product, dataset, exchange, market, pDatetime, pTimeFrame, onDailyFileReady) thisObject.dailyFiles.push(dailyFiles) } break @@ -108,7 +108,7 @@ function newProductStorage (pName) { dataSetsToLoad++ let singleFile = newSingleFile() - singleFile.initialize(pdataMine, pBot, pSession, pProduct, thisSet, pExchange, pMarket, onSingleFileReady) + singleFile.initialize(dataMine, bot, session, product, dataset, exchange, market, onSingleFileReady) thisObject.singleFile.push(singleFile) } break @@ -117,12 +117,12 @@ function newProductStorage (pName) { dataSetsToLoad++ let fileSequences = newFileSequence() - fileSequences.initialize(pdataMine, pBot, pSession, pProduct, thisSet, pExchange, pMarket, onFileSequenceReady) + fileSequences.initialize(dataMine, bot, session, product, dataset, exchange, market, onFileSequenceReady) thisObject.fileSequences.push(fileSequences) } break default: - if (ERROR_LOG === true) { logger.write('[WARN] initialize -> initialize -> dataset with no type defined. Data can not be retrieved. -> codeName = ' + thisSet.codeName) } + if (ERROR_LOG === true) { logger.write('[WARN] initialize -> initialize -> dataset with no type defined. Data can not be retrieved. -> codeName = ' + dataset.codeName) } } function onMarketFileReady (err, pCaller) { From 8d769cc9f78284c5de599f1f4e4dedcb21f4419a Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 14 Jan 2020 20:11:07 +0100 Subject: [PATCH 109/264] Bug fixed duplicating layers --- Panels/LayersPanel.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Panels/LayersPanel.js b/Panels/LayersPanel.js index 2f3f45098..992582eef 100644 --- a/Panels/LayersPanel.js +++ b/Panels/LayersPanel.js @@ -154,8 +154,8 @@ function newProductsPanel () { } } - function onLayerStatusChanged (pLayer) { - thisObject.container.eventHandler.raiseEvent('Layer Status Changed', pLayer) + function onLayerStatusChanged (layer) { + thisObject.container.eventHandler.raiseEvent('Layer Status Changed', layer) } function getLoadingLayers () { @@ -255,11 +255,10 @@ function newProductsPanel () { function removeNext () { for (let i = 0; i < thisObject.layers.length; i++) { let layer = thisObject.layers[i] - if (layer.session !== undefined) { - thisObject.layers.splice(i, 1) - localLayers.push(layer) - removeNext() - } + + thisObject.layers.splice(i, 1) + localLayers.push(layer) + removeNext() } } } From ff80ca67b1ac1aa57839aff56dcda37df2607f78 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 14 Jan 2020 21:06:31 +0100 Subject: [PATCH 110/264] Exchange Icon set --- Panels/Layer.js | 43 ++++++++++++++++++++++++++++++------------- Panels/LayersPanel.js | 4 ++-- 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/Panels/Layer.js b/Panels/Layer.js index 60e67e3dd..d1fe5c755 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -120,8 +120,8 @@ function newLayer () { } thisObject.container.frame.position = position - thisObject.container.frame.width = UI_PANEL.WIDTH.LARGE - thisObject.container.frame.height = 100 + thisObject.container.frame.width = UI_PANEL.WIDTH.LARGE * 1.5 + thisObject.container.frame.height = 60 let functionLibraryProtocolNode = newProtocolNode() let lightingPath = @@ -538,18 +538,35 @@ function newLayer () { } function drawLayerDisplay () { - const MAX_LABEL_LENGTH = 20 - let label = thisObject.payload.node.name - if (label > MAX_LABEL_LENGTH) { - label = label.substring(0, MAX_LABEL_LENGTH) + let baseAsset = thisObject.definition.referenceParent.parentNode.referenceParent.baseAsset.referenceParent.code.codeName + let quotedAsset = thisObject.definition.referenceParent.parentNode.referenceParent.quotedAsset.referenceParent.code.codeName + let market = baseAsset + '/' + quotedAsset + let exchange = thisObject.definition.referenceParent.parentNode.referenceParent.parentNode.parentNode + let plotterModule = thisObject.definition.referenceParent.referenceParent.referenceParent + + let label1 = thisObject.status.toUpperCase() + let label2 = thisObject.payload.node.name.substring(0, 20) + let label3 = exchange.name.substring(0, 15) + ' - ' + market + + let icon1 + let nodeDefinition = APP_SCHEMA_MAP.get(exchange.type) + let iconName + for (let i = 0; i < nodeDefinition.alternativeIcons.length; i++) { + alternativeIcon = nodeDefinition.alternativeIcons[i] + if (alternativeIcon.codeName === exchange.code.codeName) { + iconName = alternativeIcon.iconName + } + } + if (iconName !== undefined) { + icon1 = canvas.designerSpace.iconCollection.get(iconName) + } else { + icon1 = canvas.designerSpace.iconCollection.get(nodeDefinition.icon) } - let label1 = label - let label2 = thisObject.status - let label3 = '' - - let icon1 = canvas.designerSpace.iconCollection.get('oscillator') - let icon2 = canvas.designerSpace.iconCollection.get('poloniex') // canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.type) + let icon2 + if (plotterModule.code.icon !== undefined) { + icon2 = canvas.designerSpace.iconCollection.get(plotterModule.code.icon) + } let backgroundColor = UI_COLOR.BLACK @@ -592,7 +609,7 @@ function newLayer () { browserCanvasContext.fillText(label1, labelPoint1.x, labelPoint1.y) label2 = label2.substring(0, 20) - let xOffset2 = label2.length * fontSize2 * FONT_ASPECT_RATIO + let xOffset2 = label2.length * fontSize2 * FONT_ASPECT_RATIO + 15 let labelPoint2 = { x: thisObject.container.frame.width * 1 / 2 - xOffset2 / 2, diff --git a/Panels/LayersPanel.js b/Panels/LayersPanel.js index 992582eef..74e15dec9 100644 --- a/Panels/LayersPanel.js +++ b/Panels/LayersPanel.js @@ -47,8 +47,8 @@ function newProductsPanel () { function initialize () { thisObject.container.name = thisObject.payload.node.name thisObject.container.frame.containerName = thisObject.container.name - thisObject.container.frame.width = UI_PANEL.WIDTH.LARGE - thisObject.container.frame.height = UI_PANEL.HEIGHT.LARGE * 1.5 // viewPort.visibleArea.bottomLeft.y - viewPort.visibleArea.topLeft.y // UI_PANEL.HEIGHT.LARGE; + thisObject.container.frame.width = UI_PANEL.WIDTH.LARGE * 1.5 + thisObject.container.frame.height = UI_PANEL.HEIGHT.LARGE // viewPort.visibleArea.bottomLeft.y - viewPort.visibleArea.topLeft.y // UI_PANEL.HEIGHT.LARGE; let position = { x: viewPort.visibleArea.topLeft.x, From 9ab153762bc02c305f55e85c704340a7fd7a6388 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 14 Jan 2020 21:28:19 +0100 Subject: [PATCH 111/264] Assets Icons apperaring --- Globals.js | 2 + Panels/Layer.js | 97 +++++++++++++++++++++---------------------- Panels/LayersPanel.js | 2 +- 3 files changed, 51 insertions(+), 50 deletions(-) diff --git a/Globals.js b/Globals.js index dcb2e5ddf..2e9f15a6c 100644 --- a/Globals.js +++ b/Globals.js @@ -57,11 +57,13 @@ UI_PANEL = { WIDTH: { SMALL: 100, NORMAL: 150, + MEDIUM: 200, LARGE: 250, X_LARGE: 350 }, HEIGHT: { SMALL: 65, + MEDIUM: 90, NORMAL: 300, LARGE: 450 } diff --git a/Panels/Layer.js b/Panels/Layer.js index d1fe5c755..130d2a800 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -120,8 +120,8 @@ function newLayer () { } thisObject.container.frame.position = position - thisObject.container.frame.width = UI_PANEL.WIDTH.LARGE * 1.5 - thisObject.container.frame.height = 60 + thisObject.container.frame.width = UI_PANEL.WIDTH.MEDIUM + thisObject.container.frame.height = 90 let functionLibraryProtocolNode = newProtocolNode() let lightingPath = @@ -538,9 +538,9 @@ function newLayer () { } function drawLayerDisplay () { - let baseAsset = thisObject.definition.referenceParent.parentNode.referenceParent.baseAsset.referenceParent.code.codeName - let quotedAsset = thisObject.definition.referenceParent.parentNode.referenceParent.quotedAsset.referenceParent.code.codeName - let market = baseAsset + '/' + quotedAsset + let baseAsset = thisObject.definition.referenceParent.parentNode.referenceParent.baseAsset.referenceParent + let quotedAsset = thisObject.definition.referenceParent.parentNode.referenceParent.quotedAsset.referenceParent + let market = baseAsset.code.codeName + '/' + quotedAsset.code.codeName let exchange = thisObject.definition.referenceParent.parentNode.referenceParent.parentNode.parentNode let plotterModule = thisObject.definition.referenceParent.referenceParent.referenceParent @@ -548,26 +548,35 @@ function newLayer () { let label2 = thisObject.payload.node.name.substring(0, 20) let label3 = exchange.name.substring(0, 15) + ' - ' + market - let icon1 - let nodeDefinition = APP_SCHEMA_MAP.get(exchange.type) - let iconName - for (let i = 0; i < nodeDefinition.alternativeIcons.length; i++) { - alternativeIcon = nodeDefinition.alternativeIcons[i] - if (alternativeIcon.codeName === exchange.code.codeName) { - iconName = alternativeIcon.iconName - } - } - if (iconName !== undefined) { - icon1 = canvas.designerSpace.iconCollection.get(iconName) - } else { - icon1 = canvas.designerSpace.iconCollection.get(nodeDefinition.icon) - } + let icon1 = getIcon(exchange) let icon2 if (plotterModule.code.icon !== undefined) { icon2 = canvas.designerSpace.iconCollection.get(plotterModule.code.icon) } + let icon3 = getIcon(baseAsset) + let icon4 = getIcon(quotedAsset) + + function getIcon (node) { + let nodeDefinition = APP_SCHEMA_MAP.get(node.type) + let iconName + if (nodeDefinition.alternativeIcons !== undefined) { + for (let i = 0; i < nodeDefinition.alternativeIcons.length; i++) { + alternativeIcon = nodeDefinition.alternativeIcons[i] + if (alternativeIcon.codeName === node.code.codeName) { + iconName = alternativeIcon.iconName + } + } + } + if (iconName !== undefined) { + icon = canvas.designerSpace.iconCollection.get(iconName) + } else { + icon = canvas.designerSpace.iconCollection.get(nodeDefinition.icon) + } + return icon + } + let backgroundColor = UI_COLOR.BLACK let fontSize1 = 10 @@ -640,37 +649,27 @@ function newLayer () { /* Images */ - if (icon1 !== undefined) { - if (icon1.canDrawIcon === true) { - let imageSize = 40 - let imagePosition = { - x: thisObject.container.frame.width * 1 / 8 - imageSize / 2, - y: thisObject.container.frame.height / 2 - imageSize / 2 + drawIcon(icon1, 1 / 8, 1 / 4) + drawIcon(icon2, 7 / 8, 1 / 4) + drawIcon(icon3, 1 / 8, 3 / 4) + drawIcon(icon4, 7 / 8, 3 / 4) + + function drawIcon (icon, xFactor, yFactor) { + if (icon !== undefined) { + if (icon.canDrawIcon === true) { + let imageSize = 40 + let imagePosition = { + x: thisObject.container.frame.width * xFactor - imageSize / 2, + y: thisObject.container.frame.height * yFactor - imageSize / 2 + } + + imagePosition = thisObject.container.frame.frameThisPoint(imagePosition) + browserCanvasContext.drawImage( + icon, imagePosition.x, + imagePosition.y, + imageSize, + imageSize) } - - imagePosition = thisObject.container.frame.frameThisPoint(imagePosition) - browserCanvasContext.drawImage( - icon1, imagePosition.x, - imagePosition.y, - imageSize, - imageSize) - } - } - - if (icon2 !== undefined) { - if (icon2.canDrawIcon === true) { - let imageSize = 40 - let imagePosition = { - x: thisObject.container.frame.width * 7 / 8 - imageSize / 2, - y: thisObject.container.frame.height / 2 - imageSize / 2 - } - - imagePosition = thisObject.container.frame.frameThisPoint(imagePosition) - browserCanvasContext.drawImage( - icon2, imagePosition.x, - imagePosition.y, - imageSize, - imageSize) } } } diff --git a/Panels/LayersPanel.js b/Panels/LayersPanel.js index 74e15dec9..aa3ace3b9 100644 --- a/Panels/LayersPanel.js +++ b/Panels/LayersPanel.js @@ -47,7 +47,7 @@ function newProductsPanel () { function initialize () { thisObject.container.name = thisObject.payload.node.name thisObject.container.frame.containerName = thisObject.container.name - thisObject.container.frame.width = UI_PANEL.WIDTH.LARGE * 1.5 + thisObject.container.frame.width = UI_PANEL.WIDTH.MEDIUM thisObject.container.frame.height = UI_PANEL.HEIGHT.LARGE // viewPort.visibleArea.bottomLeft.y - viewPort.visibleArea.topLeft.y // UI_PANEL.HEIGHT.LARGE; let position = { From f10a5597e3111be8e9c8a9cfb8bc36607dcfb557 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 14 Jan 2020 22:00:29 +0100 Subject: [PATCH 112/264] 2 lines for layer name --- Panels/Layer.js | 84 ++++++++++++++++++++----------------------------- 1 file changed, 34 insertions(+), 50 deletions(-) diff --git a/Panels/Layer.js b/Panels/Layer.js index 130d2a800..935cb24f9 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -544,9 +544,18 @@ function newLayer () { let exchange = thisObject.definition.referenceParent.parentNode.referenceParent.parentNode.parentNode let plotterModule = thisObject.definition.referenceParent.referenceParent.referenceParent - let label1 = thisObject.status.toUpperCase() - let label2 = thisObject.payload.node.name.substring(0, 20) + let labelArray = thisObject.payload.node.name.split(' ') + let label1 = labelArray[0] + let label2 = labelArray[1] let label3 = exchange.name.substring(0, 15) + ' - ' + market + let label4 = thisObject.status.toUpperCase() + + if (label1 !== undefined) { + label1 = label1.substring(0, 15) + } + if (label2 !== undefined) { + label2 = label2.substring(0, 15) + } let icon1 = getIcon(exchange) @@ -579,16 +588,12 @@ function newLayer () { let backgroundColor = UI_COLOR.BLACK - let fontSize1 = 10 - let fontSize2 = 20 - let fontSize3 = 10 - const RED_LINE_HIGHT = 4 const OPACITY = 1 let params = { - cornerRadius: 15, - lineWidth: 2, + cornerRadius: 0, + lineWidth: 1, container: thisObject.container, borderColor: UI_COLOR.RUSTED_RED, castShadow: false, @@ -598,55 +603,33 @@ function newLayer () { roundedCornersBackground(params) - /* Place the Text */ - - label1 = label1.substring(0, 18) - let xOffset1 = label1.length * fontSize1 * FONT_ASPECT_RATIO - - let labelPoint1 = { - x: thisObject.container.frame.width * 1 / 2 - xOffset1 / 2 - 5, - y: thisObject.container.frame.height * 4 / 5 + if (label2 !== undefined) { + drawLabel(label1, 1 / 2, 2 / 8, 16) + drawLabel(label2, 1 / 2, 4 / 8, 16) + } else { + drawLabel(label1, 1 / 2, 3 / 8, 20) } - labelPoint1 = thisObject.container.frame.frameThisPoint(labelPoint1) - let x = labelPoint1.x - labelPoint1.x = x + drawLabel(label3, 1 / 2, 6 / 8, 10) + drawLabel(label4, 1 / 2, 7 / 8, 10) - browserCanvasContext.font = fontSize1 + 'px ' + UI_FONT.PRIMARY - browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)' + function drawLabel (label, xFactor, yFactor, fontSize) { + if (label === undefined) { return } + let xOffset = label.length * fontSize * FONT_ASPECT_RATIO + 10 - browserCanvasContext.fillText(label1, labelPoint1.x, labelPoint1.y) + let labelPoint = { + x: thisObject.container.frame.width * xFactor - xOffset / 2, + y: thisObject.container.frame.height * yFactor + } - label2 = label2.substring(0, 20) - let xOffset2 = label2.length * fontSize2 * FONT_ASPECT_RATIO + 15 + labelPoint = thisObject.container.frame.frameThisPoint(labelPoint) - let labelPoint2 = { - x: thisObject.container.frame.width * 1 / 2 - xOffset2 / 2, - y: thisObject.container.frame.height * 2 / 5 + browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY + browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)' + + browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y) } - labelPoint2 = thisObject.container.frame.frameThisPoint(labelPoint2) - - browserCanvasContext.font = fontSize2 + 'px ' + UI_FONT.PRIMARY - browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)' - - browserCanvasContext.fillText(label2, labelPoint2.x, labelPoint2.y) - - label3 = label3.substring(0, 20) - let xOffset3 = label3.length * fontSize3 * FONT_ASPECT_RATIO - - let labelPoint3 = { - x: thisObject.container.frame.width * 1 / 2 - xOffset3 / 2, - y: thisObject.container.frame.height * 3 / 5 - } - - labelPoint3 = thisObject.container.frame.frameThisPoint(labelPoint3) - - browserCanvasContext.font = fontSize3 + 'px ' + UI_FONT.PRIMARY - browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)' - - browserCanvasContext.fillText(label3, labelPoint3.x, labelPoint3.y) - /* Images */ drawIcon(icon1, 1 / 8, 1 / 4) @@ -657,7 +640,7 @@ function newLayer () { function drawIcon (icon, xFactor, yFactor) { if (icon !== undefined) { if (icon.canDrawIcon === true) { - let imageSize = 40 + let imageSize = 20 let imagePosition = { x: thisObject.container.frame.width * xFactor - imageSize / 2, y: thisObject.container.frame.height * yFactor - imageSize / 2 @@ -674,3 +657,4 @@ function newLayer () { } } } + From 44ce2949b07c51c0c4655e57ddcfb320bded4027 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 15 Jan 2020 08:29:24 +0100 Subject: [PATCH 113/264] Bug Fixed --- ChartsSpace/PlottersManager.js | 2 +- Panels/Layer.js | 8 +++-- Panels/LayersPanel.js | 62 +++++++++++++++++++--------------- 3 files changed, 40 insertions(+), 32 deletions(-) diff --git a/ChartsSpace/PlottersManager.js b/ChartsSpace/PlottersManager.js index 1f0b5e082..62a090940 100644 --- a/ChartsSpace/PlottersManager.js +++ b/ChartsSpace/PlottersManager.js @@ -110,7 +110,7 @@ function newPlottersManager () { for (let i = 0; i < layer.definition.referenceParent.referenceParent.datasets.length; i++) { let dataset = layer.definition.referenceParent.referenceParent.datasets[i] - switch (dataset.type) { + switch (dataset.code.type) { case 'Market Files': { storage.onMarketFileLoadedLayerEventsSubscriptionId = storage.eventHandler.listenToEvent('Market File Loaded', layer.onMarketFileLoaded) } diff --git a/Panels/Layer.js b/Panels/Layer.js index 935cb24f9..2ac627e97 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -104,7 +104,7 @@ function newLayer () { thisObject.container.eventHandler.stopListening(onMouseClickEventSuscriptionId) } - function initialize () { + function initialize (callBackFunction) { /* Create this objects continer */ try { thisObject.container = newContainer() @@ -149,8 +149,8 @@ function newLayer () { if (thisObject.definition.referenceParent === undefined) { return } if (thisObject.definition.referenceParent.parentNode === undefined) { return } if (thisObject.definition.referenceParent.parentNode.referenceParent === undefined) { return } - if (thisObject.definition.referenceParent.parentNode.referenceParent.referenceParent === undefined) { return } - if (thisObject.definition.referenceParent.parentNode.referenceParent.referenceParent.referenceParent === undefined) { return } + if (thisObject.definition.referenceParent.parentNode.referenceParent.parentNode === undefined) { return } + if (thisObject.definition.referenceParent.parentNode.referenceParent.parentNode.parentNode === undefined) { return } if (thisObject.definition.referenceParent.parentNode.referenceParent.baseAsset === undefined) { return } if (thisObject.definition.referenceParent.parentNode.referenceParent.baseAsset.referenceParent === undefined) { return } if (thisObject.definition.referenceParent.parentNode.referenceParent.quotedAsset === undefined) { return } @@ -174,6 +174,8 @@ function newLayer () { /* Lets listen to our own events to react when we have a Mouse Click */ onMouseClickEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick) + + callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err.stack) } } diff --git a/Panels/LayersPanel.js b/Panels/LayersPanel.js index aa3ace3b9..5bb86653c 100644 --- a/Panels/LayersPanel.js +++ b/Panels/LayersPanel.js @@ -83,36 +83,40 @@ function newProductsPanel () { layer.fitFunction = thisObject.fitFunction /* Initialize it */ - layer.initialize() - layersMap.set(layerNode.id, layer) + layer.initialize(onInitialized) + function onInitialized (err) { + if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result) { + layersMap.set(layerNode.id, layer) - /* Container Stuff */ - layer.container.frame.parentFrame = thisObject.container.frame - layer.container.parentContainer = thisObject.container - layer.container.isWheelable = true + /* Container Stuff */ + layer.container.frame.parentFrame = thisObject.container.frame + layer.container.parentContainer = thisObject.container + layer.container.isWheelable = true - /* Positioning within thisObject Panel */ - let position = { - x: 0, - y: thisObject.container.frame.height - thisObject.container.frame.getBodyHeight() + /* Positioning within thisObject Panel */ + let position = { + x: 0, + y: thisObject.container.frame.height - thisObject.container.frame.getBodyHeight() + } + + layer.container.frame.position.x = position.x + layer.container.frame.position.y = position.y + layer.container.frame.height * thisObject.layers.length + LAYER_SEPARATION + + /* Add to the Product Array */ + thisObject.layers.push(layer) + + /* Add to Visible Product Array */ + if (layer.container.frame.position.y + layer.container.frame.height < thisObject.container.frame.height) { + visibleLayers.push(layer) + } + + /* Listen to Status Changes Events */ + layer.onLayerStatusChangedEventSuscriptionId = layer.container.eventHandler.listenToEvent('Status Changed', onLayerStatusChanged) + layer.onMouseWheelEventSuscriptionId = layer.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) + + return layer + } } - - layer.container.frame.position.x = position.x - layer.container.frame.position.y = position.y + layer.container.frame.height * thisObject.layers.length + LAYER_SEPARATION - - /* Add to the Product Array */ - thisObject.layers.push(layer) - - /* Add to Visible Product Array */ - if (layer.container.frame.position.y + layer.container.frame.height < thisObject.container.frame.height) { - visibleLayers.push(layer) - } - - /* Listen to Status Changes Events */ - layer.onLayerStatusChangedEventSuscriptionId = layer.container.eventHandler.listenToEvent('Status Changed', onLayerStatusChanged) - layer.onMouseWheelEventSuscriptionId = layer.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) - - return layer } function onMouseWheel (event) { @@ -244,7 +248,9 @@ function newProductsPanel () { let found = removeFromLocalLayers(layerNode.id) if (found !== true) { layer = addLayer(layerNode) - onLayerStatusChanged(layer) + if (layer !== undefined) { + onLayerStatusChanged(layer) + } } } } From b5ed52131a716cbb71c2ccd5090c53187292a297 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 15 Jan 2020 09:11:54 +0100 Subject: [PATCH 114/264] Bugs Fixed --- Panels/Layer.js | 3 ++- ProductStorage.js | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Panels/Layer.js b/Panels/Layer.js index 2ac627e97..5f0987417 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -137,7 +137,8 @@ function newLayer () { 'Record Definition->Record Property->Formula->' + 'Data Building Procedure->Procedure Loop->Javascript Code->Procedure Initialization->Javascript Code->' + 'Calculations Procedure->Procedure Loop->Javascript Code->Procedure Initialization->Javascript Code->' + - 'Plotter Module->Shapes->' + + 'Plotter Module->Plotter->' + + 'Shapes->' + 'Chart Points->Point->Point Formula->' + 'Polygon->Polygon Body->Style->Style Condition->Style->' + 'Polygon Border->Style->Style Condition->Style->' + diff --git a/ProductStorage.js b/ProductStorage.js index 3feff668b..4e0c4142a 100644 --- a/ProductStorage.js +++ b/ProductStorage.js @@ -85,7 +85,7 @@ function newProductStorage (name) { for (let i = 0; i < product.datasets.length; i++) { let dataset = product.datasets[i] - switch (dataset.type) { + switch (dataset.code.type) { case 'Market Files': { dataSetsToLoad++ @@ -122,7 +122,7 @@ function newProductStorage (name) { } break default: - if (ERROR_LOG === true) { logger.write('[WARN] initialize -> initialize -> dataset with no type defined. Data can not be retrieved. -> codeName = ' + dataset.codeName) } + if (ERROR_LOG === true) { logger.write('[WARN] initialize -> dataset with no type defined or type not supported -> dataset.code.type = ' + dataset.code.type) } } function onMarketFileReady (err, pCaller) { From 4a379fe04dfb83cba02ac70e93572e8aac062786 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 15 Jan 2020 11:41:43 +0100 Subject: [PATCH 115/264] Mechanism to hide panels when Time Machine is out of Viewport --- Animation.js | 13 ++---- ChartsSpace/PlottersManager.js | 45 +++++++------------ ChartsSpace/TimelineChart.js | 8 ++-- Spaces/ChartSpace.js | 10 ++++- Spaces/PanelsSpace.js | 82 +++++++++++++--------------------- 5 files changed, 61 insertions(+), 97 deletions(-) diff --git a/Animation.js b/Animation.js index 400efe5c9..4aff8d1e7 100644 --- a/Animation.js +++ b/Animation.js @@ -57,21 +57,14 @@ function newAnimation () { function animationLoop () { try { if (window.canvasApp.visible === true) { - /* We set the canvas to its normal width and height */ - + /* We set the canvas to its normal width and height */ browserCanvas.width = window.innerWidth browserCanvas.height = window.innerHeight - CURRENT_TOP_MARGIN - /* First thing is to clear the actual canvas */ - + /* First thing is to clear the actual canvas */ clearBrowserCanvas() - /* Let reset the current chart that is on focus */ - - window.CHART_ON_FOCUS = '' - - /* We loop through the callback functions collections and execute them all. */ - + /* We loop through the callback functions collections and execute them all. */ let performanceMap = new Map() let totalTimeConsumed = 0 let totalElements = 0 diff --git a/ChartsSpace/PlottersManager.js b/ChartsSpace/PlottersManager.js index 62a090940..3f72c0df5 100644 --- a/ChartsSpace/PlottersManager.js +++ b/ChartsSpace/PlottersManager.js @@ -138,7 +138,10 @@ function newPlottersManager () { let baseAsset = layer.definition.referenceParent.parentNode.referenceParent.baseAsset.referenceParent.code.codeName let quotedAsset = layer.definition.referenceParent.parentNode.referenceParent.quotedAsset.referenceParent.code.codeName - let market = baseAsset + '/' + quotedAsset + let market = { + baseAsset: baseAsset, + quotedAsset: quotedAsset + } let product = layer.definition.referenceParent.referenceParent let bot = layer.definition.referenceParent.referenceParent.parentNode let dataMine = layer.definition.referenceParent.referenceParent.parentNode.parentNode @@ -188,40 +191,22 @@ function newPlottersManager () { /* Lets load now this plotter panels. */ connector.panels = [] - /* Here is where we instantiate the legacy panels */ - for (let i = 0; i < plotterModule.panels.length; i++) { - let panelConfig = plotterModule.panels[i] - - let parameters = { - dataMine: layer.product.plotter.dataMine, - plotterCodeName: layer.product.plotter.codeName, - moduleCodeName: layer.product.plotter.moduleName, - panelCodeName: panelConfig.codeName - } - - let plotterPanelHandle = canvas.panelsSpace.createNewPanel('Plotter Panel', parameters, layer.payload.node.id, layer.session) - let plotterPanel = canvas.panelsSpace.getPanel(plotterPanelHandle, layer.payload.node.id) - /* Connect Panel to the Plotter via an Event. */ - if (panelConfig.event !== undefined) { - connector.plotter.onRecordChangeEventsSubscriptionId = connector.plotter.container.eventHandler.listenToEvent(panelConfig.event, plotterPanel.onEventRaised) - } - connector.panels.push(plotterPanelHandle) - } - - /* Here we instantiate the UI Defined Panels. */ if (product !== undefined) { - for (let i = 0; i < product.referenceParent.panels.length; i++) { - let panel = product.referenceParent.panels[i] + for (let i = 0; i < plotterModule.panels.length; i++) { + let panel = plotterModule.panels[i] let parameters = { - dataMine: layer.product.plotter.dataMine, - plotterCodeName: layer.product.plotter.codeName, - moduleCodeName: layer.product.plotter.moduleName, - panelCodeName: panel.id + dataMine: dataMine.code.codeName, + plotterCodeName: plotterModule.parentNode.code.codeName, + moduleCodeName: plotterModule.code.codeName, + panelCodeName: panel.code.codeName, + panelId: panel.id, + isLegacy: panel.code.isLegacy } - let plotterPanelHandle = canvas.panelsSpace.createNewPanel('Plotter Panel', parameters, layer.payload.node.id, layer.session, panel) - let plotterPanel = canvas.panelsSpace.getPanel(plotterPanelHandle, layer.payload.node.id) + let owner = thisObject.payload.node.payload.parentNode.payload.parentNode.id // Panels are owned by the time machine. + let plotterPanelHandle = canvas.panelsSpace.createNewPanel('Plotter Panel', parameters, owner, layer.session) + let plotterPanel = canvas.panelsSpace.getPanel(plotterPanelHandle) /* Connect Panel to the Plotter via an Event. */ connector.plotter.onRecordChangeEventsSubscriptionId = connector.plotter.container.eventHandler.listenToEvent('Current Record Changed', plotterPanel.onRecordChange) diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 4bd027f1e..1dc3e7309 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -140,8 +140,9 @@ function newTimelineChart () { } function initializeLayersManager () { - layersPanelHandle = canvas.panelsSpace.createNewPanel('Layers Panel', undefined, thisObject.payload.node.id) - thisObject.layersManager = canvas.panelsSpace.getPanel(layersPanelHandle, thisObject.payload.node.id) + let owner = thisObject.payload.node.payload.parentNode.id // The real owner is the Time Machine + layersPanelHandle = canvas.panelsSpace.createNewPanel('Layers Panel', undefined, owner) + thisObject.layersManager = canvas.panelsSpace.getPanel(layersPanelHandle) thisObject.layersManager.payload = thisObject.payload.node.layersManager.payload thisObject.layersManager.initialize() @@ -376,9 +377,6 @@ function newTimelineChart () { function drawBackground () { if (thisObject.container.frame.isInViewPort()) { - if (window.CHART_ON_FOCUS === '') { - window.CHART_ON_FOCUS = thisObject.payload.node.id - } drawChartsBackground() if (thisObject.plotterManager !== undefined) { thisObject.plotterManager.draw() diff --git a/Spaces/ChartSpace.js b/Spaces/ChartSpace.js index 789e36d45..5726e7ebb 100644 --- a/Spaces/ChartSpace.js +++ b/Spaces/ChartSpace.js @@ -15,6 +15,7 @@ function newChartSpace () { let thisObject = { visible: true, container: undefined, + inViewport: new Map(), timeMachines: [], oneScreenUp: oneScreenUp, oneScreenDown: oneScreenDown, @@ -52,6 +53,7 @@ function newChartSpace () { timeMachine.finalize() } + thisObject.inViewport = undefined thisObject.timeMachines = undefined timeMachinesMap = undefined @@ -280,7 +282,13 @@ function newChartSpace () { function childrenPhysics () { for (let i = 0; i < thisObject.timeMachines.length; i++) { let timeMachine = thisObject.timeMachines[i] - timeMachine.physics() + + if (timeMachine.container.frame.isInViewPort()) { + timeMachine.physics() + thisObject.inViewport.set(timeMachine.payload.node.id, timeMachine) + } else { + thisObject.inViewport.delete(timeMachine.payload.node.id) + } } } diff --git a/Spaces/PanelsSpace.js b/Spaces/PanelsSpace.js index 938af67ed..1dc46530d 100644 --- a/Spaces/PanelsSpace.js +++ b/Spaces/PanelsSpace.js @@ -25,7 +25,6 @@ function newPanelsSpace () { container.frame.containerName = 'Panels Space' - panelsMap = new Map() return thisObject function initialize () { @@ -34,7 +33,7 @@ function newPanelsSpace () { } - function createNewPanel (pType, pParameters, pOwner, pSession, pPanelCode) { + function createNewPanel (pType, pParameters, pOwner, pSession) { let panel switch (pType) { @@ -48,12 +47,12 @@ function newPanelsSpace () { } case 'Plotter Panel': { - if (pPanelCode !== undefined) { + if (pParameters.isLegacy !== true) { panel = newPlotterPanel() panel.fitFunction = canvas.chartSpace.fitFunction panel.container.isVisibleFunction = canvas.chartSpace.isThisPointVisible panel.session = pSession - panel.initialize(pPanelCode) + panel.initialize(pParameters.panelId) } else { panel = getNewPlotterPanel(pParameters.dataMine, pParameters.plotterCodeName, pParameters.moduleCodeName, pParameters.panelCodeName) panel.fitFunction = canvas.chartSpace.fitFunction @@ -66,13 +65,8 @@ function newPanelsSpace () { } } - let panelArray = panelsMap.get(pOwner) - if (panelArray === undefined) { - panelArray = [] - panelsMap.set(pOwner, panelArray) - } - - panelArray.push(panel) + panel.owner = pOwner + thisObject.panels.push(panel) panel.handle = Math.floor((Math.random() * 10000000) + 1) @@ -94,15 +88,12 @@ function newPanelsSpace () { } } - function getPanel (pPanelHandle, pOwner) { - thisObject.panels = panelsMap.get(pOwner) - if (thisObject.panels != undefined) { - for (let i = 0; i < thisObject.panels.length; i++) { - let panel = thisObject.panels[i] + function getPanel (pPanelHandle) { + for (let i = 0; i < thisObject.panels.length; i++) { + let panel = thisObject.panels[i] - if (panel.handle === pPanelHandle) { - return panel - } + if (panel.handle === pPanelHandle) { + return panel } } } @@ -118,8 +109,11 @@ function newPanelsSpace () { if (thisObject.panels !== undefined) { for (let i = 0; i < thisObject.panels.length; i++) { let panel = thisObject.panels[i] - if (panel.physics !== undefined) { - panel.physics() + let owner = canvas.chartSpace.inViewport.get(panel.owner) + if (owner !== undefined) { + if (panel.physics !== undefined) { + panel.physics() + } } } } @@ -309,18 +303,10 @@ function newPanelsSpace () { thisObject.container.frame.draw(false, false) - thisObject.panels = panelsMap.get('Global') - if (thisObject.panels !== undefined) { - for (let i = 0; i < thisObject.panels.length; i++) { - let panel = thisObject.panels[i] - panel.draw() - } - } - - thisObject.panels = panelsMap.get(window.CHART_ON_FOCUS) - if (thisObject.panels !== undefined) { - for (let i = 0; i < thisObject.panels.length; i++) { - let panel = thisObject.panels[i] + for (let i = 0; i < thisObject.panels.length; i++) { + let panel = thisObject.panels[i] + let owner = canvas.chartSpace.inViewport.get(panel.owner) + if (owner !== undefined) { panel.draw() } } @@ -330,26 +316,20 @@ function newPanelsSpace () { if (thisObject.visible !== true) { return } let container - - /* - - We search for the container of panels in the oposite direction than we do it for drawing them, - so panels overlapping others are picked firt although they are drawn last. - - */ - if (thisObject.panels !== undefined) { - for (var i = thisObject.panels.length - 1; i >= 0; i--) { - container = thisObject.panels[i].getContainer(point) - - if (container !== undefined) { - /* We found an inner container which has the point. We return it. */ - - return container - } + /* + We search for the container of panels in the oposite direction than we do it for drawing them, + so panels overlapping others are picked firt although they are drawn last. + */ + for (let i = thisObject.panels.length - 1; i >= 0; i--) { + let panel = thisObject.panels[i] + let owner = canvas.chartSpace.inViewport.get(panel.owner) + if (owner !== undefined) { + container = panel.getContainer(point) + } + if (container !== undefined) { + return container } } - /* The point does not belong to any inner container, so we return the current container. */ - return thisObject.container } } From 6ec6014aab8aad069dc54d32571a138f5aa1bd70 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 15 Jan 2020 11:47:12 +0100 Subject: [PATCH 116/264] Candles working with panel --- ChartsSpace/PlottersManager.js | 6 ++++-- ChartsSpace/TimelineChart.js | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ChartsSpace/PlottersManager.js b/ChartsSpace/PlottersManager.js index 3f72c0df5..46cdccd33 100644 --- a/ChartsSpace/PlottersManager.js +++ b/ChartsSpace/PlottersManager.js @@ -12,6 +12,7 @@ function newPlottersManager () { let thisObject = { fitFunction: undefined, container: undefined, + payload: undefined, setDatetime: setDatetime, setTimeFrame: setTimeFrame, positionAtDatetime: positionAtDatetime, @@ -66,7 +67,8 @@ function newPlottersManager () { thisObject.container.finalize() thisObject.container = undefined - setupContainer() + + thisObject.payload = undefined } function finalizeStorage (storage) { @@ -204,7 +206,7 @@ function newPlottersManager () { isLegacy: panel.code.isLegacy } - let owner = thisObject.payload.node.payload.parentNode.payload.parentNode.id // Panels are owned by the time machine. + let owner = thisObject.payload.node.payload.parentNode.id // Panels are owned by the time machine. let plotterPanelHandle = canvas.panelsSpace.createNewPanel('Plotter Panel', parameters, owner, layer.session) let plotterPanel = canvas.panelsSpace.getPanel(plotterPanelHandle) diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 1dc3e7309..b29c67a14 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -155,6 +155,7 @@ function newTimelineChart () { thisObject.plotterManager.container.frame.position.y = 0 thisObject.plotterManager.fitFunction = thisObject.fitFunction + thisObject.plotterManager.payload = thisObject.payload thisObject.plotterManager.initialize(thisObject.layersManager, DEFAULT_EXCHANGE, DEFAULT_MARKET) thisObject.plotterManager.setTimeFrame(timeFrame) } From dbd058bd211915dbcd22cd9a118fcf8dc1123d6a Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 15 Jan 2020 12:25:49 +0100 Subject: [PATCH 117/264] Several Bug Fixes and Mantainance --- ChartsSpace/PlottersManager.js | 4 +- Container.js | 4 +- Panels/LayersPanel.js | 1 + Panels/PanelTabButton.js | 69 +++++++++++++++++++--------------- Panels/PlotterPanel.js | 26 +++++++++---- Spaces/PanelsSpace.js | 6 +-- 6 files changed, 65 insertions(+), 45 deletions(-) diff --git a/ChartsSpace/PlottersManager.js b/ChartsSpace/PlottersManager.js index 46cdccd33..5e5b40f56 100644 --- a/ChartsSpace/PlottersManager.js +++ b/ChartsSpace/PlottersManager.js @@ -201,9 +201,7 @@ function newPlottersManager () { dataMine: dataMine.code.codeName, plotterCodeName: plotterModule.parentNode.code.codeName, moduleCodeName: plotterModule.code.codeName, - panelCodeName: panel.code.codeName, - panelId: panel.id, - isLegacy: panel.code.isLegacy + panelNode: panel } let owner = thisObject.payload.node.payload.parentNode.id // Panels are owned by the time machine. diff --git a/Container.js b/Container.js index 0816953fd..81f6ab874 100644 --- a/Container.js +++ b/Container.js @@ -70,7 +70,9 @@ function newContainer () { thisObject.frame = newFrame() thisObject.frame.initialize(pType) - thisObject.frame.containerName = pName + if (pName !== undefined) { + thisObject.frame.containerName = pName + } thisObject.frame.container = thisObject thisObject.eventHandler = newEventHandler() diff --git a/Panels/LayersPanel.js b/Panels/LayersPanel.js index 5bb86653c..894909c7a 100644 --- a/Panels/LayersPanel.js +++ b/Panels/LayersPanel.js @@ -33,6 +33,7 @@ function newProductsPanel () { function finalize () { thisObject.container.eventHandler.stopListening(onMouseWheelEventSuscriptionId) + panelTabButton.finalize() panelTabButton = undefined layersMap = undefined visibleLayers = undefined diff --git a/Panels/PanelTabButton.js b/Panels/PanelTabButton.js index fe41ecbf6..dc389b7e8 100644 --- a/Panels/PanelTabButton.js +++ b/Panels/PanelTabButton.js @@ -5,35 +5,41 @@ function newPanelTabButton () { parentContainer: undefined, draw: draw, getContainer: getContainer, // returns the inner most container that holds the point received by parameter. - initialize: initialize + initialize: initialize, + finalize: finalize } let isInitialized = false /* Cointainer stuff */ - var container = newContainer() - - container.name = 'Panel Tab Button' - container.initialize() - - container.isClickeable = true - - thisObject.container = container + thisObject.container = newContainer() + thisObject.container.name = 'Panel Tab Button' + thisObject.container.initialize() + thisObject.container.isClickeable = true thisObject.container.frame.containerName = 'Panel Tab Button' - /* Lets listen to our own events to react when we have a Mouse Click */ - - thisObject.container.eventHandler.listenToEvent('onMouseClick', buttonPressed) - /* Animation to hide the pannel */ - let tabStatus = 'visible' let visiblePosition = {} let hiddenPosition = {} let transitionPosition = {} + let onMouseClickEventSuscriptionId return thisObject + function finalize () { + thisObject.container.eventHandler.stopListening(onMouseClickEventSuscriptionId) + thisObject.container.finalize() + thisObject.container = undefined + thisObject.fitFunction = undefined + thisObject.parentContainer = undefined + + tabStatus = undefined + visiblePosition = undefined + hiddenPosition = undefined + transitionPosition = undefined + } + function initialize () { thisObject.container.frame.width = 10 thisObject.container.frame.height = 10 @@ -54,10 +60,13 @@ function newPanelTabButton () { transitionPosition.x = visiblePosition.x transitionPosition.y = visiblePosition.y + /* Lets listen to our own events to react when we have a Mouse Click */ + onMouseClickEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick) + isInitialized = true } - function buttonPressed (event) { + function onMouseClick (event) { if (tabStatus === 'visible') { visiblePosition.x = thisObject.parentContainer.frame.position.x visiblePosition.y = thisObject.parentContainer.frame.position.y @@ -104,7 +113,7 @@ function newPanelTabButton () { } function getContainer (point) { - var container + let container /* First we check if thisObject point is inside thisObject space. */ @@ -132,13 +141,13 @@ function newPanelTabButton () { } point2 = { - x: container.frame.width - 3, + x: thisObject.container.frame.width - 3, y: 3 } point3 = { - x: container.frame.width / 2, - y: container.frame.height - 3 + x: thisObject.container.frame.width / 2, + y: thisObject.container.frame.height - 3 } break } @@ -150,13 +159,13 @@ function newPanelTabButton () { } point2 = { - x: container.frame.width - 4, + x: thisObject.container.frame.width - 4, y: 4 } point3 = { - x: container.frame.width / 2, - y: container.frame.height - 4 + x: thisObject.container.frame.width / 2, + y: thisObject.container.frame.height - 4 } break } @@ -164,16 +173,16 @@ function newPanelTabButton () { case 'going up': { point1 = { x: 4, - y: container.frame.height - 4 + y: thisObject.container.frame.height - 4 } point2 = { - x: container.frame.width - 4, - y: container.frame.height - 4 + x: thisObject.container.frame.width - 4, + y: thisObject.container.frame.height - 4 } point3 = { - x: container.frame.width / 2, + x: thisObject.container.frame.width / 2, y: 4 } break @@ -182,16 +191,16 @@ function newPanelTabButton () { case 'hidden': { point1 = { x: 3, - y: container.frame.height - 3 + y: thisObject.container.frame.height - 3 } point2 = { - x: container.frame.width - 3, - y: container.frame.height - 3 + x: thisObject.container.frame.width - 3, + y: thisObject.container.frame.height - 3 } point3 = { - x: container.frame.width / 2, + x: thisObject.container.frame.width / 2, y: 3 } break diff --git a/Panels/PlotterPanel.js b/Panels/PlotterPanel.js index b2d33194b..a704be207 100644 --- a/Panels/PlotterPanel.js +++ b/Panels/PlotterPanel.js @@ -8,18 +8,16 @@ function newPlotterPanel () { let thisObject = { fitFunction: undefined, - onRecordChange: onRecordChange, container: undefined, + onRecordChange: onRecordChange, draw: draw, getContainer: getContainer, - initialize: initialize + initialize: initialize, + finalize: finalize } - let container = newContainer() - container.initialize() - thisObject.container = container - - container.frame.containerName = 'Plotter Panel' + thisObject.container = newContainer() + thisObject.container.initialize('Plotter Panel') let heightFactor = 1 let currentRecord @@ -28,9 +26,21 @@ function newPlotterPanel () { return thisObject + function finalize () { + thisObject.container.finalize() + thisObject.container = undefined + thisObject.fitFunction = undefined + + heightFactor = undefined + currentRecord = undefined + panelTabButton.finalize() + panelTabButton = undefined + panelNode = undefined + } + function initialize (pPanelNode) { panelNode = pPanelNode - container.frame.containerName = panelNode.name + thisObject.container.frame.containerName = panelNode.name thisObject.container.frame.width = UI_PANEL.WIDTH.NORMAL thisObject.container.frame.height = UI_PANEL.HEIGHT.NORMAL diff --git a/Spaces/PanelsSpace.js b/Spaces/PanelsSpace.js index 1dc46530d..43442c705 100644 --- a/Spaces/PanelsSpace.js +++ b/Spaces/PanelsSpace.js @@ -47,14 +47,14 @@ function newPanelsSpace () { } case 'Plotter Panel': { - if (pParameters.isLegacy !== true) { + if (pParameters.panelNode.code.isLegacy !== true) { panel = newPlotterPanel() panel.fitFunction = canvas.chartSpace.fitFunction panel.container.isVisibleFunction = canvas.chartSpace.isThisPointVisible panel.session = pSession - panel.initialize(pParameters.panelId) + panel.initialize(pParameters.panelNode) } else { - panel = getNewPlotterPanel(pParameters.dataMine, pParameters.plotterCodeName, pParameters.moduleCodeName, pParameters.panelCodeName) + panel = getNewPlotterPanel(pParameters.dataMine, pParameters.plotterCodeName, pParameters.moduleCodeName, pParameters.panelNode.code.codeName) panel.fitFunction = canvas.chartSpace.fitFunction panel.container.isVisibleFunction = canvas.chartSpace.isThisPointVisible panel.session = pSession From 717bf0cb083c81b1c4d52630219da1cd4b812206 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 15 Jan 2020 14:45:52 +0100 Subject: [PATCH 118/264] Bug fixed and fine tunning --- ChartsSpace/PlottersManager.js | 4 +- Panels/Layer.js | 247 ++++++--------------------------- 2 files changed, 48 insertions(+), 203 deletions(-) diff --git a/ChartsSpace/PlottersManager.js b/ChartsSpace/PlottersManager.js index 5e5b40f56..3b05f692a 100644 --- a/ChartsSpace/PlottersManager.js +++ b/ChartsSpace/PlottersManager.js @@ -235,7 +235,7 @@ function newPlottersManager () { let found = false for (let i = 0; i < connectors.length; i++) { let connector = connectors[i] - if (connector.layer.code === layer.code) { + if (connector.layer.payload.node.id === layer.payload.node.id) { found = true } } @@ -250,7 +250,7 @@ function newPlottersManager () { /* If the plotter of this card is not on our Active Plotters list, then we remove it. */ for (let i = 0; i < connectors.length; i++) { let connector = connectors[i] - if (connector.layer.code === layer.code) { + if (connector.layer.payload.node.id === layer.payload.node.id) { /* Then the panels. */ for (let j = 0; j < connector.panels.length; j++) { canvas.panelsSpace.destroyPanel(connector.panels[j]) diff --git a/Panels/Layer.js b/Panels/Layer.js index 5f0987417..58e710ec8 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -315,229 +315,74 @@ function newLayer () { } function drawLayer () { - switch (thisObject.status) { - case PRODUCT_CARD_STATUS.ON: - - break - case PRODUCT_CARD_STATUS.OFF: - - break - case PRODUCT_CARD_STATUS.LOADING: - - break - } - - drawLayerDisplay() - /* ------------------- Progress Bars -------------------------- */ const ANIMATED_INCREMENT = 5 - const OPACITY_INCREMENT = 0.05 + const OPACITY_INCREMENT = 0.01 const OPACITY_MIN = 1 - let point1 - let point2 + drawLayerDisplay() - /* We draw here the Market Progress Bar. */ + drawProgressBar(marketFileProgressBar, 1, -5) + drawProgressBar(dailyFileProgressBar, 1, -6) + drawProgressBar(singleFileProgressBar, 1, -7) + drawProgressBar(fileSequenceProgressBar, 1, -8) + + function drawProgressBar (progressBar, lineWidth, offsetY) { + let point1 + let point2 + let horizontalMargin = 50 + + if (progressBar.value === 0) { + return + } /* Animate */ + if (progressBar.animatedValue < progressBar.value) { + progressBar.animatedValue = progressBar.animatedValue + ANIMATED_INCREMENT + progressBar.opacity = progressBar.opacity + OPACITY_INCREMENT + } - if (marketFileProgressBar.animatedValue < marketFileProgressBar.value) { - marketFileProgressBar.animatedValue = marketFileProgressBar.animatedValue + ANIMATED_INCREMENT - marketFileProgressBar.opacity = marketFileProgressBar.opacity + OPACITY_INCREMENT - } + if (progressBar.animatedValue >= 100) { + progressBar.animatedValue = 100 - if (marketFileProgressBar.animatedValue >= 100) { - marketFileProgressBar.animatedValue = 100 + progressBar.opacity = progressBar.opacity - OPACITY_INCREMENT + if (progressBar.opacity < OPACITY_MIN) { progressBar.opacity = OPACITY_MIN } - marketFileProgressBar.opacity = marketFileProgressBar.opacity - OPACITY_INCREMENT - if (marketFileProgressBar.opacity < OPACITY_MIN) { marketFileProgressBar.opacity = OPACITY_MIN } + progressBar.strokeStyle = LOADED_STROKE_STYLE.replace('@Opacity', progressBar.opacity.toString()) - marketFileProgressBar.fillStyle = LOADED_FILL_STYLE.replace('@Opacity', marketFileProgressBar.opacity.toString()) - marketFileProgressBar.strokeStyle = LOADED_STROKE_STYLE.replace('@Opacity', marketFileProgressBar.opacity.toString()) + changeStatusTo(PRODUCT_CARD_STATUS.ON) + } - changeStatusTo(PRODUCT_CARD_STATUS.ON) - } + point1 = { + x: 0 + horizontalMargin, + y: thisObject.container.frame.height + offsetY + } - point1 = { - x: 0, - y: thisObject.container.frame.height - 15 - } - - point2 = { - x: thisObject.container.frame.width * marketFileProgressBar.animatedValue / 100, - y: thisObject.container.frame.height - 15 - } + point2 = { + x: (thisObject.container.frame.width - horizontalMargin * 2) * progressBar.animatedValue / 100 + horizontalMargin, + y: thisObject.container.frame.height + offsetY + } /* Now the transformations. */ + point1 = thisObject.container.frame.frameThisPoint(point1) + point2 = thisObject.container.frame.frameThisPoint(point2) - point1 = thisObject.container.frame.frameThisPoint(point1) - point2 = thisObject.container.frame.frameThisPoint(point2) + point1 = thisObject.fitFunction(point1) + point2 = thisObject.fitFunction(point2) - point1 = thisObject.fitFunction(point1) - point2 = thisObject.fitFunction(point2) + browserCanvasContext.beginPath() + browserCanvasContext.moveTo(point1.x, point1.y) + browserCanvasContext.lineTo(point2.x, point2.y) - browserCanvasContext.beginPath() - browserCanvasContext.moveTo(point1.x, point1.y) - browserCanvasContext.lineTo(point2.x, point2.y) + browserCanvasContext.closePath() - browserCanvasContext.closePath() + browserCanvasContext.strokeStyle = progressBar.strokeStyle.replace('@Opacity', progressBar.opacity.toString()) - browserCanvasContext.strokeStyle = marketFileProgressBar.strokeStyle.replace('@Opacity', marketFileProgressBar.opacity.toString()) - - browserCanvasContext.setLineDash([2, 5]) - browserCanvasContext.lineWidth = 10 - browserCanvasContext.stroke() - - /* We draw here the Daily Progress Bar. */ - - /* Animate */ - - if (dailyFileProgressBar.animatedValue < dailyFileProgressBar.value) { - dailyFileProgressBar.animatedValue = dailyFileProgressBar.animatedValue + ANIMATED_INCREMENT - dailyFileProgressBar.opacity = dailyFileProgressBar.opacity + OPACITY_INCREMENT + browserCanvasContext.setLineDash([1, 4]) + browserCanvasContext.lineWidth = lineWidth + browserCanvasContext.stroke() } - - if (dailyFileProgressBar.animatedValue >= 100) { - dailyFileProgressBar.animatedValue = 100 - - dailyFileProgressBar.opacity = dailyFileProgressBar.opacity - OPACITY_INCREMENT - if (dailyFileProgressBar.opacity < OPACITY_MIN) { dailyFileProgressBar.opacity = OPACITY_MIN } - - dailyFileProgressBar.fillStyle = LOADED_FILL_STYLE.replace('@Opacity', dailyFileProgressBar.opacity.toString()) - dailyFileProgressBar.strokeStyle = LOADED_STROKE_STYLE.replace('@Opacity', dailyFileProgressBar.opacity.toString()) - - changeStatusTo(PRODUCT_CARD_STATUS.ON) - } - - point1 = { - x: 0, - y: thisObject.container.frame.height - 25 - } - - point2 = { - x: thisObject.container.frame.width * dailyFileProgressBar.animatedValue / 100, - y: thisObject.container.frame.height - 25 - } - - /* Now the transformations. */ - - point1 = thisObject.container.frame.frameThisPoint(point1) - point2 = thisObject.container.frame.frameThisPoint(point2) - - point1 = thisObject.fitFunction(point1) - point2 = thisObject.fitFunction(point2) - - browserCanvasContext.beginPath() - browserCanvasContext.moveTo(point1.x, point1.y) - browserCanvasContext.lineTo(point2.x, point2.y) - - browserCanvasContext.closePath() - - browserCanvasContext.strokeStyle = dailyFileProgressBar.strokeStyle.replace('@Opacity', dailyFileProgressBar.opacity.toString()) - - browserCanvasContext.setLineDash([2, 5]) - browserCanvasContext.lineWidth = 10 - browserCanvasContext.stroke() - - /* We draw here the Single File Progress Bar. */ - - /* Animate */ - - if (singleFileProgressBar.animatedValue < singleFileProgressBar.value) { - singleFileProgressBar.animatedValue = singleFileProgressBar.animatedValue + ANIMATED_INCREMENT - singleFileProgressBar.opacity = singleFileProgressBar.opacity + OPACITY_INCREMENT - } - - if (singleFileProgressBar.animatedValue >= 100) { - singleFileProgressBar.animatedValue = 100 - - singleFileProgressBar.opacity = singleFileProgressBar.opacity - OPACITY_INCREMENT - if (singleFileProgressBar.opacity < OPACITY_MIN) { singleFileProgressBar.opacity = OPACITY_MIN } - - singleFileProgressBar.fillStyle = LOADED_FILL_STYLE.replace('@Opacity', singleFileProgressBar.opacity.toString()) - singleFileProgressBar.strokeStyle = LOADED_STROKE_STYLE.replace('@Opacity', singleFileProgressBar.opacity.toString()) - - changeStatusTo(PRODUCT_CARD_STATUS.ON) - } - - point1 = { - x: 0, - y: thisObject.container.frame.height - 7 - } - - point2 = { - x: thisObject.container.frame.width * singleFileProgressBar.animatedValue / 100, - y: thisObject.container.frame.height - 7 - } - - /* Now the transformations. */ - - point1 = thisObject.container.frame.frameThisPoint(point1) - point2 = thisObject.container.frame.frameThisPoint(point2) - - point1 = thisObject.fitFunction(point1) - point2 = thisObject.fitFunction(point2) - - browserCanvasContext.beginPath() - browserCanvasContext.moveTo(point1.x, point1.y) - browserCanvasContext.lineTo(point2.x, point2.y) - browserCanvasContext.closePath() - - browserCanvasContext.strokeStyle = singleFileProgressBar.strokeStyle.replace('@Opacity', singleFileProgressBar.opacity.toString()) - - browserCanvasContext.setLineDash([2, 5]) - browserCanvasContext.lineWidth = 10 - - /* We draw here the File Sequence Progress Bar. */ - - /* Animate */ - - if (fileSequenceProgressBar.animatedValue < fileSequenceProgressBar.value) { - fileSequenceProgressBar.animatedValue = fileSequenceProgressBar.animatedValue + ANIMATED_INCREMENT - fileSequenceProgressBar.opacity = fileSequenceProgressBar.opacity + OPACITY_INCREMENT - } - - if (fileSequenceProgressBar.animatedValue >= 100) { - fileSequenceProgressBar.animatedValue = 100 - - fileSequenceProgressBar.opacity = fileSequenceProgressBar.opacity - OPACITY_INCREMENT - if (fileSequenceProgressBar.opacity < OPACITY_MIN) { fileSequenceProgressBar.opacity = OPACITY_MIN } - - fileSequenceProgressBar.fillStyle = LOADED_FILL_STYLE.replace('@Opacity', fileSequenceProgressBar.opacity.toString()) - fileSequenceProgressBar.strokeStyle = LOADED_STROKE_STYLE.replace('@Opacity', fileSequenceProgressBar.opacity.toString()) - - changeStatusTo(PRODUCT_CARD_STATUS.ON) - } - - point1 = { - x: 0, - y: thisObject.container.frame.height - 10 - } - - point2 = { - x: thisObject.container.frame.width * fileSequenceProgressBar.animatedValue / 100, - y: thisObject.container.frame.height - 10 - } - - /* Now the transformations. */ - - point1 = thisObject.container.frame.frameThisPoint(point1) - point2 = thisObject.container.frame.frameThisPoint(point2) - - point1 = thisObject.fitFunction(point1) - point2 = thisObject.fitFunction(point2) - - browserCanvasContext.beginPath() - browserCanvasContext.moveTo(point1.x, point1.y) - browserCanvasContext.lineTo(point2.x, point2.y) - - browserCanvasContext.closePath() - - browserCanvasContext.strokeStyle = fileSequenceProgressBar.strokeStyle.replace('@Opacity', fileSequenceProgressBar.opacity.toString()) - - browserCanvasContext.setLineDash([2, 5]) - browserCanvasContext.lineWidth = 10 } function drawLayerDisplay () { From 00f3ab68ee98b0ab75fd0ee932f08ca61abb0610 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 15 Jan 2020 15:04:17 +0100 Subject: [PATCH 119/264] Charts Radar Implementation --- ChartsSpace/TimeMachine.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index f3fef4cba..aa01ca7b1 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -473,6 +473,27 @@ function newTimeMachine () { } thisObject.container.frame.draw(false, true, false, thisObject.fitFunction) + } else { + let icon = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.type) + if (icon !== undefined) { + if (icon.canDrawIcon === true) { + let imageSize = 40 + let imagePosition = { + x: thisObject.container.frame.width / 2, + y: thisObject.container.frame.height / 2 + } + + imagePosition = transformThisPoint(imagePosition, thisObject.container) + imagePosition = thisObject.fitFunction(imagePosition, true) + + browserCanvasContext.drawImage( + icon, + imagePosition.x - imageSize / 2, + imagePosition.y - imageSize / 2, + imageSize, + imageSize) + } + } } } From b3deaea7f4c079899a5901ae8776fb8c1c420a49 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 15 Jan 2020 15:32:32 +0100 Subject: [PATCH 120/264] Fine tunning how it looks --- ChartsSpace/ViewPort.js | 16 ++++++++-------- Spaces/PanelsSpace.js | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ChartsSpace/ViewPort.js b/ChartsSpace/ViewPort.js index e9738b66f..9030c2e63 100644 --- a/ChartsSpace/ViewPort.js +++ b/ChartsSpace/ViewPort.js @@ -11,10 +11,10 @@ function newViewPort () { let ANIMATION_INCREMENT = 0.25 - let TOP_MARGIN = 30 + TOP_SPACE_HEIGHT - let BOTTOM_MARGIN = 32 + COCKPIT_SPACE_HEIGHT - let LEFT_MARGIN = 50 - let RIGHT_MARGIN = 50 + let TOP_MARGIN = 57 + TOP_SPACE_HEIGHT + let BOTTOM_MARGIN = 62 + COCKPIT_SPACE_HEIGHT + let LEFT_MARGIN = 200 + let RIGHT_MARGIN = 200 let MARGINS = { TOP: TOP_MARGIN, BOTTOM: BOTTOM_MARGIN, @@ -82,10 +82,10 @@ function newViewPort () { } function resize () { - TOP_MARGIN = 30 + TOP_SPACE_HEIGHT - BOTTOM_MARGIN = 32 + browserCanvas.height - COCKPIT_SPACE_POSITION - LEFT_MARGIN = 0 - RIGHT_MARGIN = 0 + TOP_MARGIN = 57 + TOP_SPACE_HEIGHT + BOTTOM_MARGIN = 62 + browserCanvas.height - COCKPIT_SPACE_POSITION + LEFT_MARGIN = 200 + RIGHT_MARGIN = 200 MARGINS = { TOP: TOP_MARGIN, BOTTOM: BOTTOM_MARGIN, diff --git a/Spaces/PanelsSpace.js b/Spaces/PanelsSpace.js index 43442c705..b6574d7ae 100644 --- a/Spaces/PanelsSpace.js +++ b/Spaces/PanelsSpace.js @@ -158,8 +158,8 @@ function newPanelsSpace () { } else { desAccelerateOnX() } - if (panel.container.frame.position.x < viewPort.visibleArea.topLeft.x) { - panel.container.frame.position.x = viewPort.visibleArea.topLeft.x + if (panel.container.frame.position.x < 0) { + panel.container.frame.position.x = 0 } } else { panel.container.frame.position.x = panel.container.frame.position.x + panel.container.speed.x @@ -169,8 +169,8 @@ function newPanelsSpace () { } else { desAccelerateOnX() } - if (panel.container.frame.position.x + panel.container.frame.width > viewPort.visibleArea.topRight.x) { - panel.container.frame.position.x = viewPort.visibleArea.topRight.x - panel.container.frame.width + if (panel.container.frame.position.x + panel.container.frame.width > browserCanvas.width) { + panel.container.frame.position.x = browserCanvas.width - panel.container.frame.width } } if (panel.container.frame.height <= viewPort.visibleArea.bottomRight.y - viewPort.visibleArea.topRight.y) { From 2ea7dfeecdd75ceaaf0f0242fa1c32b859418df3 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 15 Jan 2020 16:07:44 +0100 Subject: [PATCH 121/264] fine tuning --- ChartsSpace/ViewPort.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ChartsSpace/ViewPort.js b/ChartsSpace/ViewPort.js index 9030c2e63..9a106749f 100644 --- a/ChartsSpace/ViewPort.js +++ b/ChartsSpace/ViewPort.js @@ -13,8 +13,8 @@ function newViewPort () { let TOP_MARGIN = 57 + TOP_SPACE_HEIGHT let BOTTOM_MARGIN = 62 + COCKPIT_SPACE_HEIGHT - let LEFT_MARGIN = 200 - let RIGHT_MARGIN = 200 + let LEFT_MARGIN = 0 + let RIGHT_MARGIN = 0 let MARGINS = { TOP: TOP_MARGIN, BOTTOM: BOTTOM_MARGIN, @@ -84,8 +84,8 @@ function newViewPort () { function resize () { TOP_MARGIN = 57 + TOP_SPACE_HEIGHT BOTTOM_MARGIN = 62 + browserCanvas.height - COCKPIT_SPACE_POSITION - LEFT_MARGIN = 200 - RIGHT_MARGIN = 200 + LEFT_MARGIN = 0 + RIGHT_MARGIN = 0 MARGINS = { TOP: TOP_MARGIN, BOTTOM: BOTTOM_MARGIN, From 155e35b2a8eb3a61deb775651521d8850638380d Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 15 Jan 2020 16:41:39 +0100 Subject: [PATCH 122/264] Header of Layers Panel --- Panels/Layer.js | 55 +++++---------------------- Panels/LayersPanel.js | 40 +++++++++++++++++-- Utilities/RoundedCornersBackground.js | 35 +++++++++++++++++ 3 files changed, 80 insertions(+), 50 deletions(-) diff --git a/Panels/Layer.js b/Panels/Layer.js index 58e710ec8..ff0859df5 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -452,57 +452,20 @@ function newLayer () { roundedCornersBackground(params) if (label2 !== undefined) { - drawLabel(label1, 1 / 2, 2 / 8, 16) - drawLabel(label2, 1 / 2, 4 / 8, 16) + drawLabel(label1, 1 / 2, 2 / 8, 16, thisObject.container) + drawLabel(label2, 1 / 2, 4 / 8, 16, thisObject.container) } else { - drawLabel(label1, 1 / 2, 3 / 8, 20) + drawLabel(label1, 1 / 2, 3 / 8, 20, thisObject.container) } - drawLabel(label3, 1 / 2, 6 / 8, 10) - drawLabel(label4, 1 / 2, 7 / 8, 10) - - function drawLabel (label, xFactor, yFactor, fontSize) { - if (label === undefined) { return } - let xOffset = label.length * fontSize * FONT_ASPECT_RATIO + 10 - - let labelPoint = { - x: thisObject.container.frame.width * xFactor - xOffset / 2, - y: thisObject.container.frame.height * yFactor - } - - labelPoint = thisObject.container.frame.frameThisPoint(labelPoint) - - browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY - browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)' - - browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y) - } + drawLabel(label3, 1 / 2, 6 / 8, 10, thisObject.container) + drawLabel(label4, 1 / 2, 7 / 8, 10, thisObject.container) /* Images */ - - drawIcon(icon1, 1 / 8, 1 / 4) - drawIcon(icon2, 7 / 8, 1 / 4) - drawIcon(icon3, 1 / 8, 3 / 4) - drawIcon(icon4, 7 / 8, 3 / 4) - - function drawIcon (icon, xFactor, yFactor) { - if (icon !== undefined) { - if (icon.canDrawIcon === true) { - let imageSize = 20 - let imagePosition = { - x: thisObject.container.frame.width * xFactor - imageSize / 2, - y: thisObject.container.frame.height * yFactor - imageSize / 2 - } - - imagePosition = thisObject.container.frame.frameThisPoint(imagePosition) - browserCanvasContext.drawImage( - icon, imagePosition.x, - imagePosition.y, - imageSize, - imageSize) - } - } - } + drawIcon(icon1, 1 / 8, 1 / 4, 20, thisObject.container) + drawIcon(icon2, 7 / 8, 1 / 4, 20, thisObject.container) + drawIcon(icon3, 1 / 8, 3 / 4, 20, thisObject.container) + drawIcon(icon4, 7 / 8, 3 / 4, 20, thisObject.container) } } diff --git a/Panels/LayersPanel.js b/Panels/LayersPanel.js index 894909c7a..71e8a0a19 100644 --- a/Panels/LayersPanel.js +++ b/Panels/LayersPanel.js @@ -49,7 +49,7 @@ function newProductsPanel () { thisObject.container.name = thisObject.payload.node.name thisObject.container.frame.containerName = thisObject.container.name thisObject.container.frame.width = UI_PANEL.WIDTH.MEDIUM - thisObject.container.frame.height = UI_PANEL.HEIGHT.LARGE // viewPort.visibleArea.bottomLeft.y - viewPort.visibleArea.topLeft.y // UI_PANEL.HEIGHT.LARGE; + thisObject.container.frame.height = 95 * 5 + 60 let position = { x: viewPort.visibleArea.topLeft.x, @@ -97,7 +97,7 @@ function newProductsPanel () { /* Positioning within thisObject Panel */ let position = { x: 0, - y: thisObject.container.frame.height - thisObject.container.frame.getBodyHeight() + y: 60 } layer.container.frame.position.x = position.x @@ -148,7 +148,7 @@ function newProductsPanel () { /* Positioning within thisObject Panel */ let position = { x: 0, - y: thisObject.container.frame.height - thisObject.container.frame.getBodyHeight() + y: 60 } layer.container.frame.position.x = position.x layer.container.frame.position.y = position.y + layer.container.frame.height * visibleLayers.length + LAYER_SEPARATION @@ -292,12 +292,44 @@ function newProductsPanel () { function draw () { if (isInitialized === false) { return } - thisObject.container.frame.draw(false, false, false, thisObject.fitFunction) + // thisObject.container.frame.draw(false, false, false, thisObject.fitFunction) + drawHeader() for (let i = 0; i < visibleLayers.length; i++) { visibleLayers[i].draw() } panelTabButton.draw() } + + function drawHeader () { + let label1 = thisObject.payload.node.name.substring(0, 15) + let label2 = thisObject.payload.node.payload.parentNode.name.substring(0, 15) + let label3 = '' + + let icon1 = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.payload.parentNode.type) + let icon2 = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.type) + + let backgroundColor = UI_COLOR.BLACK + + let params = { + cornerRadius: 15, + lineWidth: 2, + container: thisObject.container, + borderColor: UI_COLOR.RUSTED_RED, + castShadow: false, + backgroundColor: backgroundColor, + opacity: 1 + } + + roundedCornersBackground(params) + + drawLabel(label1, 1 / 2, 6 / 100, 10, thisObject.container) + drawLabel(label2, 1 / 2, 9 / 100, 10, thisObject.container) + + /* Images */ + drawIcon(icon1, 1 / 8, 6 / 100, 40, thisObject.container) + drawIcon(icon2, 7 / 8, 6 / 100, 40, thisObject.container) + } } + diff --git a/Utilities/RoundedCornersBackground.js b/Utilities/RoundedCornersBackground.js index 557f1de72..7a2827c62 100644 --- a/Utilities/RoundedCornersBackground.js +++ b/Utilities/RoundedCornersBackground.js @@ -104,3 +104,38 @@ function roundedCornersBackground (params) { browserCanvasContext.strokeStyle = 'rgba(' + params.borderColor + ', ' + params.opacity + ')' browserCanvasContext.stroke() } + +function drawLabel (label, xFactor, yFactor, fontSize, container) { + if (label === undefined) { return } + let xOffset = label.length * fontSize * FONT_ASPECT_RATIO + 10 + + let labelPoint = { + x: container.frame.width * xFactor - xOffset / 2, + y: container.frame.height * yFactor + } + + labelPoint = container.frame.frameThisPoint(labelPoint) + + browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY + browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)' + + browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y) +} + +function drawIcon (icon, xFactor, yFactor, imageSize, container) { + if (icon !== undefined) { + if (icon.canDrawIcon === true) { + let imagePosition = { + x: container.frame.width * xFactor - imageSize / 2, + y: container.frame.height * yFactor - imageSize / 2 + } + + imagePosition = container.frame.frameThisPoint(imagePosition) + browserCanvasContext.drawImage( + icon, imagePosition.x, + imagePosition.y, + imageSize, + imageSize) + } + } +} From 09f7befe6c2ea33454ecef93db08e414206eeddd Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 15 Jan 2020 16:54:24 +0100 Subject: [PATCH 123/264] Simplifying Code --- Panels/LayersPanel.js | 1 - Scales/Commons.js | 86 +++---------------------------------------- 2 files changed, 5 insertions(+), 82 deletions(-) diff --git a/Panels/LayersPanel.js b/Panels/LayersPanel.js index 71e8a0a19..016943dda 100644 --- a/Panels/LayersPanel.js +++ b/Panels/LayersPanel.js @@ -327,7 +327,6 @@ function newProductsPanel () { drawLabel(label1, 1 / 2, 6 / 100, 10, thisObject.container) drawLabel(label2, 1 / 2, 9 / 100, 10, thisObject.container) - /* Images */ drawIcon(icon1, 1 / 8, 6 / 100, 40, thisObject.container) drawIcon(icon2, 7 / 8, 6 / 100, 40, thisObject.container) } diff --git a/Scales/Commons.js b/Scales/Commons.js index db0bb567e..476149859 100644 --- a/Scales/Commons.js +++ b/Scales/Commons.js @@ -1,9 +1,5 @@ function drawScaleDisplay (label1, label2, label3, xExtraOffSet1, xExtraOffSet2, xExtraOffSet3, icon1, icon2, container, backgroundColor) { - let fontSize1 = 10 - let fontSize2 = 20 - let fontSize3 = 10 - const RED_LINE_HIGHT = 4 const OPACITY = 1 @@ -22,87 +18,15 @@ function drawScaleDisplay (label1, label2, label3, xExtraOffSet1, xExtraOffSet2, /* Place the Text */ label1 = label1.substring(0, 18) - let xOffset1 = label1.length * fontSize1 * FONT_ASPECT_RATIO - - let labelPoint1 = { - x: container.frame.width * 1 / 2 - xOffset1 / 2 + xExtraOffSet1 - 5, - y: container.frame.height * 4 / 5 - } - - labelPoint1 = container.frame.frameThisPoint(labelPoint1) - let x = labelPoint1.x - labelPoint1.x = x - - browserCanvasContext.font = fontSize1 + 'px ' + UI_FONT.PRIMARY - browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)' - - browserCanvasContext.fillText(label1, labelPoint1.x, labelPoint1.y) - label2 = label2.substring(0, 20) - let xOffset2 = label2.length * fontSize2 * FONT_ASPECT_RATIO - - let labelPoint2 = { - x: container.frame.width * 1 / 2 - xOffset2 / 2 + xExtraOffSet2, - y: container.frame.height * 2 / 5 - } - - labelPoint2 = container.frame.frameThisPoint(labelPoint2) - - browserCanvasContext.font = fontSize2 + 'px ' + UI_FONT.PRIMARY - browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)' - - browserCanvasContext.fillText(label2, labelPoint2.x, labelPoint2.y) - label3 = label3.substring(0, 20) - let xOffset3 = label3.length * fontSize3 * FONT_ASPECT_RATIO - let labelPoint3 = { - x: container.frame.width * 1 / 2 - xOffset3 / 2 + xExtraOffSet3, - y: container.frame.height * 3 / 5 - } + drawLabel(label1, 1 / 2, 4 / 5, 10, container) + drawLabel(label2, 1 / 2, 2 / 5, 20, container) + drawLabel(label3, 1 / 2, 3 / 5, 10, container) - labelPoint3 = container.frame.frameThisPoint(labelPoint3) - - browserCanvasContext.font = fontSize3 + 'px ' + UI_FONT.PRIMARY - browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)' - - browserCanvasContext.fillText(label3, labelPoint3.x, labelPoint3.y) - - /* Images */ - - if (icon1 !== undefined) { - if (icon1.canDrawIcon === true) { - let imageSize = 40 - let imagePosition = { - x: container.frame.width * 1 / 8 - imageSize / 2, - y: container.frame.height / 2 - imageSize / 2 - } - - imagePosition = container.frame.frameThisPoint(imagePosition) - browserCanvasContext.drawImage( - icon1, imagePosition.x, - imagePosition.y, - imageSize, - imageSize) - } - } - - if (icon2 !== undefined) { - if (icon2.canDrawIcon === true) { - let imageSize = 40 - let imagePosition = { - x: container.frame.width * 7 / 8 - imageSize / 2, - y: container.frame.height / 2 - imageSize / 2 - } - - imagePosition = container.frame.frameThisPoint(imagePosition) - browserCanvasContext.drawImage( - icon2, imagePosition.x, - imagePosition.y, - imageSize, - imageSize) - } - } + drawIcon(icon1, 1 / 8, 1 / 2, 40, container) + drawIcon(icon2, 7 / 8, 1 / 2, 40, container) } function drawScaleDisplayCover (container) { From 62f628a591b029e62a36d6d5d2394637d7cfeb6e Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 15 Jan 2020 21:32:02 +0100 Subject: [PATCH 124/264] Bug Fixed --- Scales/RateScale.js | 10 ++++++---- Scales/TimeFrameScale.js | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Scales/RateScale.js b/Scales/RateScale.js index 71c1b9a23..0cc561907 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -167,10 +167,12 @@ function newRateScale () { } for (let i = 0; i < thisObject.payload.parentNode.payload.parentNode.timelineCharts.length; i++) { let timelineChart = thisObject.payload.parentNode.payload.parentNode.timelineCharts[i] - if (thisObject.payload.node.id !== timelineChart.rateScale.id) { - displaceFactor++ - } else { - break + if (timelineChart.rateScale !== undefined) { + if (thisObject.payload.node.id !== timelineChart.rateScale.id) { + displaceFactor++ + } else { + break + } } } } diff --git a/Scales/TimeFrameScale.js b/Scales/TimeFrameScale.js index c4b438ded..018a7a644 100644 --- a/Scales/TimeFrameScale.js +++ b/Scales/TimeFrameScale.js @@ -144,10 +144,12 @@ function newTimeFrameScale () { } for (let i = 0; i < thisObject.payload.parentNode.payload.parentNode.timelineCharts.length; i++) { let timelineChart = thisObject.payload.parentNode.payload.parentNode.timelineCharts[i] - if (thisObject.payload.node.id !== timelineChart.timeFrameScale.id) { - displaceFactor++ - } else { - break + if (timelineChart.timeFrameScale !== undefined) { + if (thisObject.payload.node.id !== timelineChart.timeFrameScale.id) { + displaceFactor++ + } else { + break + } } } } From f55679072d2d29517726574a85aaa08335db1e05 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 15 Jan 2020 22:18:27 +0100 Subject: [PATCH 125/264] Panel hidding layers as less space is available --- Panels/Layer.js | 2 +- Panels/LayersPanel.js | 48 +++++++++++++++++++++---------------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Panels/Layer.js b/Panels/Layer.js index ff0859df5..68d2eaffc 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -437,7 +437,7 @@ function newLayer () { let backgroundColor = UI_COLOR.BLACK const RED_LINE_HIGHT = 4 - const OPACITY = 1 + const OPACITY = 0.25 let params = { cornerRadius: 0, diff --git a/Panels/LayersPanel.js b/Panels/LayersPanel.js index 016943dda..426cefcdb 100644 --- a/Panels/LayersPanel.js +++ b/Panels/LayersPanel.js @@ -27,6 +27,13 @@ function newProductsPanel () { const LAYER_SEPARATION = 5 let panelTabButton + let heatherHeight = 60 + let layerHeight = 90 + let desiredVisibleLayers = 5 + let posibleVisibleLayers = 5 + let desiredPanelHeight = (layerHeight + LAYER_SEPARATION) * desiredVisibleLayers + heatherHeight + let posiblePanelHeight = (layerHeight + LAYER_SEPARATION) * posibleVisibleLayers + heatherHeight + let onMouseWheelEventSuscriptionId return thisObject @@ -49,7 +56,7 @@ function newProductsPanel () { thisObject.container.name = thisObject.payload.node.name thisObject.container.frame.containerName = thisObject.container.name thisObject.container.frame.width = UI_PANEL.WIDTH.MEDIUM - thisObject.container.frame.height = 95 * 5 + 60 + thisObject.container.frame.height = heatherHeight let position = { x: viewPort.visibleArea.topLeft.x, @@ -94,23 +101,9 @@ function newProductsPanel () { layer.container.parentContainer = thisObject.container layer.container.isWheelable = true - /* Positioning within thisObject Panel */ - let position = { - x: 0, - y: 60 - } - - layer.container.frame.position.x = position.x - layer.container.frame.position.y = position.y + layer.container.frame.height * thisObject.layers.length + LAYER_SEPARATION - /* Add to the Product Array */ thisObject.layers.push(layer) - /* Add to Visible Product Array */ - if (layer.container.frame.position.y + layer.container.frame.height < thisObject.container.frame.height) { - visibleLayers.push(layer) - } - /* Listen to Status Changes Events */ layer.onLayerStatusChangedEventSuscriptionId = layer.container.eventHandler.listenToEvent('Status Changed', onLayerStatusChanged) layer.onMouseWheelEventSuscriptionId = layer.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) @@ -133,8 +126,21 @@ function newProductsPanel () { calculateVisbleLayers() } + function panelSizePhysics () { + let viewPortHeight = viewPort.visibleArea.bottomLeft.y - viewPort.visibleArea.topLeft.y + if (desiredPanelHeight > viewPortHeight) { + posibleVisibleLayers = Math.trunc((viewPortHeight - heatherHeight) / (layerHeight + LAYER_SEPARATION)) + } else { + posibleVisibleLayers = desiredVisibleLayers + } + + posiblePanelHeight = (layerHeight + LAYER_SEPARATION) * posibleVisibleLayers + heatherHeight + thisObject.container.frame.height = posiblePanelHeight + } + function calculateVisbleLayers () { - let availableSlots = visibleLayers.length + panelSizePhysics() + let availableSlots = posibleVisibleLayers if (firstVisibleLayer < 1) { firstVisibleLayer = 1 } if (firstVisibleLayer > (thisObject.layers.length - availableSlots + 1)) { firstVisibleLayer = thisObject.layers.length - availableSlots + 1 } @@ -145,13 +151,8 @@ function newProductsPanel () { if (i + 1 >= firstVisibleLayer && i + 1 < firstVisibleLayer + availableSlots) { let layer = thisObject.layers[i] - /* Positioning within thisObject Panel */ - let position = { - x: 0, - y: 60 - } - layer.container.frame.position.x = position.x - layer.container.frame.position.y = position.y + layer.container.frame.height * visibleLayers.length + LAYER_SEPARATION + layer.container.frame.position.x = 0 + layer.container.frame.position.y = (layerHeight + LAYER_SEPARATION) * visibleLayers.length + heatherHeight /* Add to Visible Product Array */ visibleLayers.push(layer) @@ -331,4 +332,3 @@ function newProductsPanel () { drawIcon(icon2, 7 / 8, 6 / 100, 40, thisObject.container) } } - From d59561473a5cf89aed7e1d157987e22d8718fd79 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 15 Jan 2020 22:31:40 +0100 Subject: [PATCH 126/264] Bug fixed with header --- Panels/Layer.js | 18 +++++++++--------- Panels/LayersPanel.js | 8 ++++---- Scales/Commons.js | 10 +++++----- Utilities/RoundedCornersBackground.js | 14 +++++++------- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Panels/Layer.js b/Panels/Layer.js index 68d2eaffc..eb3d4a805 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -452,20 +452,20 @@ function newLayer () { roundedCornersBackground(params) if (label2 !== undefined) { - drawLabel(label1, 1 / 2, 2 / 8, 16, thisObject.container) - drawLabel(label2, 1 / 2, 4 / 8, 16, thisObject.container) + drawLabel(label1, 1 / 2, 2 / 8, 0, 0, 16, thisObject.container) + drawLabel(label2, 1 / 2, 4 / 8, 0, 0, 16, thisObject.container) } else { - drawLabel(label1, 1 / 2, 3 / 8, 20, thisObject.container) + drawLabel(label1, 1 / 2, 3 / 8, 0, 0, 20, thisObject.container) } - drawLabel(label3, 1 / 2, 6 / 8, 10, thisObject.container) - drawLabel(label4, 1 / 2, 7 / 8, 10, thisObject.container) + drawLabel(label3, 1 / 2, 6 / 8, 0, 0, 10, thisObject.container) + drawLabel(label4, 1 / 2, 7 / 8, 0, 0, 10, thisObject.container) /* Images */ - drawIcon(icon1, 1 / 8, 1 / 4, 20, thisObject.container) - drawIcon(icon2, 7 / 8, 1 / 4, 20, thisObject.container) - drawIcon(icon3, 1 / 8, 3 / 4, 20, thisObject.container) - drawIcon(icon4, 7 / 8, 3 / 4, 20, thisObject.container) + drawIcon(icon1, 1 / 8, 1 / 4, 0, 0, 20, thisObject.container) + drawIcon(icon2, 7 / 8, 1 / 4, 0, 0, 20, thisObject.container) + drawIcon(icon3, 1 / 8, 3 / 4, 0, 0, 20, thisObject.container) + drawIcon(icon4, 7 / 8, 3 / 4, 0, 0, 20, thisObject.container) } } diff --git a/Panels/LayersPanel.js b/Panels/LayersPanel.js index 426cefcdb..3c9a82d6c 100644 --- a/Panels/LayersPanel.js +++ b/Panels/LayersPanel.js @@ -325,10 +325,10 @@ function newProductsPanel () { roundedCornersBackground(params) - drawLabel(label1, 1 / 2, 6 / 100, 10, thisObject.container) - drawLabel(label2, 1 / 2, 9 / 100, 10, thisObject.container) + drawLabel(label1, 1 / 2, 0, 0, 20, 10, thisObject.container) + drawLabel(label2, 1 / 2, 0, 0, 40, 10, thisObject.container) - drawIcon(icon1, 1 / 8, 6 / 100, 40, thisObject.container) - drawIcon(icon2, 7 / 8, 6 / 100, 40, thisObject.container) + drawIcon(icon1, 1 / 8, 0, 0, 20, 40, thisObject.container) + drawIcon(icon2, 7 / 8, 0, 0, 40, 40, thisObject.container) } } diff --git a/Scales/Commons.js b/Scales/Commons.js index 476149859..9c6ad4a26 100644 --- a/Scales/Commons.js +++ b/Scales/Commons.js @@ -21,12 +21,12 @@ function drawScaleDisplay (label1, label2, label3, xExtraOffSet1, xExtraOffSet2, label2 = label2.substring(0, 20) label3 = label3.substring(0, 20) - drawLabel(label1, 1 / 2, 4 / 5, 10, container) - drawLabel(label2, 1 / 2, 2 / 5, 20, container) - drawLabel(label3, 1 / 2, 3 / 5, 10, container) + drawLabel(label1, 1 / 2, 4 / 5, 0, 0, 10, container) + drawLabel(label2, 1 / 2, 2 / 5, 0, 0, 20, container) + drawLabel(label3, 1 / 2, 3 / 5, 0, 0, 10, container) - drawIcon(icon1, 1 / 8, 1 / 2, 40, container) - drawIcon(icon2, 7 / 8, 1 / 2, 40, container) + drawIcon(icon1, 1 / 8, 1 / 2, 0, 0, 40, container) + drawIcon(icon2, 7 / 8, 1 / 2, 0, 0, 40, container) } function drawScaleDisplayCover (container) { diff --git a/Utilities/RoundedCornersBackground.js b/Utilities/RoundedCornersBackground.js index 7a2827c62..f534964ca 100644 --- a/Utilities/RoundedCornersBackground.js +++ b/Utilities/RoundedCornersBackground.js @@ -105,13 +105,13 @@ function roundedCornersBackground (params) { browserCanvasContext.stroke() } -function drawLabel (label, xFactor, yFactor, fontSize, container) { +function drawLabel (label, xFactor, yFactor, xOffset, yOffset, fontSize, container) { if (label === undefined) { return } - let xOffset = label.length * fontSize * FONT_ASPECT_RATIO + 10 + let fontOffset = label.length * fontSize * FONT_ASPECT_RATIO + 10 let labelPoint = { - x: container.frame.width * xFactor - xOffset / 2, - y: container.frame.height * yFactor + x: container.frame.width * xFactor + xOffset - fontOffset / 2, + y: container.frame.height * yFactor + yOffset } labelPoint = container.frame.frameThisPoint(labelPoint) @@ -122,12 +122,12 @@ function drawLabel (label, xFactor, yFactor, fontSize, container) { browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y) } -function drawIcon (icon, xFactor, yFactor, imageSize, container) { +function drawIcon (icon, xFactor, yFactor, xOffset, yOffset, imageSize, container) { if (icon !== undefined) { if (icon.canDrawIcon === true) { let imagePosition = { - x: container.frame.width * xFactor - imageSize / 2, - y: container.frame.height * yFactor - imageSize / 2 + x: container.frame.width * xFactor + xOffset - imageSize / 2, + y: container.frame.height * yFactor + yOffset - imageSize / 2 } imagePosition = container.frame.frameThisPoint(imagePosition) From bf380732809e70aa8d63a04b424640b4cf55f03b Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 15 Jan 2020 22:40:46 +0100 Subject: [PATCH 127/264] Added Footer --- Panels/Layer.js | 2 +- Panels/LayersPanel.js | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Panels/Layer.js b/Panels/Layer.js index eb3d4a805..7cd1cb82e 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -437,7 +437,7 @@ function newLayer () { let backgroundColor = UI_COLOR.BLACK const RED_LINE_HIGHT = 4 - const OPACITY = 0.25 + const OPACITY = 0.75 let params = { cornerRadius: 0, diff --git a/Panels/LayersPanel.js b/Panels/LayersPanel.js index 3c9a82d6c..0c629f7d9 100644 --- a/Panels/LayersPanel.js +++ b/Panels/LayersPanel.js @@ -24,15 +24,16 @@ function newProductsPanel () { let visibleLayers = [] let firstVisibleLayer = 1 - const LAYER_SEPARATION = 5 + const LAYER_SEPARATION = 0 let panelTabButton let heatherHeight = 60 + let footerHeight = 15 let layerHeight = 90 let desiredVisibleLayers = 5 let posibleVisibleLayers = 5 - let desiredPanelHeight = (layerHeight + LAYER_SEPARATION) * desiredVisibleLayers + heatherHeight - let posiblePanelHeight = (layerHeight + LAYER_SEPARATION) * posibleVisibleLayers + heatherHeight + let desiredPanelHeight = (layerHeight + LAYER_SEPARATION) * desiredVisibleLayers + heatherHeight + footerHeight + let posiblePanelHeight = (layerHeight + LAYER_SEPARATION) * posibleVisibleLayers + heatherHeight + footerHeight let onMouseWheelEventSuscriptionId return thisObject @@ -129,12 +130,13 @@ function newProductsPanel () { function panelSizePhysics () { let viewPortHeight = viewPort.visibleArea.bottomLeft.y - viewPort.visibleArea.topLeft.y if (desiredPanelHeight > viewPortHeight) { - posibleVisibleLayers = Math.trunc((viewPortHeight - heatherHeight) / (layerHeight + LAYER_SEPARATION)) + posibleVisibleLayers = Math.trunc((viewPortHeight - heatherHeight - footerHeight) / (layerHeight + LAYER_SEPARATION)) } else { posibleVisibleLayers = desiredVisibleLayers } + if (thisObject.layers.length < posibleVisibleLayers) { posibleVisibleLayers = thisObject.layers.length } - posiblePanelHeight = (layerHeight + LAYER_SEPARATION) * posibleVisibleLayers + heatherHeight + posiblePanelHeight = (layerHeight + LAYER_SEPARATION) * posibleVisibleLayers + heatherHeight + footerHeight thisObject.container.frame.height = posiblePanelHeight } @@ -328,7 +330,7 @@ function newProductsPanel () { drawLabel(label1, 1 / 2, 0, 0, 20, 10, thisObject.container) drawLabel(label2, 1 / 2, 0, 0, 40, 10, thisObject.container) - drawIcon(icon1, 1 / 8, 0, 0, 20, 40, thisObject.container) - drawIcon(icon2, 7 / 8, 0, 0, 40, 40, thisObject.container) + drawIcon(icon1, 1 / 8, 0, 0, 30, 40, thisObject.container) + drawIcon(icon2, 7 / 8, 0, 0, 30, 40, thisObject.container) } } From d4185f123579e3217365beac9c5d5adf4026ced2 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 15 Jan 2020 23:12:23 +0100 Subject: [PATCH 128/264] Rolling Up and Down --- Panels/LayersPanel.js | 17 ++++++++++++++--- Scales/Commons.js | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Panels/LayersPanel.js b/Panels/LayersPanel.js index 0c629f7d9..46c2fc459 100644 --- a/Panels/LayersPanel.js +++ b/Panels/LayersPanel.js @@ -122,8 +122,14 @@ function newProductsPanel () { delta = 1 } - firstVisibleLayer = firstVisibleLayer + delta - + if (event.y - thisObject.container.frame.position.y - CURRENT_TOP_MARGIN < heatherHeight) { + desiredVisibleLayers = desiredVisibleLayers + delta + if (desiredVisibleLayers < 0) { desiredVisibleLayers = 0 } + if (desiredVisibleLayers > thisObject.layers.length) { desiredVisibleLayers = thisObject.layers.length } + } else { + firstVisibleLayer = firstVisibleLayer + delta + } + desiredPanelHeight = (layerHeight + LAYER_SEPARATION) * desiredVisibleLayers + heatherHeight + footerHeight calculateVisbleLayers() } @@ -136,7 +142,12 @@ function newProductsPanel () { } if (thisObject.layers.length < posibleVisibleLayers) { posibleVisibleLayers = thisObject.layers.length } - posiblePanelHeight = (layerHeight + LAYER_SEPARATION) * posibleVisibleLayers + heatherHeight + footerHeight + if (posibleVisibleLayers === 0) { + posiblePanelHeight = (layerHeight + LAYER_SEPARATION) * posibleVisibleLayers + heatherHeight + } else { + posiblePanelHeight = (layerHeight + LAYER_SEPARATION) * posibleVisibleLayers + heatherHeight + footerHeight + } + thisObject.container.frame.height = posiblePanelHeight } diff --git a/Scales/Commons.js b/Scales/Commons.js index 9c6ad4a26..0e5bce110 100644 --- a/Scales/Commons.js +++ b/Scales/Commons.js @@ -37,7 +37,7 @@ function drawScaleDisplayCover (container) { borderColor: UI_COLOR.WHITE, castShadow: false, backgroundColor: UI_COLOR.WHITE, - opacity: '0.75' + opacity: '0.50' } roundedCornersBackground(params) From 2ac47410046a5f340d112551859c21618abcbd97 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 16 Jan 2020 09:26:44 +0100 Subject: [PATCH 129/264] Scroll Bar done --- Panels/LayersPanel.js | 49 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/Panels/LayersPanel.js b/Panels/LayersPanel.js index 46c2fc459..039a3fa30 100644 --- a/Panels/LayersPanel.js +++ b/Panels/LayersPanel.js @@ -312,7 +312,7 @@ function newProductsPanel () { for (let i = 0; i < visibleLayers.length; i++) { visibleLayers[i].draw() } - + drawScrollBar() panelTabButton.draw() } @@ -344,4 +344,51 @@ function newProductsPanel () { drawIcon(icon1, 1 / 8, 0, 0, 30, 40, thisObject.container) drawIcon(icon2, 7 / 8, 0, 0, 30, 40, thisObject.container) } + + function drawScrollBar () { + if (thisObject.layers.length > posibleVisibleLayers && posibleVisibleLayers > 0) { + let xOffset = 5 + let barTopPoint = { + x: thisObject.container.frame.width - xOffset, + y: heatherHeight + } + let barBottomPoint = { + x: thisObject.container.frame.width - xOffset, + y: thisObject.container.frame.height - footerHeight + } + let ratio = posibleVisibleLayers / thisObject.layers.length + let handleHeight = (posibleVisibleLayers * (layerHeight + LAYER_SEPARATION)) * ratio + let handleTopPoint = { + x: thisObject.container.frame.width - xOffset, + y: heatherHeight + (layerHeight + LAYER_SEPARATION) * ratio * (firstVisibleLayer - 1) + } + let handleBottomPoint = { + x: thisObject.container.frame.width - xOffset, + y: handleTopPoint.y + handleHeight + } + barTopPoint = thisObject.container.frame.frameThisPoint(barTopPoint) + barBottomPoint = thisObject.container.frame.frameThisPoint(barBottomPoint) + handleTopPoint = thisObject.container.frame.frameThisPoint(handleTopPoint) + handleBottomPoint = thisObject.container.frame.frameThisPoint(handleBottomPoint) + + browserCanvasContext.beginPath() + browserCanvasContext.moveTo(barTopPoint.x, barTopPoint.y) + browserCanvasContext.lineTo(barBottomPoint.x, barBottomPoint.y) + browserCanvasContext.closePath() + browserCanvasContext.setLineDash([0, 0]) + browserCanvasContext.lineWidth = 1 + browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.GREY + ', ' + 1 + ')' + browserCanvasContext.stroke() + + browserCanvasContext.beginPath() + browserCanvasContext.moveTo(handleTopPoint.x, handleTopPoint.y) + browserCanvasContext.lineTo(handleBottomPoint.x, handleBottomPoint.y) + browserCanvasContext.closePath() + browserCanvasContext.setLineDash([0, 0]) + browserCanvasContext.lineWidth = 6 + browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.PATINATED_TURQUOISE + ', ' + 1 + ')' + browserCanvasContext.stroke() + } + } } + From 261fdbd5999542f08105c415241149bb21405215 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 16 Jan 2020 09:37:52 +0100 Subject: [PATCH 130/264] Fine Tunning --- Frame.js | 4 ++++ Panels/LayersPanel.js | 2 +- Scales/Commons.js | 6 +++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Frame.js b/Frame.js index 943a18a25..51a72a13e 100644 --- a/Frame.js +++ b/Frame.js @@ -290,6 +290,7 @@ function newFrame () { browserCanvasContext.lineWidth = 0.1 browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.MANGANESE_PURPLE + ', 0.75)' + browserCanvasContext.setLineDash([0, 0]) browserCanvasContext.stroke() /* print the title */ @@ -373,6 +374,7 @@ function newFrame () { browserCanvasContext.strokeStyle = 'rgba(150, 150, 150, 1)' browserCanvasContext.lineWidth = 1 + browserCanvasContext.setLineDash([0, 0]) browserCanvasContext.stroke() browserCanvasContext.closePath() @@ -434,6 +436,7 @@ function newFrame () { browserCanvasContext.closePath() browserCanvasContext.strokeStyle = 'rgba(150, 150, 150, 0.1)' browserCanvasContext.lineWidth = 1 + browserCanvasContext.setLineDash([0, 0]) browserCanvasContext.stroke() } @@ -491,6 +494,7 @@ function newFrame () { browserCanvasContext.closePath() browserCanvasContext.strokeStyle = 'rgba(100, 100, 100, 0.2)' browserCanvasContext.lineWidth = 1 + browserCanvasContext.setLineDash([0, 0]) browserCanvasContext.stroke() } } diff --git a/Panels/LayersPanel.js b/Panels/LayersPanel.js index 039a3fa30..e8a8e9ec3 100644 --- a/Panels/LayersPanel.js +++ b/Panels/LayersPanel.js @@ -328,7 +328,7 @@ function newProductsPanel () { let params = { cornerRadius: 15, - lineWidth: 2, + lineWidth: 1, container: thisObject.container, borderColor: UI_COLOR.RUSTED_RED, castShadow: false, diff --git a/Scales/Commons.js b/Scales/Commons.js index 0e5bce110..dfbdd37de 100644 --- a/Scales/Commons.js +++ b/Scales/Commons.js @@ -5,7 +5,7 @@ function drawScaleDisplay (label1, label2, label3, xExtraOffSet1, xExtraOffSet2, let params = { cornerRadius: 15, - lineWidth: 2, + lineWidth: 1, container: container, borderColor: UI_COLOR.RUSTED_RED, castShadow: false, @@ -32,12 +32,12 @@ function drawScaleDisplay (label1, label2, label3, xExtraOffSet1, xExtraOffSet2, function drawScaleDisplayCover (container) { let params = { cornerRadius: 15, - lineWidth: 2, + lineWidth: 1, container: container, borderColor: UI_COLOR.WHITE, castShadow: false, backgroundColor: UI_COLOR.WHITE, - opacity: '0.50' + opacity: '0.25' } roundedCornersBackground(params) From 4e7dd306c437e6a8fc6ecaf79463dc9881aa4a03 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 16 Jan 2020 11:28:57 +0100 Subject: [PATCH 131/264] Bug fixes --- Panels/LayersPanel.js | 10 +++++++++- Spaces/ChartSpace.js | 7 +++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Panels/LayersPanel.js b/Panels/LayersPanel.js index e8a8e9ec3..3ef32dbbd 100644 --- a/Panels/LayersPanel.js +++ b/Panels/LayersPanel.js @@ -27,6 +27,7 @@ function newProductsPanel () { const LAYER_SEPARATION = 0 let panelTabButton + let visible = true let heatherHeight = 60 let footerHeight = 15 let layerHeight = 90 @@ -135,6 +136,13 @@ function newProductsPanel () { function panelSizePhysics () { let viewPortHeight = viewPort.visibleArea.bottomLeft.y - viewPort.visibleArea.topLeft.y + + if (viewPortHeight < heatherHeight) { + visible = false + } else { + visible = true + } + if (desiredPanelHeight > viewPortHeight) { posibleVisibleLayers = Math.trunc((viewPortHeight - heatherHeight - footerHeight) / (layerHeight + LAYER_SEPARATION)) } else { @@ -304,7 +312,7 @@ function newProductsPanel () { } function draw () { - if (isInitialized === false) { return } + if (isInitialized === false || visible === false) { return } // thisObject.container.frame.draw(false, false, false, thisObject.fitFunction) diff --git a/Spaces/ChartSpace.js b/Spaces/ChartSpace.js index 5726e7ebb..a9a2b8118 100644 --- a/Spaces/ChartSpace.js +++ b/Spaces/ChartSpace.js @@ -242,10 +242,14 @@ function newChartSpace () { } function initializeTimeMachine (node, syncWithDesignerLoop) { + if (node.payload === undefined) { return } // not ready to consider this Time Machine + if (node.payload.uiObject === undefined) { return } + let timeMachine = newTimeMachine() timeMachine.syncWithDesignerLoop = syncWithDesignerLoop timeMachine.payload = node.payload timeMachine.nodeId = node.id + timeMachinesMap.set(node.id, timeMachine) timeMachine.payload.uiObject.setValue('Loading...') @@ -282,6 +286,9 @@ function newChartSpace () { function childrenPhysics () { for (let i = 0; i < thisObject.timeMachines.length; i++) { let timeMachine = thisObject.timeMachines[i] + if (timeMachine.payload.node === undefined) { + continue + } if (timeMachine.container.frame.isInViewPort()) { timeMachine.physics() From 4bee5930da1372379af151ecc38176d32a4b7244 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 16 Jan 2020 11:38:09 +0100 Subject: [PATCH 132/264] replacing workspace bug fixed --- DesignerSpace/Workspace/Workspace.js | 3 +-- Spaces/ChartSpace.js | 27 ++++++++++++++++++++------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/DesignerSpace/Workspace/Workspace.js b/DesignerSpace/Workspace/Workspace.js index 34d758b20..7f16509a3 100644 --- a/DesignerSpace/Workspace/Workspace.js +++ b/DesignerSpace/Workspace/Workspace.js @@ -136,8 +136,7 @@ function newWorkspace () { workingAtTask++ break case 5: - canvas.chartSpace.finalize() - canvas.chartSpace.initialize() + canvas.chartSpace.reset() workingAtTask++ break case 6: diff --git a/Spaces/ChartSpace.js b/Spaces/ChartSpace.js index a9a2b8118..61f5858ce 100644 --- a/Spaces/ChartSpace.js +++ b/Spaces/ChartSpace.js @@ -13,10 +13,11 @@ function newChartSpace () { logger.fileName = MODULE_NAME let thisObject = { - visible: true, + visible: undefined, container: undefined, - inViewport: new Map(), - timeMachines: [], + inViewport: undefined, + timeMachines: undefined, + reset: reset, oneScreenUp: oneScreenUp, oneScreenDown: oneScreenDown, oneScreenLeft: oneScreenLeft, @@ -31,15 +32,27 @@ function newChartSpace () { } let canvasBrowserResizedEventSubscriptionId - let timeMachinesMap = new Map() - let syncWithDesignerLoop = 0 + let timeMachinesMap + let syncWithDesignerLoop const PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT = 25 - setupContainer() + initialSetup() return thisObject - function setupContainer () { + function reset () { + finalize() + initialSetup() + initialize() + } + + function initialSetup () { + thisObject.timeMachines = [] + thisObject.visible = true + timeMachinesMap = new Map() + syncWithDesignerLoop = 0 + thisObject.inViewport = new Map() + thisObject.container = newContainer() thisObject.container.initialize(MODULE_NAME) From b2a0fbab96ce4c5060f148b52754e2001cd5cff5 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 16 Jan 2020 13:44:43 +0100 Subject: [PATCH 133/264] Several aesthetic adjustments --- Canvas.js | 2 +- FloatingSpace/UiObjectTitle.js | 2 +- Globals.js | 4 ++-- Panels/Layer.js | 39 +++++++++++++++------------------- Panels/LayersPanel.js | 16 +++++++------- Scales/Commons.js | 8 +++---- Scales/RateScale.js | 4 ++-- Scales/TimeFrameScale.js | 4 ++-- Scales/TimeScale.js | 4 ++-- SplashScreen.js | 2 +- 10 files changed, 40 insertions(+), 45 deletions(-) diff --git a/Canvas.js b/Canvas.js index b6c7cd525..4d4110faf 100644 --- a/Canvas.js +++ b/Canvas.js @@ -144,7 +144,7 @@ function newCanvas () { function initializeBrowserCanvas () { try { browserCanvasContext = browserCanvas.getContext('2d') - browserCanvasContext.font = 'Saira' + browserCanvasContext.font = 'Saira Condensed' viewPort.initialize() } catch (err) { diff --git a/FloatingSpace/UiObjectTitle.js b/FloatingSpace/UiObjectTitle.js index 49e4c153c..4d5d777b9 100644 --- a/FloatingSpace/UiObjectTitle.js +++ b/FloatingSpace/UiObjectTitle.js @@ -181,7 +181,7 @@ function newUiObjectTitle () { } } - input.style = 'resize: none; border: none; outline: none; box-shadow: none; overflow:hidden; font-family: Saira; font-size: ' + fontSize + 'px; background-color: rgb(' + backgroundColor + ');color:rgb(255, 255, 255); width: ' + WIDTH + 'px; height: ' + HEIGHT + 'px' + input.style = 'resize: none; border: none; outline: none; box-shadow: none; overflow:hidden; font-family: Saira Condensed; font-size: ' + fontSize + 'px; background-color: rgb(' + backgroundColor + ');color:rgb(255, 255, 255); width: ' + WIDTH + 'px; height: ' + HEIGHT + 'px' input.style.display = 'block' input.focus() } diff --git a/Globals.js b/Globals.js index 2e9f15a6c..8b29030a7 100644 --- a/Globals.js +++ b/Globals.js @@ -37,11 +37,11 @@ UI_COLOR = { /* User Interface Fonts */ UI_FONT = { - PRIMARY: "Saira", + PRIMARY: "Saira Condensed", SECONDARY: "Source Code Pro" }; -FONT_ASPECT_RATIO = 0.45; +let FONT_ASPECT_RATIO = 0.35; const MIN_ZOOM_LEVEL = -28.25 const GET_CONTAINER_PURPOSE = { diff --git a/Panels/Layer.js b/Panels/Layer.js index 7cd1cb82e..ec12bd93a 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -120,8 +120,8 @@ function newLayer () { } thisObject.container.frame.position = position - thisObject.container.frame.width = UI_PANEL.WIDTH.MEDIUM - thisObject.container.frame.height = 90 + thisObject.container.frame.width = UI_PANEL.WIDTH.NORMAL + thisObject.container.frame.height = 70 let functionLibraryProtocolNode = newProtocolNode() let lightingPath = @@ -323,15 +323,15 @@ function newLayer () { drawLayerDisplay() - drawProgressBar(marketFileProgressBar, 1, -5) - drawProgressBar(dailyFileProgressBar, 1, -6) - drawProgressBar(singleFileProgressBar, 1, -7) - drawProgressBar(fileSequenceProgressBar, 1, -8) + drawProgressBar(marketFileProgressBar, 1, -55) + drawProgressBar(dailyFileProgressBar, 1, -56) + drawProgressBar(singleFileProgressBar, 1, -57) + drawProgressBar(fileSequenceProgressBar, 1, -58) function drawProgressBar (progressBar, lineWidth, offsetY) { let point1 let point2 - let horizontalMargin = 50 + let horizontalMargin = 15 if (progressBar.value === 0) { return @@ -393,13 +393,13 @@ function newLayer () { let plotterModule = thisObject.definition.referenceParent.referenceParent.referenceParent let labelArray = thisObject.payload.node.name.split(' ') - let label1 = labelArray[0] - let label2 = labelArray[1] + let label1 = thisObject.payload.node.name + let label2 = '' let label3 = exchange.name.substring(0, 15) + ' - ' + market let label4 = thisObject.status.toUpperCase() if (label1 !== undefined) { - label1 = label1.substring(0, 15) + label1 = label1.substring(0, 22) } if (label2 !== undefined) { label2 = label2.substring(0, 15) @@ -451,21 +451,16 @@ function newLayer () { roundedCornersBackground(params) - if (label2 !== undefined) { - drawLabel(label1, 1 / 2, 2 / 8, 0, 0, 16, thisObject.container) - drawLabel(label2, 1 / 2, 4 / 8, 0, 0, 16, thisObject.container) - } else { - drawLabel(label1, 1 / 2, 3 / 8, 0, 0, 20, thisObject.container) - } + drawLabel(label1, 1 / 2, 6 / 10, -5, 0, 17, thisObject.container) - drawLabel(label3, 1 / 2, 6 / 8, 0, 0, 10, thisObject.container) - drawLabel(label4, 1 / 2, 7 / 8, 0, 0, 10, thisObject.container) + drawLabel(label3, 1 / 2, 8.2 / 10, -5, 0, 10, thisObject.container) + drawLabel(label4, 1 / 2, 9.5 / 10, -5, 0, 10, thisObject.container) /* Images */ - drawIcon(icon1, 1 / 8, 1 / 4, 0, 0, 20, thisObject.container) - drawIcon(icon2, 7 / 8, 1 / 4, 0, 0, 20, thisObject.container) - drawIcon(icon3, 1 / 8, 3 / 4, 0, 0, 20, thisObject.container) - drawIcon(icon4, 7 / 8, 3 / 4, 0, 0, 20, thisObject.container) + drawIcon(icon1, 1 / 8, 2 / 10, 0, 0, 15, thisObject.container) + drawIcon(icon2, 7 / 8, 2 / 10, 0, 0, 15, thisObject.container) + drawIcon(icon3, 3 / 8, 2 / 10, 0, 0, 15, thisObject.container) + drawIcon(icon4, 5 / 8, 2 / 10, 0, 0, 15, thisObject.container) } } diff --git a/Panels/LayersPanel.js b/Panels/LayersPanel.js index 3ef32dbbd..d6153345d 100644 --- a/Panels/LayersPanel.js +++ b/Panels/LayersPanel.js @@ -28,9 +28,9 @@ function newProductsPanel () { let panelTabButton let visible = true - let heatherHeight = 60 + let heatherHeight = 50 let footerHeight = 15 - let layerHeight = 90 + let layerHeight = 70 let desiredVisibleLayers = 5 let posibleVisibleLayers = 5 let desiredPanelHeight = (layerHeight + LAYER_SEPARATION) * desiredVisibleLayers + heatherHeight + footerHeight @@ -57,7 +57,7 @@ function newProductsPanel () { function initialize () { thisObject.container.name = thisObject.payload.node.name thisObject.container.frame.containerName = thisObject.container.name - thisObject.container.frame.width = UI_PANEL.WIDTH.MEDIUM + thisObject.container.frame.width = UI_PANEL.WIDTH.NORMAL thisObject.container.frame.height = heatherHeight let position = { @@ -335,7 +335,7 @@ function newProductsPanel () { let backgroundColor = UI_COLOR.BLACK let params = { - cornerRadius: 15, + cornerRadius: 5, lineWidth: 1, container: thisObject.container, borderColor: UI_COLOR.RUSTED_RED, @@ -349,13 +349,13 @@ function newProductsPanel () { drawLabel(label1, 1 / 2, 0, 0, 20, 10, thisObject.container) drawLabel(label2, 1 / 2, 0, 0, 40, 10, thisObject.container) - drawIcon(icon1, 1 / 8, 0, 0, 30, 40, thisObject.container) - drawIcon(icon2, 7 / 8, 0, 0, 30, 40, thisObject.container) + drawIcon(icon1, 1 / 8, 0, 0, 30, 30, thisObject.container) + drawIcon(icon2, 7 / 8, 0, 0, 30, 30, thisObject.container) } function drawScrollBar () { if (thisObject.layers.length > posibleVisibleLayers && posibleVisibleLayers > 0) { - let xOffset = 5 + let xOffset = 4 let barTopPoint = { x: thisObject.container.frame.width - xOffset, y: heatherHeight @@ -393,7 +393,7 @@ function newProductsPanel () { browserCanvasContext.lineTo(handleBottomPoint.x, handleBottomPoint.y) browserCanvasContext.closePath() browserCanvasContext.setLineDash([0, 0]) - browserCanvasContext.lineWidth = 6 + browserCanvasContext.lineWidth = 4 browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.PATINATED_TURQUOISE + ', ' + 1 + ')' browserCanvasContext.stroke() } diff --git a/Scales/Commons.js b/Scales/Commons.js index dfbdd37de..f07fb2fe5 100644 --- a/Scales/Commons.js +++ b/Scales/Commons.js @@ -4,7 +4,7 @@ function drawScaleDisplay (label1, label2, label3, xExtraOffSet1, xExtraOffSet2, const OPACITY = 1 let params = { - cornerRadius: 15, + cornerRadius: 5, lineWidth: 1, container: container, borderColor: UI_COLOR.RUSTED_RED, @@ -25,13 +25,13 @@ function drawScaleDisplay (label1, label2, label3, xExtraOffSet1, xExtraOffSet2, drawLabel(label2, 1 / 2, 2 / 5, 0, 0, 20, container) drawLabel(label3, 1 / 2, 3 / 5, 0, 0, 10, container) - drawIcon(icon1, 1 / 8, 1 / 2, 0, 0, 40, container) - drawIcon(icon2, 7 / 8, 1 / 2, 0, 0, 40, container) + drawIcon(icon1, 1 / 8, 1 / 2, 0, 0, 30, container) + drawIcon(icon2, 7 / 8, 1 / 2, 0, 0, 30, container) } function drawScaleDisplayCover (container) { let params = { - cornerRadius: 15, + cornerRadius: 5, lineWidth: 1, container: container, borderColor: UI_COLOR.WHITE, diff --git a/Scales/RateScale.js b/Scales/RateScale.js index 0cc561907..1c3c8ef4f 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -28,8 +28,8 @@ function newRateScale () { thisObject.container.isWheelable = true thisObject.container.detectMouseOver = true - thisObject.container.frame.width = 200 - thisObject.container.frame.height = 60 + thisObject.container.frame.width = UI_PANEL.WIDTH.NORMAL + thisObject.container.frame.height = 50 let visible = true let isMouseOver diff --git a/Scales/TimeFrameScale.js b/Scales/TimeFrameScale.js index 018a7a644..8d2b1b696 100644 --- a/Scales/TimeFrameScale.js +++ b/Scales/TimeFrameScale.js @@ -54,8 +54,8 @@ function newTimeFrameScale () { thisObject.container.isWheelable = true thisObject.container.detectMouseOver = true - thisObject.container.frame.width = 200 - thisObject.container.frame.height = 60 + thisObject.container.frame.width = UI_PANEL.WIDTH.NORMAL + thisObject.container.frame.height = 50 } function finalize () { diff --git a/Scales/TimeScale.js b/Scales/TimeScale.js index 88260326e..2ddc33294 100644 --- a/Scales/TimeScale.js +++ b/Scales/TimeScale.js @@ -27,8 +27,8 @@ function newTimeScale () { thisObject.container.isWheelable = true thisObject.container.detectMouseOver = true - thisObject.container.frame.width = 200 - thisObject.container.frame.height = 60 + thisObject.container.frame.width = UI_PANEL.WIDTH.NORMAL + thisObject.container.frame.height = 50 let visible = true let isMouseOver diff --git a/SplashScreen.js b/SplashScreen.js index c73dcad85..1bfc3ca07 100644 --- a/SplashScreen.js +++ b/SplashScreen.js @@ -133,7 +133,7 @@ function newSplashScreen () { } browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY - browserCanvasContext.font = 'Saira' + browserCanvasContext.font = 'Saira Condensed' browserCanvasContext.fillStyle = 'rgba(0, 0, 0, ' + opacity + ')' browserCanvasContext.fillText(title, titlePoint.x, titlePoint.y) } From 0a9dd387865141111229c3d4694e196c00687eaf Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 16 Jan 2020 14:12:36 +0100 Subject: [PATCH 134/264] More fine tunning --- Globals.js | 2 +- Panels/LayersPanel.js | 12 ++++++------ Scales/Commons.js | 10 +++++----- Scales/RateScale.js | 2 +- Scales/TimeFrameScale.js | 2 +- Scales/TimeScale.js | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Globals.js b/Globals.js index 8b29030a7..8c5fa7858 100644 --- a/Globals.js +++ b/Globals.js @@ -41,7 +41,7 @@ UI_FONT = { SECONDARY: "Source Code Pro" }; -let FONT_ASPECT_RATIO = 0.35; +let FONT_ASPECT_RATIO = 0.32; const MIN_ZOOM_LEVEL = -28.25 const GET_CONTAINER_PURPOSE = { diff --git a/Panels/LayersPanel.js b/Panels/LayersPanel.js index d6153345d..debf7c8b0 100644 --- a/Panels/LayersPanel.js +++ b/Panels/LayersPanel.js @@ -28,8 +28,8 @@ function newProductsPanel () { let panelTabButton let visible = true - let heatherHeight = 50 - let footerHeight = 15 + let heatherHeight = 40 + let footerHeight = 10 let layerHeight = 70 let desiredVisibleLayers = 5 let posibleVisibleLayers = 5 @@ -346,11 +346,11 @@ function newProductsPanel () { roundedCornersBackground(params) - drawLabel(label1, 1 / 2, 0, 0, 20, 10, thisObject.container) - drawLabel(label2, 1 / 2, 0, 0, 40, 10, thisObject.container) + drawLabel(label1, 1 / 2, 0, 0, 15, 10, thisObject.container) + drawLabel(label2, 1 / 2, 0, 0, 30, 10, thisObject.container) - drawIcon(icon1, 1 / 8, 0, 0, 30, 30, thisObject.container) - drawIcon(icon2, 7 / 8, 0, 0, 30, 30, thisObject.container) + drawIcon(icon1, 1 / 8, 0, 0, 20, 35, thisObject.container) + drawIcon(icon2, 7 / 8, 0, 0, 20, 35, thisObject.container) } function drawScrollBar () { diff --git a/Scales/Commons.js b/Scales/Commons.js index f07fb2fe5..9011b35cf 100644 --- a/Scales/Commons.js +++ b/Scales/Commons.js @@ -21,12 +21,12 @@ function drawScaleDisplay (label1, label2, label3, xExtraOffSet1, xExtraOffSet2, label2 = label2.substring(0, 20) label3 = label3.substring(0, 20) - drawLabel(label1, 1 / 2, 4 / 5, 0, 0, 10, container) - drawLabel(label2, 1 / 2, 2 / 5, 0, 0, 20, container) - drawLabel(label3, 1 / 2, 3 / 5, 0, 0, 10, container) + drawLabel(label1, 1 / 2, 92 / 100, 0, 0, 10, container) + drawLabel(label2, 1 / 2, 42 / 100, 0, 0, 18, container) + drawLabel(label3, 1 / 2, 67 / 100, 0, 0, 10, container) - drawIcon(icon1, 1 / 8, 1 / 2, 0, 0, 30, container) - drawIcon(icon2, 7 / 8, 1 / 2, 0, 0, 30, container) + drawIcon(icon1, 1 / 8, 1 / 2, 0, 0, 35, container) + drawIcon(icon2, 7 / 8, 1 / 2, 0, 0, 35, container) } function drawScaleDisplayCover (container) { diff --git a/Scales/RateScale.js b/Scales/RateScale.js index 1c3c8ef4f..330049e80 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -29,7 +29,7 @@ function newRateScale () { thisObject.container.detectMouseOver = true thisObject.container.frame.width = UI_PANEL.WIDTH.NORMAL - thisObject.container.frame.height = 50 + thisObject.container.frame.height = 40 let visible = true let isMouseOver diff --git a/Scales/TimeFrameScale.js b/Scales/TimeFrameScale.js index 8d2b1b696..0ab1af933 100644 --- a/Scales/TimeFrameScale.js +++ b/Scales/TimeFrameScale.js @@ -55,7 +55,7 @@ function newTimeFrameScale () { thisObject.container.detectMouseOver = true thisObject.container.frame.width = UI_PANEL.WIDTH.NORMAL - thisObject.container.frame.height = 50 + thisObject.container.frame.height = 40 } function finalize () { diff --git a/Scales/TimeScale.js b/Scales/TimeScale.js index 2ddc33294..b3293ec29 100644 --- a/Scales/TimeScale.js +++ b/Scales/TimeScale.js @@ -28,7 +28,7 @@ function newTimeScale () { thisObject.container.detectMouseOver = true thisObject.container.frame.width = UI_PANEL.WIDTH.NORMAL - thisObject.container.frame.height = 50 + thisObject.container.frame.height = 40 let visible = true let isMouseOver From 64d13afac58f298a7673e665b31c44c5b6c803b1 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 16 Jan 2020 14:37:29 +0100 Subject: [PATCH 135/264] Standarizing sizes --- Globals.js | 25 ------------------------- Panels/Layer.js | 6 +++--- Panels/LayersPanel.js | 8 ++++---- Scales/Commons.js | 9 +++++---- Utilities.js | 15 +++++++++++++++ 5 files changed, 27 insertions(+), 36 deletions(-) diff --git a/Globals.js b/Globals.js index 8c5fa7858..3727148bc 100644 --- a/Globals.js +++ b/Globals.js @@ -99,31 +99,6 @@ let dailyFilePeriods = dailyFilePeriods = JSON.parse(dailyFilePeriods); -function convertTimeFrameToName(pTimeFrame) { - - for (let i = 0; i < dailyFilePeriods.length; i++) { - - let period = dailyFilePeriods[i]; - - if (period[0] === pTimeFrame) { - - return period[1]; - - } - } - - for (let i = 0; i < marketFilesPeriods.length; i++) { - - let period = marketFilesPeriods[i]; - - if (period[0] === pTimeFrame) { - - return period[1]; - - } - } -} - window.AT_BREAKPOINT = false; let testUser = window.localStorage.getItem("test_user") diff --git a/Panels/Layer.js b/Panels/Layer.js index ec12bd93a..95272fb30 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -451,10 +451,10 @@ function newLayer () { roundedCornersBackground(params) - drawLabel(label1, 1 / 2, 6 / 10, -5, 0, 17, thisObject.container) + drawLabel(label1, 1 / 2, 6 / 10, -5, 0, 18, thisObject.container) - drawLabel(label3, 1 / 2, 8.2 / 10, -5, 0, 10, thisObject.container) - drawLabel(label4, 1 / 2, 9.5 / 10, -5, 0, 10, thisObject.container) + drawLabel(label3, 1 / 2, 8.2 / 10, -5, 0, 9, thisObject.container) + drawLabel(label4, 1 / 2, 9.5 / 10, -5, 0, 9, thisObject.container) /* Images */ drawIcon(icon1, 1 / 8, 2 / 10, 0, 0, 15, thisObject.container) diff --git a/Panels/LayersPanel.js b/Panels/LayersPanel.js index debf7c8b0..0bcf9cb7f 100644 --- a/Panels/LayersPanel.js +++ b/Panels/LayersPanel.js @@ -346,11 +346,11 @@ function newProductsPanel () { roundedCornersBackground(params) - drawLabel(label1, 1 / 2, 0, 0, 15, 10, thisObject.container) - drawLabel(label2, 1 / 2, 0, 0, 30, 10, thisObject.container) + drawLabel(label1, 1 / 2, 0, 0, 15, 9, thisObject.container) + drawLabel(label2, 1 / 2, 0, 0, 30, 9, thisObject.container) - drawIcon(icon1, 1 / 8, 0, 0, 20, 35, thisObject.container) - drawIcon(icon2, 7 / 8, 0, 0, 20, 35, thisObject.container) + drawIcon(icon1, 1 / 8, 0, 0, 20, 32, thisObject.container) + drawIcon(icon2, 7 / 8, 0, 0, 20, 32, thisObject.container) } function drawScrollBar () { diff --git a/Scales/Commons.js b/Scales/Commons.js index 9011b35cf..381dd53a0 100644 --- a/Scales/Commons.js +++ b/Scales/Commons.js @@ -21,12 +21,12 @@ function drawScaleDisplay (label1, label2, label3, xExtraOffSet1, xExtraOffSet2, label2 = label2.substring(0, 20) label3 = label3.substring(0, 20) - drawLabel(label1, 1 / 2, 92 / 100, 0, 0, 10, container) + drawLabel(label1, 1 / 2, 92 / 100, 0, 0, 9, container) drawLabel(label2, 1 / 2, 42 / 100, 0, 0, 18, container) - drawLabel(label3, 1 / 2, 67 / 100, 0, 0, 10, container) + drawLabel(label3, 1 / 2, 67 / 100, 0, 0, 9, container) - drawIcon(icon1, 1 / 8, 1 / 2, 0, 0, 35, container) - drawIcon(icon2, 7 / 8, 1 / 2, 0, 0, 35, container) + drawIcon(icon1, 1 / 8, 1 / 2, 0, 0, 32, container) + drawIcon(icon2, 7 / 8, 1 / 2, 0, 0, 32, container) } function drawScaleDisplayCover (container) { @@ -42,3 +42,4 @@ function drawScaleDisplayCover (container) { roundedCornersBackground(params) } + diff --git a/Utilities.js b/Utilities.js index 52f02cbf4..7c900b3b7 100644 --- a/Utilities.js +++ b/Utilities.js @@ -1,3 +1,18 @@ +function convertTimeFrameToName (pTimeFrame) { + for (let i = 0; i < dailyFilePeriods.length; i++) { + let period = dailyFilePeriods[i] + if (period[0] === pTimeFrame) { + return period[1] + } + } + + for (let i = 0; i < marketFilesPeriods.length; i++) { + let period = marketFilesPeriods[i] + if (period[0] === pTimeFrame) { + return period[1] + } + } +} function download (filename, text) { let element = document.createElement('a') From 983450aa7f16f262deb19f9347373d5f49b88bec Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 16 Jan 2020 14:47:36 +0100 Subject: [PATCH 136/264] More fine tunning --- Globals.js | 8 ++------ Spaces/ChartSpace.js | 4 ++-- Spaces/CockpitSpace.js | 2 +- Spaces/TopSpace.js | 2 +- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/Globals.js b/Globals.js index 3727148bc..c153385b2 100644 --- a/Globals.js +++ b/Globals.js @@ -158,8 +158,8 @@ maxDate.setDate(maxDate.getDate() + 365 * 1); // We might have charts that proj const MIN_PLOTABLE_DATE = new Date(2015, 0, 1, 0, 0, 0); const MAX_PLOTABLE_DATE = maxDate; -const TOP_SPACE_HEIGHT = 5; -const COCKPIT_SPACE_HEIGHT = 40; +const TOP_SPACE_HEIGHT = 2 +const COCKPIT_SPACE_HEIGHT = 30; const BREAKPOINT_HEIGHT = 15; const SIDE_PANEL_WIDTH = 450 let COCKPIT_SPACE_POSITION = browserCanvas.height - COCKPIT_SPACE_HEIGHT @@ -184,10 +184,6 @@ const PERIOD_10_MIN = "10-min"; const PERIOD_05_MIN = "05-min"; const PERIOD_01_MIN = "01-min"; - - - - /* We define here the size of the chartSpace. It has to bee enough big in order to accomodate all the charts we expect to display in this space. */ diff --git a/Spaces/ChartSpace.js b/Spaces/ChartSpace.js index 61f5858ce..3d6c52e41 100644 --- a/Spaces/ChartSpace.js +++ b/Spaces/ChartSpace.js @@ -185,8 +185,8 @@ function newChartSpace () { } } - if (point.y < 0) { - returnPoint.y = 0 + if (point.y < TOP_SPACE_HEIGHT) { + returnPoint.y = TOP_SPACE_HEIGHT } return returnPoint diff --git a/Spaces/CockpitSpace.js b/Spaces/CockpitSpace.js index b93494d0f..5df695dab 100644 --- a/Spaces/CockpitSpace.js +++ b/Spaces/CockpitSpace.js @@ -183,7 +183,7 @@ y: 0 } - const RED_LINE_HIGHT = 5 + const RED_LINE_HIGHT = 2 zeroPoint = thisObject.container.frame.frameThisPoint(zeroPoint) diff --git a/Spaces/TopSpace.js b/Spaces/TopSpace.js index ed96650ac..83fc1432f 100644 --- a/Spaces/TopSpace.js +++ b/Spaces/TopSpace.js @@ -59,7 +59,7 @@ function newTopSpace () { browserCanvasContext.beginPath() browserCanvasContext.rect(0, 0, thisObject.container.frame.width, thisObject.container.frame.height) - browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.RUSTED_RED + ', ' + opacity + ')' + browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.PATINATED_TURQUOISE + ', ' + opacity + ')' browserCanvasContext.closePath() From f41a445aa08e215e6aec6e11afbc30147dc5fced Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 16 Jan 2020 15:08:18 +0100 Subject: [PATCH 137/264] Final aesthetic touches --- ChartsSpace/ViewPort.js | 8 +-- Panels/Layer.js | 143 +++++++++++++++++++--------------------- Panels/LayersPanel.js | 4 +- Scales/Commons.js | 6 +- 4 files changed, 76 insertions(+), 85 deletions(-) diff --git a/ChartsSpace/ViewPort.js b/ChartsSpace/ViewPort.js index 9a106749f..34d531aab 100644 --- a/ChartsSpace/ViewPort.js +++ b/ChartsSpace/ViewPort.js @@ -11,8 +11,8 @@ function newViewPort () { let ANIMATION_INCREMENT = 0.25 - let TOP_MARGIN = 57 + TOP_SPACE_HEIGHT - let BOTTOM_MARGIN = 62 + COCKPIT_SPACE_HEIGHT + let TOP_MARGIN = 40 + TOP_SPACE_HEIGHT + let BOTTOM_MARGIN = 42 + COCKPIT_SPACE_HEIGHT let LEFT_MARGIN = 0 let RIGHT_MARGIN = 0 let MARGINS = { @@ -82,8 +82,8 @@ function newViewPort () { } function resize () { - TOP_MARGIN = 57 + TOP_SPACE_HEIGHT - BOTTOM_MARGIN = 62 + browserCanvas.height - COCKPIT_SPACE_POSITION + TOP_MARGIN = 40 + TOP_SPACE_HEIGHT + BOTTOM_MARGIN = 42 + browserCanvas.height - COCKPIT_SPACE_POSITION LEFT_MARGIN = 0 RIGHT_MARGIN = 0 MARGINS = { diff --git a/Panels/Layer.js b/Panels/Layer.js index 95272fb30..c085e2e86 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -315,74 +315,67 @@ function newLayer () { } function drawLayer () { - /* ------------------- Progress Bars -------------------------- */ + drawLayerDisplay() + } + function drawProgressBar (progressBar, lineWidth, offsetY) { const ANIMATED_INCREMENT = 5 const OPACITY_INCREMENT = 0.01 const OPACITY_MIN = 1 - drawLayerDisplay() + let point1 + let point2 + let horizontalMargin = 15 - drawProgressBar(marketFileProgressBar, 1, -55) - drawProgressBar(dailyFileProgressBar, 1, -56) - drawProgressBar(singleFileProgressBar, 1, -57) - drawProgressBar(fileSequenceProgressBar, 1, -58) - - function drawProgressBar (progressBar, lineWidth, offsetY) { - let point1 - let point2 - let horizontalMargin = 15 - - if (progressBar.value === 0) { - return - } - - /* Animate */ - if (progressBar.animatedValue < progressBar.value) { - progressBar.animatedValue = progressBar.animatedValue + ANIMATED_INCREMENT - progressBar.opacity = progressBar.opacity + OPACITY_INCREMENT - } - - if (progressBar.animatedValue >= 100) { - progressBar.animatedValue = 100 - - progressBar.opacity = progressBar.opacity - OPACITY_INCREMENT - if (progressBar.opacity < OPACITY_MIN) { progressBar.opacity = OPACITY_MIN } - - progressBar.strokeStyle = LOADED_STROKE_STYLE.replace('@Opacity', progressBar.opacity.toString()) - - changeStatusTo(PRODUCT_CARD_STATUS.ON) - } - - point1 = { - x: 0 + horizontalMargin, - y: thisObject.container.frame.height + offsetY - } - - point2 = { - x: (thisObject.container.frame.width - horizontalMargin * 2) * progressBar.animatedValue / 100 + horizontalMargin, - y: thisObject.container.frame.height + offsetY - } - - /* Now the transformations. */ - point1 = thisObject.container.frame.frameThisPoint(point1) - point2 = thisObject.container.frame.frameThisPoint(point2) - - point1 = thisObject.fitFunction(point1) - point2 = thisObject.fitFunction(point2) - - browserCanvasContext.beginPath() - browserCanvasContext.moveTo(point1.x, point1.y) - browserCanvasContext.lineTo(point2.x, point2.y) - - browserCanvasContext.closePath() - - browserCanvasContext.strokeStyle = progressBar.strokeStyle.replace('@Opacity', progressBar.opacity.toString()) - - browserCanvasContext.setLineDash([1, 4]) - browserCanvasContext.lineWidth = lineWidth - browserCanvasContext.stroke() + if (progressBar.value === 0) { + return } + + /* Animate */ + if (progressBar.animatedValue < progressBar.value) { + progressBar.animatedValue = progressBar.animatedValue + ANIMATED_INCREMENT + progressBar.opacity = progressBar.opacity + OPACITY_INCREMENT + } + + if (progressBar.animatedValue >= 100) { + progressBar.animatedValue = 100 + + progressBar.opacity = progressBar.opacity - OPACITY_INCREMENT + if (progressBar.opacity < OPACITY_MIN) { progressBar.opacity = OPACITY_MIN } + + progressBar.strokeStyle = LOADED_STROKE_STYLE.replace('@Opacity', progressBar.opacity.toString()) + + changeStatusTo(PRODUCT_CARD_STATUS.ON) + } + + point1 = { + x: 0 + horizontalMargin, + y: thisObject.container.frame.height + offsetY + } + + point2 = { + x: (thisObject.container.frame.width - horizontalMargin * 2) * progressBar.animatedValue / 100 + horizontalMargin, + y: thisObject.container.frame.height + offsetY + } + + /* Now the transformations. */ + point1 = thisObject.container.frame.frameThisPoint(point1) + point2 = thisObject.container.frame.frameThisPoint(point2) + + point1 = thisObject.fitFunction(point1) + point2 = thisObject.fitFunction(point2) + + browserCanvasContext.beginPath() + browserCanvasContext.moveTo(point1.x, point1.y) + browserCanvasContext.lineTo(point2.x, point2.y) + + browserCanvasContext.closePath() + + browserCanvasContext.strokeStyle = progressBar.strokeStyle.replace('@Opacity', progressBar.opacity.toString()) + + browserCanvasContext.setLineDash([1, 4]) + browserCanvasContext.lineWidth = lineWidth + browserCanvasContext.stroke() } function drawLayerDisplay () { @@ -392,18 +385,13 @@ function newLayer () { let exchange = thisObject.definition.referenceParent.parentNode.referenceParent.parentNode.parentNode let plotterModule = thisObject.definition.referenceParent.referenceParent.referenceParent - let labelArray = thisObject.payload.node.name.split(' ') let label1 = thisObject.payload.node.name - let label2 = '' - let label3 = exchange.name.substring(0, 15) + ' - ' + market - let label4 = thisObject.status.toUpperCase() + let label2 = exchange.name.substring(0, 15) + ' - ' + market + let label3 = thisObject.status.toUpperCase() if (label1 !== undefined) { label1 = label1.substring(0, 22) } - if (label2 !== undefined) { - label2 = label2.substring(0, 15) - } let icon1 = getIcon(exchange) @@ -451,16 +439,19 @@ function newLayer () { roundedCornersBackground(params) - drawLabel(label1, 1 / 2, 6 / 10, -5, 0, 18, thisObject.container) + drawLabel(label1, 1 / 2, 6 / 10, -5, 0, 17, thisObject.container) + drawLabel(label2, 1 / 2, 8.2 / 10, -5, 0, 9, thisObject.container) + drawLabel(label3, 1 / 2, 9.5 / 10, -5, 0, 9, thisObject.container) - drawLabel(label3, 1 / 2, 8.2 / 10, -5, 0, 9, thisObject.container) - drawLabel(label4, 1 / 2, 9.5 / 10, -5, 0, 9, thisObject.container) + drawProgressBar(marketFileProgressBar, 1, -55) + drawProgressBar(dailyFileProgressBar, 1, -56) + drawProgressBar(singleFileProgressBar, 1, -57) + drawProgressBar(fileSequenceProgressBar, 1, -58) - /* Images */ - drawIcon(icon1, 1 / 8, 2 / 10, 0, 0, 15, thisObject.container) - drawIcon(icon2, 7 / 8, 2 / 10, 0, 0, 15, thisObject.container) - drawIcon(icon3, 3 / 8, 2 / 10, 0, 0, 15, thisObject.container) - drawIcon(icon4, 5 / 8, 2 / 10, 0, 0, 15, thisObject.container) + drawIcon(icon1, 1 / 8, 2 / 10, 0, 0, 14, thisObject.container) + drawIcon(icon2, 7 / 8, 2 / 10, 0, 0, 14, thisObject.container) + drawIcon(icon3, 3.5 / 8, 2 / 10, 0, 0, 14, thisObject.container) + drawIcon(icon4, 4.5 / 8, 2 / 10, 0, 0, 14, thisObject.container) } } diff --git a/Panels/LayersPanel.js b/Panels/LayersPanel.js index 0bcf9cb7f..e927656e2 100644 --- a/Panels/LayersPanel.js +++ b/Panels/LayersPanel.js @@ -349,8 +349,8 @@ function newProductsPanel () { drawLabel(label1, 1 / 2, 0, 0, 15, 9, thisObject.container) drawLabel(label2, 1 / 2, 0, 0, 30, 9, thisObject.container) - drawIcon(icon1, 1 / 8, 0, 0, 20, 32, thisObject.container) - drawIcon(icon2, 7 / 8, 0, 0, 20, 32, thisObject.container) + drawIcon(icon1, 1 / 8, 0, 0, 20, 28, thisObject.container) + drawIcon(icon2, 7 / 8, 0, 0, 20, 28, thisObject.container) } function drawScrollBar () { diff --git a/Scales/Commons.js b/Scales/Commons.js index 381dd53a0..49dda6e71 100644 --- a/Scales/Commons.js +++ b/Scales/Commons.js @@ -22,11 +22,11 @@ function drawScaleDisplay (label1, label2, label3, xExtraOffSet1, xExtraOffSet2, label3 = label3.substring(0, 20) drawLabel(label1, 1 / 2, 92 / 100, 0, 0, 9, container) - drawLabel(label2, 1 / 2, 42 / 100, 0, 0, 18, container) + drawLabel(label2, 1 / 2, 42 / 100, 0, 0, 17, container) drawLabel(label3, 1 / 2, 67 / 100, 0, 0, 9, container) - drawIcon(icon1, 1 / 8, 1 / 2, 0, 0, 32, container) - drawIcon(icon2, 7 / 8, 1 / 2, 0, 0, 32, container) + drawIcon(icon1, 1 / 8, 1 / 2, 0, 0, 28, container) + drawIcon(icon2, 7 / 8, 1 / 2, 0, 0, 28, container) } function drawScaleDisplayCover (container) { From bea863eeb13e05170d543000b0ab4cc7db17e859 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 16 Jan 2020 15:16:56 +0100 Subject: [PATCH 138/264] Disabling Full Screen --- Spaces/CockpitSpace.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Spaces/CockpitSpace.js b/Spaces/CockpitSpace.js index 5df695dab..6f5e7b779 100644 --- a/Spaces/CockpitSpace.js +++ b/Spaces/CockpitSpace.js @@ -156,8 +156,8 @@ function getContainer (point) { let container - container = thisObject.fullscreen.getContainer(point) - if (container !== undefined) { return container } + // container = thisObject.fullscreen.getContainer(point) + // if (container !== undefined) { return container } if (thisObject.container.frame.isThisPointHere(point, true) === true) { return thisObject.container @@ -172,7 +172,7 @@ drawBackground() thisObject.assetBalances.draw() - thisObject.fullscreen.draw() + // thisObject.fullscreen.draw() } function drawBackground () { From 226227a68e9ac2d8e26969bd57f12ffb2b3fd312 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 16 Jan 2020 15:29:04 +0100 Subject: [PATCH 139/264] Fine tuning again --- Panels/Layer.js | 4 ++-- Panels/LayersPanel.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Panels/Layer.js b/Panels/Layer.js index c085e2e86..847476a6e 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -450,8 +450,8 @@ function newLayer () { drawIcon(icon1, 1 / 8, 2 / 10, 0, 0, 14, thisObject.container) drawIcon(icon2, 7 / 8, 2 / 10, 0, 0, 14, thisObject.container) - drawIcon(icon3, 3.5 / 8, 2 / 10, 0, 0, 14, thisObject.container) - drawIcon(icon4, 4.5 / 8, 2 / 10, 0, 0, 14, thisObject.container) + drawIcon(icon3, 3.3 / 8, 2 / 10, 0, 0, 14, thisObject.container) + drawIcon(icon4, 4.7 / 8, 2 / 10, 0, 0, 14, thisObject.container) } } diff --git a/Panels/LayersPanel.js b/Panels/LayersPanel.js index e927656e2..b657711e7 100644 --- a/Panels/LayersPanel.js +++ b/Panels/LayersPanel.js @@ -325,12 +325,12 @@ function newProductsPanel () { } function drawHeader () { - let label1 = thisObject.payload.node.name.substring(0, 15) + let label1 = thisObject.payload.node.payload.parentNode.payload.parentNode.name.substring(0, 15) let label2 = thisObject.payload.node.payload.parentNode.name.substring(0, 15) let label3 = '' - let icon1 = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.payload.parentNode.type) - let icon2 = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.type) + let icon1 = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.payload.parentNode.payload.parentNode.type) + let icon2 = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.payload.parentNode.type) let backgroundColor = UI_COLOR.BLACK From 04e34939eaf6d887361feb4f0b31150c97cab7db Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 16 Jan 2020 15:50:30 +0100 Subject: [PATCH 140/264] Bug fixed with titles popung up at config editor --- FloatingSpace/CircularMenuItem.js | 2 +- FloatingSpace/ConfigEditor.js | 6 ++--- FloatingSpace/UiObject.js | 39 ++++++++++++++++++++++++++++--- 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/FloatingSpace/CircularMenuItem.js b/FloatingSpace/CircularMenuItem.js index 71da46801..ccda72ca8 100644 --- a/FloatingSpace/CircularMenuItem.js +++ b/FloatingSpace/CircularMenuItem.js @@ -110,7 +110,7 @@ function newCircularMenuItem () { selfMouseNotOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) if (thisObject.type === 'Icon & Text') { - thisObject.container.frame.width = 185 + thisObject.container.frame.width = 150 } else { thisObject.container.frame.width = 50 } diff --git a/FloatingSpace/ConfigEditor.js b/FloatingSpace/ConfigEditor.js index 17fbd8818..5ce7398bc 100644 --- a/FloatingSpace/ConfigEditor.js +++ b/FloatingSpace/ConfigEditor.js @@ -135,8 +135,8 @@ function newConfigEditor () { thisObject.container.frame.position.x = 0 thisObject.container.frame.position.y = 0 - thisObject.container.frame.width = thisObject.container.frame.radius * 1.8 * 2 - thisObject.container.frame.height = thisObject.container.frame.radius * 1 * 2 + thisObject.container.frame.width = thisObject.container.frame.radius * 1.8 + thisObject.container.frame.height = thisObject.container.frame.radius * 1 let textAreaPosition = { x: 0 - thisObject.container.frame.width / 2, @@ -168,7 +168,7 @@ function newConfigEditor () { position = thisObject.container.frame.frameThisPoint(position) - let radius = thisObject.container.frame.radius * 2 + let radius = thisObject.container.frame.radius if (radius > 0.5) { browserCanvasContext.beginPath() diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index 37e832461..d59f9fdc9 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -189,8 +189,33 @@ function newUiObject () { if (container !== undefined) { return container } } - container = thisObject.uiObjectTitle.getContainer(point) - if (container !== undefined) { return container } + let getitle = true + + if (thisObject.codeEditor !== undefined) { + if (thisObject.codeEditor.visible === true) { + getitle = false + } + } + if (thisObject.configEditor !== undefined) { + if (thisObject.configEditor.visible === true) { + getitle = false + } + } + if (thisObject.conditionEditor !== undefined) { + if (thisObject.conditionEditor.visible === true) { + getitle = false + } + } + if (thisObject.formulaEditor !== undefined) { + if (thisObject.formulaEditor.visible === true) { + getitle = false + } + } + + if (getitle === true) { + container = thisObject.uiObjectTitle.getContainer(point) + if (container !== undefined) { return container } + } container = thisObject.menu.getContainer(point) if (container !== undefined) { return container } @@ -811,25 +836,30 @@ function newUiObject () { } let drawMenu = true + let drawTitle = true if (thisObject.codeEditor !== undefined) { if (thisObject.codeEditor.visible === true) { drawMenu = false + drawTitle = false } } if (thisObject.configEditor !== undefined) { if (thisObject.configEditor.visible === true) { drawMenu = false + drawTitle = false } } if (thisObject.conditionEditor !== undefined) { if (thisObject.conditionEditor.visible === true) { drawMenu = false + drawTitle = false } } if (thisObject.formulaEditor !== undefined) { if (thisObject.formulaEditor.visible === true) { drawMenu = false + drawTitle = false } } @@ -844,7 +874,10 @@ function newUiObject () { drawErrorMessage() drawValue() drawText() - thisObject.uiObjectTitle.draw() + + if (drawTitle === true) { + thisObject.uiObjectTitle.draw() + } } } From 5536c0f3d5d8d21a589117a0c595af0cc9d80603 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 16 Jan 2020 16:14:31 +0100 Subject: [PATCH 141/264] Tunning the config editor --- FloatingSpace/ConfigEditor.js | 7 ++++--- FloatingSpace/UiObjectTitle.js | 8 +++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/FloatingSpace/ConfigEditor.js b/FloatingSpace/ConfigEditor.js index 5ce7398bc..83048c84a 100644 --- a/FloatingSpace/ConfigEditor.js +++ b/FloatingSpace/ConfigEditor.js @@ -34,6 +34,7 @@ function newConfigEditor () { thisObject.container.frame.position.y = 0 let isMouseOver = false + let SIZE_FACTOR = 0.6 return thisObject @@ -135,8 +136,8 @@ function newConfigEditor () { thisObject.container.frame.position.x = 0 thisObject.container.frame.position.y = 0 - thisObject.container.frame.width = thisObject.container.frame.radius * 1.8 - thisObject.container.frame.height = thisObject.container.frame.radius * 1 + thisObject.container.frame.width = thisObject.container.frame.radius * 1.8 * SIZE_FACTOR + thisObject.container.frame.height = thisObject.container.frame.radius * 1 * SIZE_FACTOR let textAreaPosition = { x: 0 - thisObject.container.frame.width / 2, @@ -168,7 +169,7 @@ function newConfigEditor () { position = thisObject.container.frame.frameThisPoint(position) - let radius = thisObject.container.frame.radius + let radius = thisObject.container.frame.radius * SIZE_FACTOR if (radius > 0.5) { browserCanvasContext.beginPath() diff --git a/FloatingSpace/UiObjectTitle.js b/FloatingSpace/UiObjectTitle.js index 4d5d777b9..41ca0ebd8 100644 --- a/FloatingSpace/UiObjectTitle.js +++ b/FloatingSpace/UiObjectTitle.js @@ -107,9 +107,10 @@ function newUiObjectTitle () { /* Here we set the dimensions and position of this object */ const FRAME_HEIGHT = 25 - const FRAME_WIDTH = title.length / 2 * thisObject.payload.floatingObject.currentFontSize * FONT_ASPECT_RATIO * 1.2 * 2 + const Y_OFFSET = -20 + const FRAME_WIDTH = (title.length + 2) / 2 * thisObject.payload.floatingObject.currentFontSize * FONT_ASPECT_RATIO * 1.2 * 2 thisObject.container.frame.position.x = 0 - FRAME_WIDTH / 2 - thisObject.container.frame.position.y = 0 - thisObject.container.frame.radius * 1 / 2 - thisObject.payload.floatingObject.currentFontSize * FONT_ASPECT_RATIO - 20 - FRAME_HEIGHT + thisObject.container.frame.position.y = 0 - thisObject.container.frame.radius * 1 / 2 - thisObject.payload.floatingObject.currentFontSize * FONT_ASPECT_RATIO + Y_OFFSET - FRAME_HEIGHT thisObject.container.frame.width = FRAME_WIDTH thisObject.container.frame.height = FRAME_HEIGHT @@ -117,7 +118,7 @@ function newUiObjectTitle () { if (thisObject.editMode === true) { let inputPosition = { x: 0, - y: 0 + CURRENT_TOP_MARGIN + y: 0 + CURRENT_TOP_MARGIN + Y_OFFSET } inputPosition = thisObject.container.frame.frameThisPoint(inputPosition) @@ -257,3 +258,4 @@ function newUiObjectTitle () { return title } } + From 186cb51f1f0582f3e1c280393f8e610223b9a934 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 16 Jan 2020 19:47:14 +0100 Subject: [PATCH 142/264] Layers Remembering their status --- Panels/Layer.js | 68 +++++++++++++++++++++++++++-------------- Panels/LayersPanel.js | 9 ++++++ Spaces/DesignerSpace.js | 1 - 3 files changed, 54 insertions(+), 24 deletions(-) diff --git a/Panels/Layer.js b/Panels/Layer.js index 847476a6e..f45cb3da8 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -10,6 +10,7 @@ function newLayer () { fitFunction: undefined, payload: undefined, definition: undefined, + physics: physics, draw: draw, turnOff: turnOff, turnOn: turnOn, @@ -160,19 +161,6 @@ function newLayer () { if (thisObject.definition.referenceParent.referenceParent.parentNode === undefined) { return } if (thisObject.definition.referenceParent.referenceParent.parentNode.parentNode === undefined) { return } - /* We retrieve the locally stored status of the Product */ - let storedValue = window.localStorage.getItem(thisObject.payload.node.id) - - if (storedValue !== null) { - thisObject.status = storedValue - - if (thisObject.status === PRODUCT_CARD_STATUS.ON) { - changeStatusTo(PRODUCT_CARD_STATUS.LOADING) - } - } else { - changeStatusTo(PRODUCT_CARD_STATUS.OFF) - } - /* Lets listen to our own events to react when we have a Mouse Click */ onMouseClickEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick) @@ -301,12 +289,49 @@ function newLayer () { fileSequenceProgressBar.strokeStyle = UNLOADED_STROKE_STYLE } - function changeStatusTo (pNewStatus) { - if (thisObject.status !== pNewStatus) { - thisObject.status = pNewStatus + function physics () { + /* We retrieve the stored status at the config. */ + try { + let code = JSON.parse(thisObject.payload.node.code) + let storedValue = code.status + + if (storedValue !== undefined) { + thisObject.status = storedValue + + if (thisObject.status === PRODUCT_CARD_STATUS.ON) { + changeStatusTo(PRODUCT_CARD_STATUS.LOADING) + } + } else { + changeStatusTo(PRODUCT_CARD_STATUS.OFF) + } + } catch (err) { + // we ignore errors here since most likely they will be parsing errors. + } + + /* Check when the loading finishes */ + if ( + thisObject.status === PRODUCT_CARD_STATUS.LOADING && + marketFileProgressBar.value === 100 && + dailyFileProgressBar.value === 100 + ) { + changeStatusTo(PRODUCT_CARD_STATUS.ON) + } + } + + function changeStatusTo (newStatus) { + if (thisObject.status !== newStatus) { + thisObject.status = newStatus + + try { + let code = JSON.parse(thisObject.payload.node.code) + code.status = thisObject.status + thisObject.payload.node.code = JSON.stringify(code) + } catch (err) { + // we ignore errors here since most likely they will be parsing errors. + } + let eventData = thisObject thisObject.container.eventHandler.raiseEvent('Status Changed', eventData) - window.localStorage.setItem(thisObject.code, thisObject.status) } } @@ -325,7 +350,7 @@ function newLayer () { let point1 let point2 - let horizontalMargin = 15 + let horizontalMargin = 32 if (progressBar.value === 0) { return @@ -344,8 +369,6 @@ function newLayer () { if (progressBar.opacity < OPACITY_MIN) { progressBar.opacity = OPACITY_MIN } progressBar.strokeStyle = LOADED_STROKE_STYLE.replace('@Opacity', progressBar.opacity.toString()) - - changeStatusTo(PRODUCT_CARD_STATUS.ON) } point1 = { @@ -450,8 +473,7 @@ function newLayer () { drawIcon(icon1, 1 / 8, 2 / 10, 0, 0, 14, thisObject.container) drawIcon(icon2, 7 / 8, 2 / 10, 0, 0, 14, thisObject.container) - drawIcon(icon3, 3.3 / 8, 2 / 10, 0, 0, 14, thisObject.container) - drawIcon(icon4, 4.7 / 8, 2 / 10, 0, 0, 14, thisObject.container) + drawIcon(icon3, 3.4 / 8, 2 / 10, 0, 0, 14, thisObject.container) + drawIcon(icon4, 4.6 / 8, 2 / 10, 0, 0, 14, thisObject.container) } } - diff --git a/Panels/LayersPanel.js b/Panels/LayersPanel.js index b657711e7..97bea92be 100644 --- a/Panels/LayersPanel.js +++ b/Panels/LayersPanel.js @@ -94,6 +94,7 @@ function newProductsPanel () { /* Initialize it */ layer.initialize(onInitialized) + function onInitialized (err) { if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result) { layersMap.set(layerNode.id, layer) @@ -238,6 +239,13 @@ function newProductsPanel () { } } + function childrenPhysics () { + for (let i = 0; i < thisObject.layers.length; i++) { + let layer = thisObject.layers[i] + layer.physics() + } + } + function physics () { if (isInitialized === false) { return } @@ -254,6 +262,7 @@ function newProductsPanel () { If we find new layers we will add them at that point. Finally, the cards that still remain at the local array after all the layers at the designer have been processed, are turned off and discarded. */ + childrenPhysics() let localLayers = [] moveToLocalLayers() diff --git a/Spaces/DesignerSpace.js b/Spaces/DesignerSpace.js index b2aaedc46..971a8cd95 100644 --- a/Spaces/DesignerSpace.js +++ b/Spaces/DesignerSpace.js @@ -240,7 +240,6 @@ function newDesignerSpace () { } function physics () { - if (visible !== true) { return } thisObject.workspace.physics() } From f9fbea8d50ad4faf1fb4de91000d5f3664476e2f Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 16 Jan 2020 20:14:48 +0100 Subject: [PATCH 143/264] Soring and retrieving layer status from config working --- Panels/Layer.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Panels/Layer.js b/Panels/Layer.js index f45cb3da8..e9ebed439 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -248,6 +248,7 @@ function newLayer () { function turnOn () { if (thisObject.status === PRODUCT_CARD_STATUS.OFF) { + resetProgressBars() changeStatusTo(PRODUCT_CARD_STATUS.LOADING) } } @@ -259,6 +260,7 @@ function newLayer () { changeStatusTo(PRODUCT_CARD_STATUS.OFF) break case PRODUCT_CARD_STATUS.OFF: + resetProgressBars() changeStatusTo(PRODUCT_CARD_STATUS.LOADING) break case PRODUCT_CARD_STATUS.LOADING: @@ -296,12 +298,18 @@ function newLayer () { let storedValue = code.status if (storedValue !== undefined) { - thisObject.status = storedValue - - if (thisObject.status === PRODUCT_CARD_STATUS.ON) { - changeStatusTo(PRODUCT_CARD_STATUS.LOADING) + if (storedValue !== thisObject.status) { + if (storedValue === PRODUCT_CARD_STATUS.ON) { + resetProgressBars() + changeStatusTo(PRODUCT_CARD_STATUS.LOADING) + } + if (storedValue === PRODUCT_CARD_STATUS.OFF) { + resetProgressBars() + changeStatusTo(PRODUCT_CARD_STATUS.OFF) + } } } else { + resetProgressBars() changeStatusTo(PRODUCT_CARD_STATUS.OFF) } } catch (err) { From 51ae9ec779ff7cafedaf196cdbd1f9fa9a180625 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 17 Jan 2020 09:31:08 +0100 Subject: [PATCH 144/264] Time Frame Scale saving its value at the config --- Scales/TimeFrameScale.js | 52 +++++++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/Scales/TimeFrameScale.js b/Scales/TimeFrameScale.js index 0ab1af933..830ba4796 100644 --- a/Scales/TimeFrameScale.js +++ b/Scales/TimeFrameScale.js @@ -22,11 +22,10 @@ function newTimeFrameScale () { let visible = true let isMouseOver - let objectStorage = {} let filePeriodIndex = FILES_PERIOD_DEFAULT_VALUE let timeFrameIndex = TIME_PERIOD_DEFAULT_VALUE let timeFramesMasterArray = [marketFilesPeriods, dailyFilePeriods] - let timeFrameLabel = '' + let timeFrameLabel = '24-hs' let onMouseWheelEventSubscriptionId let onZoomChangedEventSubscriptionId @@ -64,8 +63,6 @@ function newTimeFrameScale () { thisObject.container.eventHandler.stopListening(onMouseOverEventSubscriptionId) thisObject.container.eventHandler.stopListening(onMouseNotOverEventSubscriptionId) - objectStorage = undefined - thisObject.container.finalize() thisObject.container = undefined thisObject.fitFunction = undefined @@ -116,6 +113,11 @@ function newTimeFrameScale () { } function physics () { + readObjectState() + positioningphysics() + } + + function positioningphysics () { /* Container Limits */ let upCorner = { @@ -190,8 +192,8 @@ function newTimeFrameScale () { } } } - saveObjectState() newTimeFrame() + saveObjectState() } } } @@ -222,8 +224,8 @@ function newTimeFrameScale () { } } - saveObjectState() newTimeFrame() + saveObjectState() } function getContainer (point) { @@ -233,17 +235,39 @@ function newTimeFrameScale () { } function saveObjectState () { - objectStorage.filePeriodIndex = filePeriodIndex - objectStorage.timeFrameIndex = timeFrameIndex - window.localStorage.setItem(MODULE_NAME, JSON.stringify(objectStorage)) + try { + let code = JSON.parse(thisObject.payload.node.code) + code.value = timeFrameLabel + thisObject.payload.node.code = JSON.stringify(code) + } catch (err) { + // we ignore errors here since most likely they will be parsing errors. + } } function readObjectState () { - let objectStorageString = window.localStorage.getItem(MODULE_NAME) - if (objectStorageString !== null && objectStorageString !== '') { - objectStorage = JSON.parse(objectStorageString) - filePeriodIndex = objectStorage.filePeriodIndex - timeFrameIndex = objectStorage.timeFrameIndex + try { + let code = JSON.parse(thisObject.payload.node.code) + if (code.value !== timeFrameLabel) { + let found = false + for (let i = 0; i < timeFramesMasterArray.length; i++) { + let timeFrameArray = timeFramesMasterArray[i] + for (let j = 0; j < timeFrameArray.length; j++) { + let record = timeFrameArray[j] + if (code.value === record[1]) { + filePeriodIndex = i + timeFrameIndex = j + found = true + } + } + } + if (found === true) { + newTimeFrame() + } else { + saveObjectState() + } + } + } catch (err) { + // we ignore errors here since most likely they will be parsing errors. } } From 3336961af004b5fbe9a71699cac366371e71dd59 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 17 Jan 2020 10:54:38 +0100 Subject: [PATCH 145/264] Time Scales Storing value at config --- Scales/TimeScale.js | 55 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 9 deletions(-) diff --git a/Scales/TimeScale.js b/Scales/TimeScale.js index b3293ec29..ea40a3c9b 100644 --- a/Scales/TimeScale.js +++ b/Scales/TimeScale.js @@ -18,6 +18,7 @@ function newTimeScale () { const LENGHT_PERCENTAGE_DEFAULT_VALUE = 5 const STEP_SIZE = 2.5 + const LENGHT_PERCENTAGE_MAX_VALUE = 400 thisObject.container = newContainer() thisObject.container.initialize(MODULE_NAME) @@ -71,12 +72,8 @@ function newTimeScale () { onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) onMouseNotOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) - thisObject.lenghtPercentage = window.localStorage.getItem(MODULE_NAME) - if (!thisObject.lenghtPercentage) { - thisObject.lenghtPercentage = LENGHT_PERCENTAGE_DEFAULT_VALUE - } else { - thisObject.lenghtPercentage = JSON.parse(thisObject.lenghtPercentage) - } + thisObject.lenghtPercentage = LENGHT_PERCENTAGE_DEFAULT_VALUE + readObjectState() let event = {} event.lenghtPercentage = thisObject.lenghtPercentage @@ -123,13 +120,13 @@ function newTimeScale () { if (thisObject.lenghtPercentage < STEP_SIZE) { thisObject.lenghtPercentage = STEP_SIZE } } else { thisObject.lenghtPercentage = thisObject.lenghtPercentage + STEP_SIZE * morePower - if (thisObject.lenghtPercentage > 400) { thisObject.lenghtPercentage = 400 } + if (thisObject.lenghtPercentage > LENGHT_PERCENTAGE_MAX_VALUE) { thisObject.lenghtPercentage = LENGHT_PERCENTAGE_MAX_VALUE } } event.lenghtPercentage = thisObject.lenghtPercentage thisObject.container.eventHandler.raiseEvent('Lenght Percentage Changed', event) - window.localStorage.setItem(MODULE_NAME, thisObject.lenghtPercentage) + saveObjectState() } function getContainer (point) { @@ -138,7 +135,47 @@ function newTimeScale () { } } + function saveObjectState () { + try { + let code = JSON.parse(thisObject.payload.node.code) + code.value = thisObject.lenghtPercentage / LENGHT_PERCENTAGE_MAX_VALUE * 100 + thisObject.payload.node.code = JSON.stringify(code) + } catch (err) { + // we ignore errors here since most likely they will be parsing errors. + } + } + + function readObjectState () { + try { + let code = JSON.parse(thisObject.payload.node.code) + + if (isNaN(code.value) || code.value === null || code.value === undefined) { + saveObjectState() + return + } + code.value = code.value / 100 * LENGHT_PERCENTAGE_MAX_VALUE + if (code.value < STEP_SIZE) { code.value = STEP_SIZE } + if (code.value > LENGHT_PERCENTAGE_MAX_VALUE) { code.value = LENGHT_PERCENTAGE_MAX_VALUE } + + if (code.value !== thisObject.lenghtPercentage) { + thisObject.lenghtPercentage = code.value + let event = {} + event.lenghtPercentage = thisObject.lenghtPercentage + thisObject.container.eventHandler.raiseEvent('Lenght Percentage Changed', event) + } else { + saveObjectState() + } + } catch (err) { + // we ignore errors here since most likely they will be parsing errors. + } + } + function physics () { + readObjectState() + positioningphysics() + } + + function positioningphysics () { /* Container Limits */ let upCorner = { @@ -229,7 +266,7 @@ function newTimeScale () { const DISTANCE_BETWEEN_ARROWS = 10 const MIN_DISTANCE_FROM_CENTER = 110 const CURRENT_VALUE_DISTANCE = MIN_DISTANCE_FROM_CENTER + thisObject.lenghtPercentage - const MAX_DISTANCE_FROM_CENTER = MIN_DISTANCE_FROM_CENTER + 400 + DISTANCE_BETWEEN_ARROWS + const MAX_DISTANCE_FROM_CENTER = MIN_DISTANCE_FROM_CENTER + LENGHT_PERCENTAGE_MAX_VALUE + DISTANCE_BETWEEN_ARROWS let ARROW_DIRECTION = 0 From 44d0944a5657fcac60252b3c929a241243cca2c9 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 17 Jan 2020 11:24:12 +0100 Subject: [PATCH 146/264] rateScales saving at config --- Scales/RateScale.js | 58 +++++++++++++++++++++++++++++++++++++-------- Scales/TimeScale.js | 17 ++++++------- 2 files changed, 57 insertions(+), 18 deletions(-) diff --git a/Scales/RateScale.js b/Scales/RateScale.js index 330049e80..a75eb29b5 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -6,7 +6,7 @@ function newRateScale () { rate: undefined, fitFunction: undefined, payload: undefined, - heightPercentage: 150, + heightPercentage: undefined, onMouseOverSomeTimeMachineContainer: onMouseOverSomeTimeMachineContainer, physics: physics, draw: draw, @@ -16,9 +16,10 @@ function newRateScale () { finalize: finalize } - const HEIGHT_PERCENTAGE_DEFAULT_VALUE = 50 + const DEFAULT_VALUE = 50 const STEP_SIZE = 2 const MIN_WIDTH = 50 + const MAX_VALUE = 150 thisObject.container = newContainer() thisObject.container.initialize(MODULE_NAME) @@ -72,12 +73,8 @@ function newRateScale () { onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) onMouseNotOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) - thisObject.heightPercentage = window.localStorage.getItem(MODULE_NAME) - if (!thisObject.heightPercentage) { - thisObject.heightPercentage = HEIGHT_PERCENTAGE_DEFAULT_VALUE - } else { - thisObject.heightPercentage = JSON.parse(thisObject.heightPercentage) - } + thisObject.heightPercentage = DEFAULT_VALUE + readObjectState() let event = {} event.heightPercentage = thisObject.heightPercentage @@ -124,12 +121,12 @@ function newRateScale () { if (thisObject.heightPercentage < STEP_SIZE * 3) { thisObject.heightPercentage = STEP_SIZE } } else { thisObject.heightPercentage = thisObject.heightPercentage + STEP_SIZE * morePower - if (thisObject.heightPercentage > 150) { thisObject.heightPercentage = 200 } + if (thisObject.heightPercentage > MAX_VALUE) { thisObject.heightPercentage = MAX_VALUE } } event.heightPercentage = thisObject.heightPercentage thisObject.container.eventHandler.raiseEvent('Height Percentage Changed', event) - window.localStorage.setItem(MODULE_NAME, thisObject.heightPercentage) + saveObjectState() } function getContainer (point) { @@ -138,7 +135,48 @@ function newRateScale () { } } + function saveObjectState () { + try { + let code = JSON.parse(thisObject.payload.node.code) + code.value = thisObject.heightPercentage / MAX_VALUE * 100 + code.value = code.value.toFixed(2) + thisObject.payload.node.code = JSON.stringify(code) + } catch (err) { + // we ignore errors here since most likely they will be parsing errors. + } + } + + function readObjectState () { + try { + let code = JSON.parse(thisObject.payload.node.code) + + if (isNaN(code.value) || code.value === null || code.value === undefined) { + saveObjectState() + return + } + code.value = code.value / 100 * MAX_VALUE + if (code.value < STEP_SIZE) { code.value = STEP_SIZE } + if (code.value > MAX_VALUE) { code.value = MAX_VALUE } + + if (code.value !== thisObject.heightPercentage) { + thisObject.heightPercentage = code.value + let event = {} + event.heightPercentage = thisObject.heightPercentage + thisObject.container.eventHandler.raiseEvent('Height Percentage Changed', event) + } else { + saveObjectState() + } + } catch (err) { + // we ignore errors here since most likely they will be parsing errors. + } + } + function physics () { + readObjectState() + positioningphysics() + } + + function positioningphysics () { /* Container Limits */ let upCorner = { diff --git a/Scales/TimeScale.js b/Scales/TimeScale.js index ea40a3c9b..1490958a5 100644 --- a/Scales/TimeScale.js +++ b/Scales/TimeScale.js @@ -16,9 +16,9 @@ function newTimeScale () { finalize: finalize } - const LENGHT_PERCENTAGE_DEFAULT_VALUE = 5 + const DEFAULT_VALUE = 5 const STEP_SIZE = 2.5 - const LENGHT_PERCENTAGE_MAX_VALUE = 400 + const MAX_VALUE = 400 thisObject.container = newContainer() thisObject.container.initialize(MODULE_NAME) @@ -72,7 +72,7 @@ function newTimeScale () { onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) onMouseNotOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) - thisObject.lenghtPercentage = LENGHT_PERCENTAGE_DEFAULT_VALUE + thisObject.lenghtPercentage = DEFAULT_VALUE readObjectState() let event = {} @@ -120,7 +120,7 @@ function newTimeScale () { if (thisObject.lenghtPercentage < STEP_SIZE) { thisObject.lenghtPercentage = STEP_SIZE } } else { thisObject.lenghtPercentage = thisObject.lenghtPercentage + STEP_SIZE * morePower - if (thisObject.lenghtPercentage > LENGHT_PERCENTAGE_MAX_VALUE) { thisObject.lenghtPercentage = LENGHT_PERCENTAGE_MAX_VALUE } + if (thisObject.lenghtPercentage > MAX_VALUE) { thisObject.lenghtPercentage = MAX_VALUE } } event.lenghtPercentage = thisObject.lenghtPercentage @@ -138,7 +138,8 @@ function newTimeScale () { function saveObjectState () { try { let code = JSON.parse(thisObject.payload.node.code) - code.value = thisObject.lenghtPercentage / LENGHT_PERCENTAGE_MAX_VALUE * 100 + code.value = thisObject.lenghtPercentage / MAX_VALUE * 100 + code.value = code.value.toFixed(2) thisObject.payload.node.code = JSON.stringify(code) } catch (err) { // we ignore errors here since most likely they will be parsing errors. @@ -153,9 +154,9 @@ function newTimeScale () { saveObjectState() return } - code.value = code.value / 100 * LENGHT_PERCENTAGE_MAX_VALUE + code.value = code.value / 100 * MAX_VALUE if (code.value < STEP_SIZE) { code.value = STEP_SIZE } - if (code.value > LENGHT_PERCENTAGE_MAX_VALUE) { code.value = LENGHT_PERCENTAGE_MAX_VALUE } + if (code.value > MAX_VALUE) { code.value = MAX_VALUE } if (code.value !== thisObject.lenghtPercentage) { thisObject.lenghtPercentage = code.value @@ -266,7 +267,7 @@ function newTimeScale () { const DISTANCE_BETWEEN_ARROWS = 10 const MIN_DISTANCE_FROM_CENTER = 110 const CURRENT_VALUE_DISTANCE = MIN_DISTANCE_FROM_CENTER + thisObject.lenghtPercentage - const MAX_DISTANCE_FROM_CENTER = MIN_DISTANCE_FROM_CENTER + LENGHT_PERCENTAGE_MAX_VALUE + DISTANCE_BETWEEN_ARROWS + const MAX_DISTANCE_FROM_CENTER = MIN_DISTANCE_FROM_CENTER + MAX_VALUE + DISTANCE_BETWEEN_ARROWS let ARROW_DIRECTION = 0 From b5dd022c0ff4736fb42dea8e4cfdbbbd895c4856 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 17 Jan 2020 11:28:26 +0100 Subject: [PATCH 147/264] stadarizing refactoring --- ChartsSpace/TimeMachine.js | 4 ++-- ChartsSpace/TimelineChart.js | 2 +- Scales/RateScale.js | 26 +++++++++++++------------- Scales/TimeScale.js | 26 +++++++++++++------------- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index aa01ca7b1..bce17b21b 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -178,7 +178,7 @@ function newTimeMachine () { thisObject.timeScale.payload = thisObject.payload.node.timeScale.payload timeScaleEventSuscriptionId = thisObject.timeScale.container.eventHandler.listenToEvent('Lenght Percentage Changed', function (event) { - thisObject.container.frame.width = TIME_MACHINE_WIDTH * event.lenghtPercentage / 100 + thisObject.container.frame.width = TIME_MACHINE_WIDTH * event.value / 100 recalculateCoordinateSystem() moveToUserPosition(thisObject.container, timeMachineCoordinateSystem, false, true, event.mousePosition, false, true) thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) @@ -199,7 +199,7 @@ function newTimeMachine () { thisObject.rateScale.payload = thisObject.payload.node.rateScale.payload rateScaleEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('Height Percentage Changed', function (event) { - thisObject.container.frame.height = TIME_MACHINE_HEIGHT * event.heightPercentage / 100 + thisObject.container.frame.height = TIME_MACHINE_HEIGHT * event.value / 100 recalculateCoordinateSystem() moveToUserPosition(thisObject.container, timeMachineCoordinateSystem, true, false, event.mousePosition, false, true) thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index b29c67a14..1ded4af09 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -166,7 +166,7 @@ function newTimelineChart () { thisObject.rateScale.payload = thisObject.payload.node.rateScale.payload rateScaleEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('Height Percentage Changed', function (event) { - thisObject.container.frame.height = TIME_MACHINE_HEIGHT * event.heightPercentage / 100 + thisObject.container.frame.height = TIME_MACHINE_HEIGHT * event.value / 100 recalculateCoordinateSystem() moveToUserPosition(thisObject.container, timelineChartCoordinateSystem, true, false, event.mousePosition, false, true) thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) diff --git a/Scales/RateScale.js b/Scales/RateScale.js index a75eb29b5..2a49212ff 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -6,7 +6,7 @@ function newRateScale () { rate: undefined, fitFunction: undefined, payload: undefined, - heightPercentage: undefined, + value: undefined, onMouseOverSomeTimeMachineContainer: onMouseOverSomeTimeMachineContainer, physics: physics, draw: draw, @@ -73,11 +73,11 @@ function newRateScale () { onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) onMouseNotOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) - thisObject.heightPercentage = DEFAULT_VALUE + thisObject.value = DEFAULT_VALUE readObjectState() let event = {} - event.heightPercentage = thisObject.heightPercentage + event.value = thisObject.value thisObject.container.eventHandler.raiseEvent('Height Percentage Changed', event) } @@ -117,13 +117,13 @@ function newRateScale () { delta = event.wheelDelta if (delta < 0) { - thisObject.heightPercentage = thisObject.heightPercentage - STEP_SIZE * morePower - if (thisObject.heightPercentage < STEP_SIZE * 3) { thisObject.heightPercentage = STEP_SIZE } + thisObject.value = thisObject.value - STEP_SIZE * morePower + if (thisObject.value < STEP_SIZE * 3) { thisObject.value = STEP_SIZE } } else { - thisObject.heightPercentage = thisObject.heightPercentage + STEP_SIZE * morePower - if (thisObject.heightPercentage > MAX_VALUE) { thisObject.heightPercentage = MAX_VALUE } + thisObject.value = thisObject.value + STEP_SIZE * morePower + if (thisObject.value > MAX_VALUE) { thisObject.value = MAX_VALUE } } - event.heightPercentage = thisObject.heightPercentage + event.value = thisObject.value thisObject.container.eventHandler.raiseEvent('Height Percentage Changed', event) saveObjectState() @@ -138,7 +138,7 @@ function newRateScale () { function saveObjectState () { try { let code = JSON.parse(thisObject.payload.node.code) - code.value = thisObject.heightPercentage / MAX_VALUE * 100 + code.value = thisObject.value / MAX_VALUE * 100 code.value = code.value.toFixed(2) thisObject.payload.node.code = JSON.stringify(code) } catch (err) { @@ -158,10 +158,10 @@ function newRateScale () { if (code.value < STEP_SIZE) { code.value = STEP_SIZE } if (code.value > MAX_VALUE) { code.value = MAX_VALUE } - if (code.value !== thisObject.heightPercentage) { - thisObject.heightPercentage = code.value + if (code.value !== thisObject.value) { + thisObject.value = code.value let event = {} - event.heightPercentage = thisObject.heightPercentage + event.value = thisObject.value thisObject.container.eventHandler.raiseEvent('Height Percentage Changed', event) } else { saveObjectState() @@ -288,7 +288,7 @@ function newRateScale () { const OPACITY = 0.2 const DISTANCE_BETWEEN_ARROWS = 10 const MIN_DISTANCE_FROM_CENTER = 30 - const CURRENT_VALUE_DISTANCE = MIN_DISTANCE_FROM_CENTER + thisObject.heightPercentage + const CURRENT_VALUE_DISTANCE = MIN_DISTANCE_FROM_CENTER + thisObject.value const MAX_DISTANCE_FROM_CENTER = MIN_DISTANCE_FROM_CENTER + 215 + DISTANCE_BETWEEN_ARROWS let ARROW_DIRECTION = 0 diff --git a/Scales/TimeScale.js b/Scales/TimeScale.js index 1490958a5..faca8abdb 100644 --- a/Scales/TimeScale.js +++ b/Scales/TimeScale.js @@ -2,7 +2,7 @@ function newTimeScale () { const MODULE_NAME = 'Time Scale' let thisObject = { - lenghtPercentage: undefined, + value: undefined, container: undefined, date: undefined, fitFunction: undefined, @@ -72,11 +72,11 @@ function newTimeScale () { onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) onMouseNotOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) - thisObject.lenghtPercentage = DEFAULT_VALUE + thisObject.value = DEFAULT_VALUE readObjectState() let event = {} - event.lenghtPercentage = thisObject.lenghtPercentage + event.value = thisObject.value thisObject.container.eventHandler.raiseEvent('Lenght Percentage Changed', event) } @@ -116,14 +116,14 @@ function newTimeScale () { delta = event.wheelDelta if (delta < 0) { - thisObject.lenghtPercentage = thisObject.lenghtPercentage - STEP_SIZE * morePower - if (thisObject.lenghtPercentage < STEP_SIZE) { thisObject.lenghtPercentage = STEP_SIZE } + thisObject.value = thisObject.value - STEP_SIZE * morePower + if (thisObject.value < STEP_SIZE) { thisObject.value = STEP_SIZE } } else { - thisObject.lenghtPercentage = thisObject.lenghtPercentage + STEP_SIZE * morePower - if (thisObject.lenghtPercentage > MAX_VALUE) { thisObject.lenghtPercentage = MAX_VALUE } + thisObject.value = thisObject.value + STEP_SIZE * morePower + if (thisObject.value > MAX_VALUE) { thisObject.value = MAX_VALUE } } - event.lenghtPercentage = thisObject.lenghtPercentage + event.value = thisObject.value thisObject.container.eventHandler.raiseEvent('Lenght Percentage Changed', event) saveObjectState() @@ -138,7 +138,7 @@ function newTimeScale () { function saveObjectState () { try { let code = JSON.parse(thisObject.payload.node.code) - code.value = thisObject.lenghtPercentage / MAX_VALUE * 100 + code.value = thisObject.value / MAX_VALUE * 100 code.value = code.value.toFixed(2) thisObject.payload.node.code = JSON.stringify(code) } catch (err) { @@ -158,10 +158,10 @@ function newTimeScale () { if (code.value < STEP_SIZE) { code.value = STEP_SIZE } if (code.value > MAX_VALUE) { code.value = MAX_VALUE } - if (code.value !== thisObject.lenghtPercentage) { - thisObject.lenghtPercentage = code.value + if (code.value !== thisObject.value) { + thisObject.value = code.value let event = {} - event.lenghtPercentage = thisObject.lenghtPercentage + event.value = thisObject.value thisObject.container.eventHandler.raiseEvent('Lenght Percentage Changed', event) } else { saveObjectState() @@ -266,7 +266,7 @@ function newTimeScale () { const OPACITY = 0.2 const DISTANCE_BETWEEN_ARROWS = 10 const MIN_DISTANCE_FROM_CENTER = 110 - const CURRENT_VALUE_DISTANCE = MIN_DISTANCE_FROM_CENTER + thisObject.lenghtPercentage + const CURRENT_VALUE_DISTANCE = MIN_DISTANCE_FROM_CENTER + thisObject.value const MAX_DISTANCE_FROM_CENTER = MIN_DISTANCE_FROM_CENTER + MAX_VALUE + DISTANCE_BETWEEN_ARROWS let ARROW_DIRECTION = 0 From 0df490bd1fa26aaa3a9e5de16d233a32fa1e4ae9 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 17 Jan 2020 15:27:06 +0100 Subject: [PATCH 148/264] Saving and Loading Frame position --- ChartsSpace/TimeMachine.js | 7 +++-- ChartsSpace/TimelineChart.js | 2 +- CockpitSpace/Speedometer.js | 24 ++++++++--------- .../FunctionLibraries/ProtocolNode.js | 12 +++++++++ FloatingSpace/CircularMenuItem.js | 14 +++++----- Utilities.js | 26 +++++++++++++++++++ 6 files changed, 63 insertions(+), 22 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index bce17b21b..4f49ab99f 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -132,6 +132,8 @@ function newTimeMachine () { function initialize (callBackFunction) { timeFrame = INITIAL_TIME_PERIOD + loadFrame(thisObject.payload, thisObject.container.frame) + recalculateCoordinateSystem() onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) @@ -180,7 +182,7 @@ function newTimeMachine () { timeScaleEventSuscriptionId = thisObject.timeScale.container.eventHandler.listenToEvent('Lenght Percentage Changed', function (event) { thisObject.container.frame.width = TIME_MACHINE_WIDTH * event.value / 100 recalculateCoordinateSystem() - moveToUserPosition(thisObject.container, timeMachineCoordinateSystem, false, true, event.mousePosition, false, true) + // moveToUserPosition(thisObject.container, timeMachineCoordinateSystem, false, true, event.mousePosition, false, true) thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) }) @@ -201,7 +203,7 @@ function newTimeMachine () { rateScaleEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('Height Percentage Changed', function (event) { thisObject.container.frame.height = TIME_MACHINE_HEIGHT * event.value / 100 recalculateCoordinateSystem() - moveToUserPosition(thisObject.container, timeMachineCoordinateSystem, true, false, event.mousePosition, false, true) + // moveToUserPosition(thisObject.container, timeMachineCoordinateSystem, true, false, event.mousePosition, false, true) thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) }) @@ -328,6 +330,7 @@ function newTimeMachine () { thisObjectPhysics() childrenPhysics() syncWithDesigner() + saveFrame(thisObject.payload, thisObject.container.frame) } function syncWithDesigner () { diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 1ded4af09..e65536f86 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -168,7 +168,7 @@ function newTimelineChart () { rateScaleEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('Height Percentage Changed', function (event) { thisObject.container.frame.height = TIME_MACHINE_HEIGHT * event.value / 100 recalculateCoordinateSystem() - moveToUserPosition(thisObject.container, timelineChartCoordinateSystem, true, false, event.mousePosition, false, true) + // moveToUserPosition(thisObject.container, timelineChartCoordinateSystem, true, false, event.mousePosition, false, true) thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) }) diff --git a/CockpitSpace/Speedometer.js b/CockpitSpace/Speedometer.js index 9d129c778..93178ab38 100644 --- a/CockpitSpace/Speedometer.js +++ b/CockpitSpace/Speedometer.js @@ -52,7 +52,7 @@ function newSpeedometer () { function drawAssetCircle () { const RED_LINE_HIGHT = 5 - const RADIOUS = 50 + const RADIUS = 50 const OPACITY = 1 let centerPoint = { @@ -61,14 +61,14 @@ function newSpeedometer () { } browserCanvasContext.beginPath() - browserCanvasContext.arc(centerPoint.x, centerPoint.y, RADIOUS + RED_LINE_HIGHT, 0.85 * Math.PI, 2.15 * Math.PI) + browserCanvasContext.arc(centerPoint.x, centerPoint.y, RADIUS + RED_LINE_HIGHT, 0.85 * Math.PI, 2.15 * Math.PI) browserCanvasContext.closePath() browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.RUSTED_RED + ', ' + OPACITY + ')' browserCanvasContext.fill() browserCanvasContext.beginPath() - browserCanvasContext.arc(centerPoint.x, centerPoint.y, RADIOUS, 0.0 * Math.PI, 2.0 * Math.PI) + browserCanvasContext.arc(centerPoint.x, centerPoint.y, RADIUS, 0.0 * Math.PI, 2.0 * Math.PI) browserCanvasContext.closePath() browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.DARK_TURQUOISE + ', ' + OPACITY + ')' @@ -79,7 +79,7 @@ function newSpeedometer () { const DEFAULT_THICKNESS = 2 const VALUE_THICKNESS = 8 const VALUE_BG_THICKNESS = 1 - const BAR_RADIOUS = RADIOUS * 0.85 + const BAR_RADIUS = RADIUS * 0.85 let BAR_START_ANGLE = 0.85 * Math.PI let BAR_END_ANGLE = 2.15 * Math.PI @@ -100,7 +100,7 @@ function newSpeedometer () { browserCanvasContext.setLineDash([0, 0]) browserCanvasContext.beginPath() - browserCanvasContext.arc(centerPoint.x, centerPoint.y, BAR_RADIOUS, BAR_START_ANGLE, MIN_VALUE_ANGLE) + browserCanvasContext.arc(centerPoint.x, centerPoint.y, BAR_RADIUS, BAR_START_ANGLE, MIN_VALUE_ANGLE) browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.TITANIUM_YELLOW + ', ' + OPACITY + ')' browserCanvasContext.lineWidth = VALUE_BG_THICKNESS @@ -108,7 +108,7 @@ function newSpeedometer () { browserCanvasContext.closePath() browserCanvasContext.beginPath() - browserCanvasContext.arc(centerPoint.x, centerPoint.y, BAR_RADIOUS, MIN_VALUE_ANGLE, CURRENT_VALUE_ANGLE) + browserCanvasContext.arc(centerPoint.x, centerPoint.y, BAR_RADIUS, MIN_VALUE_ANGLE, CURRENT_VALUE_ANGLE) browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.WHITE + ', ' + OPACITY + ')' browserCanvasContext.lineWidth = VALUE_BG_THICKNESS @@ -116,7 +116,7 @@ function newSpeedometer () { browserCanvasContext.closePath() browserCanvasContext.beginPath() - browserCanvasContext.arc(centerPoint.x, centerPoint.y, BAR_RADIOUS, CURRENT_VALUE_ANGLE, INIT_VALUE_ANGLE) + browserCanvasContext.arc(centerPoint.x, centerPoint.y, BAR_RADIUS, CURRENT_VALUE_ANGLE, INIT_VALUE_ANGLE) browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.RED + ', ' + OPACITY + ')' browserCanvasContext.lineWidth = VALUE_BG_THICKNESS @@ -125,7 +125,7 @@ function newSpeedometer () { if (PROFIT_VALUE_ANGLE > INIT_VALUE_ANGLE) { browserCanvasContext.beginPath() - browserCanvasContext.arc(centerPoint.x, centerPoint.y, BAR_RADIOUS, INIT_VALUE_ANGLE, PROFIT_VALUE_ANGLE) + browserCanvasContext.arc(centerPoint.x, centerPoint.y, BAR_RADIUS, INIT_VALUE_ANGLE, PROFIT_VALUE_ANGLE) browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.GREEN + ', ' + OPACITY + ')' browserCanvasContext.lineWidth = VALUE_BG_THICKNESS @@ -136,7 +136,7 @@ function newSpeedometer () { browserCanvasContext.setLineDash([2, 3]) browserCanvasContext.beginPath() - browserCanvasContext.arc(centerPoint.x, centerPoint.y, BAR_RADIOUS, BAR_START_ANGLE, MIN_VALUE_ANGLE) + browserCanvasContext.arc(centerPoint.x, centerPoint.y, BAR_RADIUS, BAR_START_ANGLE, MIN_VALUE_ANGLE) browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.TITANIUM_YELLOW + ', ' + OPACITY + ')' browserCanvasContext.lineWidth = VALUE_THICKNESS @@ -144,7 +144,7 @@ function newSpeedometer () { browserCanvasContext.closePath() browserCanvasContext.beginPath() - browserCanvasContext.arc(centerPoint.x, centerPoint.y, BAR_RADIOUS, MIN_VALUE_ANGLE, CURRENT_VALUE_ANGLE) + browserCanvasContext.arc(centerPoint.x, centerPoint.y, BAR_RADIUS, MIN_VALUE_ANGLE, CURRENT_VALUE_ANGLE) browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.WHITE + ', ' + OPACITY + ')' browserCanvasContext.lineWidth = VALUE_THICKNESS @@ -152,7 +152,7 @@ function newSpeedometer () { browserCanvasContext.closePath() browserCanvasContext.beginPath() - browserCanvasContext.arc(centerPoint.x, centerPoint.y, BAR_RADIOUS, CURRENT_VALUE_ANGLE, INIT_VALUE_ANGLE) + browserCanvasContext.arc(centerPoint.x, centerPoint.y, BAR_RADIUS, CURRENT_VALUE_ANGLE, INIT_VALUE_ANGLE) browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.RED + ', ' + OPACITY + ')' browserCanvasContext.lineWidth = VALUE_THICKNESS @@ -161,7 +161,7 @@ function newSpeedometer () { if (PROFIT_VALUE_ANGLE > INIT_VALUE_ANGLE) { browserCanvasContext.beginPath() - browserCanvasContext.arc(centerPoint.x, centerPoint.y, BAR_RADIOUS, INIT_VALUE_ANGLE, PROFIT_VALUE_ANGLE) + browserCanvasContext.arc(centerPoint.x, centerPoint.y, BAR_RADIUS, INIT_VALUE_ANGLE, PROFIT_VALUE_ANGLE) browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.GREEN + ', ' + OPACITY + ')' browserCanvasContext.lineWidth = VALUE_THICKNESS diff --git a/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js b/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js index f16aa80e6..63e6ffb08 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js +++ b/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js @@ -157,6 +157,18 @@ function newProtocolNode () { } } + if (node.payload.frame !== undefined) { + savedPayload.frame = { + position: { + x: node.payload.frame.position.x, + y: node.payload.frame.position.y + }, + width: node.payload.frame.width, + height: node.payload.frame.height, + radius: node.payload.frame.radius + } + } + if (includeReferencesInSavedPayload) { /* Next for the ones that have a reference parent, we include it */ if (node.payload.referenceParent !== undefined) { diff --git a/FloatingSpace/CircularMenuItem.js b/FloatingSpace/CircularMenuItem.js index ccda72ca8..f377c8c45 100644 --- a/FloatingSpace/CircularMenuItem.js +++ b/FloatingSpace/CircularMenuItem.js @@ -144,28 +144,28 @@ function newCircularMenuItem () { } } - let radiousGrowthFactor + let radiusGrowthFactor if (thisObject.type === 'Icon Only') { switch (thisObject.ring) { case 1: { - radiousGrowthFactor = 5 + radiusGrowthFactor = 5 break } case 2: { - radiousGrowthFactor = 3.5 + radiusGrowthFactor = 3.5 break } case 3: { - radiousGrowthFactor = 2 + radiusGrowthFactor = 2 break } } } else { - radiousGrowthFactor = 4 + radiusGrowthFactor = 4 } - thisObject.container.frame.position.x = thisObject.container.frame.radius * radiousGrowthFactor / 7 * Math.cos(toRadians(thisObject.angle)) - thisObject.currentRadius * 1.5 - thisObject.container.frame.position.y = thisObject.container.frame.radius * radiousGrowthFactor / 7 * Math.sin(toRadians(thisObject.angle)) - thisObject.container.frame.height / 2 + thisObject.container.frame.position.x = thisObject.container.frame.radius * radiusGrowthFactor / 7 * Math.cos(toRadians(thisObject.angle)) - thisObject.currentRadius * 1.5 + thisObject.container.frame.position.y = thisObject.container.frame.radius * radiusGrowthFactor / 7 * Math.sin(toRadians(thisObject.angle)) - thisObject.container.frame.height / 2 /* Temporary Status impacts on the label to use and the background of that label */ if (temporaryStatusCounter > 0) { diff --git a/Utilities.js b/Utilities.js index 7c900b3b7..26ec74a47 100644 --- a/Utilities.js +++ b/Utilities.js @@ -1,3 +1,29 @@ + +function saveFrame (payload, frame) { + payload.frame = { + position: { + x: frame.position.x, + y: frame.position.y + }, + width: frame.width, + height: frame.height, + radius: frame.radius + } +} + +function loadFrame (payload, frame) { + if (payload.node.savedPayload !== undefined) { + if (payload.node.savedPayload.frame !== undefined) { + frame.position.x = payload.node.savedPayload.frame.position.x + frame.position.y = payload.node.savedPayload.frame.position.y + frame.width = payload.node.savedPayload.frame.width + frame.height = payload.node.savedPayload.frame.height + frame.radius = payload.node.savedPayload.frame.radius + } + } + payload.node.savedPayload.frame = undefined +} + function convertTimeFrameToName (pTimeFrame) { for (let i = 0; i < dailyFilePeriods.length; i++) { let period = dailyFilePeriods[i] From b9522736c6c7d3f2a0ccd9a2571347bb4f58e608 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 17 Jan 2020 15:40:04 +0100 Subject: [PATCH 149/264] Bug on set to user location --- ChartsSpace/TimeMachine.js | 8 ++++++-- ChartsSpace/TimelineChart.js | 4 +++- Scales/RateScale.js | 1 + Scales/TimeScale.js | 1 + 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 4f49ab99f..943f70bf7 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -182,7 +182,9 @@ function newTimeMachine () { timeScaleEventSuscriptionId = thisObject.timeScale.container.eventHandler.listenToEvent('Lenght Percentage Changed', function (event) { thisObject.container.frame.width = TIME_MACHINE_WIDTH * event.value / 100 recalculateCoordinateSystem() - // moveToUserPosition(thisObject.container, timeMachineCoordinateSystem, false, true, event.mousePosition, false, true) + if (event.isUserAction === true) { + moveToUserPosition(thisObject.container, timeMachineCoordinateSystem, false, true, event.mousePosition, false, true) + } thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) }) @@ -203,7 +205,9 @@ function newTimeMachine () { rateScaleEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('Height Percentage Changed', function (event) { thisObject.container.frame.height = TIME_MACHINE_HEIGHT * event.value / 100 recalculateCoordinateSystem() - // moveToUserPosition(thisObject.container, timeMachineCoordinateSystem, true, false, event.mousePosition, false, true) + if (event.isUserAction === true) { + moveToUserPosition(thisObject.container, timeMachineCoordinateSystem, true, false, event.mousePosition, false, true) + } thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) }) diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index e65536f86..58913d908 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -168,7 +168,9 @@ function newTimelineChart () { rateScaleEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('Height Percentage Changed', function (event) { thisObject.container.frame.height = TIME_MACHINE_HEIGHT * event.value / 100 recalculateCoordinateSystem() - // moveToUserPosition(thisObject.container, timelineChartCoordinateSystem, true, false, event.mousePosition, false, true) + if (event.isUserAction === true) { + moveToUserPosition(thisObject.container, timelineChartCoordinateSystem, true, false, event.mousePosition, false, true) + } thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) }) diff --git a/Scales/RateScale.js b/Scales/RateScale.js index 2a49212ff..f1f49481b 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -124,6 +124,7 @@ function newRateScale () { if (thisObject.value > MAX_VALUE) { thisObject.value = MAX_VALUE } } event.value = thisObject.value + event.isUserAction = true thisObject.container.eventHandler.raiseEvent('Height Percentage Changed', event) saveObjectState() diff --git a/Scales/TimeScale.js b/Scales/TimeScale.js index faca8abdb..f22047e79 100644 --- a/Scales/TimeScale.js +++ b/Scales/TimeScale.js @@ -124,6 +124,7 @@ function newTimeScale () { } event.value = thisObject.value + event.isUserAction = true thisObject.container.eventHandler.raiseEvent('Lenght Percentage Changed', event) saveObjectState() From ce5d77e643b5ce85e3b70fb069d3dd2d1eb4902f Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 17 Jan 2020 17:48:51 +0100 Subject: [PATCH 150/264] Viewport Related Refactoring --- Canvas.js | 2 +- ChartsSpace/TimelineChart.js | 20 ++++---- ChartsSpace/ViewPort.js | 90 +++++++++++++++++++----------------- Plotter.js | 10 ++-- Scales/TimeFrameScale.js | 8 ++-- 5 files changed, 68 insertions(+), 62 deletions(-) diff --git a/Canvas.js b/Canvas.js index 4d4110faf..e80e06107 100644 --- a/Canvas.js +++ b/Canvas.js @@ -125,12 +125,12 @@ function newCanvas () { animation.addCallBackFunction('Chart Space Physics', thisObject.chartSpace.physics) animation.addCallBackFunction('Strategy Space Physics', thisObject.designerSpace.physics) animation.addCallBackFunction('Panels Space Physics', thisObject.panelsSpace.physics) + animation.addCallBackFunction('ViewPort physics', viewPort.physics) /* Spcaces Drawing */ animation.addCallBackFunction('Floating Space Draw', thisObject.floatingSpace.draw) animation.addCallBackFunction('Chart Space Draw', thisObject.chartSpace.draw) animation.addCallBackFunction('Panels Space', thisObject.panelsSpace.draw) - animation.addCallBackFunction('ViewPort Animate', viewPort.animate) animation.addCallBackFunction('CockpitSpace Draw', thisObject.cockpitSpace.draw) animation.addCallBackFunction('Designer Space Draw', thisObject.designerSpace.draw) animation.addCallBackFunction('Top Space Draw', thisObject.topSpace.draw) diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 58913d908..7686ecfd6 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -35,8 +35,8 @@ function newTimelineChart () { let layersPanelHandle - let onOffsetChangedEventSuscriptionId - let onZoomChangedEventSuscriptionId + let onViewportPositionChangedEventSuscriptionId + let onViewportZoomChangedEventSuscriptionId let onMouseOverEventSuscriptionId let onMouseNotOverEventSuscriptionId let timeFrameScaleEventSuscriptionId @@ -72,8 +72,8 @@ function newTimelineChart () { finalizeTimeFrameScale() } - viewPort.eventHandler.stopListening(onOffsetChangedEventSuscriptionId) - viewPort.eventHandler.stopListening(onZoomChangedEventSuscriptionId) + viewPort.eventHandler.stopListening(onViewportPositionChangedEventSuscriptionId) + viewPort.eventHandler.stopListening(onViewportZoomChangedEventSuscriptionId) thisObject.container.eventHandler.stopListening(onMouseOverEventSuscriptionId) thisObject.container.eventHandler.stopListening(onMouseNotOverEventSuscriptionId) @@ -132,8 +132,8 @@ function newTimelineChart () { datetime = NEW_SESSION_INITIAL_DATE /* Event Subscriptions - we need this events to be fired first here and then in active Plotters. */ - onOffsetChangedEventSuscriptionId = viewPort.eventHandler.listenToEvent('Offset Changed', onOffsetChanged) - onZoomChangedEventSuscriptionId = viewPort.eventHandler.listenToEvent('Zoom Changed', onZoomChanged) + onViewportPositionChangedEventSuscriptionId = viewPort.eventHandler.listenToEvent('Position Changed', onViewportPositionChanged) + onViewportZoomChangedEventSuscriptionId = viewPort.eventHandler.listenToEvent('Zoom Changed', onViewportZoomChanged) onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) onMouseNotOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) @@ -246,11 +246,13 @@ function newTimelineChart () { } } - function onZoomChanged (event) { - recalculateCurrentDatetime() + function onViewportZoomChanged (event) { + if (thisObject.container.frame.isInViewPort()) { + recalculateCurrentDatetime() + } } - function onOffsetChanged () { + function onViewportPositionChanged () { if (thisObject.container.frame.isInViewPort()) { recalculateCurrentDatetime() } diff --git a/ChartsSpace/ViewPort.js b/ChartsSpace/ViewPort.js index 34d531aab..5bbdca43c 100644 --- a/ChartsSpace/ViewPort.js +++ b/ChartsSpace/ViewPort.js @@ -41,7 +41,7 @@ function newViewPort () { fitIntoVisibleArea: fitIntoVisibleArea, displace: displace, displaceTarget: displaceTarget, - animate: animate, + physics: physics, draw: draw, raiseEvents: raiseEvents, resize: resize, @@ -50,17 +50,17 @@ function newViewPort () { let increment = 0.035 - let offset = { + let position = { x: 0, y: 0 } - var targetOffset = { + let targetPosition = { x: 0, y: 0 } - let offsetIncrement = { + let positionIncrement = { x: 0, y: 0 } @@ -106,13 +106,17 @@ function newViewPort () { function raiseEvents () { let event = { - newOffset: offset + newPosition: position } - thisObject.eventHandler.raiseEvent('Offset Changed', event) + thisObject.eventHandler.raiseEvent('Position Changed', event) } - function animate () { + function physics () { + animationPhysics() + } + + function animationPhysics () { if (thisObject.zoomLevel < thisObject.zoomTargetLevel) { if (thisObject.zoomTargetLevel - thisObject.zoomLevel < ANIMATION_INCREMENT) { ANIMATION_INCREMENT = Math.abs(thisObject.zoomTargetLevel - thisObject.zoomLevel) @@ -129,43 +133,43 @@ function newViewPort () { changeZoom(thisObject.zoomLevel + ANIMATION_INCREMENT, thisObject.zoomLevel) } - if (offsetIncrement.y !== 0) { - if (Math.trunc(Math.abs(targetOffset.y - offset.y) * 1000) >= Math.trunc(Math.abs(offsetIncrement.y) * 1000)) { - offset.y = offset.y + offsetIncrement.y + if (positionIncrement.y !== 0) { + if (Math.trunc(Math.abs(targetPosition.y - position.y) * 1000) >= Math.trunc(Math.abs(positionIncrement.y) * 1000)) { + position.y = position.y + positionIncrement.y - // console.log("offset.y changed to " + offset.y) + // console.log("position.y changed to " + position.y) } else { - offsetIncrement.y = 0 + positionIncrement.y = 0 } } } function displace (displaceVector, recalculate) { - offset.x = offset.x + displaceVector.x - offset.y = offset.y + displaceVector.y + position.x = position.x + displaceVector.x + position.y = position.y + displaceVector.y saveObjectState() let event = { - newOffset: offset, + newPosition: position, recalculate: recalculate } - thisObject.eventHandler.raiseEvent('Offset Changed', event) + thisObject.eventHandler.raiseEvent('Position Changed', event) - // console.log("displace produced new Offset x = " + offset.x + " y = " + offset.y); + // console.log("displace produced new Position x = " + position.x + " y = " + position.y); } function displaceTarget (displaceVector) { - targetOffset.x = targetOffset.x + displaceVector.x - targetOffset.y = targetOffset.y + displaceVector.y + targetPosition.x = targetPosition.x + displaceVector.x + targetPosition.y = targetPosition.y + displaceVector.y - offsetIncrement = { - x: (targetOffset.x - offset.x) / 10, - y: (targetOffset.y - offset.y) / 10 + positionIncrement = { + x: (targetPosition.x - position.x) / 10, + y: (targetPosition.y - position.y) / 10 } - // console.log("displaceTarget x = " + targetOffset.x + " y = " + targetOffset.y); + // console.log("displaceTarget x = " + targetPosition.x + " y = " + targetPosition.y); } function newZoomLevel (level) { @@ -178,7 +182,7 @@ function newViewPort () { let event = { newLevel: thisObject.zoomTargetLevel, - newOffset: offset, + newPosition: position, type: undefined } @@ -250,7 +254,7 @@ function newViewPort () { let event = { newLevel: thisObject.zoomTargetLevel, - newOffset: offset, + newPosition: position, type: undefined } @@ -269,15 +273,15 @@ function newViewPort () { let mouseNoZoom = unzoomThisPoint(thisObject.mousePosition, oldLevel) let newMouse = zoomThisPoint(mouseNoZoom, newLevel) - offset.x = offset.x - newMouse.x + thisObject.mousePosition.x - offset.y = offset.y - newMouse.y + thisObject.mousePosition.y + position.x = position.x - newMouse.x + thisObject.mousePosition.x + position.y = position.y - newMouse.y + thisObject.mousePosition.y saveObjectState() - targetOffset.x = offset.x - targetOffset.y = offset.y + targetPosition.x = position.x + targetPosition.y = position.y - offsetIncrement = { + positionIncrement = { x: 0, y: 0 } @@ -323,11 +327,11 @@ function newViewPort () { let zoomFactor = increment // + increment * thisObject.zoomLevel / 100; if (level === undefined) { - point.x = point.x * (1 + zoomFactor * thisObject.zoomLevel) + offset.x - point.y = point.y * (1 + zoomFactor * thisObject.zoomLevel) + offset.y + point.x = point.x * (1 + zoomFactor * thisObject.zoomLevel) + position.x + point.y = point.y * (1 + zoomFactor * thisObject.zoomLevel) + position.y } else { - point.x = point.x * (1 + zoomFactor * level) + offset.x - point.y = point.y * (1 + zoomFactor * level) + offset.y + point.x = point.x * (1 + zoomFactor * level) + position.x + point.y = point.y * (1 + zoomFactor * level) + position.y } return point @@ -339,13 +343,13 @@ function newViewPort () { if (level === undefined) { pointWithoutZoom = { - x: (pointWithZoom.x - offset.x) / (1 + zoomFactor * thisObject.zoomLevel), - y: (pointWithZoom.y - offset.y) / (1 + zoomFactor * thisObject.zoomLevel) + x: (pointWithZoom.x - position.x) / (1 + zoomFactor * thisObject.zoomLevel), + y: (pointWithZoom.y - position.y) / (1 + zoomFactor * thisObject.zoomLevel) } } else { pointWithoutZoom = { - x: (pointWithZoom.x - offset.x) / (1 + zoomFactor * level), - y: (pointWithZoom.y - offset.y) / (1 + zoomFactor * level) + x: (pointWithZoom.x - position.x) / (1 + zoomFactor * level), + y: (pointWithZoom.y - position.y) / (1 + zoomFactor * level) } } return pointWithoutZoom @@ -373,8 +377,8 @@ function newViewPort () { let squareWidth = (thisObject.visibleArea.bottomRight.x - thisObject.visibleArea.bottomLeft.x) / step squareWidth = squareWidth + squareWidth * increment * thisObject.zoomLevel - let startingX = offset.x - Math.trunc(offset.x / squareWidth) * squareWidth - let startingY = offset.y - Math.trunc(offset.y / squareWidth) * squareWidth + let startingX = position.x - Math.trunc(position.x / squareWidth) * squareWidth + let startingY = position.y - Math.trunc(position.y / squareWidth) * squareWidth let lineWidth = 0.4 + thisObject.zoomLevel / 100 lineWidth = lineWidth.toFixed(2) @@ -428,7 +432,7 @@ function newViewPort () { } function saveObjectState () { - objectStorage.offset = offset + objectStorage.position = position objectStorage.zoomLevel = thisObject.zoomLevel window.localStorage.setItem(MODULE_NAME, JSON.stringify(objectStorage)) } @@ -437,12 +441,12 @@ function newViewPort () { let objectStorageString = window.localStorage.getItem(MODULE_NAME) if (objectStorageString !== null && objectStorageString !== '') { objectStorage = JSON.parse(objectStorageString) - offset = objectStorage.offset + position = objectStorage.position thisObject.zoomLevel = objectStorage.zoomLevel thisObject.zoomTargetLevel = objectStorage.zoomLevel INITIAL_TIME_PERIOD = recalculatePeriod(thisObject.zoomLevel) } else { // Setting default values for first session - offset = { + position = { x: 0, y: 0 } diff --git a/Plotter.js b/Plotter.js index cb4dfb45d..7489bae12 100644 --- a/Plotter.js +++ b/Plotter.js @@ -117,8 +117,8 @@ function newPlotter () { fileCursor = dailyFiles.getFileCursor(pTimeFrame) /* Listen to the necesary events. */ - zoomChangedEventSubscriptionId = viewPort.eventHandler.listenToEvent('Zoom Changed', onZoomChanged) - offsetChangedEventSubscriptionId = viewPort.eventHandler.listenToEvent('Offset Changed', onOffsetChanged) + zoomChangedEventSubscriptionId = viewPort.eventHandler.listenToEvent('Zoom Changed', onViewportZoomChanged) + offsetChangedEventSubscriptionId = viewPort.eventHandler.listenToEvent('Position Changed', onViewportPositionChanged) dragFinishedEventSubscriptionId = canvas.eventHandler.listenToEvent('Drag Finished', onDragFinished) marketFilesUpdatedEventSubscriptionId = marketFiles.eventHandler.listenToEvent('Files Updated', onMarketFilesUpdated) dailyFilesUpdatedEventSubscriptionId = dailyFiles.eventHandler.listenToEvent('Files Updated', onDailyFilesUpdated) @@ -769,12 +769,12 @@ function newPlotter () { } } - function onZoomChanged (event) { + function onViewportZoomChanged (event) { try { mustRecalculateDataPoints = true recalculate() } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] onZoomChanged -> err = ' + err.stack) } + if (ERROR_LOG === true) { logger.write('[ERROR] onViewportZoomChanged -> err = ' + err.stack) } } } @@ -790,7 +790,7 @@ function newPlotter () { recalculateAll(event) } - function onOffsetChanged (event) { + function onViewportPositionChanged (event) { recalculateAll(event) } diff --git a/Scales/TimeFrameScale.js b/Scales/TimeFrameScale.js index 830ba4796..f66f9b7f4 100644 --- a/Scales/TimeFrameScale.js +++ b/Scales/TimeFrameScale.js @@ -28,7 +28,7 @@ function newTimeFrameScale () { let timeFrameLabel = '24-hs' let onMouseWheelEventSubscriptionId - let onZoomChangedEventSubscriptionId + let onViewportZoomChangedEventSubscriptionId let onMouseOverEventSubscriptionId let onMouseNotOverEventSubscriptionId @@ -59,7 +59,7 @@ function newTimeFrameScale () { function finalize () { thisObject.container.eventHandler.stopListening(onMouseWheelEventSubscriptionId) - viewPort.eventHandler.stopListening(onZoomChangedEventSubscriptionId) + viewPort.eventHandler.stopListening(onViewportZoomChangedEventSubscriptionId) thisObject.container.eventHandler.stopListening(onMouseOverEventSubscriptionId) thisObject.container.eventHandler.stopListening(onMouseNotOverEventSubscriptionId) @@ -77,7 +77,7 @@ function newTimeFrameScale () { newTimeFrame() onMouseWheelEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) - onZoomChangedEventSubscriptionId = viewPort.eventHandler.listenToEvent('Zoom Changed', onZoomChanged) + onViewportZoomChangedEventSubscriptionId = viewPort.eventHandler.listenToEvent('Zoom Changed', onViewportZoomChanged) onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) onMouseNotOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) } @@ -177,7 +177,7 @@ function newTimeFrameScale () { thisObject.container.frame.position.y = timePoint.y - thisObject.container.frame.height } - function onZoomChanged (event) { + function onViewportZoomChanged (event) { if (event !== undefined) { // it is undefined when the level is just being animated. let currentTimeFrame = thisObject.timeFrame let timeFrame = recalculatePeriod(event.newLevel) From d370306e232e3ffac2793d892ef858ee417f766d Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 17 Jan 2020 18:13:10 +0100 Subject: [PATCH 151/264] finalize --- ChartsSpace/ViewPort.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/ChartsSpace/ViewPort.js b/ChartsSpace/ViewPort.js index 5bbdca43c..0938d4080 100644 --- a/ChartsSpace/ViewPort.js +++ b/ChartsSpace/ViewPort.js @@ -31,6 +31,7 @@ function newViewPort () { zoomLevel: undefined, mousePosition: undefined, margins: MARGINS, + payload: undefined, newZoomLevel: newZoomLevel, applyZoom: applyZoom, isMinZoom: isMinZoom, @@ -45,37 +46,37 @@ function newViewPort () { draw: draw, raiseEvents: raiseEvents, resize: resize, - initialize: initialize + initialize: initialize, + finalize: finalize } - let increment = 0.035 - let position = { x: 0, y: 0 } - let targetPosition = { x: 0, y: 0 } - let positionIncrement = { x: 0, y: 0 } - thisObject.mousePosition = { x: 0, y: 0 } - thisObject.eventHandler = newEventHandler() - let objectStorage = {} - return thisObject + function finalize () { + logger = undefined + thisObject.eventHandler.finalize() + thisObject.payload = undefined + thisObject = undefined + } + function initialize () { resize() readObjectState() @@ -435,6 +436,10 @@ function newViewPort () { objectStorage.position = position objectStorage.zoomLevel = thisObject.zoomLevel window.localStorage.setItem(MODULE_NAME, JSON.stringify(objectStorage)) + + let frame = {} + frame.position = position + saveFrame(thisObject.payload, frame) } function readObjectState () { @@ -455,4 +460,3 @@ function newViewPort () { } } } - From 3389c1c64c1af9e98134eb57f83ae1f0ab3c780a Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 17 Jan 2020 18:46:20 +0100 Subject: [PATCH 152/264] Viewport inside the Chartspace --- Canvas.js | 31 +++++++++++++++++++++---------- ChartsSpace/TimelineChart.js | 16 ++++++++-------- ChartsSpace/ViewPort.js | 2 +- ControlsToolBox/SidePanel.js | 2 +- Dashboard.js | 34 +--------------------------------- Frame.js | 4 ++-- Globals.js | 4 ++-- Panels/LayersPanel.js | 6 +++--- Panels/PanelTabButton.js | 4 ++-- Panels/PlotterPanel.js | 4 ++-- Plotter.js | 24 ++++++++++++------------ Scales/TimeFrameScale.js | 4 ++-- Spaces/ChartSpace.js | 21 ++++++++++++++------- Spaces/CockpitSpace.js | 4 ++-- Spaces/PanelsSpace.js | 14 +++++++------- Spaces/TopSpace.js | 4 ++-- SplashScreen.js | 2 +- Utilities.js | 26 +++++++++++++------------- 18 files changed, 96 insertions(+), 110 deletions(-) diff --git a/Canvas.js b/Canvas.js index e80e06107..c971fe548 100644 --- a/Canvas.js +++ b/Canvas.js @@ -125,7 +125,7 @@ function newCanvas () { animation.addCallBackFunction('Chart Space Physics', thisObject.chartSpace.physics) animation.addCallBackFunction('Strategy Space Physics', thisObject.designerSpace.physics) animation.addCallBackFunction('Panels Space Physics', thisObject.panelsSpace.physics) - animation.addCallBackFunction('ViewPort physics', viewPort.physics) + animation.addCallBackFunction('ViewPort physics', canvas.chartSpace.viewport.physics) /* Spcaces Drawing */ animation.addCallBackFunction('Floating Space Draw', thisObject.floatingSpace.draw) @@ -146,7 +146,7 @@ function newCanvas () { browserCanvasContext = browserCanvas.getContext('2d') browserCanvasContext.font = 'Saira Condensed' - viewPort.initialize() + canvas.chartSpace.viewport.initialize() } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] initializeBrowserCanvas -> err = ' + err.stack) } } @@ -154,11 +154,12 @@ function newCanvas () { function addCanvasEvents () { try { + canvas.eventHandler.listenToEvent('Browser Resized', browserResized) + /* Keyboard events */ window.addEventListener('keydown', onKeyDown, true) /* Mouse Events */ - browserCanvas.addEventListener('mousedown', onMouseDown, false) browserCanvas.addEventListener('mouseup', onMouseUp, false) browserCanvas.addEventListener('mousemove', onMouseMove, false) @@ -171,7 +172,6 @@ function newCanvas () { } else browserCanvas.attachEvent('onmousewheel', onMouseWheel)// IE 6/7/8 /* Dragging Files Over the Canvas */ - browserCanvas.addEventListener('dragenter', onDragEnter, false) browserCanvas.addEventListener('dragleave', onDragLeave, false) browserCanvas.addEventListener('dragover', onDragOver, false) @@ -186,6 +186,17 @@ function newCanvas () { } } + function browserResized () { + try { + browserCanvas = document.getElementById('canvas') + + browserCanvas.width = window.innerWidth + browserCanvas.height = window.innerHeight - CURRENT_TOP_MARGIN + } catch (err) { + if (ERROR_LOG === true) { logger.write('[ERROR] browserResized -> err = ' + err.stack) } + } + } + function onKeyDown (event) { let nodeOnFocus = canvas.designerSpace.workspace.getNodeThatIsOnFocus() if (nodeOnFocus !== undefined) { @@ -623,8 +634,8 @@ function newCanvas () { y: event.pageY - CURRENT_TOP_MARGIN } - viewPort.mousePosition.x = point.x - viewPort.mousePosition.y = point.y + canvas.chartSpace.viewport.mousePosition.x = point.x + canvas.chartSpace.viewport.mousePosition.y = point.y if (containerDragStarted === true || floatingObjectDragStarted === true || viewPortBeingDragged === true) { if (floatingObjectDragStarted === true) { @@ -794,7 +805,7 @@ function newCanvas () { } if (container !== undefined) { - viewPort.applyZoom(delta) + canvas.chartSpace.viewport.applyZoom(delta) return false } @@ -862,7 +873,7 @@ function newCanvas () { } let downNoZoom - downNoZoom = viewPort.unzoomThisPoint(downCopy) + downNoZoom = canvas.chartSpace.viewport.unzoomThisPoint(downCopy) let upCopy = { x: dragVector.upX, @@ -870,7 +881,7 @@ function newCanvas () { } let upNoZoom - upNoZoom = viewPort.unzoomThisPoint(upCopy) + upNoZoom = canvas.chartSpace.viewport.unzoomThisPoint(upCopy) displaceVector = { x: upNoZoom.x - downNoZoom.x, @@ -879,7 +890,7 @@ function newCanvas () { } if (viewPortBeingDragged) { - viewPort.displace(displaceVector) + canvas.chartSpace.viewport.displace(displaceVector) } if (containerBeingDragged !== undefined) { diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 7686ecfd6..174507d59 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -72,8 +72,8 @@ function newTimelineChart () { finalizeTimeFrameScale() } - viewPort.eventHandler.stopListening(onViewportPositionChangedEventSuscriptionId) - viewPort.eventHandler.stopListening(onViewportZoomChangedEventSuscriptionId) + canvas.chartSpace.viewport.eventHandler.stopListening(onViewportPositionChangedEventSuscriptionId) + canvas.chartSpace.viewport.eventHandler.stopListening(onViewportZoomChangedEventSuscriptionId) thisObject.container.eventHandler.stopListening(onMouseOverEventSuscriptionId) thisObject.container.eventHandler.stopListening(onMouseNotOverEventSuscriptionId) @@ -132,8 +132,8 @@ function newTimelineChart () { datetime = NEW_SESSION_INITIAL_DATE /* Event Subscriptions - we need this events to be fired first here and then in active Plotters. */ - onViewportPositionChangedEventSuscriptionId = viewPort.eventHandler.listenToEvent('Position Changed', onViewportPositionChanged) - onViewportZoomChangedEventSuscriptionId = viewPort.eventHandler.listenToEvent('Zoom Changed', onViewportZoomChanged) + onViewportPositionChangedEventSuscriptionId = canvas.chartSpace.viewport.eventHandler.listenToEvent('Position Changed', onViewportPositionChanged) + onViewportZoomChangedEventSuscriptionId = canvas.chartSpace.viewport.eventHandler.listenToEvent('Zoom Changed', onViewportZoomChanged) onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) onMouseNotOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) @@ -267,8 +267,8 @@ function newTimelineChart () { */ let center = { - x: (viewPort.visibleArea.bottomRight.x - viewPort.visibleArea.bottomLeft.x) / 2, - y: (viewPort.visibleArea.bottomRight.y - viewPort.visibleArea.topRight.y) / 2 + x: (canvas.chartSpace.viewport.visibleArea.bottomRight.x - canvas.chartSpace.viewport.visibleArea.bottomLeft.x) / 2, + y: (canvas.chartSpace.viewport.visibleArea.bottomRight.y - canvas.chartSpace.viewport.visibleArea.topRight.y) / 2 } center = unTransformThisPoint(center, thisObject.container) @@ -365,7 +365,7 @@ function newTimelineChart () { } function tooTiny () { - if (viewPort.zoomLevel < Math.trunc(-28.25 * 100) / 100) { + if (canvas.chartSpace.viewport.zoomLevel < Math.trunc(-28.25 * 100) / 100) { return true } else { return false @@ -373,7 +373,7 @@ function newTimelineChart () { } function tooSmall () { - if (viewPort.zoomLevel < Math.trunc(-27.25 * 100) / 100) { + if (canvas.chartSpace.viewport.zoomLevel < Math.trunc(-27.25 * 100) / 100) { return true } else { return false diff --git a/ChartsSpace/ViewPort.js b/ChartsSpace/ViewPort.js index 0938d4080..c9a070ff4 100644 --- a/ChartsSpace/ViewPort.js +++ b/ChartsSpace/ViewPort.js @@ -439,7 +439,7 @@ function newViewPort () { let frame = {} frame.position = position - saveFrame(thisObject.payload, frame) + // saveFrame(thisObject.payload, frame) } function readObjectState () { diff --git a/ControlsToolBox/SidePanel.js b/ControlsToolBox/SidePanel.js index c6f0e772a..8c133e6cc 100644 --- a/ControlsToolBox/SidePanel.js +++ b/ControlsToolBox/SidePanel.js @@ -26,7 +26,7 @@ function newSidePanel () { thisObject.sidePanelTab.container.connectToParent(thisObject.container, false, false) thisObject.sidePanelTab.initialize() - window.canvasApp.eventHandler.listenToEvent('Browser Resized', resize) + canvas.eventHandler.listenToEvent('Browser Resized', resize) isInitialized = true } diff --git a/Dashboard.js b/Dashboard.js index c4b0be206..16e514b82 100644 --- a/Dashboard.js +++ b/Dashboard.js @@ -2,7 +2,7 @@ let canvas let markets let ecosystem = newEcosystem() let systemEventHandler -let viewPort + let APP_SCHEMA_MAP = new Map() let APP_SCHEMA_ARRAY = [] @@ -19,17 +19,12 @@ function newDashboard () { const DEBUG_START_UP_DELAY = 0 // 3000; // This is a waiting time in case there is a need to debug the very first steps of initialization, to be able to hit F12 on time. - let userProfileChangedEventSubscriptionId - let browserResizedEventSubscriptionId - return thisObject function start () { try { setBrowserEvents() - viewPort = newViewPort() - systemEventHandler = newSystemEventHandler() systemEventHandler.initialize(setUpAppSchema) @@ -61,12 +56,6 @@ function newDashboard () { window.localStorage.setItem(LOGGED_IN_USER_LOCAL_STORAGE_KEY, '{"authId":"x|x","alias":"user"}') // Dummy Local User } - /* Here we will setup the global eventHandler that will enable the Canvas App to react to events happening outside its execution scope. */ - - window.canvasApp.eventHandler = newEventHandler() - userProfileChangedEventSubscriptionId = window.canvasApp.eventHandler.listenToEvent('User Profile Changed', userProfileChanged) - browserResizedEventSubscriptionId = window.canvasApp.eventHandler.listenToEvent('Browser Resized', browserResized) - /* Here we used to have a call to the DataMines Module to get the profile pictures. That was removed but to keep things working, we do this: */ window.canvasApp.context.dataMineProfileImages = new Map() @@ -100,27 +89,6 @@ function newDashboard () { } } - function userProfileChanged () { - try { - canvas.topSpace.initialize() - } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] userProfileChanged -> err = ' + err.stack) } - } - } - - function browserResized () { - try { - browserCanvas = document.getElementById('canvas') - - browserCanvas.width = window.innerWidth - browserCanvas.height = window.innerHeight - CURRENT_TOP_MARGIN - - viewPort.initialize() - } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] browserResized -> err = ' + err.stack) } - } - } - function setBrowserEvents () { window.onbeforeunload = onBrowserClosed function onBrowserClosed () { diff --git a/Frame.js b/Frame.js index 51a72a13e..3f5b4cf4e 100644 --- a/Frame.js +++ b/Frame.js @@ -41,7 +41,7 @@ function newFrame () { } function isInViewPort () { - /* This function is usefull to know if the object who has this frame is currently appearing at least in part at the viewPort */ + /* This function is usefull to know if the object who has this frame is currently appearing at least in part at the canvas.chartSpace.viewport */ point1 = { x: 0, @@ -58,7 +58,7 @@ function newFrame () { point1 = transformThisPoint(point1, thisObject.container) point3 = transformThisPoint(point3, thisObject.container) - if (point1.x < viewPort.visibleArea.topRight.x && point1.y < viewPort.visibleArea.bottomRight.y && point3.x > viewPort.visibleArea.bottomLeft.x && point3.y > viewPort.visibleArea.topLeft.y) { + if (point1.x < canvas.chartSpace.viewport.visibleArea.topRight.x && point1.y < canvas.chartSpace.viewport.visibleArea.bottomRight.y && point3.x > canvas.chartSpace.viewport.visibleArea.bottomLeft.x && point3.y > canvas.chartSpace.viewport.visibleArea.topLeft.y) { return true } else { return false diff --git a/Globals.js b/Globals.js index c153385b2..de880a05a 100644 --- a/Globals.js +++ b/Globals.js @@ -143,9 +143,9 @@ const _3_MINUTES_IN_MILISECONDS = 3 * 60 * 1000; const _2_MINUTES_IN_MILISECONDS = 2 * 60 * 1000; const _1_MINUTE_IN_MILISECONDS = 1 * 60 * 1000; -let NEW_SESSION_INITIAL_DATE = new Date(); // This value will be overwritten at the viewPort.initialize if the user had a prevous session with this same browser. +let NEW_SESSION_INITIAL_DATE = new Date(); // This value will be overwritten at the canvas.chartSpace.viewport.initialize if the user had a prevous session with this same browser. let INITIAL_ZOOM_LEVEL = -28.25 // This is the zoom level at the view port in which the APP starts. -let INITIAL_TIME_PERIOD = ONE_DAY_IN_MILISECONDS // This value will be overwritten at the viewPort.initialize if the user had a prevous session with this same browser. +let INITIAL_TIME_PERIOD = ONE_DAY_IN_MILISECONDS // This value will be overwritten at the canvas.chartSpace.viewport.initialize if the user had a prevous session with this same browser. let VERY_LARGE_NUMBER = 100000000000 let CURRENT_TOP_MARGIN = window.canvasApp.topMargin diff --git a/Panels/LayersPanel.js b/Panels/LayersPanel.js index 97bea92be..f4c257052 100644 --- a/Panels/LayersPanel.js +++ b/Panels/LayersPanel.js @@ -61,8 +61,8 @@ function newProductsPanel () { thisObject.container.frame.height = heatherHeight let position = { - x: viewPort.visibleArea.topLeft.x, - y: viewPort.visibleArea.topLeft.y// viewPort.visibleArea.bottomLeft.y - thisObject.container.frame.height + x: canvas.chartSpace.viewport.visibleArea.topLeft.x, + y: canvas.chartSpace.viewport.visibleArea.topLeft.y// canvas.chartSpace.viewport.visibleArea.bottomLeft.y - thisObject.container.frame.height } thisObject.container.frame.position = position @@ -136,7 +136,7 @@ function newProductsPanel () { } function panelSizePhysics () { - let viewPortHeight = viewPort.visibleArea.bottomLeft.y - viewPort.visibleArea.topLeft.y + let viewPortHeight = canvas.chartSpace.viewport.visibleArea.bottomLeft.y - canvas.chartSpace.viewport.visibleArea.topLeft.y if (viewPortHeight < heatherHeight) { visible = false diff --git a/Panels/PanelTabButton.js b/Panels/PanelTabButton.js index dc389b7e8..1105e1372 100644 --- a/Panels/PanelTabButton.js +++ b/Panels/PanelTabButton.js @@ -55,7 +55,7 @@ function newPanelTabButton () { visiblePosition.y = thisObject.parentContainer.frame.position.y hiddenPosition.x = thisObject.parentContainer.frame.position.x - hiddenPosition.y = viewPort.visibleArea.bottomRight.y + hiddenPosition.y = canvas.chartSpace.viewport.visibleArea.bottomRight.y transitionPosition.x = visiblePosition.x transitionPosition.y = visiblePosition.y @@ -72,7 +72,7 @@ function newPanelTabButton () { visiblePosition.y = thisObject.parentContainer.frame.position.y hiddenPosition.x = thisObject.parentContainer.frame.position.x - hiddenPosition.y = viewPort.visibleArea.bottomRight.y + hiddenPosition.y = canvas.chartSpace.viewport.visibleArea.bottomRight.y transitionPosition.x = visiblePosition.x transitionPosition.y = visiblePosition.y diff --git a/Panels/PlotterPanel.js b/Panels/PlotterPanel.js index a704be207..f578e95c8 100644 --- a/Panels/PlotterPanel.js +++ b/Panels/PlotterPanel.js @@ -45,8 +45,8 @@ function newPlotterPanel () { thisObject.container.frame.width = UI_PANEL.WIDTH.NORMAL thisObject.container.frame.height = UI_PANEL.HEIGHT.NORMAL - thisObject.container.frame.position.x = viewPort.visibleArea.topRight.x - thisObject.container.frame.width - thisObject.container.frame.width * Math.random() * 8 - thisObject.container.frame.position.y = viewPort.visibleArea.bottomLeft.y - thisObject.container.frame.height - thisObject.container.frame.height * Math.random() * 1.5 + thisObject.container.frame.position.x = canvas.chartSpace.viewport.visibleArea.topRight.x - thisObject.container.frame.width - thisObject.container.frame.width * Math.random() * 8 + thisObject.container.frame.position.y = canvas.chartSpace.viewport.visibleArea.bottomLeft.y - thisObject.container.frame.height - thisObject.container.frame.height * Math.random() * 1.5 panelTabButton = newPanelTabButton() panelTabButton.parentContainer = thisObject.container diff --git a/Plotter.js b/Plotter.js index 7489bae12..2f73675b7 100644 --- a/Plotter.js +++ b/Plotter.js @@ -34,7 +34,7 @@ function newPlotter () { let coordinateSystem = newCoordinateSystem() // Needed to be able to plot on the timeline. let slotCoordinateSystem // Needed to be able to plot on a slot over the timeline. let plotterModuleConfig - let slotHeight = (viewPort.visibleArea.bottomRight.y - viewPort.visibleArea.topLeft.y) / 10 // This is the amount of slots available + let slotHeight = (canvas.chartSpace.viewport.visibleArea.bottomRight.y - canvas.chartSpace.viewport.visibleArea.topLeft.y) / 10 // This is the amount of slots available let mustRecalculateDataPoints = false let atMousePositionFillStyles = new Map() let atMousePositionStrokeStyles = new Map() @@ -66,8 +66,8 @@ function newPlotter () { function finalize () { try { /* Stop listening to the necesary events. */ - viewPort.eventHandler.stopListening(zoomChangedEventSubscriptionId) - viewPort.eventHandler.stopListening(offsetChangedEventSubscriptionId) + canvas.chartSpace.viewport.eventHandler.stopListening(zoomChangedEventSubscriptionId) + canvas.chartSpace.viewport.eventHandler.stopListening(offsetChangedEventSubscriptionId) canvas.eventHandler.stopListening(dragFinishedEventSubscriptionId) thisObject.container.eventHandler.stopListening(dimmensionsChangedEventSubscriptionId) marketFiles.eventHandler.stopListening(marketFilesUpdatedEventSubscriptionId) @@ -117,8 +117,8 @@ function newPlotter () { fileCursor = dailyFiles.getFileCursor(pTimeFrame) /* Listen to the necesary events. */ - zoomChangedEventSubscriptionId = viewPort.eventHandler.listenToEvent('Zoom Changed', onViewportZoomChanged) - offsetChangedEventSubscriptionId = viewPort.eventHandler.listenToEvent('Position Changed', onViewportPositionChanged) + zoomChangedEventSubscriptionId = canvas.chartSpace.viewport.eventHandler.listenToEvent('Zoom Changed', onViewportZoomChanged) + offsetChangedEventSubscriptionId = canvas.chartSpace.viewport.eventHandler.listenToEvent('Position Changed', onViewportPositionChanged) dragFinishedEventSubscriptionId = canvas.eventHandler.listenToEvent('Drag Finished', onDragFinished) marketFilesUpdatedEventSubscriptionId = marketFiles.eventHandler.listenToEvent('Files Updated', onMarketFilesUpdated) dailyFilesUpdatedEventSubscriptionId = dailyFiles.eventHandler.listenToEvent('Files Updated', onDailyFilesUpdated) @@ -353,8 +353,8 @@ function newPlotter () { let daysOnSides = getSideDays(timeFrame) - let leftDate = getDateFromPoint(viewPort.visibleArea.topLeft, thisObject.container, coordinateSystem) - let rightDate = getDateFromPoint(viewPort.visibleArea.topRight, thisObject.container, coordinateSystem) + let leftDate = getDateFromPoint(canvas.chartSpace.viewport.visibleArea.topLeft, thisObject.container, coordinateSystem) + let rightDate = getDateFromPoint(canvas.chartSpace.viewport.visibleArea.topRight, thisObject.container, coordinateSystem) let dateDiff = rightDate.valueOf() - leftDate.valueOf() @@ -406,8 +406,8 @@ function newPlotter () { let daysOnSides = getSideDays(timeFrame) - let leftDate = getDateFromPoint(viewPort.visibleArea.topLeft, thisObject.container, coordinateSystem) - let rightDate = getDateFromPoint(viewPort.visibleArea.topRight, thisObject.container, coordinateSystem) + let leftDate = getDateFromPoint(canvas.chartSpace.viewport.visibleArea.topLeft, thisObject.container, coordinateSystem) + let rightDate = getDateFromPoint(canvas.chartSpace.viewport.visibleArea.topRight, thisObject.container, coordinateSystem) let dateDiff = rightDate.valueOf() - leftDate.valueOf() @@ -517,7 +517,7 @@ function newPlotter () { beginPoint = transformThisPoint(beginPoint, thisObject.container) endPoint = transformThisPoint(endPoint, thisObject.container) - if (endPoint.x < viewPort.visibleArea.bottomLeft.x || beginPoint.x > viewPort.visibleArea.bottomRight.x) { + if (endPoint.x < canvas.chartSpace.viewport.visibleArea.bottomLeft.x || beginPoint.x > canvas.chartSpace.viewport.visibleArea.bottomRight.x) { continue } @@ -580,7 +580,7 @@ function newPlotter () { if (plotterModuleConfig !== undefined) { if (plotterModuleConfig.slot !== undefined) { /* We reset the y coordinate since it will be transformed with another coordinate system to fit into a slot. */ - dataPoint.y = (-1) * y * slotCoordinateSystem.scale.y + (plotterModuleConfig.slot.number - 1) * slotHeight + viewPort.visibleArea.topLeft.y + dataPoint.y = (-1) * y * slotCoordinateSystem.scale.y + (plotterModuleConfig.slot.number - 1) * slotHeight + canvas.chartSpace.viewport.visibleArea.topLeft.y } } } @@ -720,7 +720,7 @@ function newPlotter () { y: dataPointObject.y } /* We make sure the points do not fall outside the viewport visible area. This step allways need to be done. */ - dataPoint = viewPort.fitIntoVisibleArea(dataPoint) + dataPoint = canvas.chartSpace.viewport.fitIntoVisibleArea(dataPoint) if (k === 0) { browserCanvasContext.moveTo(dataPoint.x, dataPoint.y) } else { diff --git a/Scales/TimeFrameScale.js b/Scales/TimeFrameScale.js index f66f9b7f4..fb09442fc 100644 --- a/Scales/TimeFrameScale.js +++ b/Scales/TimeFrameScale.js @@ -59,7 +59,7 @@ function newTimeFrameScale () { function finalize () { thisObject.container.eventHandler.stopListening(onMouseWheelEventSubscriptionId) - viewPort.eventHandler.stopListening(onViewportZoomChangedEventSubscriptionId) + canvas.chartSpace.viewport.eventHandler.stopListening(onViewportZoomChangedEventSubscriptionId) thisObject.container.eventHandler.stopListening(onMouseOverEventSubscriptionId) thisObject.container.eventHandler.stopListening(onMouseNotOverEventSubscriptionId) @@ -77,7 +77,7 @@ function newTimeFrameScale () { newTimeFrame() onMouseWheelEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) - onViewportZoomChangedEventSubscriptionId = viewPort.eventHandler.listenToEvent('Zoom Changed', onViewportZoomChanged) + onViewportZoomChangedEventSubscriptionId = canvas.chartSpace.viewport.eventHandler.listenToEvent('Zoom Changed', onViewportZoomChanged) onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) onMouseNotOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) } diff --git a/Spaces/ChartSpace.js b/Spaces/ChartSpace.js index 3d6c52e41..99a26b614 100644 --- a/Spaces/ChartSpace.js +++ b/Spaces/ChartSpace.js @@ -17,6 +17,7 @@ function newChartSpace () { container: undefined, inViewport: undefined, timeMachines: undefined, + viewport: undefined, reset: reset, oneScreenUp: oneScreenUp, oneScreenDown: oneScreenDown, @@ -74,10 +75,15 @@ function newChartSpace () { thisObject.container.finalize() thisObject.container = undefined + + thisObject.viewport.finalize() + thisObject.viewport = undefined } function initialize () { - canvasBrowserResizedEventSubscriptionId = window.canvasApp.eventHandler.listenToEvent('Browser Resized', resize) + thisObject.viewport = newViewPort() + thisObject.viewport.initialize() + canvasBrowserResizedEventSubscriptionId = canvas.eventHandler.listenToEvent('Browser Resized', resize) } function getContainer (point, purpose) { @@ -119,6 +125,7 @@ function newChartSpace () { } function resize () { + thisObject.viewport.resize() thisObject.container.frame.width = browserCanvas.width thisObject.container.frame.height = COCKPIT_SPACE_POSITION } @@ -129,7 +136,7 @@ function newChartSpace () { y: +browserCanvas.height * PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT / 100 } - viewPort.displace(displaceVector) + canvas.chartSpace.viewport.displace(displaceVector) } function oneScreenDown () { @@ -138,7 +145,7 @@ function newChartSpace () { y: -browserCanvas.height * PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT / 100 } - viewPort.displace(displaceVector) + canvas.chartSpace.viewport.displace(displaceVector) } function oneScreenLeft () { @@ -147,7 +154,7 @@ function newChartSpace () { y: 0 } - viewPort.displace(displaceVector, true) + canvas.chartSpace.viewport.displace(displaceVector, true) } function oneScreenRight () { @@ -156,7 +163,7 @@ function newChartSpace () { y: 0 } - viewPort.displace(displaceVector, true) + canvas.chartSpace.viewport.displace(displaceVector, true) } function fitFunction (point, fullVisible) { @@ -279,7 +286,7 @@ function newChartSpace () { thisObject.timeMachines.push(timeMachine) timeMachine.payload.uiObject.setValue('') - viewPort.raiseEvents() // These events will impacts on objects just initialized. + canvas.chartSpace.viewport.raiseEvents() // These events will impacts on objects just initialized. } } } @@ -293,7 +300,7 @@ function newChartSpace () { thisObject.visible = true } - viewPort.resize() + canvas.chartSpace.viewport.resize() } function childrenPhysics () { diff --git a/Spaces/CockpitSpace.js b/Spaces/CockpitSpace.js index 6f5e7b779..239eef308 100644 --- a/Spaces/CockpitSpace.js +++ b/Spaces/CockpitSpace.js @@ -62,7 +62,7 @@ thisObject.container.frame.position.y = browserCanvas.height * INITIAL_POSITION / 100 - COCKPIT_SPACE_HEIGHT } - canvasBrowserResizedEventSubscriptionId = window.canvasApp.eventHandler.listenToEvent('Browser Resized', resize) + canvasBrowserResizedEventSubscriptionId = canvas.eventHandler.listenToEvent('Browser Resized', resize) selfMouseClickEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick) thisObject.assetBalances = newQuotedAssetalances() @@ -150,7 +150,7 @@ spacePosition: COCKPIT_SPACE_POSITION } window.localStorage.setItem(MODULE_NAME, JSON.stringify(storage)) - viewPort.resize() + canvas.chartSpace.viewport.resize() } function getContainer (point) { diff --git a/Spaces/PanelsSpace.js b/Spaces/PanelsSpace.js index b6574d7ae..4be89c240 100644 --- a/Spaces/PanelsSpace.js +++ b/Spaces/PanelsSpace.js @@ -146,8 +146,8 @@ function newPanelsSpace () { centerPoint.y = centerPoint.y + panel.container.frame.height / 2 /* Lets see which quadrant the panel is at */ - let verticalLine = (viewPort.visibleArea.topRight.x - viewPort.visibleArea.topLeft.x) / 2 + viewPort.visibleArea.topLeft.x - let horizontalLine = (viewPort.visibleArea.bottomRight.y - viewPort.visibleArea.topRight.y) * 2 / 3 + viewPort.visibleArea.topRight.y + let verticalLine = (canvas.chartSpace.viewport.visibleArea.topRight.x - canvas.chartSpace.viewport.visibleArea.topLeft.x) / 2 + canvas.chartSpace.viewport.visibleArea.topLeft.x + let horizontalLine = (canvas.chartSpace.viewport.visibleArea.bottomRight.y - canvas.chartSpace.viewport.visibleArea.topRight.y) * 2 / 3 + canvas.chartSpace.viewport.visibleArea.topRight.y /* According to the quadrant we push the panels to the sides */ if (centerPoint.x < verticalLine) { @@ -173,7 +173,7 @@ function newPanelsSpace () { panel.container.frame.position.x = browserCanvas.width - panel.container.frame.width } } - if (panel.container.frame.height <= viewPort.visibleArea.bottomRight.y - viewPort.visibleArea.topRight.y) { + if (panel.container.frame.height <= canvas.chartSpace.viewport.visibleArea.bottomRight.y - canvas.chartSpace.viewport.visibleArea.topRight.y) { if (centerPoint.y < horizontalLine) { panel.container.frame.position.y = panel.container.frame.position.y - panel.container.speed.y if (isOverlapping(i, panel.container) === true) { @@ -182,8 +182,8 @@ function newPanelsSpace () { } else { desAccelerateOnY() } - if (panel.container.frame.position.y < viewPort.visibleArea.topLeft.y) { - panel.container.frame.position.y = viewPort.visibleArea.topLeft.y + if (panel.container.frame.position.y < canvas.chartSpace.viewport.visibleArea.topLeft.y) { + panel.container.frame.position.y = canvas.chartSpace.viewport.visibleArea.topLeft.y } } else { panel.container.frame.position.y = panel.container.frame.position.y + panel.container.speed.y @@ -193,8 +193,8 @@ function newPanelsSpace () { } else { desAccelerateOnY() } - if (panel.container.frame.position.y + panel.container.frame.height > viewPort.visibleArea.bottomRight.y) { - panel.container.frame.position.y = viewPort.visibleArea.bottomRight.y - panel.container.frame.height + if (panel.container.frame.position.y + panel.container.frame.height > canvas.chartSpace.viewport.visibleArea.bottomRight.y) { + panel.container.frame.position.y = canvas.chartSpace.viewport.visibleArea.bottomRight.y - panel.container.frame.height } } } diff --git a/Spaces/TopSpace.js b/Spaces/TopSpace.js index 83fc1432f..7a2b22fb6 100644 --- a/Spaces/TopSpace.js +++ b/Spaces/TopSpace.js @@ -18,7 +18,7 @@ function newTopSpace () { return thisObject function initialize () { - window.canvasApp.eventHandler.listenToEvent('Browser Resized', resize) + canvas.eventHandler.listenToEvent('Browser Resized', resize) } function resize () { @@ -27,7 +27,7 @@ function newTopSpace () { container.frame.position.x = 0 try { - container.frame.position.y = viewPort.visibleArea.bottomLeft.y + container.frame.position.y = canvas.chartSpace.viewport.visibleArea.bottomLeft.y } catch (e) { } } diff --git a/SplashScreen.js b/SplashScreen.js index 1bfc3ca07..6efbdf87d 100644 --- a/SplashScreen.js +++ b/SplashScreen.js @@ -45,7 +45,7 @@ function newSplashScreen () { logo.src = window.canvasApp.urlPrefix + 'Images/Superalgos-logo-horz-sm-t.png' - window.canvasApp.eventHandler.listenToEvent('Browser Resized', resize) + canvas.eventHandler.listenToEvent('Browser Resized', resize) } function resize () { diff --git a/Utilities.js b/Utilities.js index 26ec74a47..b192039b3 100644 --- a/Utilities.js +++ b/Utilities.js @@ -55,15 +55,15 @@ function transformThisPoint (point, container) { point = container.frame.frameThisPoint(point) - /* We pass this point through the viewPort lends, meaning we apply the viewPort zoom and displacement. */ + /* We pass this point through the canvas.chartSpace.viewport lends, meaning we apply the canvas.chartSpace.viewport zoom and displacement. */ - point = viewPort.zoomThisPoint(point) + point = canvas.chartSpace.viewport.zoomThisPoint(point) return point } function unTransformThisPoint (point, container) { - point = viewPort.unzoomThisPoint(point) + point = canvas.chartSpace.viewport.unzoomThisPoint(point) point = container.frame.unframeThisPoint(point) return point @@ -108,8 +108,8 @@ function getMilisecondsFromPoint (point, container, timeLineCoordinateSystem) { function saveUserPosition (container, timeLineCoordinateSystem, position) { if (position === undefined) { position = { - x: (viewPort.visibleArea.bottomRight.x - viewPort.visibleArea.topLeft.x) / 2, - y: (viewPort.visibleArea.bottomRight.y - viewPort.visibleArea.topLeft.y) / 2 + x: (canvas.chartSpace.viewport.visibleArea.bottomRight.x - canvas.chartSpace.viewport.visibleArea.topLeft.x) / 2, + y: (canvas.chartSpace.viewport.visibleArea.bottomRight.y - canvas.chartSpace.viewport.visibleArea.topLeft.y) / 2 } } @@ -117,7 +117,7 @@ function saveUserPosition (container, timeLineCoordinateSystem, position) { date: getDateFromPoint(position, container, timeLineCoordinateSystem), rate: getRateFromPoint(position, container, timeLineCoordinateSystem), market: DEFAULT_MARKET, - zoom: viewPort.zoomTargetLevel + zoom: canvas.chartSpace.viewport.zoomTargetLevel } window.localStorage.setItem('userPosition', JSON.stringify(userPosition)) @@ -150,7 +150,7 @@ function moveToUserPosition (container, timeLineCoordinateSystem, ignoreX, ignor let userPosition = getUserPosition(timeLineCoordinateSystem) if (considerZoom === true) { - viewPort.newZoomLevel(userPosition.zoom) + canvas.chartSpace.viewport.newZoomLevel(userPosition.zoom) } INITIAL_TIME_PERIOD = recalculatePeriod(userPosition.zoom) @@ -161,7 +161,7 @@ function moveToUserPosition (container, timeLineCoordinateSystem, ignoreX, ignor y: userPosition.rate } - /* Put this po int in the coordinate system of the viewPort */ + /* Put this po int in the coordinate system of the canvas.chartSpace.viewport */ targetPoint = timeLineCoordinateSystem.transformThisPoint(targetPoint) targetPoint = transformThisPoint(targetPoint, container) @@ -174,8 +174,8 @@ function moveToUserPosition (container, timeLineCoordinateSystem, ignoreX, ignor } } else { centerPoint = { - x: (viewPort.visibleArea.bottomRight.x - viewPort.visibleArea.topLeft.x) / 2, - y: (viewPort.visibleArea.bottomRight.y - viewPort.visibleArea.topLeft.y) / 2 + x: (canvas.chartSpace.viewport.visibleArea.bottomRight.x - canvas.chartSpace.viewport.visibleArea.topLeft.x) / 2, + y: (canvas.chartSpace.viewport.visibleArea.bottomRight.y - canvas.chartSpace.viewport.visibleArea.topLeft.y) / 2 } } @@ -190,7 +190,7 @@ function moveToUserPosition (container, timeLineCoordinateSystem, ignoreX, ignor } let targetNoZoom - targetNoZoom = viewPort.unzoomThisPoint(targetCopy) + targetNoZoom = canvas.chartSpace.viewport.unzoomThisPoint(targetCopy) let centerCopy = { x: centerPoint.x, @@ -198,7 +198,7 @@ function moveToUserPosition (container, timeLineCoordinateSystem, ignoreX, ignor } let centerNoZoom - centerNoZoom = viewPort.unzoomThisPoint(centerCopy) + centerNoZoom = canvas.chartSpace.viewport.unzoomThisPoint(centerCopy) displaceVector = { x: centerNoZoom.x - targetNoZoom.x, @@ -218,7 +218,7 @@ function moveToUserPosition (container, timeLineCoordinateSystem, ignoreX, ignor if (ignoreX) { displaceVector.x = 0 } if (ignoreY) { displaceVector.y = 0 } - viewPort.displace(displaceVector) + canvas.chartSpace.viewport.displace(displaceVector) } } From 3dd69a7aca2148a129fda42e18401b61bf2f97d2 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 18 Jan 2020 09:21:21 +0100 Subject: [PATCH 153/264] name refactoring --- ChartsSpace/ViewPort.js | 4 ++-- Spaces/ChartSpace.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ChartsSpace/ViewPort.js b/ChartsSpace/ViewPort.js index c9a070ff4..edc9a7ec9 100644 --- a/ChartsSpace/ViewPort.js +++ b/ChartsSpace/ViewPort.js @@ -1,5 +1,5 @@ -function newViewPort () { +function newViewport () { const MODULE_NAME = 'Viewport' const INFO_LOG = false const INTENSIVE_LOG = false @@ -439,7 +439,7 @@ function newViewPort () { let frame = {} frame.position = position - // saveFrame(thisObject.payload, frame) + saveFrame(thisObject.payload, frame) } function readObjectState () { diff --git a/Spaces/ChartSpace.js b/Spaces/ChartSpace.js index 99a26b614..49b8cf3c0 100644 --- a/Spaces/ChartSpace.js +++ b/Spaces/ChartSpace.js @@ -81,7 +81,7 @@ function newChartSpace () { } function initialize () { - thisObject.viewport = newViewPort() + thisObject.viewport = newViewport() thisObject.viewport.initialize() canvasBrowserResizedEventSubscriptionId = canvas.eventHandler.listenToEvent('Browser Resized', resize) } From 7357d8d4479aa1e4abca8800d4f3f605b711217b Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 18 Jan 2020 09:30:20 +0100 Subject: [PATCH 154/264] charts space with payload --- Spaces/ChartSpace.js | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/Spaces/ChartSpace.js b/Spaces/ChartSpace.js index 49b8cf3c0..19d76391c 100644 --- a/Spaces/ChartSpace.js +++ b/Spaces/ChartSpace.js @@ -18,6 +18,7 @@ function newChartSpace () { inViewport: undefined, timeMachines: undefined, viewport: undefined, + payload: undefined, reset: reset, oneScreenUp: oneScreenUp, oneScreenDown: oneScreenDown, @@ -78,9 +79,19 @@ function newChartSpace () { thisObject.viewport.finalize() thisObject.viewport = undefined + + thisObject.payload = undefined } function initialize () { + let rootNodes = canvas.designerSpace.workspace.workspaceNode.rootNodes + for (let i = 0; i < rootNodes.length; i++) { + let rootNode = rootNodes[i] + if (rootNode.type === 'Charting System') { + thisObject.payload = rootNode.payload + } + } + thisObject.viewport = newViewport() thisObject.viewport.initialize() canvasBrowserResizedEventSubscriptionId = canvas.eventHandler.listenToEvent('Browser Resized', resize) @@ -228,26 +239,20 @@ function newChartSpace () { function syncWithDesigner () { syncWithDesignerLoop = syncWithDesignerLoop + 0.00000000001 - let rootNodes = canvas.designerSpace.workspace.workspaceNode.rootNodes - for (let i = 0; i < rootNodes.length; i++) { - let rootNode = rootNodes[i] - if (rootNode.type === 'Charting System') { - let chartingSystem = rootNode - if (chartingSystem.timeMachines !== undefined) { - for (let j = 0; j < chartingSystem.timeMachines.length; j++) { - let node = chartingSystem.timeMachines[j] - let timeMachine = timeMachinesMap.get(node.id) - if (timeMachine === undefined) { + if (thisObject.payload.node.timeMachines !== undefined) { + for (let j = 0; j < thisObject.payload.node.timeMachines.length; j++) { + let node = thisObject.payload.node.timeMachines[j] + let timeMachine = timeMachinesMap.get(node.id) + if (timeMachine === undefined) { /* The time machine node is new, thus we need to initialize a new timeMachine */ - initializeTimeMachine(node, syncWithDesignerLoop) - } else { + initializeTimeMachine(node, syncWithDesignerLoop) + } else { /* The time machine already exists, we tag it as existing at the current loop. */ - timeMachine.syncWithDesignerLoop = syncWithDesignerLoop - } - } + timeMachine.syncWithDesignerLoop = syncWithDesignerLoop } } } + /* We check all the timeMachines we have to see if we need to remove any of them */ for (let i = 0; i < thisObject.timeMachines.length; i++) { let timeMachine = thisObject.timeMachines[i] From 29166cfb4735ef8341f94a9d815e0edab8e881d0 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 18 Jan 2020 10:05:54 +0100 Subject: [PATCH 155/264] Viewport position being saved at payload --- Canvas.js | 9 ++++----- ChartsSpace/ViewPort.js | 18 ++++++++++++++++-- Spaces/ChartSpace.js | 19 +++++++++++++++++-- Spaces/CockpitSpace.js | 4 +++- 4 files changed, 40 insertions(+), 10 deletions(-) diff --git a/Canvas.js b/Canvas.js index c971fe548..97a0ccac0 100644 --- a/Canvas.js +++ b/Canvas.js @@ -125,7 +125,6 @@ function newCanvas () { animation.addCallBackFunction('Chart Space Physics', thisObject.chartSpace.physics) animation.addCallBackFunction('Strategy Space Physics', thisObject.designerSpace.physics) animation.addCallBackFunction('Panels Space Physics', thisObject.panelsSpace.physics) - animation.addCallBackFunction('ViewPort physics', canvas.chartSpace.viewport.physics) /* Spcaces Drawing */ animation.addCallBackFunction('Floating Space Draw', thisObject.floatingSpace.draw) @@ -145,8 +144,6 @@ function newCanvas () { try { browserCanvasContext = browserCanvas.getContext('2d') browserCanvasContext.font = 'Saira Condensed' - - canvas.chartSpace.viewport.initialize() } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] initializeBrowserCanvas -> err = ' + err.stack) } } @@ -634,8 +631,10 @@ function newCanvas () { y: event.pageY - CURRENT_TOP_MARGIN } - canvas.chartSpace.viewport.mousePosition.x = point.x - canvas.chartSpace.viewport.mousePosition.y = point.y + if (canvas.chartSpace.viewport !== undefined) { + canvas.chartSpace.viewport.mousePosition.x = point.x + canvas.chartSpace.viewport.mousePosition.y = point.y + } if (containerDragStarted === true || floatingObjectDragStarted === true || viewPortBeingDragged === true) { if (floatingObjectDragStarted === true) { diff --git a/ChartsSpace/ViewPort.js b/ChartsSpace/ViewPort.js index edc9a7ec9..8a81f0c92 100644 --- a/ChartsSpace/ViewPort.js +++ b/ChartsSpace/ViewPort.js @@ -433,7 +433,7 @@ function newViewport () { } function saveObjectState () { - objectStorage.position = position + if (thisObject.payload === undefined) { return } objectStorage.zoomLevel = thisObject.zoomLevel window.localStorage.setItem(MODULE_NAME, JSON.stringify(objectStorage)) @@ -443,10 +443,24 @@ function newViewport () { } function readObjectState () { + if (thisObject.payload === undefined) { return } + let frame = { + position: { + x: 0, + y: 0 + } + } + loadFrame(thisObject.payload, frame) + if (!isNaN(frame.position.x)) { + position.x = frame.position.x + } + if (!isNaN(frame.position.y)) { + position.y = frame.position.y + } + let objectStorageString = window.localStorage.getItem(MODULE_NAME) if (objectStorageString !== null && objectStorageString !== '') { objectStorage = JSON.parse(objectStorageString) - position = objectStorage.position thisObject.zoomLevel = objectStorage.zoomLevel thisObject.zoomTargetLevel = objectStorage.zoomLevel INITIAL_TIME_PERIOD = recalculatePeriod(thisObject.zoomLevel) diff --git a/Spaces/ChartSpace.js b/Spaces/ChartSpace.js index 19d76391c..538bb912c 100644 --- a/Spaces/ChartSpace.js +++ b/Spaces/ChartSpace.js @@ -93,7 +93,14 @@ function newChartSpace () { } thisObject.viewport = newViewport() + if (thisObject.payload.node.viewport === undefined) { + if (ERROR_LOG === true) { logger.write('[WARN] initialize -> There must exist a Viewport node attached to the Charting System node in order for the Viewport save its properties. ') } + } else { + thisObject.viewport.payload = thisObject.payload.node.viewport.payload + } + thisObject.viewport.initialize() + canvasBrowserResizedEventSubscriptionId = canvas.eventHandler.listenToEvent('Browser Resized', resize) } @@ -231,6 +238,10 @@ function newChartSpace () { } function physics () { + if (thisObject.viewport !== undefined) { + thisObject.viewport.physics() + } + thisObjectPhysics() childrenPhysics() syncWithDesigner() @@ -291,7 +302,9 @@ function newChartSpace () { thisObject.timeMachines.push(timeMachine) timeMachine.payload.uiObject.setValue('') - canvas.chartSpace.viewport.raiseEvents() // These events will impacts on objects just initialized. + if (canvas.chartSpace.viewport !== undefined) { + canvas.chartSpace.viewport.raiseEvents() // These events will impacts on objects just initialized. + } } } } @@ -305,7 +318,9 @@ function newChartSpace () { thisObject.visible = true } - canvas.chartSpace.viewport.resize() + if (canvas.chartSpace.viewport !== undefined) { + canvas.chartSpace.viewport.resize() + } } function childrenPhysics () { diff --git a/Spaces/CockpitSpace.js b/Spaces/CockpitSpace.js index 239eef308..3fd7ac075 100644 --- a/Spaces/CockpitSpace.js +++ b/Spaces/CockpitSpace.js @@ -150,7 +150,9 @@ spacePosition: COCKPIT_SPACE_POSITION } window.localStorage.setItem(MODULE_NAME, JSON.stringify(storage)) - canvas.chartSpace.viewport.resize() + if (canvas.chartSpace.viewport !== undefined) { + canvas.chartSpace.viewport.resize() + } } function getContainer (point) { From 1d36187296047eef522cd069b8f3f82bd086ce6a Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 18 Jan 2020 10:48:45 +0100 Subject: [PATCH 156/264] viewport zoom being saved into config --- ChartsSpace/ViewPort.js | 58 +++++++++++++++++++++++++++++------------ Globals.js | 2 +- 2 files changed, 43 insertions(+), 17 deletions(-) diff --git a/ChartsSpace/ViewPort.js b/ChartsSpace/ViewPort.js index 8a81f0c92..7c8d3944a 100644 --- a/ChartsSpace/ViewPort.js +++ b/ChartsSpace/ViewPort.js @@ -8,6 +8,8 @@ function newViewport () { logger.fileName = MODULE_NAME const CONSOLE_LOG = true + const MIN_ZOOM_LEVEL = -28.25 + const MAX_ZOOM_LEVEL = 1000 let ANIMATION_INCREMENT = 0.25 @@ -67,7 +69,12 @@ function newViewport () { y: 0 } thisObject.eventHandler = newEventHandler() - let objectStorage = {} + +/* Initial default value */ + thisObject.zoomLevel = MIN_ZOOM_LEVEL + thisObject.zoomTargetLevel = MIN_ZOOM_LEVEL + INITIAL_TIME_PERIOD = recalculatePeriod(thisObject.zoomLevel) + return thisObject function finalize () { @@ -233,7 +240,7 @@ function newViewport () { } } - if (thisObject.zoomTargetLevel + amount > 1000) { + if (thisObject.zoomTargetLevel + amount > MAX_ZOOM_LEVEL) { return false } @@ -434,9 +441,18 @@ function newViewport () { function saveObjectState () { if (thisObject.payload === undefined) { return } - objectStorage.zoomLevel = thisObject.zoomLevel - window.localStorage.setItem(MODULE_NAME, JSON.stringify(objectStorage)) + /* Save the zoom at the node config, so that the user can change it if he wishes to. */ + try { + let code = JSON.parse(thisObject.payload.node.code) + code.zoom = (thisObject.zoomLevel - MIN_ZOOM_LEVEL) / (MAX_ZOOM_LEVEL - MIN_ZOOM_LEVEL) * 100 + code.zoom = code.zoom.toFixed(2) + thisObject.payload.node.code = JSON.stringify(code) + } catch (err) { + // we ignore errors here since most likely they will be parsing errors. + } + + /* Save the position at the frame lavel */ let frame = {} frame.position = position saveFrame(thisObject.payload, frame) @@ -444,6 +460,8 @@ function newViewport () { function readObjectState () { if (thisObject.payload === undefined) { return } + + /* Read the position from the frame structure */ let frame = { position: { x: 0, @@ -458,19 +476,27 @@ function newViewport () { position.y = frame.position.y } - let objectStorageString = window.localStorage.getItem(MODULE_NAME) - if (objectStorageString !== null && objectStorageString !== '') { - objectStorage = JSON.parse(objectStorageString) - thisObject.zoomLevel = objectStorage.zoomLevel - thisObject.zoomTargetLevel = objectStorage.zoomLevel - INITIAL_TIME_PERIOD = recalculatePeriod(thisObject.zoomLevel) - } else { // Setting default values for first session - position = { - x: 0, - y: 0 + /* Read the zoom level from the node config */ + try { + let code = JSON.parse(thisObject.payload.node.code) + + if (isNaN(code.zoom) || code.zoom === null || code.zoom === undefined) { + saveObjectState() + return } - thisObject.zoomLevel = MIN_ZOOM_LEVEL - thisObject.zoomTargetLevel = MIN_ZOOM_LEVEL + code.zoom = code.zoom / 100 * (MAX_ZOOM_LEVEL - MIN_ZOOM_LEVEL) + MIN_ZOOM_LEVEL + if (code.zoom < MIN_ZOOM_LEVEL) { code.zoom = MIN_ZOOM_LEVEL } + if (code.zoom > MAX_ZOOM_LEVEL) { code.zoom = MAX_ZOOM_LEVEL } + + if (code.zoom !== thisObject.zoomLevel) { + thisObject.zoomLevel = code.zoom + thisObject.zoomTargetLevel = code.zoom + INITIAL_TIME_PERIOD = recalculatePeriod(thisObject.zoomLevel) + } else { + saveObjectState() + } + } catch (err) { + // we ignore errors here since most likely they will be parsing errors. } } } diff --git a/Globals.js b/Globals.js index de880a05a..de949a28c 100644 --- a/Globals.js +++ b/Globals.js @@ -42,7 +42,7 @@ UI_FONT = { }; let FONT_ASPECT_RATIO = 0.32; -const MIN_ZOOM_LEVEL = -28.25 + const GET_CONTAINER_PURPOSE = { MOUSE_OVER: 1, From f29986488f651dcfd84ec3be1f2ba80492df4107 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 18 Jan 2020 11:16:20 +0100 Subject: [PATCH 157/264] Viewport saving zoom level --- ChartsSpace/TimelineChart.js | 4 ++- ChartsSpace/ViewPort.js | 53 ++++++++++++++++++++---------------- 2 files changed, 32 insertions(+), 25 deletions(-) diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 174507d59..b368f2f96 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -283,7 +283,9 @@ function newTimelineChart () { datetime = newDate - thisObject.plotterManager.setDatetime(datetime) + if (thisObject.plotterManager !== undefined) { + thisObject.plotterManager.setDatetime(datetime) + } } function getContainer (point, purpose) { diff --git a/ChartsSpace/ViewPort.js b/ChartsSpace/ViewPort.js index 7c8d3944a..f29d0c043 100644 --- a/ChartsSpace/ViewPort.js +++ b/ChartsSpace/ViewPort.js @@ -8,7 +8,7 @@ function newViewport () { logger.fileName = MODULE_NAME const CONSOLE_LOG = true - const MIN_ZOOM_LEVEL = -28.25 + const MIN_ZOOM_LEVEL = -28.04435 const MAX_ZOOM_LEVEL = 1000 let ANIMATION_INCREMENT = 0.25 @@ -85,6 +85,23 @@ function newViewport () { } function initialize () { + if (thisObject.payload !== undefined) { + /* Read the position from the frame structure */ + let frame = { + position: { + x: 0, + y: 0 + } + } + loadFrame(thisObject.payload, frame) + if (!isNaN(frame.position.x)) { + position.x = frame.position.x + } + if (!isNaN(frame.position.y)) { + position.y = frame.position.y + } + } + resize() readObjectState() } @@ -122,6 +139,16 @@ function newViewport () { function physics () { animationPhysics() + positioningphysics() + readObjectState() + } + + function positioningphysics () { + if (thisObject.payload === undefined) { return } + /* Save the position at the frame lavel */ + let frame = {} + frame.position = position + saveFrame(thisObject.payload, frame) } function animationPhysics () { @@ -451,31 +478,11 @@ function newViewport () { } catch (err) { // we ignore errors here since most likely they will be parsing errors. } - - /* Save the position at the frame lavel */ - let frame = {} - frame.position = position - saveFrame(thisObject.payload, frame) } function readObjectState () { if (thisObject.payload === undefined) { return } - /* Read the position from the frame structure */ - let frame = { - position: { - x: 0, - y: 0 - } - } - loadFrame(thisObject.payload, frame) - if (!isNaN(frame.position.x)) { - position.x = frame.position.x - } - if (!isNaN(frame.position.y)) { - position.y = frame.position.y - } - /* Read the zoom level from the node config */ try { let code = JSON.parse(thisObject.payload.node.code) @@ -489,9 +496,7 @@ function newViewport () { if (code.zoom > MAX_ZOOM_LEVEL) { code.zoom = MAX_ZOOM_LEVEL } if (code.zoom !== thisObject.zoomLevel) { - thisObject.zoomLevel = code.zoom - thisObject.zoomTargetLevel = code.zoom - INITIAL_TIME_PERIOD = recalculatePeriod(thisObject.zoomLevel) + newZoomLevel(code.zoom) } else { saveObjectState() } From dee06fb88d2eba5c40dff564841b4299edffaf46 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 18 Jan 2020 11:57:01 +0100 Subject: [PATCH 158/264] previous value --- ChartsSpace/ViewPort.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChartsSpace/ViewPort.js b/ChartsSpace/ViewPort.js index f29d0c043..69b1d435d 100644 --- a/ChartsSpace/ViewPort.js +++ b/ChartsSpace/ViewPort.js @@ -8,7 +8,7 @@ function newViewport () { logger.fileName = MODULE_NAME const CONSOLE_LOG = true - const MIN_ZOOM_LEVEL = -28.04435 + const MIN_ZOOM_LEVEL = -28.25 const MAX_ZOOM_LEVEL = 1000 let ANIMATION_INCREMENT = 0.25 From 24e28768159256e4944bb5473fc9caf94b1b88a7 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 18 Jan 2020 12:11:44 +0100 Subject: [PATCH 159/264] Unused code removed --- ChartsSpace/PlottersManager.js | 10 ---- ChartsSpace/ViewPort.js | 98 ---------------------------------- 2 files changed, 108 deletions(-) diff --git a/ChartsSpace/PlottersManager.js b/ChartsSpace/PlottersManager.js index 3b05f692a..593248445 100644 --- a/ChartsSpace/PlottersManager.js +++ b/ChartsSpace/PlottersManager.js @@ -15,7 +15,6 @@ function newPlottersManager () { payload: undefined, setDatetime: setDatetime, setTimeFrame: setTimeFrame, - positionAtDatetime: positionAtDatetime, draw: draw, getContainer: getContainer, initialize: initialize, @@ -290,15 +289,6 @@ function newPlottersManager () { } } - function positionAtDatetime (pDatetime) { - for (let i = 0; i < connectors.length; i++) { - let connector = connectors[i] - if (connector.plotter.positionAtDatetime !== undefined) { - connector.plotter.positionAtDatetime(pDatetime) - } - } - } - function getContainer (point) { } diff --git a/ChartsSpace/ViewPort.js b/ChartsSpace/ViewPort.js index 69b1d435d..cf0e5430c 100644 --- a/ChartsSpace/ViewPort.js +++ b/ChartsSpace/ViewPort.js @@ -36,16 +36,12 @@ function newViewport () { payload: undefined, newZoomLevel: newZoomLevel, applyZoom: applyZoom, - isMinZoom: isMinZoom, - zoomFontSize: zoomFontSize, zoomThisPoint: zoomThisPoint, unzoomThisPoint: unzoomThisPoint, isThisPointVisible: isThisPointVisible, fitIntoVisibleArea: fitIntoVisibleArea, displace: displace, - displaceTarget: displaceTarget, physics: physics, - draw: draw, raiseEvents: raiseEvents, resize: resize, initialize: initialize, @@ -195,18 +191,6 @@ function newViewport () { // console.log("displace produced new Position x = " + position.x + " y = " + position.y); } - function displaceTarget (displaceVector) { - targetPosition.x = targetPosition.x + displaceVector.x - targetPosition.y = targetPosition.y + displaceVector.y - - positionIncrement = { - x: (targetPosition.x - position.x) / 10, - y: (targetPosition.y - position.y) / 10 - } - - // console.log("displaceTarget x = " + targetPosition.x + " y = " + targetPosition.y); - } - function newZoomLevel (level) { thisObject.zoomTargetLevel = level thisObject.zoomLevel = level @@ -226,12 +210,6 @@ function newViewport () { return true } - function isMinZoom () { - /* returns true is we are currently at the min zoom level. */ - - if (thisObject.zoomTargetLevel === MIN_ZOOM_LEVEL) { return true } else { return false } - } - function applyZoom (amount) { // console.log("applyZoom amount: " + amount); @@ -324,18 +302,6 @@ function newViewport () { thisObject.eventHandler.raiseEvent('Zoom Changed') } - function zoomFontSize (baseSize, level) { - let zoomFactor = increment // + increment * thisObject.zoomLevel / 100; - - if (level === undefined) { - baseSize = baseSize * (1 + zoomFactor * thisObject.zoomLevel) - } else { - baseSize = baseSize * (1 + zoomFactor * level) - } - - return baseSize - } - function fitIntoVisibleArea (point) { /* Here we check the boundaries of the resulting points, so they dont go out of the visible area. */ @@ -402,70 +368,6 @@ function newViewport () { } } - function draw () { - drawGrid(0.1) - } - - function drawGrid (step) { - if (thisObject.zoomLevel > -17) { return } - - let squareWidth = (thisObject.visibleArea.bottomRight.x - thisObject.visibleArea.bottomLeft.x) / step - squareWidth = squareWidth + squareWidth * increment * thisObject.zoomLevel - - let startingX = position.x - Math.trunc(position.x / squareWidth) * squareWidth - let startingY = position.y - Math.trunc(position.y / squareWidth) * squareWidth - let lineWidth = 0.4 + thisObject.zoomLevel / 100 - lineWidth = lineWidth.toFixed(2) - - if (lineWidth < 0.1) { - return - } - - if (lineWidth > 2) { - lineWidth = 2 - } - - browserCanvasContext.beginPath() - - let CROSS_SIZE = 4 - - for (var i = startingX; i < thisObject.visibleArea.bottomRight.x + RIGHT_MARGIN; i = i + squareWidth) { - for (var j = startingY; j < thisObject.visibleArea.bottomRight.y + BOTTOM_MARGIN; j = j + squareWidth) { - let point1 = { - x: Math.trunc(i - CROSS_SIZE), - y: Math.trunc(j) - } - - let point2 = { - x: Math.trunc(i + CROSS_SIZE), - y: Math.trunc(j) - } - - browserCanvasContext.moveTo(point1.x, point1.y) - browserCanvasContext.lineTo(point2.x, point2.y) - - let point3 = { - x: Math.trunc(i), - y: Math.trunc(j - CROSS_SIZE) - } - - let point4 = { - x: Math.trunc(i), - y: Math.trunc(j + CROSS_SIZE) - } - - browserCanvasContext.moveTo(point3.x, point3.y) - browserCanvasContext.lineTo(point4.x, point4.y) - } - } - browserCanvasContext.closePath() - browserCanvasContext.strokeStyle = 'rgba(150, 150, 150, 0.5)' - - browserCanvasContext.lineWidth = 1 - - browserCanvasContext.stroke() - } - function saveObjectState () { if (thisObject.payload === undefined) { return } From fd91ce3dcba50c1dbcb202eda9f54368a9b3398a Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 18 Jan 2020 23:13:13 +0100 Subject: [PATCH 160/264] Working Again --- Animation.js | 2 +- Canvas.js | 6 +- ChartsSpace/ChartUtilities.js | 37 +++--- ChartsSpace/TimeMachine.js | 12 +- ChartsSpace/TimelineChart.js | 29 ++--- ChartsSpace/ViewPort.js | 209 ++++++++++++++++------------------ Globals.js | 4 +- Scales/RateScale.js | 7 +- Scales/TimeFrameScale.js | 3 +- Scales/TimeScale.js | 10 +- Spaces/ChartSpace.js | 6 +- Utilities.js | 14 +-- 12 files changed, 158 insertions(+), 181 deletions(-) diff --git a/Animation.js b/Animation.js index 4aff8d1e7..cd00a0fb7 100644 --- a/Animation.js +++ b/Animation.js @@ -62,7 +62,7 @@ function newAnimation () { browserCanvas.height = window.innerHeight - CURRENT_TOP_MARGIN /* First thing is to clear the actual canvas */ - clearBrowserCanvas() + // clearBrowserCanvas() /* We loop through the callback functions collections and execute them all. */ let performanceMap = new Map() diff --git a/Canvas.js b/Canvas.js index 97a0ccac0..450b94ee7 100644 --- a/Canvas.js +++ b/Canvas.js @@ -804,7 +804,7 @@ function newCanvas () { } if (container !== undefined) { - canvas.chartSpace.viewport.applyZoom(delta) + canvas.chartSpace.viewport.onMouseWheel(delta) return false } @@ -872,7 +872,7 @@ function newCanvas () { } let downNoZoom - downNoZoom = canvas.chartSpace.viewport.unzoomThisPoint(downCopy) + downNoZoom = canvas.chartSpace.viewport.unTransformThisPoint(downCopy) let upCopy = { x: dragVector.upX, @@ -880,7 +880,7 @@ function newCanvas () { } let upNoZoom - upNoZoom = canvas.chartSpace.viewport.unzoomThisPoint(upCopy) + upNoZoom = canvas.chartSpace.viewport.unTransformThisPoint(upCopy) displaceVector = { x: upNoZoom.x - downNoZoom.x, diff --git a/ChartsSpace/ChartUtilities.js b/ChartsSpace/ChartUtilities.js index 16f47e1d0..e3ddf4cd7 100644 --- a/ChartsSpace/ChartUtilities.js +++ b/ChartsSpace/ChartUtilities.js @@ -64,11 +64,11 @@ function getTransparenceFactor (timeFrame) { function recalculatePeriod (zoomLevel) { // console.log(" recalculatePeriod > " + zoomLevel); - if (zoomLevel > 200) { + if (zoomLevel > 90) { return _1_MINUTE_IN_MILISECONDS } - if (zoomLevel > 120) { + if (zoomLevel > 85) { return _2_MINUTES_IN_MILISECONDS } @@ -76,68 +76,65 @@ function recalculatePeriod (zoomLevel) { return _3_MINUTES_IN_MILISECONDS } - if (zoomLevel > 60) { + if (zoomLevel > 75) { return _4_MINUTES_IN_MILISECONDS } - if (zoomLevel > 15) { + if (zoomLevel > 70) { return _5_MINUTES_IN_MILISECONDS } - if (zoomLevel > -7) { + if (zoomLevel > 65) { return _10_MINUTES_IN_MILISECONDS } - if (zoomLevel > -10) { + if (zoomLevel > 60) { return _15_MINUTES_IN_MILISECONDS } - if (zoomLevel > -13) { + if (zoomLevel > 55) { return _20_MINUTES_IN_MILISECONDS } - if (zoomLevel > -15) { + if (zoomLevel > 50) { return _30_MINUTES_IN_MILISECONDS } - if (zoomLevel > -16) { + if (zoomLevel > 45) { return _40_MINUTES_IN_MILISECONDS } - if (zoomLevel > -17) { + if (zoomLevel > 50) { return _45_MINUTES_IN_MILISECONDS } - if (zoomLevel > -18) { + if (zoomLevel > 35) { return _1_HOUR_IN_MILISECONDS } - if (zoomLevel > -24) { + if (zoomLevel > 30) { return _2_HOURS_IN_MILISECONDS } - if (zoomLevel > -25) { + if (zoomLevel > 25) { return _3_HOURS_IN_MILISECONDS } - if (zoomLevel > -27) { + if (zoomLevel > 20) { return _4_HOURS_IN_MILISECONDS } - if (zoomLevel > -27.5) { + if (zoomLevel > 15) { return _6_HOURS_IN_MILISECONDS } - if (zoomLevel > -27.75) { + if (zoomLevel > 10) { return _8_HOURS_IN_MILISECONDS } - if (zoomLevel > -28) { + if (zoomLevel > 5) { return _12_HOURS_IN_MILISECONDS } - if (zoomLevel <= -28) { - return ONE_DAY_IN_MILISECONDS - } return ONE_DAY_IN_MILISECONDS } diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 943f70bf7..186bbe0bf 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -132,7 +132,7 @@ function newTimeMachine () { function initialize (callBackFunction) { timeFrame = INITIAL_TIME_PERIOD - loadFrame(thisObject.payload, thisObject.container.frame) + // loadFrame(thisObject.payload, thisObject.container.frame) recalculateCoordinateSystem() @@ -180,10 +180,10 @@ function newTimeMachine () { thisObject.timeScale.payload = thisObject.payload.node.timeScale.payload timeScaleEventSuscriptionId = thisObject.timeScale.container.eventHandler.listenToEvent('Lenght Percentage Changed', function (event) { - thisObject.container.frame.width = TIME_MACHINE_WIDTH * event.value / 100 + thisObject.container.frame.width = TIME_MACHINE_WIDTH * event.value recalculateCoordinateSystem() if (event.isUserAction === true) { - moveToUserPosition(thisObject.container, timeMachineCoordinateSystem, false, true, event.mousePosition, false, true) + moveToUserPosition(thisObject.container, timeMachineCoordinateSystem, false, true, event.mousePosition, true) } thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) }) @@ -203,10 +203,10 @@ function newTimeMachine () { thisObject.rateScale.payload = thisObject.payload.node.rateScale.payload rateScaleEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('Height Percentage Changed', function (event) { - thisObject.container.frame.height = TIME_MACHINE_HEIGHT * event.value / 100 + thisObject.container.frame.height = TIME_MACHINE_HEIGHT * event.value recalculateCoordinateSystem() if (event.isUserAction === true) { - moveToUserPosition(thisObject.container, timeMachineCoordinateSystem, true, false, event.mousePosition, false, true) + moveToUserPosition(thisObject.container, timeMachineCoordinateSystem, true, false, event.mousePosition, true) } thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) }) @@ -411,7 +411,7 @@ function newTimeMachine () { timelineChart.container.fitFunction = thisObject.container.fitFunction timelineChart.fitFunction = thisObject.fitFunction timelineChart.container.frame.height = thisObject.container.frame.height - timelineChart.container.frame.position.x = thisObject.container.frame.width / 2 - timelineChart.container.frame.width / 2 + timelineChart.container.frame.position.x = 0 timelineChart.container.frame.position.y = 0 timelineChart.initialize(timeMachineCoordinateSystem) diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index b368f2f96..b4c073f61 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -57,6 +57,9 @@ function newTimelineChart () { thisObject.container = newContainer() thisObject.container.initialize(MODULE_NAME) thisObject.container.detectMouseOver = true + + thisObject.container.frame.width = TIME_MACHINE_WIDTH + thisObject.container.frame.height = TIME_MACHINE_HEIGHT } function finalize () { @@ -119,8 +122,10 @@ function newTimelineChart () { thisObject.rateScale = undefined /* Resets the local container with the dimessions of its parent, the Time Machine */ + thisObject.container.frame.position.position.x = 0 thisObject.container.frame.position.position.y = 0 - thisObject.container.frame.position.height = thisObject.container.parentContainer.frame.height + thisObject.container.frame.height = TIME_MACHINE_HEIGHT + thisObject.container.frame.width = TIME_MACHINE_WIDTH } function initialize (pTimeMachineCoordinateSystem) { @@ -166,10 +171,10 @@ function newTimelineChart () { thisObject.rateScale.payload = thisObject.payload.node.rateScale.payload rateScaleEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('Height Percentage Changed', function (event) { - thisObject.container.frame.height = TIME_MACHINE_HEIGHT * event.value / 100 + thisObject.container.frame.height = TIME_MACHINE_HEIGHT * event.value recalculateCoordinateSystem() if (event.isUserAction === true) { - moveToUserPosition(thisObject.container, timelineChartCoordinateSystem, true, false, event.mousePosition, false, true) + moveToUserPosition(thisObject.container, timelineChartCoordinateSystem, true, false, event.mousePosition, true) } thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) }) @@ -279,7 +284,7 @@ function newTimelineChart () { } let newDate = new Date(0) - newDate.setUTCSeconds(center.x / 1000) + newDate.setUTCSeconds(center.x) datetime = newDate @@ -366,22 +371,6 @@ function newTimelineChart () { } } - function tooTiny () { - if (canvas.chartSpace.viewport.zoomLevel < Math.trunc(-28.25 * 100) / 100) { - return true - } else { - return false - } - } - - function tooSmall () { - if (canvas.chartSpace.viewport.zoomLevel < Math.trunc(-27.25 * 100) / 100) { - return true - } else { - return false - } - } - function drawBackground () { if (thisObject.container.frame.isInViewPort()) { drawChartsBackground() diff --git a/ChartsSpace/ViewPort.js b/ChartsSpace/ViewPort.js index cf0e5430c..0d0f65e2c 100644 --- a/ChartsSpace/ViewPort.js +++ b/ChartsSpace/ViewPort.js @@ -1,17 +1,12 @@ function newViewport () { const MODULE_NAME = 'Viewport' - const INFO_LOG = false - const INTENSIVE_LOG = false - const ERROR_LOG = true - const logger = newWebDebugLog() - logger.fileName = MODULE_NAME - const CONSOLE_LOG = true - const MIN_ZOOM_LEVEL = -28.25 - const MAX_ZOOM_LEVEL = 1000 + const MIN_ZOOM_LEVEL = 1 + const MAX_ZOOM_LEVEL = 100 let ANIMATION_INCREMENT = 0.25 + let ANIMATION_STEPS = 5 let TOP_MARGIN = 40 + TOP_SPACE_HEIGHT let BOTTOM_MARGIN = 42 + COCKPIT_SPACE_HEIGHT @@ -34,10 +29,10 @@ function newViewport () { mousePosition: undefined, margins: MARGINS, payload: undefined, - newZoomLevel: newZoomLevel, - applyZoom: applyZoom, - zoomThisPoint: zoomThisPoint, - unzoomThisPoint: unzoomThisPoint, + changeZoom: changeZoom, + onMouseWheel: onMouseWheel, + transformThisPoint: transformThisPoint, + unTransformThisPoint: unTransformThisPoint, isThisPointVisible: isThisPointVisible, fitIntoVisibleArea: fitIntoVisibleArea, displace: displace, @@ -74,7 +69,6 @@ function newViewport () { return thisObject function finalize () { - logger = undefined thisObject.eventHandler.finalize() thisObject.payload = undefined thisObject = undefined @@ -83,6 +77,7 @@ function newViewport () { function initialize () { if (thisObject.payload !== undefined) { /* Read the position from the frame structure */ + let frame = { position: { x: 0, @@ -91,15 +86,15 @@ function newViewport () { } loadFrame(thisObject.payload, frame) if (!isNaN(frame.position.x)) { - position.x = frame.position.x + // position.x = frame.position.x } if (!isNaN(frame.position.y)) { - position.y = frame.position.y + // position.y = frame.position.y } } resize() - readObjectState() + // readObjectState() } function resize () { @@ -123,6 +118,11 @@ function newViewport () { thisObject.width = thisObject.visibleArea.topRight.x - thisObject.visibleArea.topLeft.x thisObject.height = thisObject.visibleArea.bottomRight.y - thisObject.visibleArea.topLeft.y + + thisObject.center = { + x: LEFT_MARGIN + thisObject.width / 2, + y: TOP_MARGIN + thisObject.height / 2 + } } function raiseEvents () { @@ -136,7 +136,7 @@ function newViewport () { function physics () { animationPhysics() positioningphysics() - readObjectState() + // readObjectState() } function positioningphysics () { @@ -175,57 +175,19 @@ function newViewport () { } } - function displace (displaceVector, recalculate) { - position.x = position.x + displaceVector.x - position.y = position.y + displaceVector.y - - saveObjectState() - - let event = { - newPosition: position, - recalculate: recalculate - } - - thisObject.eventHandler.raiseEvent('Position Changed', event) - - // console.log("displace produced new Position x = " + position.x + " y = " + position.y); - } - - function newZoomLevel (level) { - thisObject.zoomTargetLevel = level - thisObject.zoomLevel = level - - saveObjectState() - - ANIMATION_INCREMENT = Math.abs(thisObject.zoomTargetLevel - thisObject.zoomLevel) / 3 - - let event = { - newLevel: thisObject.zoomTargetLevel, - newPosition: position, - type: undefined - } - - thisObject.eventHandler.raiseEvent('Zoom Changed', event) - - return true - } - - function applyZoom (amount) { - // console.log("applyZoom amount: " + amount); - + function onMouseWheel (amount) { /* We adjust the sensitivity for Mac Users */ let isMac = navigator.platform.toUpperCase().indexOf('MAC') >= 0 if (isMac) { amount = amount / 5 } +/* if (amount > 0) { if (thisObject.zoomTargetLevel > -5) { amount = amount * 2 } - if (thisObject.zoomTargetLevel > 10) { amount = amount * 3 } - if (thisObject.zoomTargetLevel > 15) { amount = amount * 4 } @@ -235,35 +197,31 @@ function newViewport () { if (thisObject.zoomTargetLevel > -4) { amount = amount * 2 } - if (thisObject.zoomTargetLevel > 13) { amount = amount * 3 } - if (thisObject.zoomTargetLevel > 19) { amount = amount * 4 } } - if (thisObject.zoomTargetLevel + amount > MAX_ZOOM_LEVEL) { - return false - } - if (thisObject.zoomTargetLevel <= -27 && amount < 0) { amount = amount / 4 } - if (thisObject.zoomTargetLevel < -27 && amount > 0) { amount = amount / 4 } +*/ + if (thisObject.zoomTargetLevel + amount > MAX_ZOOM_LEVEL) { + return false + } if (thisObject.zoomTargetLevel + amount < MIN_ZOOM_LEVEL) { return false } - thisObject.zoomTargetLevel = thisObject.zoomTargetLevel + amount - ANIMATION_INCREMENT = Math.abs(thisObject.zoomTargetLevel - thisObject.zoomLevel) / 3 + ANIMATION_INCREMENT = Math.abs(thisObject.zoomTargetLevel - thisObject.zoomLevel) / ANIMATION_STEPS let event = { newLevel: thisObject.zoomTargetLevel, @@ -278,30 +236,9 @@ function newViewport () { } thisObject.eventHandler.raiseEvent('Zoom Changed', event) - return true } - function changeZoom (oldLevel, newLevel) { - let mouseNoZoom = unzoomThisPoint(thisObject.mousePosition, oldLevel) - let newMouse = zoomThisPoint(mouseNoZoom, newLevel) - - position.x = position.x - newMouse.x + thisObject.mousePosition.x - position.y = position.y - newMouse.y + thisObject.mousePosition.y - - saveObjectState() - - targetPosition.x = position.x - targetPosition.y = position.y - - positionIncrement = { - x: 0, - y: 0 - } - - thisObject.eventHandler.raiseEvent('Zoom Changed') - } - function fitIntoVisibleArea (point) { /* Here we check the boundaries of the resulting points, so they dont go out of the visible area. */ @@ -324,35 +261,74 @@ function newViewport () { return point } - function zoomThisPoint (point, level) { - let zoomFactor = increment // + increment * thisObject.zoomLevel / 100; + function displace (displaceVector, recalculate) { + position.x = position.x + displaceVector.x + position.y = position.y + displaceVector.y - if (level === undefined) { - point.x = point.x * (1 + zoomFactor * thisObject.zoomLevel) + position.x - point.y = point.y * (1 + zoomFactor * thisObject.zoomLevel) + position.y - } else { - point.x = point.x * (1 + zoomFactor * level) + position.x - point.y = point.y * (1 + zoomFactor * level) + position.y + saveObjectState() + + let event = { + newPosition: position, + recalculate: recalculate } - return point + thisObject.eventHandler.raiseEvent('Position Changed', event) + + // console.log("displace produced new Position x = " + position.x + " y = " + position.y); } - function unzoomThisPoint (pointWithZoom, level) { - let pointWithoutZoom - let zoomFactor = increment // + increment * thisObject.zoomLevel / 100; + function changeZoom (oldLevel, newLevel) { + let oldMouse = unTransformThisPoint(thisObject.mousePosition, oldLevel) + let newMouse = transformThisPoint(oldMouse, newLevel) + + position.x = position.x - newMouse.x + thisObject.mousePosition.x + position.y = position.y - newMouse.y + thisObject.mousePosition.y + + let testPoint = unTransformThisPoint(thisObject.mousePosition, newLevel) + + saveObjectState() + + targetPosition.x = position.x + targetPosition.y = position.y + + positionIncrement = { + x: 0, + y: 0 + } + + thisObject.eventHandler.raiseEvent('Zoom Changed') + } + + function transformThisPoint (point, level) { + let transformedPoint = { + x: 0, + y: 0 + } if (level === undefined) { - pointWithoutZoom = { - x: (pointWithZoom.x - position.x) / (1 + zoomFactor * thisObject.zoomLevel), - y: (pointWithZoom.y - position.y) / (1 + zoomFactor * thisObject.zoomLevel) - } + transformedPoint.x = point.x * (1 + thisObject.zoomLevel) + position.x + transformedPoint.y = point.y * (1 + thisObject.zoomLevel) + position.y } else { - pointWithoutZoom = { - x: (pointWithZoom.x - position.x) / (1 + zoomFactor * level), - y: (pointWithZoom.y - position.y) / (1 + zoomFactor * level) - } + transformedPoint.x = point.x * (1 + level) + position.x + transformedPoint.y = point.y * (1 + level) + position.y } + + return transformedPoint + } + + function unTransformThisPoint (point, level) { + let pointWithoutZoom = { + x: 0, + y: 0 + } + if (level === undefined) { + pointWithoutZoom.x = (point.x - position.x) / (1 + thisObject.zoomLevel) + pointWithoutZoom.y = (point.y - position.y) / (1 + thisObject.zoomLevel) + } else { + pointWithoutZoom.x = (point.x - position.x) / (1 + level) + pointWithoutZoom.y = (point.y - position.y) / (1 + level) + } + return pointWithoutZoom } @@ -374,7 +350,7 @@ function newViewport () { /* Save the zoom at the node config, so that the user can change it if he wishes to. */ try { let code = JSON.parse(thisObject.payload.node.code) - code.zoom = (thisObject.zoomLevel - MIN_ZOOM_LEVEL) / (MAX_ZOOM_LEVEL - MIN_ZOOM_LEVEL) * 100 + code.zoom = (thisObject.zoomTargetLevel - MIN_ZOOM_LEVEL) / (MAX_ZOOM_LEVEL - MIN_ZOOM_LEVEL) * 100 code.zoom = code.zoom.toFixed(2) thisObject.payload.node.code = JSON.stringify(code) } catch (err) { @@ -397,7 +373,7 @@ function newViewport () { if (code.zoom < MIN_ZOOM_LEVEL) { code.zoom = MIN_ZOOM_LEVEL } if (code.zoom > MAX_ZOOM_LEVEL) { code.zoom = MAX_ZOOM_LEVEL } - if (code.zoom !== thisObject.zoomLevel) { + if (code.zoom !== thisObject.zoomTargetLevel) { newZoomLevel(code.zoom) } else { saveObjectState() @@ -405,5 +381,20 @@ function newViewport () { } catch (err) { // we ignore errors here since most likely they will be parsing errors. } + + function newZoomLevel (level) { + thisObject.level = level + thisObject.zoomTargetLevel = level + saveObjectState() + ANIMATION_INCREMENT = 0 + + let event = { + newLevel: thisObject.zoomTargetLevel, + newPosition: position, + type: undefined + } + thisObject.eventHandler.raiseEvent('Zoom Changed', event) + return true + } } } diff --git a/Globals.js b/Globals.js index de949a28c..9e3c41edb 100644 --- a/Globals.js +++ b/Globals.js @@ -188,8 +188,8 @@ const PERIOD_01_MIN = "01-min"; We define here the size of the chartSpace. It has to bee enough big in order to accomodate all the charts we expect to display in this space. */ -const TIME_MACHINE_WIDTH = browserCanvas.width * 1000; -const TIME_MACHINE_HEIGHT = browserCanvas.height * 100; +const TIME_MACHINE_WIDTH = 500; +const TIME_MACHINE_HEIGHT = 100; function toRadians(angle) { return angle * (Math.PI / 180); diff --git a/Scales/RateScale.js b/Scales/RateScale.js index f1f49481b..934a70714 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -16,10 +16,10 @@ function newRateScale () { finalize: finalize } - const DEFAULT_VALUE = 50 - const STEP_SIZE = 2 + const DEFAULT_VALUE = 1 + const STEP_SIZE = 1 const MIN_WIDTH = 50 - const MAX_VALUE = 150 + const MAX_VALUE = 100 thisObject.container = newContainer() thisObject.container.initialize(MODULE_NAME) @@ -148,6 +148,7 @@ function newRateScale () { } function readObjectState () { + return try { let code = JSON.parse(thisObject.payload.node.code) diff --git a/Scales/TimeFrameScale.js b/Scales/TimeFrameScale.js index fb09442fc..ae8523fb5 100644 --- a/Scales/TimeFrameScale.js +++ b/Scales/TimeFrameScale.js @@ -180,7 +180,7 @@ function newTimeFrameScale () { function onViewportZoomChanged (event) { if (event !== undefined) { // it is undefined when the level is just being animated. let currentTimeFrame = thisObject.timeFrame - let timeFrame = recalculatePeriod(event.newLevel) + let timeFrame = currentTimeFrame // recalculatePeriod(event.newLevel) if (timeFrame !== currentTimeFrame) { for (let i = 0; i < timeFramesMasterArray.length; i++) { let timeFrameArray = timeFramesMasterArray[i] @@ -245,6 +245,7 @@ function newTimeFrameScale () { } function readObjectState () { + return try { let code = JSON.parse(thisObject.payload.node.code) if (code.value !== timeFrameLabel) { diff --git a/Scales/TimeScale.js b/Scales/TimeScale.js index f22047e79..f9f9cc71f 100644 --- a/Scales/TimeScale.js +++ b/Scales/TimeScale.js @@ -16,8 +16,9 @@ function newTimeScale () { finalize: finalize } - const DEFAULT_VALUE = 5 - const STEP_SIZE = 2.5 + const DEFAULT_VALUE = 1 + const STEP_SIZE = 1 + const MIN_VALUE = 1 const MAX_VALUE = 400 thisObject.container = newContainer() @@ -117,7 +118,7 @@ function newTimeScale () { delta = event.wheelDelta if (delta < 0) { thisObject.value = thisObject.value - STEP_SIZE * morePower - if (thisObject.value < STEP_SIZE) { thisObject.value = STEP_SIZE } + if (thisObject.value < MIN_VALUE) { thisObject.value = STEP_SIZE } } else { thisObject.value = thisObject.value + STEP_SIZE * morePower if (thisObject.value > MAX_VALUE) { thisObject.value = MAX_VALUE } @@ -148,6 +149,7 @@ function newTimeScale () { } function readObjectState () { + return try { let code = JSON.parse(thisObject.payload.node.code) @@ -156,7 +158,7 @@ function newTimeScale () { return } code.value = code.value / 100 * MAX_VALUE - if (code.value < STEP_SIZE) { code.value = STEP_SIZE } + if (code.value < MIN_VALUE) { code.value = STEP_SIZE } if (code.value > MAX_VALUE) { code.value = MAX_VALUE } if (code.value !== thisObject.value) { diff --git a/Spaces/ChartSpace.js b/Spaces/ChartSpace.js index 538bb912c..25d105712 100644 --- a/Spaces/ChartSpace.js +++ b/Spaces/ChartSpace.js @@ -151,7 +151,7 @@ function newChartSpace () { function oneScreenUp () { let displaceVector = { x: 0, - y: +browserCanvas.height * PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT / 100 + y: browserCanvas.height * PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT / 100 } canvas.chartSpace.viewport.displace(displaceVector) @@ -290,8 +290,8 @@ function newChartSpace () { timeMachine.payload.uiObject.setValue('Loading...') /* Setting up the new time machine. */ - timeMachine.container.frame.position.x = thisObject.container.frame.width / 2 - timeMachine.container.frame.width / 2 - timeMachine.container.frame.position.y = thisObject.container.frame.height / 2 - timeMachine.container.frame.height / 2 + timeMachine.container.frame.position.x = browserCanvas.width / 2 - TIME_MACHINE_WIDTH / 2 + timeMachine.container.frame.position.y = browserCanvas.height / 2 - TIME_MACHINE_HEIGHT / 2 timeMachine.initialize(onTimeMachineInitialized) function onTimeMachineInitialized (err) { diff --git a/Utilities.js b/Utilities.js index b192039b3..5ec3e13b4 100644 --- a/Utilities.js +++ b/Utilities.js @@ -57,13 +57,13 @@ function transformThisPoint (point, container) { /* We pass this point through the canvas.chartSpace.viewport lends, meaning we apply the canvas.chartSpace.viewport zoom and displacement. */ - point = canvas.chartSpace.viewport.zoomThisPoint(point) + point = canvas.chartSpace.viewport.transformThisPoint(point) return point } function unTransformThisPoint (point, container) { - point = canvas.chartSpace.viewport.unzoomThisPoint(point) + point = canvas.chartSpace.viewport.unTransformThisPoint(point) point = container.frame.unframeThisPoint(point) return point @@ -146,13 +146,9 @@ function getUserPosition (timeLineCoordinateSystem) { return userPosition } -function moveToUserPosition (container, timeLineCoordinateSystem, ignoreX, ignoreY, center, considerZoom, moveContainer) { +function moveToUserPosition (container, timeLineCoordinateSystem, ignoreX, ignoreY, center, moveContainer) { let userPosition = getUserPosition(timeLineCoordinateSystem) - if (considerZoom === true) { - canvas.chartSpace.viewport.newZoomLevel(userPosition.zoom) - } - INITIAL_TIME_PERIOD = recalculatePeriod(userPosition.zoom) NEW_SESSION_INITIAL_DATE = new Date(userPosition.date) @@ -190,7 +186,7 @@ function moveToUserPosition (container, timeLineCoordinateSystem, ignoreX, ignor } let targetNoZoom - targetNoZoom = canvas.chartSpace.viewport.unzoomThisPoint(targetCopy) + targetNoZoom = canvas.chartSpace.viewport.unTransformThisPoint(targetCopy) let centerCopy = { x: centerPoint.x, @@ -198,7 +194,7 @@ function moveToUserPosition (container, timeLineCoordinateSystem, ignoreX, ignor } let centerNoZoom - centerNoZoom = canvas.chartSpace.viewport.unzoomThisPoint(centerCopy) + centerNoZoom = canvas.chartSpace.viewport.unTransformThisPoint(centerCopy) displaceVector = { x: centerNoZoom.x - targetNoZoom.x, From 60e78f7b63cb5372bf34bbdb3e930e5717049517 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 18 Jan 2020 23:28:24 +0100 Subject: [PATCH 161/264] Min Zoom Level set --- ChartsSpace/ViewPort.js | 3 ++- Globals.js | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ChartsSpace/ViewPort.js b/ChartsSpace/ViewPort.js index 0d0f65e2c..55250512e 100644 --- a/ChartsSpace/ViewPort.js +++ b/ChartsSpace/ViewPort.js @@ -2,7 +2,7 @@ function newViewport () { const MODULE_NAME = 'Viewport' - const MIN_ZOOM_LEVEL = 1 + const MIN_ZOOM_LEVEL = 0 const MAX_ZOOM_LEVEL = 100 let ANIMATION_INCREMENT = 0.25 @@ -134,6 +134,7 @@ function newViewport () { } function physics () { + console.log(position, thisObject.zoomLevel) animationPhysics() positioningphysics() // readObjectState() diff --git a/Globals.js b/Globals.js index 9e3c41edb..e8fed4264 100644 --- a/Globals.js +++ b/Globals.js @@ -188,8 +188,8 @@ const PERIOD_01_MIN = "01-min"; We define here the size of the chartSpace. It has to bee enough big in order to accomodate all the charts we expect to display in this space. */ -const TIME_MACHINE_WIDTH = 500; -const TIME_MACHINE_HEIGHT = 100; +const TIME_MACHINE_WIDTH = 1000; +const TIME_MACHINE_HEIGHT = 200; function toRadians(angle) { return angle * (Math.PI / 180); From b570f87e0ddc4827678312d8ec5bae9e57124d99 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 19 Jan 2020 00:05:15 +0100 Subject: [PATCH 162/264] zoom, kind of tunned --- ChartsSpace/ChartUtilities.js | 36 ++++++++++++++--------------- ChartsSpace/ViewPort.js | 43 ++++++++--------------------------- Globals.js | 2 +- Scales/TimeFrameScale.js | 2 +- 4 files changed, 30 insertions(+), 53 deletions(-) diff --git a/ChartsSpace/ChartUtilities.js b/ChartsSpace/ChartUtilities.js index e3ddf4cd7..369974660 100644 --- a/ChartsSpace/ChartUtilities.js +++ b/ChartsSpace/ChartUtilities.js @@ -64,75 +64,75 @@ function getTransparenceFactor (timeFrame) { function recalculatePeriod (zoomLevel) { // console.log(" recalculatePeriod > " + zoomLevel); - if (zoomLevel > 90) { + if (zoomLevel > 400) { return _1_MINUTE_IN_MILISECONDS } - if (zoomLevel > 85) { + if (zoomLevel > 360) { return _2_MINUTES_IN_MILISECONDS } - if (zoomLevel > 80) { + if (zoomLevel > 330) { return _3_MINUTES_IN_MILISECONDS } - if (zoomLevel > 75) { + if (zoomLevel > 300) { return _4_MINUTES_IN_MILISECONDS } - if (zoomLevel > 70) { + if (zoomLevel > 270) { return _5_MINUTES_IN_MILISECONDS } - if (zoomLevel > 65) { + if (zoomLevel > 250) { return _10_MINUTES_IN_MILISECONDS } - if (zoomLevel > 60) { + if (zoomLevel > 230) { return _15_MINUTES_IN_MILISECONDS } - if (zoomLevel > 55) { + if (zoomLevel > 210) { return _20_MINUTES_IN_MILISECONDS } - if (zoomLevel > 50) { + if (zoomLevel > 190) { return _30_MINUTES_IN_MILISECONDS } - if (zoomLevel > 45) { + if (zoomLevel > 170) { return _40_MINUTES_IN_MILISECONDS } - if (zoomLevel > 50) { + if (zoomLevel > 150) { return _45_MINUTES_IN_MILISECONDS } - if (zoomLevel > 35) { + if (zoomLevel > 130) { return _1_HOUR_IN_MILISECONDS } - if (zoomLevel > 30) { + if (zoomLevel > 110) { return _2_HOURS_IN_MILISECONDS } - if (zoomLevel > 25) { + if (zoomLevel > 90) { return _3_HOURS_IN_MILISECONDS } - if (zoomLevel > 20) { + if (zoomLevel > 70) { return _4_HOURS_IN_MILISECONDS } - if (zoomLevel > 15) { + if (zoomLevel > 50) { return _6_HOURS_IN_MILISECONDS } - if (zoomLevel > 10) { + if (zoomLevel > 30) { return _8_HOURS_IN_MILISECONDS } - if (zoomLevel > 5) { + if (zoomLevel > 15) { return _12_HOURS_IN_MILISECONDS } diff --git a/ChartsSpace/ViewPort.js b/ChartsSpace/ViewPort.js index 55250512e..13380cc79 100644 --- a/ChartsSpace/ViewPort.js +++ b/ChartsSpace/ViewPort.js @@ -3,7 +3,7 @@ function newViewport () { const MODULE_NAME = 'Viewport' const MIN_ZOOM_LEVEL = 0 - const MAX_ZOOM_LEVEL = 100 + const MAX_ZOOM_LEVEL = 500 let ANIMATION_INCREMENT = 0.25 let ANIMATION_STEPS = 5 @@ -134,7 +134,6 @@ function newViewport () { } function physics () { - console.log(position, thisObject.zoomLevel) animationPhysics() positioningphysics() // readObjectState() @@ -181,39 +180,17 @@ function newViewport () { let isMac = navigator.platform.toUpperCase().indexOf('MAC') >= 0 if (isMac) { amount = amount / 5 } -/* - if (amount > 0) { - if (thisObject.zoomTargetLevel > -5) { - amount = amount * 2 - } - if (thisObject.zoomTargetLevel > 10) { - amount = amount * 3 - } - if (thisObject.zoomTargetLevel > 15) { - amount = amount * 4 - } + if (thisObject.zoomTargetLevel > 10) { + amount = amount * 2 + } + if (thisObject.zoomTargetLevel > 25) { + amount = amount * 3 + } + if (thisObject.zoomTargetLevel > 50) { + amount = amount * 3.5 } - if (amount < 0) { - if (thisObject.zoomTargetLevel > -4) { - amount = amount * 2 - } - if (thisObject.zoomTargetLevel > 13) { - amount = amount * 3 - } - if (thisObject.zoomTargetLevel > 19) { - amount = amount * 4 - } - } - - if (thisObject.zoomTargetLevel <= -27 && amount < 0) { - amount = amount / 4 - } - if (thisObject.zoomTargetLevel < -27 && amount > 0) { - amount = amount / 4 - } - -*/ + console.log(thisObject.zoomLevel, amount) if (thisObject.zoomTargetLevel + amount > MAX_ZOOM_LEVEL) { return false } diff --git a/Globals.js b/Globals.js index e8fed4264..06fdd3706 100644 --- a/Globals.js +++ b/Globals.js @@ -189,7 +189,7 @@ We define here the size of the chartSpace. It has to bee enough big in order to */ const TIME_MACHINE_WIDTH = 1000; -const TIME_MACHINE_HEIGHT = 200; +const TIME_MACHINE_HEIGHT = 50; function toRadians(angle) { return angle * (Math.PI / 180); diff --git a/Scales/TimeFrameScale.js b/Scales/TimeFrameScale.js index ae8523fb5..1e3dd51cc 100644 --- a/Scales/TimeFrameScale.js +++ b/Scales/TimeFrameScale.js @@ -180,7 +180,7 @@ function newTimeFrameScale () { function onViewportZoomChanged (event) { if (event !== undefined) { // it is undefined when the level is just being animated. let currentTimeFrame = thisObject.timeFrame - let timeFrame = currentTimeFrame // recalculatePeriod(event.newLevel) + let timeFrame = recalculatePeriod(event.newLevel) if (timeFrame !== currentTimeFrame) { for (let i = 0; i < timeFramesMasterArray.length; i++) { let timeFrameArray = timeFramesMasterArray[i] From 40b3bafcfceaf2815305c43e62dcf3d6219d9b8a Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 19 Jan 2020 09:09:35 +0100 Subject: [PATCH 163/264] morep power at viewport wheel --- Canvas.js | 4 ++-- ChartsSpace/ViewPort.js | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Canvas.js b/Canvas.js index 450b94ee7..a37e2f31e 100644 --- a/Canvas.js +++ b/Canvas.js @@ -768,7 +768,7 @@ function newCanvas () { try { // cross-browser wheel delta var event = window.event || event // old IE support - let delta = Math.max(-1, Math.min(1, event.wheelDelta || -event.detail)) + event.delta = Math.max(-1, Math.min(1, event.wheelDelta || -event.detail)) /* We try first with panels. */ @@ -804,7 +804,7 @@ function newCanvas () { } if (container !== undefined) { - canvas.chartSpace.viewport.onMouseWheel(delta) + canvas.chartSpace.viewport.onMouseWheel(event) return false } diff --git a/ChartsSpace/ViewPort.js b/ChartsSpace/ViewPort.js index 13380cc79..b082bec4f 100644 --- a/ChartsSpace/ViewPort.js +++ b/ChartsSpace/ViewPort.js @@ -175,7 +175,10 @@ function newViewport () { } } - function onMouseWheel (amount) { + function onMouseWheel (event) { + let morePower = 1 + let amount = event.delta + if (event.buttons === 4) { morePower = 2 } // Mouse wheel pressed. /* We adjust the sensitivity for Mac Users */ let isMac = navigator.platform.toUpperCase().indexOf('MAC') >= 0 if (isMac) { amount = amount / 5 } @@ -191,29 +194,29 @@ function newViewport () { } console.log(thisObject.zoomLevel, amount) - if (thisObject.zoomTargetLevel + amount > MAX_ZOOM_LEVEL) { + if (thisObject.zoomTargetLevel + amount * morePower > MAX_ZOOM_LEVEL) { return false } - if (thisObject.zoomTargetLevel + amount < MIN_ZOOM_LEVEL) { + if (thisObject.zoomTargetLevel + amount * morePower < MIN_ZOOM_LEVEL) { return false } - thisObject.zoomTargetLevel = thisObject.zoomTargetLevel + amount + thisObject.zoomTargetLevel = thisObject.zoomTargetLevel + amount * morePower ANIMATION_INCREMENT = Math.abs(thisObject.zoomTargetLevel - thisObject.zoomLevel) / ANIMATION_STEPS - let event = { + let newEvent = { newLevel: thisObject.zoomTargetLevel, newPosition: position, type: undefined } if (amount > 0) { - event.type = 'Zoom In' + newEvent.type = 'Zoom In' } else { - event.type = 'Zoom Out' + newEvent.type = 'Zoom Out' } - thisObject.eventHandler.raiseEvent('Zoom Changed', event) + thisObject.eventHandler.raiseEvent('Zoom Changed', newEvent) return true } From d6edd6898409661e085f22c274098780b46bf6b1 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 19 Jan 2020 09:32:55 +0100 Subject: [PATCH 164/264] Viewport saving --- ChartsSpace/ViewPort.js | 8 ++++---- Globals.js | 4 ++-- Scales/RateScale.js | 2 +- Scales/TimeFrameScale.js | 1 - 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/ChartsSpace/ViewPort.js b/ChartsSpace/ViewPort.js index b082bec4f..fe7199a23 100644 --- a/ChartsSpace/ViewPort.js +++ b/ChartsSpace/ViewPort.js @@ -86,15 +86,15 @@ function newViewport () { } loadFrame(thisObject.payload, frame) if (!isNaN(frame.position.x)) { - // position.x = frame.position.x + position.x = frame.position.x } if (!isNaN(frame.position.y)) { - // position.y = frame.position.y + position.y = frame.position.y } } resize() - // readObjectState() + readObjectState() } function resize () { @@ -136,7 +136,7 @@ function newViewport () { function physics () { animationPhysics() positioningphysics() - // readObjectState() + readObjectState() } function positioningphysics () { diff --git a/Globals.js b/Globals.js index 06fdd3706..66c535e1e 100644 --- a/Globals.js +++ b/Globals.js @@ -188,8 +188,8 @@ const PERIOD_01_MIN = "01-min"; We define here the size of the chartSpace. It has to bee enough big in order to accomodate all the charts we expect to display in this space. */ -const TIME_MACHINE_WIDTH = 1000; -const TIME_MACHINE_HEIGHT = 50; +const TIME_MACHINE_WIDTH = 2000; +const TIME_MACHINE_HEIGHT = 200 / 25; function toRadians(angle) { return angle * (Math.PI / 180); diff --git a/Scales/RateScale.js b/Scales/RateScale.js index 934a70714..0c79ee8a3 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -16,7 +16,7 @@ function newRateScale () { finalize: finalize } - const DEFAULT_VALUE = 1 + const DEFAULT_VALUE = 25 const STEP_SIZE = 1 const MIN_WIDTH = 50 const MAX_VALUE = 100 diff --git a/Scales/TimeFrameScale.js b/Scales/TimeFrameScale.js index 1e3dd51cc..fb09442fc 100644 --- a/Scales/TimeFrameScale.js +++ b/Scales/TimeFrameScale.js @@ -245,7 +245,6 @@ function newTimeFrameScale () { } function readObjectState () { - return try { let code = JSON.parse(thisObject.payload.node.code) if (code.value !== timeFrameLabel) { From 9f354e6c3cbde753342053368ca449bf19f13179 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 19 Jan 2020 09:53:54 +0100 Subject: [PATCH 165/264] Bug Fixed --- ChartsSpace/TimeMachine.js | 2 +- ChartsSpace/ViewPort.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 186bbe0bf..9050e0e80 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -132,7 +132,7 @@ function newTimeMachine () { function initialize (callBackFunction) { timeFrame = INITIAL_TIME_PERIOD - // loadFrame(thisObject.payload, thisObject.container.frame) + loadFrame(thisObject.payload, thisObject.container.frame) recalculateCoordinateSystem() diff --git a/ChartsSpace/ViewPort.js b/ChartsSpace/ViewPort.js index fe7199a23..8fd9dbc9c 100644 --- a/ChartsSpace/ViewPort.js +++ b/ChartsSpace/ViewPort.js @@ -364,8 +364,9 @@ function newViewport () { } function newZoomLevel (level) { - thisObject.level = level + thisObject.zoomLevel = level thisObject.zoomTargetLevel = level + INITIAL_TIME_PERIOD = recalculatePeriod(level) saveObjectState() ANIMATION_INCREMENT = 0 From 971a5acccdcc9c8422b0a65aa84e99b35a29c995 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 19 Jan 2020 10:05:14 +0100 Subject: [PATCH 166/264] Bug fixed --- ChartsSpace/TimelineChart.js | 4 ++-- Scales/RateScale.js | 1 - Scales/TimeScale.js | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index b4c073f61..e0eec99f7 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -122,8 +122,8 @@ function newTimelineChart () { thisObject.rateScale = undefined /* Resets the local container with the dimessions of its parent, the Time Machine */ - thisObject.container.frame.position.position.x = 0 - thisObject.container.frame.position.position.y = 0 + thisObject.container.frame.position.x = 0 + thisObject.container.frame.position.y = 0 thisObject.container.frame.height = TIME_MACHINE_HEIGHT thisObject.container.frame.width = TIME_MACHINE_WIDTH } diff --git a/Scales/RateScale.js b/Scales/RateScale.js index 0c79ee8a3..685f6f2f5 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -148,7 +148,6 @@ function newRateScale () { } function readObjectState () { - return try { let code = JSON.parse(thisObject.payload.node.code) diff --git a/Scales/TimeScale.js b/Scales/TimeScale.js index f9f9cc71f..fe078815f 100644 --- a/Scales/TimeScale.js +++ b/Scales/TimeScale.js @@ -149,7 +149,6 @@ function newTimeScale () { } function readObjectState () { - return try { let code = JSON.parse(thisObject.payload.node.code) From ebd1413457b854f1928dd6ad1ff8d3c56ea83f98 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 19 Jan 2020 10:44:17 +0100 Subject: [PATCH 167/264] Very ugly bug fixed related to decimals comparison --- ChartsSpace/ViewPort.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/ChartsSpace/ViewPort.js b/ChartsSpace/ViewPort.js index 8fd9dbc9c..ef25bfd50 100644 --- a/ChartsSpace/ViewPort.js +++ b/ChartsSpace/ViewPort.js @@ -167,8 +167,6 @@ function newViewport () { if (positionIncrement.y !== 0) { if (Math.trunc(Math.abs(targetPosition.y - position.y) * 1000) >= Math.trunc(Math.abs(positionIncrement.y) * 1000)) { position.y = position.y + positionIncrement.y - - // console.log("position.y changed to " + position.y) } else { positionIncrement.y = 0 } @@ -193,7 +191,6 @@ function newViewport () { amount = amount * 3.5 } - console.log(thisObject.zoomLevel, amount) if (thisObject.zoomTargetLevel + amount * morePower > MAX_ZOOM_LEVEL) { return false } @@ -254,8 +251,6 @@ function newViewport () { } thisObject.eventHandler.raiseEvent('Position Changed', event) - - // console.log("displace produced new Position x = " + position.x + " y = " + position.y); } function changeZoom (oldLevel, newLevel) { @@ -354,7 +349,7 @@ function newViewport () { if (code.zoom < MIN_ZOOM_LEVEL) { code.zoom = MIN_ZOOM_LEVEL } if (code.zoom > MAX_ZOOM_LEVEL) { code.zoom = MAX_ZOOM_LEVEL } - if (code.zoom !== thisObject.zoomTargetLevel) { + if (code.zoom.toFixed(2) !== thisObject.zoomTargetLevel.toFixed(2)) { newZoomLevel(code.zoom) } else { saveObjectState() @@ -366,7 +361,7 @@ function newViewport () { function newZoomLevel (level) { thisObject.zoomLevel = level thisObject.zoomTargetLevel = level - INITIAL_TIME_PERIOD = recalculatePeriod(level) + // INITIAL_TIME_PERIOD = recalculatePeriod(level) saveObjectState() ANIMATION_INCREMENT = 0 From 0c8d7a1e97e980660addb328863fb9fc4cd2cad2 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 19 Jan 2020 11:15:24 +0100 Subject: [PATCH 168/264] fine tuning --- Panels/Layer.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Panels/Layer.js b/Panels/Layer.js index e9ebed439..537a6ac99 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -358,7 +358,7 @@ function newLayer () { let point1 let point2 - let horizontalMargin = 32 + let horizontalMargin = 12 if (progressBar.value === 0) { return @@ -474,10 +474,10 @@ function newLayer () { drawLabel(label2, 1 / 2, 8.2 / 10, -5, 0, 9, thisObject.container) drawLabel(label3, 1 / 2, 9.5 / 10, -5, 0, 9, thisObject.container) - drawProgressBar(marketFileProgressBar, 1, -55) - drawProgressBar(dailyFileProgressBar, 1, -56) - drawProgressBar(singleFileProgressBar, 1, -57) - drawProgressBar(fileSequenceProgressBar, 1, -58) + drawProgressBar(marketFileProgressBar, 1, -45) + drawProgressBar(dailyFileProgressBar, 1, -46) + drawProgressBar(singleFileProgressBar, 1, -47) + drawProgressBar(fileSequenceProgressBar, 1, -48) drawIcon(icon1, 1 / 8, 2 / 10, 0, 0, 14, thisObject.container) drawIcon(icon2, 7 / 8, 2 / 10, 0, 0, 14, thisObject.container) @@ -485,3 +485,4 @@ function newLayer () { drawIcon(icon4, 4.6 / 8, 2 / 10, 0, 0, 14, thisObject.container) } } + From df785830d0d09abf88d6575e89d3cdeb90dfe888 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 19 Jan 2020 12:06:18 +0100 Subject: [PATCH 169/264] Nasty Bug preventing daily files to be plotted --- ChartsSpace/ChartUtilities.js | 13 ++++++------- ChartsSpace/TimelineChart.js | 3 +-- ChartsSpace/ViewPort.js | 2 +- Scales/TimeFrameScale.js | 2 +- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/ChartsSpace/ChartUtilities.js b/ChartsSpace/ChartUtilities.js index 369974660..4139c96e1 100644 --- a/ChartsSpace/ChartUtilities.js +++ b/ChartsSpace/ChartUtilities.js @@ -62,8 +62,7 @@ function getTransparenceFactor (timeFrame) { } function recalculatePeriod (zoomLevel) { - // console.log(" recalculatePeriod > " + zoomLevel); - + console.log('NEW ZOOM LEVEL', zoomLevel) if (zoomLevel > 400) { return _1_MINUTE_IN_MILISECONDS } @@ -116,23 +115,23 @@ function recalculatePeriod (zoomLevel) { return _2_HOURS_IN_MILISECONDS } - if (zoomLevel > 90) { + if (zoomLevel > 80) { return _3_HOURS_IN_MILISECONDS } - if (zoomLevel > 70) { + if (zoomLevel > 50) { return _4_HOURS_IN_MILISECONDS } - if (zoomLevel > 50) { + if (zoomLevel > 35) { return _6_HOURS_IN_MILISECONDS } - if (zoomLevel > 30) { + if (zoomLevel > 20) { return _8_HOURS_IN_MILISECONDS } - if (zoomLevel > 15) { + if (zoomLevel > 10) { return _12_HOURS_IN_MILISECONDS } diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index e0eec99f7..e46f04557 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -283,8 +283,7 @@ function newTimelineChart () { center = timelineChartCoordinateSystem.unInverseTransform(center, thisObject.container.frame.height) } - let newDate = new Date(0) - newDate.setUTCSeconds(center.x) + let newDate = new Date(center.x) datetime = newDate diff --git a/ChartsSpace/ViewPort.js b/ChartsSpace/ViewPort.js index ef25bfd50..7a66442cf 100644 --- a/ChartsSpace/ViewPort.js +++ b/ChartsSpace/ViewPort.js @@ -361,7 +361,7 @@ function newViewport () { function newZoomLevel (level) { thisObject.zoomLevel = level thisObject.zoomTargetLevel = level - // INITIAL_TIME_PERIOD = recalculatePeriod(level) + INITIAL_TIME_PERIOD = recalculatePeriod(level) saveObjectState() ANIMATION_INCREMENT = 0 diff --git a/Scales/TimeFrameScale.js b/Scales/TimeFrameScale.js index fb09442fc..1a2b08412 100644 --- a/Scales/TimeFrameScale.js +++ b/Scales/TimeFrameScale.js @@ -275,7 +275,7 @@ function newTimeFrameScale () { let timeFrameArray = timeFramesMasterArray[filePeriodIndex] thisObject.timeFrame = timeFrameArray[timeFrameIndex][0] timeFrameLabel = timeFrameArray[timeFrameIndex][1] - + console.log('NEW TIME FRAME LABEL', timeFrameLabel) let event = {} event.timeFrame = thisObject.timeFrame thisObject.container.eventHandler.raiseEvent('Time Frame Changed', event) From 5349d453a05d4856264a5d361fa287f9b8e53390 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 19 Jan 2020 12:34:52 +0100 Subject: [PATCH 170/264] cleaning logs --- ChartsSpace/ChartUtilities.js | 2 +- Scales/TimeFrameScale.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ChartsSpace/ChartUtilities.js b/ChartsSpace/ChartUtilities.js index 4139c96e1..cdc205ec2 100644 --- a/ChartsSpace/ChartUtilities.js +++ b/ChartsSpace/ChartUtilities.js @@ -62,7 +62,7 @@ function getTransparenceFactor (timeFrame) { } function recalculatePeriod (zoomLevel) { - console.log('NEW ZOOM LEVEL', zoomLevel) + // console.log('NEW ZOOM LEVEL', zoomLevel) if (zoomLevel > 400) { return _1_MINUTE_IN_MILISECONDS } diff --git a/Scales/TimeFrameScale.js b/Scales/TimeFrameScale.js index 1a2b08412..2f5c1984e 100644 --- a/Scales/TimeFrameScale.js +++ b/Scales/TimeFrameScale.js @@ -275,7 +275,7 @@ function newTimeFrameScale () { let timeFrameArray = timeFramesMasterArray[filePeriodIndex] thisObject.timeFrame = timeFrameArray[timeFrameIndex][0] timeFrameLabel = timeFrameArray[timeFrameIndex][1] - console.log('NEW TIME FRAME LABEL', timeFrameLabel) + // console.log('NEW TIME FRAME LABEL', timeFrameLabel) let event = {} event.timeFrame = thisObject.timeFrame thisObject.container.eventHandler.raiseEvent('Time Frame Changed', event) From e4b10bdff53fed85be1ca9555198779a46e52aa3 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 19 Jan 2020 15:55:28 +0100 Subject: [PATCH 171/264] rate scale offset implemented --- ChartsSpace/TimeMachine.js | 47 ++++++++++---------- ChartsSpace/TimelineChart.js | 38 +++++++++------- Container.js | 2 + Frame.js | 25 ++++++++--- Scales/RateScale.js | 85 ++++++++++++++++++++++++++++-------- Scales/TimeFrameScale.js | 2 +- Scales/TimeScale.js | 16 +++---- 7 files changed, 142 insertions(+), 73 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 9050e0e80..124db9076 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -47,9 +47,9 @@ function newTimeMachine () { let onMouseOverEventSuscriptionId let onMouseNotOverEventSuscriptionId - let timeScaleEventSuscriptionId + let timeScaleValueEventSuscriptionId let timeScaleMouseOverEventSuscriptionId - let rateScaleEventSuscriptionId + let rateScaleValueEventSuscriptionId let rateScaleMouseOverEventSuscriptionId let timeFrameScaleEventSuscriptionId let timeFrameScaleMouseOverEventSuscriptionId @@ -106,7 +106,7 @@ function newTimeMachine () { function finalizeTimeScale () { if (thisObject.timeScale === undefined) { return } - thisObject.timeScale.container.eventHandler.stopListening(timeScaleEventSuscriptionId) + thisObject.timeScale.container.eventHandler.stopListening(timeScaleValueEventSuscriptionId) thisObject.timeScale.container.eventHandler.stopListening(timeScaleMouseOverEventSuscriptionId) thisObject.timeScale.finalize() thisObject.timeScale = undefined @@ -115,7 +115,7 @@ function newTimeMachine () { function finalizeRateScale () { if (thisObject.rateScale === undefined) { return } - thisObject.rateScale.container.eventHandler.stopListening(rateScaleEventSuscriptionId) + thisObject.rateScale.container.eventHandler.stopListening(rateScaleValueEventSuscriptionId) thisObject.rateScale.container.eventHandler.stopListening(rateScaleMouseOverEventSuscriptionId) thisObject.rateScale.finalize() thisObject.rateScale = undefined @@ -179,19 +179,18 @@ function newTimeMachine () { thisObject.timeScale.fitFunction = thisObject.fitFunction thisObject.timeScale.payload = thisObject.payload.node.timeScale.payload - timeScaleEventSuscriptionId = thisObject.timeScale.container.eventHandler.listenToEvent('Lenght Percentage Changed', function (event) { + timeScaleValueEventSuscriptionId = thisObject.timeScale.container.eventHandler.listenToEvent('Time Scale Value Changed', timeScaleValueChanged) + timeScaleMouseOverEventSuscriptionId = thisObject.timeScale.container.eventHandler.listenToEvent('onMouseOverScale', timeScaleMouseOver) + thisObject.timeScale.initialize(timeMachineCoordinateSystem, thisObject.container) + + function timeScaleValueChanged (event) { thisObject.container.frame.width = TIME_MACHINE_WIDTH * event.value recalculateCoordinateSystem() if (event.isUserAction === true) { moveToUserPosition(thisObject.container, timeMachineCoordinateSystem, false, true, event.mousePosition, true) } thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) - }) - - thisObject.timeScale.initialize(timeMachineCoordinateSystem, thisObject.container) - - timeScaleMouseOverEventSuscriptionId = thisObject.timeScale.container.eventHandler.listenToEvent('onMouseOverScale', timeScaleMouseOver) - + } function timeScaleMouseOver (event) { thisObject.container.eventHandler.raiseEvent('onMouseOver', event) } @@ -202,19 +201,18 @@ function newTimeMachine () { thisObject.rateScale.fitFunction = thisObject.fitFunction thisObject.rateScale.payload = thisObject.payload.node.rateScale.payload - rateScaleEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('Height Percentage Changed', function (event) { + rateScaleValueEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('Rate Scale Value Changed', rateScaleValueChanged) + rateScaleMouseOverEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('onMouseOverScale', rateScaleMouseOver) + thisObject.rateScale.initialize(timeMachineCoordinateSystem, thisObject.container) + + function rateScaleValueChanged (event) { thisObject.container.frame.height = TIME_MACHINE_HEIGHT * event.value recalculateCoordinateSystem() if (event.isUserAction === true) { moveToUserPosition(thisObject.container, timeMachineCoordinateSystem, true, false, event.mousePosition, true) } thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) - }) - - thisObject.rateScale.initialize(timeMachineCoordinateSystem, thisObject.container) - - rateScaleMouseOverEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('onMouseOverScale', rateScaleMouseOver) - + } function rateScaleMouseOver (event) { thisObject.container.eventHandler.raiseEvent('onMouseOver', event) } @@ -225,7 +223,11 @@ function newTimeMachine () { thisObject.timeFrameScale.fitFunction = thisObject.fitFunction thisObject.timeFrameScale.payload = thisObject.payload.node.timeFrameScale.payload - timeFrameScaleEventSuscriptionId = thisObject.timeFrameScale.container.eventHandler.listenToEvent('Time Frame Changed', function (event) { + timeFrameScaleEventSuscriptionId = thisObject.timeFrameScale.container.eventHandler.listenToEvent('Time Frame Value Changed', timeFrameScaleValueChanged) + timeFrameScaleMouseOverEventSuscriptionId = thisObject.timeFrameScale.container.eventHandler.listenToEvent('onMouseOverScale', timeFrameScaleMouseOver) + thisObject.timeFrameScale.initialize(timeMachineCoordinateSystem, thisObject.container) + + function timeFrameScaleValueChanged (event) { let currentTimeFrame = timeFrame timeFrame = event.timeFrame if (timeFrame !== currentTimeFrame) { @@ -237,12 +239,7 @@ function newTimeMachine () { } } } - }) - - thisObject.timeFrameScale.initialize(timeMachineCoordinateSystem, thisObject.container) - - timeFrameScaleMouseOverEventSuscriptionId = thisObject.timeFrameScale.container.eventHandler.listenToEvent('onMouseOverScale', timeFrameScaleMouseOver) - + } function timeFrameScaleMouseOver (event) { thisObject.container.eventHandler.raiseEvent('onMouseOver', event) } diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index e46f04557..c56fc3755 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -39,6 +39,9 @@ function newTimelineChart () { let onViewportZoomChangedEventSuscriptionId let onMouseOverEventSuscriptionId let onMouseNotOverEventSuscriptionId + let rateScaleValueEventSuscriptionId + let rateScaleMouseOverEventSuscriptionId + let rateScaleOffsetEventSuscriptionId let timeFrameScaleEventSuscriptionId let timeFrameScaleMouseOverEventSuscriptionId @@ -116,7 +119,8 @@ function newTimelineChart () { function finalizeRateScale () { if (thisObject.rateScale === undefined) { return } - thisObject.rateScale.container.eventHandler.stopListening(rateScaleEventSuscriptionId) + thisObject.rateScale.container.eventHandler.stopListening(rateScaleOffsetEventSuscriptionId) + thisObject.rateScale.container.eventHandler.stopListening(rateScaleValueEventSuscriptionId) thisObject.rateScale.container.eventHandler.stopListening(rateScaleMouseOverEventSuscriptionId) thisObject.rateScale.finalize() thisObject.rateScale = undefined @@ -170,18 +174,23 @@ function newTimelineChart () { thisObject.rateScale.fitFunction = thisObject.fitFunction thisObject.rateScale.payload = thisObject.payload.node.rateScale.payload - rateScaleEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('Height Percentage Changed', function (event) { + rateScaleOffsetEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('Rate Scale Offset Changed', rateScaleOffsetChanged) + rateScaleValueEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('Rate Scale Value Changed', rateScaleValueChanged) + rateScaleMouseOverEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('onMouseOverScale', rateScaleMouseOver) + thisObject.rateScale.initialize(timelineChartCoordinateSystem, thisObject.container.parentContainer) + + function rateScaleOffsetChanged (event) { + thisObject.container.frame.offset.y = event.offset + } + + function rateScaleValueChanged (event) { thisObject.container.frame.height = TIME_MACHINE_HEIGHT * event.value recalculateCoordinateSystem() if (event.isUserAction === true) { - moveToUserPosition(thisObject.container, timelineChartCoordinateSystem, true, false, event.mousePosition, true) + // moveToUserPosition(thisObject.container, timelineChartCoordinateSystem, true, false, event.mousePosition, true) } thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) - }) - - thisObject.rateScale.initialize(timelineChartCoordinateSystem, thisObject.container.parentContainer) - - rateScaleMouseOverEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('onMouseOverScale', rateScaleMouseOver) + } function rateScaleMouseOver (event) { thisObject.container.eventHandler.raiseEvent('onChildrenMouseOver', event) @@ -193,7 +202,11 @@ function newTimelineChart () { thisObject.timeFrameScale.fitFunction = thisObject.fitFunction thisObject.timeFrameScale.payload = thisObject.payload.node.timeFrameScale.payload - timeFrameScaleEventSuscriptionId = thisObject.timeFrameScale.container.eventHandler.listenToEvent('Time Frame Changed', function (event) { + timeFrameScaleEventSuscriptionId = thisObject.timeFrameScale.container.eventHandler.listenToEvent('Time Frame Value Changed', timeFrameScaleValueChanged) + timeFrameScaleMouseOverEventSuscriptionId = thisObject.timeFrameScale.container.eventHandler.listenToEvent('onMouseOverScale', timeFrameScaleMouseOver) + thisObject.timeFrameScale.initialize(timeMachineCoordinateSystem, thisObject.container.parentContainer) + + function timeFrameScaleValueChanged (event) { let currentTimeFrame = timeFrame timeFrame = event.timeFrame if (timeFrame !== currentTimeFrame) { @@ -201,15 +214,10 @@ function newTimelineChart () { thisObject.plotterManager.setTimeFrame(timeFrame) } } - }) - - thisObject.timeFrameScale.initialize(timeMachineCoordinateSystem, thisObject.container.parentContainer) - - timeFrameScaleMouseOverEventSuscriptionId = thisObject.timeFrameScale.container.eventHandler.listenToEvent('onMouseOverScale', timeFrameScaleMouseOver) + } function timeFrameScaleMouseOver (event) { thisObject.container.eventHandler.raiseEvent('onChildrenMouseOver', event) - saveUserPosition(thisObject.container, timeMachineCoordinateSystem, event) } } diff --git a/Container.js b/Container.js index 81f6ab874..a4a0b5901 100644 --- a/Container.js +++ b/Container.js @@ -61,6 +61,8 @@ function newContainer () { thisObject.parentContainer = undefined thisObject.eventHandler.finalize() + + thisObject.frame.finalize() } } diff --git a/Frame.js b/Frame.js index 3f5b4cf4e..0c4023664 100644 --- a/Frame.js +++ b/Frame.js @@ -8,6 +8,7 @@ function newFrame () { containerName: '', // This is for debugging purposes only. parentFrame: undefined, // Here we store the parent cointainer zoom object. radius: 0, + offset: undefined, position: undefined, container: undefined, width: browserCanvas.width, @@ -20,20 +21,30 @@ function newFrame () { isThisPointHere: isThisPointHere, // This function return true is the point received as parameter lives within this frame. isThisScreenPointHere: isThisScreenPointHere, isInViewPort: isInViewPort, - initialize: initialize + initialize: initialize, + finalize: finalize } return thisObject + function finalize () { + thisObject.parentFrame = undefined + thisObject.position = undefined + thisObject.offset = undefined + } + function initialize (pType) { if (pType !== undefined) { thisObject.type = pType } - let position = { + thisObject.position = { x: 0, y: 0 } - thisObject.position = position + thisObject.offset = { + x: 0, + y: 0 + } } function getBodyHeight () { @@ -86,11 +97,11 @@ function newFrame () { if (thisObject.parentFrame !== undefined) { parentPoint = thisObject.parentFrame.frameThisPoint(checkPoint) - returnPoint.x = parentPoint.x + thisObject.position.x - returnPoint.y = parentPoint.y + thisObject.position.y + returnPoint.x = parentPoint.x + thisObject.position.x + thisObject.offset.x + returnPoint.y = parentPoint.y + thisObject.position.y + thisObject.offset.y } else { - returnPoint.x = checkPoint.x + thisObject.position.x - returnPoint.y = checkPoint.y + thisObject.position.y + returnPoint.x = checkPoint.x + thisObject.position.x + thisObject.offset.x + returnPoint.y = checkPoint.y + thisObject.position.y + thisObject.offset.y } return returnPoint diff --git a/Scales/RateScale.js b/Scales/RateScale.js index 685f6f2f5..bc5e7988d 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -7,6 +7,7 @@ function newRateScale () { fitFunction: undefined, payload: undefined, value: undefined, + offset: undefined, onMouseOverSomeTimeMachineContainer: onMouseOverSomeTimeMachineContainer, physics: physics, draw: draw, @@ -17,10 +18,16 @@ function newRateScale () { } const DEFAULT_VALUE = 25 - const STEP_SIZE = 1 - const MIN_WIDTH = 50 + const STEP_VALUE = 1 + const MIN_VALUE = 1 const MAX_VALUE = 100 + const DEFAULT_OFFSET = 0 + const STEP_OFFSET = 1 + const MIN_OFFSET = -1000 + const MAX_OFFSET = 1000 + const SNAP_THRESHOLD_OFFSET = 5 + thisObject.container = newContainer() thisObject.container.initialize(MODULE_NAME) @@ -32,6 +39,8 @@ function newRateScale () { thisObject.container.frame.width = UI_PANEL.WIDTH.NORMAL thisObject.container.frame.height = 40 + thisObject.offset = DEFAULT_OFFSET + let visible = true let isMouseOver @@ -78,7 +87,7 @@ function newRateScale () { let event = {} event.value = thisObject.value - thisObject.container.eventHandler.raiseEvent('Height Percentage Changed', event) + thisObject.container.eventHandler.raiseEvent('Rate Scale Value Changed', event) } function onMouseOverSomeTimeMachineContainer (event) { @@ -113,21 +122,48 @@ function newRateScale () { function onMouseWheel (event) { let morePower = 1 - if (event.buttons === 4) { morePower = 5 } // Mouse wheel pressed. + let delta - delta = event.wheelDelta - if (delta < 0) { - thisObject.value = thisObject.value - STEP_SIZE * morePower - if (thisObject.value < STEP_SIZE * 3) { thisObject.value = STEP_SIZE } + if (event.shiftKey === true) { + if (event.buttons === 4) { morePower = 10 } // Mouse wheel pressed. + delta = event.wheelDelta + if (delta > 0) { + thisObject.offset = thisObject.offset - STEP_OFFSET * morePower + if (thisObject.offset < MIN_OFFSET) { thisObject.offset = STEP_OFFSET } + } else { + thisObject.offset = thisObject.offset + STEP_OFFSET * morePower + if (thisObject.offset > MAX_OFFSET) { thisObject.offset = MAX_OFFSET } + } + + if ( + thisObject.offset <= +SNAP_THRESHOLD_OFFSET && + thisObject.offset >= -SNAP_THRESHOLD_OFFSET + ) { + event.offset = 0 + } else { + event.offset = thisObject.offset + } + + event.isUserAction = true + thisObject.container.eventHandler.raiseEvent('Rate Scale Offset Changed', event) + + saveObjectState() } else { - thisObject.value = thisObject.value + STEP_SIZE * morePower - if (thisObject.value > MAX_VALUE) { thisObject.value = MAX_VALUE } - } - event.value = thisObject.value - event.isUserAction = true - thisObject.container.eventHandler.raiseEvent('Height Percentage Changed', event) + if (event.buttons === 4) { morePower = 5 } // Mouse wheel pressed. + delta = event.wheelDelta + if (delta < 0) { + thisObject.value = thisObject.value - STEP_VALUE * morePower + if (thisObject.value < MIN_VALUE) { thisObject.value = MIN_VALUE } + } else { + thisObject.value = thisObject.value + STEP_VALUE * morePower + if (thisObject.value > MAX_VALUE) { thisObject.value = MAX_VALUE } + } + event.value = thisObject.value + event.isUserAction = true + thisObject.container.eventHandler.raiseEvent('Rate Scale Value Changed', event) - saveObjectState() + saveObjectState() + } } function getContainer (point) { @@ -141,6 +177,7 @@ function newRateScale () { let code = JSON.parse(thisObject.payload.node.code) code.value = thisObject.value / MAX_VALUE * 100 code.value = code.value.toFixed(2) + code.offset = thisObject.offset thisObject.payload.node.code = JSON.stringify(code) } catch (err) { // we ignore errors here since most likely they will be parsing errors. @@ -156,16 +193,30 @@ function newRateScale () { return } code.value = code.value / 100 * MAX_VALUE - if (code.value < STEP_SIZE) { code.value = STEP_SIZE } + if (code.value < MIN_VALUE) { code.value = MIN_VALUE } if (code.value > MAX_VALUE) { code.value = MAX_VALUE } if (code.value !== thisObject.value) { thisObject.value = code.value let event = {} event.value = thisObject.value - thisObject.container.eventHandler.raiseEvent('Height Percentage Changed', event) + thisObject.container.eventHandler.raiseEvent('Rate Scale Value Changed', event) } else { saveObjectState() + return + } + + if (code.offset < MIN_OFFSET) { code.offset = MIN_OFFSET } + if (code.offset > MAX_OFFSET) { code.offset = MAX_OFFSET } + + if (code.offset !== thisObject.offset) { + thisObject.offset = code.offset + let event = {} + event.offset = thisObject.offset + thisObject.container.eventHandler.raiseEvent('Rate Scale Offset Changed', event) + } else { + saveObjectState() + return } } catch (err) { // we ignore errors here since most likely they will be parsing errors. diff --git a/Scales/TimeFrameScale.js b/Scales/TimeFrameScale.js index 2f5c1984e..e6e49e99b 100644 --- a/Scales/TimeFrameScale.js +++ b/Scales/TimeFrameScale.js @@ -278,7 +278,7 @@ function newTimeFrameScale () { // console.log('NEW TIME FRAME LABEL', timeFrameLabel) let event = {} event.timeFrame = thisObject.timeFrame - thisObject.container.eventHandler.raiseEvent('Time Frame Changed', event) + thisObject.container.eventHandler.raiseEvent('Time Frame Value Changed', event) window.localStorage.setItem('Current Time Frame', JSON.stringify({filePeriodIndex: filePeriodIndex, timeFrameIndex: timeFrameIndex})) } diff --git a/Scales/TimeScale.js b/Scales/TimeScale.js index fe078815f..d6a4de797 100644 --- a/Scales/TimeScale.js +++ b/Scales/TimeScale.js @@ -17,7 +17,7 @@ function newTimeScale () { } const DEFAULT_VALUE = 1 - const STEP_SIZE = 1 + const STEP_VALUE = 1 const MIN_VALUE = 1 const MAX_VALUE = 400 @@ -78,7 +78,7 @@ function newTimeScale () { let event = {} event.value = thisObject.value - thisObject.container.eventHandler.raiseEvent('Lenght Percentage Changed', event) + thisObject.container.eventHandler.raiseEvent('Time Scale Value Changed', event) } function onMouseOverSomeTimeMachineContainer (event) { @@ -117,16 +117,16 @@ function newTimeScale () { delta = event.wheelDelta if (delta < 0) { - thisObject.value = thisObject.value - STEP_SIZE * morePower - if (thisObject.value < MIN_VALUE) { thisObject.value = STEP_SIZE } + thisObject.value = thisObject.value - STEP_VALUE * morePower + if (thisObject.value < MIN_VALUE) { thisObject.value = MIN_VALUE } } else { - thisObject.value = thisObject.value + STEP_SIZE * morePower + thisObject.value = thisObject.value + STEP_VALUE * morePower if (thisObject.value > MAX_VALUE) { thisObject.value = MAX_VALUE } } event.value = thisObject.value event.isUserAction = true - thisObject.container.eventHandler.raiseEvent('Lenght Percentage Changed', event) + thisObject.container.eventHandler.raiseEvent('Time Scale Value Changed', event) saveObjectState() } @@ -157,14 +157,14 @@ function newTimeScale () { return } code.value = code.value / 100 * MAX_VALUE - if (code.value < MIN_VALUE) { code.value = STEP_SIZE } + if (code.value < MIN_VALUE) { code.value = MIN_VALUE } if (code.value > MAX_VALUE) { code.value = MAX_VALUE } if (code.value !== thisObject.value) { thisObject.value = code.value let event = {} event.value = thisObject.value - thisObject.container.eventHandler.raiseEvent('Lenght Percentage Changed', event) + thisObject.container.eventHandler.raiseEvent('Time Scale Value Changed', event) } else { saveObjectState() } From f63c0efb4d0e6fafd1701ae20bc886ab6964b2c4 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 19 Jan 2020 16:24:10 +0100 Subject: [PATCH 172/264] snapping working at rate scale in both value and offset --- Scales/RateScale.js | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/Scales/RateScale.js b/Scales/RateScale.js index bc5e7988d..5931eaec3 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -21,12 +21,13 @@ function newRateScale () { const STEP_VALUE = 1 const MIN_VALUE = 1 const MAX_VALUE = 100 + const SNAP_THRESHOLD_VALUE = 2 const DEFAULT_OFFSET = 0 const STEP_OFFSET = 1 const MIN_OFFSET = -1000 const MAX_OFFSET = 1000 - const SNAP_THRESHOLD_OFFSET = 5 + const SNAP_THRESHOLD_OFFSET = 4 thisObject.container = newContainer() thisObject.container.initialize(MODULE_NAME) @@ -136,8 +137,8 @@ function newRateScale () { } if ( - thisObject.offset <= +SNAP_THRESHOLD_OFFSET && - thisObject.offset >= -SNAP_THRESHOLD_OFFSET + thisObject.offset <= DEFAULT_OFFSET + SNAP_THRESHOLD_OFFSET && + thisObject.offset >= DEFAULT_OFFSET - SNAP_THRESHOLD_OFFSET ) { event.offset = 0 } else { @@ -158,7 +159,16 @@ function newRateScale () { thisObject.value = thisObject.value + STEP_VALUE * morePower if (thisObject.value > MAX_VALUE) { thisObject.value = MAX_VALUE } } - event.value = thisObject.value + + if ( + thisObject.value <= DEFAULT_VALUE + SNAP_THRESHOLD_VALUE && + thisObject.value >= DEFAULT_VALUE - SNAP_THRESHOLD_VALUE + ) { + event.value = DEFAULT_VALUE + } else { + event.value = thisObject.value + } + event.isUserAction = true thisObject.container.eventHandler.raiseEvent('Rate Scale Value Changed', event) @@ -199,7 +209,14 @@ function newRateScale () { if (code.value !== thisObject.value) { thisObject.value = code.value let event = {} - event.value = thisObject.value + if ( + thisObject.value <= DEFAULT_VALUE + SNAP_THRESHOLD_VALUE && + thisObject.value >= DEFAULT_VALUE - SNAP_THRESHOLD_VALUE + ) { + event.value = DEFAULT_VALUE + } else { + event.value = thisObject.value + } thisObject.container.eventHandler.raiseEvent('Rate Scale Value Changed', event) } else { saveObjectState() @@ -212,7 +229,14 @@ function newRateScale () { if (code.offset !== thisObject.offset) { thisObject.offset = code.offset let event = {} - event.offset = thisObject.offset + if ( + thisObject.offset <= DEFAULT_OFFSET + SNAP_THRESHOLD_OFFSET && + thisObject.offset >= DEFAULT_OFFSET - SNAP_THRESHOLD_OFFSET + ) { + event.offset = 0 + } else { + event.offset = thisObject.offset + } thisObject.container.eventHandler.raiseEvent('Rate Scale Offset Changed', event) } else { saveObjectState() From 42b8abdd24c2431d119cfeda7c9207986242568d Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 19 Jan 2020 18:51:44 +0100 Subject: [PATCH 173/264] snap at time scale --- Scales/TimeScale.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Scales/TimeScale.js b/Scales/TimeScale.js index d6a4de797..8b5b70241 100644 --- a/Scales/TimeScale.js +++ b/Scales/TimeScale.js @@ -20,6 +20,7 @@ function newTimeScale () { const STEP_VALUE = 1 const MIN_VALUE = 1 const MAX_VALUE = 400 + const SNAP_THRESHOLD_VALUE = 0 thisObject.container = newContainer() thisObject.container.initialize(MODULE_NAME) @@ -124,7 +125,15 @@ function newTimeScale () { if (thisObject.value > MAX_VALUE) { thisObject.value = MAX_VALUE } } - event.value = thisObject.value + if ( + thisObject.value <= DEFAULT_VALUE + SNAP_THRESHOLD_VALUE && + thisObject.value >= DEFAULT_VALUE - SNAP_THRESHOLD_VALUE + ) { + event.value = DEFAULT_VALUE + } else { + event.value = thisObject.value + } + event.isUserAction = true thisObject.container.eventHandler.raiseEvent('Time Scale Value Changed', event) @@ -163,7 +172,14 @@ function newTimeScale () { if (code.value !== thisObject.value) { thisObject.value = code.value let event = {} - event.value = thisObject.value + if ( + thisObject.value <= DEFAULT_VALUE + SNAP_THRESHOLD_VALUE && + thisObject.value >= DEFAULT_VALUE - SNAP_THRESHOLD_VALUE + ) { + event.value = DEFAULT_VALUE + } else { + event.value = thisObject.value + } thisObject.container.eventHandler.raiseEvent('Time Scale Value Changed', event) } else { saveObjectState() From 4c0a365d6950740468d8ed1257ae8688d99d0311 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 19 Jan 2020 19:17:05 +0100 Subject: [PATCH 174/264] rateScale labels working --- ChartsSpace/TimeMachine.js | 4 +- ChartsSpace/TimelineChart.js | 2 +- Scales/RateScale.js | 95 +++++++++++++++++++++--------------- Scales/TimeScale.js | 72 +++++++++++++-------------- 4 files changed, 96 insertions(+), 77 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 124db9076..cfb8c4aa1 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -184,7 +184,7 @@ function newTimeMachine () { thisObject.timeScale.initialize(timeMachineCoordinateSystem, thisObject.container) function timeScaleValueChanged (event) { - thisObject.container.frame.width = TIME_MACHINE_WIDTH * event.value + thisObject.container.frame.width = TIME_MACHINE_WIDTH * event.scale recalculateCoordinateSystem() if (event.isUserAction === true) { moveToUserPosition(thisObject.container, timeMachineCoordinateSystem, false, true, event.mousePosition, true) @@ -206,7 +206,7 @@ function newTimeMachine () { thisObject.rateScale.initialize(timeMachineCoordinateSystem, thisObject.container) function rateScaleValueChanged (event) { - thisObject.container.frame.height = TIME_MACHINE_HEIGHT * event.value + thisObject.container.frame.height = TIME_MACHINE_HEIGHT * event.scale recalculateCoordinateSystem() if (event.isUserAction === true) { moveToUserPosition(thisObject.container, timeMachineCoordinateSystem, true, false, event.mousePosition, true) diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index c56fc3755..cf15cc0ca 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -184,7 +184,7 @@ function newTimelineChart () { } function rateScaleValueChanged (event) { - thisObject.container.frame.height = TIME_MACHINE_HEIGHT * event.value + thisObject.container.frame.height = TIME_MACHINE_HEIGHT * event.scale recalculateCoordinateSystem() if (event.isUserAction === true) { // moveToUserPosition(thisObject.container, timelineChartCoordinateSystem, true, false, event.mousePosition, true) diff --git a/Scales/RateScale.js b/Scales/RateScale.js index 5931eaec3..a6faab4f8 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -6,7 +6,7 @@ function newRateScale () { rate: undefined, fitFunction: undefined, payload: undefined, - value: undefined, + scale: undefined, offset: undefined, onMouseOverSomeTimeMachineContainer: onMouseOverSomeTimeMachineContainer, physics: physics, @@ -17,11 +17,11 @@ function newRateScale () { finalize: finalize } - const DEFAULT_VALUE = 25 - const STEP_VALUE = 1 - const MIN_VALUE = 1 - const MAX_VALUE = 100 - const SNAP_THRESHOLD_VALUE = 2 + const DEFAULT_SCALE = 25 + const STEP_SCALE = 1 + const MIN_SCALE = 1 + const MAX_SCALE = 100 + const SNAP_THRESHOLD_SCALE = 2 const DEFAULT_OFFSET = 0 const STEP_OFFSET = 1 @@ -58,6 +58,9 @@ function newRateScale () { y: 0 } } + + let offsetTimer = 0 + let scaleTimer = 0 return thisObject function finalize () { @@ -83,11 +86,11 @@ function newRateScale () { onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) onMouseNotOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) - thisObject.value = DEFAULT_VALUE + thisObject.scale = DEFAULT_SCALE readObjectState() let event = {} - event.value = thisObject.value + event.scale = thisObject.scale thisObject.container.eventHandler.raiseEvent('Rate Scale Value Changed', event) } @@ -119,6 +122,8 @@ function newRateScale () { function onMouseNotOver () { isMouseOver = false + offsetTimer = 0 + scaleTimer = 0 } function onMouseWheel (event) { @@ -128,7 +133,7 @@ function newRateScale () { if (event.shiftKey === true) { if (event.buttons === 4) { morePower = 10 } // Mouse wheel pressed. delta = event.wheelDelta - if (delta > 0) { + if (delta < 0) { thisObject.offset = thisObject.offset - STEP_OFFSET * morePower if (thisObject.offset < MIN_OFFSET) { thisObject.offset = STEP_OFFSET } } else { @@ -142,37 +147,39 @@ function newRateScale () { ) { event.offset = 0 } else { - event.offset = thisObject.offset + event.offset = -thisObject.offset } event.isUserAction = true thisObject.container.eventHandler.raiseEvent('Rate Scale Offset Changed', event) saveObjectState() + offsetTimer = 100 } else { if (event.buttons === 4) { morePower = 5 } // Mouse wheel pressed. delta = event.wheelDelta if (delta < 0) { - thisObject.value = thisObject.value - STEP_VALUE * morePower - if (thisObject.value < MIN_VALUE) { thisObject.value = MIN_VALUE } + thisObject.scale = thisObject.scale - STEP_SCALE * morePower + if (thisObject.scale < MIN_SCALE) { thisObject.scale = MIN_SCALE } } else { - thisObject.value = thisObject.value + STEP_VALUE * morePower - if (thisObject.value > MAX_VALUE) { thisObject.value = MAX_VALUE } + thisObject.scale = thisObject.scale + STEP_SCALE * morePower + if (thisObject.scale > MAX_SCALE) { thisObject.scale = MAX_SCALE } } if ( - thisObject.value <= DEFAULT_VALUE + SNAP_THRESHOLD_VALUE && - thisObject.value >= DEFAULT_VALUE - SNAP_THRESHOLD_VALUE + thisObject.scale <= DEFAULT_SCALE + SNAP_THRESHOLD_SCALE && + thisObject.scale >= DEFAULT_SCALE - SNAP_THRESHOLD_SCALE ) { - event.value = DEFAULT_VALUE + event.scale = DEFAULT_SCALE } else { - event.value = thisObject.value + event.scale = thisObject.scale } event.isUserAction = true thisObject.container.eventHandler.raiseEvent('Rate Scale Value Changed', event) saveObjectState() + scaleTimer = 100 } } @@ -185,8 +192,8 @@ function newRateScale () { function saveObjectState () { try { let code = JSON.parse(thisObject.payload.node.code) - code.value = thisObject.value / MAX_VALUE * 100 - code.value = code.value.toFixed(2) + code.scale = thisObject.scale / MAX_SCALE * 100 + code.scale = code.scale.toFixed(2) code.offset = thisObject.offset thisObject.payload.node.code = JSON.stringify(code) } catch (err) { @@ -198,24 +205,24 @@ function newRateScale () { try { let code = JSON.parse(thisObject.payload.node.code) - if (isNaN(code.value) || code.value === null || code.value === undefined) { + if (isNaN(code.scale) || code.scale === null || code.scale === undefined) { saveObjectState() return } - code.value = code.value / 100 * MAX_VALUE - if (code.value < MIN_VALUE) { code.value = MIN_VALUE } - if (code.value > MAX_VALUE) { code.value = MAX_VALUE } + code.scale = code.scale / 100 * MAX_SCALE + if (code.scale < MIN_SCALE) { code.scale = MIN_SCALE } + if (code.scale > MAX_SCALE) { code.scale = MAX_SCALE } - if (code.value !== thisObject.value) { - thisObject.value = code.value + if (code.scale !== thisObject.scale) { + thisObject.scale = code.scale let event = {} if ( - thisObject.value <= DEFAULT_VALUE + SNAP_THRESHOLD_VALUE && - thisObject.value >= DEFAULT_VALUE - SNAP_THRESHOLD_VALUE + thisObject.scale <= DEFAULT_SCALE + SNAP_THRESHOLD_SCALE && + thisObject.scale >= DEFAULT_SCALE - SNAP_THRESHOLD_SCALE ) { - event.value = DEFAULT_VALUE + event.scale = DEFAULT_SCALE } else { - event.value = thisObject.value + event.scale = thisObject.scale } thisObject.container.eventHandler.raiseEvent('Rate Scale Value Changed', event) } else { @@ -235,7 +242,7 @@ function newRateScale () { ) { event.offset = 0 } else { - event.offset = thisObject.offset + event.offset = -thisObject.offset } thisObject.container.eventHandler.raiseEvent('Rate Scale Offset Changed', event) } else { @@ -248,6 +255,8 @@ function newRateScale () { } function physics () { + offsetTimer-- + scaleTimer-- readObjectState() positioningphysics() } @@ -350,6 +359,16 @@ function newRateScale () { let backgroundColor = UI_COLOR.BLACK + if (offsetTimer > 0) { + label2 = thisObject.offset.toFixed(0) + label3 = 'OFFSET' + } + + if (scaleTimer > 0) { + label2 = thisObject.scale.toFixed(0) + label3 = 'SCALE' + } + drawScaleDisplay(label1, label2, label3, 0, 0, 0, icon1, icon2, thisObject.container, backgroundColor) } @@ -364,7 +383,7 @@ function newRateScale () { const OPACITY = 0.2 const DISTANCE_BETWEEN_ARROWS = 10 const MIN_DISTANCE_FROM_CENTER = 30 - const CURRENT_VALUE_DISTANCE = MIN_DISTANCE_FROM_CENTER + thisObject.value + const CURRENT_SCALE_DISTANCE = MIN_DISTANCE_FROM_CENTER + thisObject.scale const MAX_DISTANCE_FROM_CENTER = MIN_DISTANCE_FROM_CENTER + 215 + DISTANCE_BETWEEN_ARROWS let ARROW_DIRECTION = 0 @@ -377,17 +396,17 @@ function newRateScale () { function drawTwoArrows () { point1 = { x: X_OFFSET - WIDTH / 2, - y: Y_OFFSET + DISTANCE_BETWEEN_ARROWS / 2 * ARROW_DIRECTION + CURRENT_VALUE_DISTANCE * ARROW_DIRECTION + y: Y_OFFSET + DISTANCE_BETWEEN_ARROWS / 2 * ARROW_DIRECTION + CURRENT_SCALE_DISTANCE * ARROW_DIRECTION } point2 = { x: X_OFFSET, - y: Y_OFFSET + HEIGHT * ARROW_DIRECTION + DISTANCE_BETWEEN_ARROWS / 2 * ARROW_DIRECTION + CURRENT_VALUE_DISTANCE * ARROW_DIRECTION + y: Y_OFFSET + HEIGHT * ARROW_DIRECTION + DISTANCE_BETWEEN_ARROWS / 2 * ARROW_DIRECTION + CURRENT_SCALE_DISTANCE * ARROW_DIRECTION } point3 = { x: X_OFFSET + WIDTH / 2, - y: Y_OFFSET + DISTANCE_BETWEEN_ARROWS / 2 * ARROW_DIRECTION + CURRENT_VALUE_DISTANCE * ARROW_DIRECTION + y: Y_OFFSET + DISTANCE_BETWEEN_ARROWS / 2 * ARROW_DIRECTION + CURRENT_SCALE_DISTANCE * ARROW_DIRECTION } point1 = thisObject.container.frame.frameThisPoint(point1) @@ -396,17 +415,17 @@ function newRateScale () { point4 = { x: X_OFFSET - WIDTH / 2, - y: Y_OFFSET - DISTANCE_BETWEEN_ARROWS / 2 * ARROW_DIRECTION + CURRENT_VALUE_DISTANCE * ARROW_DIRECTION + y: Y_OFFSET - DISTANCE_BETWEEN_ARROWS / 2 * ARROW_DIRECTION + CURRENT_SCALE_DISTANCE * ARROW_DIRECTION } point5 = { x: X_OFFSET, - y: Y_OFFSET + HEIGHT * ARROW_DIRECTION - DISTANCE_BETWEEN_ARROWS / 2 * ARROW_DIRECTION + CURRENT_VALUE_DISTANCE * ARROW_DIRECTION + y: Y_OFFSET + HEIGHT * ARROW_DIRECTION - DISTANCE_BETWEEN_ARROWS / 2 * ARROW_DIRECTION + CURRENT_SCALE_DISTANCE * ARROW_DIRECTION } point6 = { x: X_OFFSET + WIDTH / 2, - y: Y_OFFSET - DISTANCE_BETWEEN_ARROWS / 2 * ARROW_DIRECTION + CURRENT_VALUE_DISTANCE * ARROW_DIRECTION + y: Y_OFFSET - DISTANCE_BETWEEN_ARROWS / 2 * ARROW_DIRECTION + CURRENT_SCALE_DISTANCE * ARROW_DIRECTION } point4 = thisObject.container.frame.frameThisPoint(point4) diff --git a/Scales/TimeScale.js b/Scales/TimeScale.js index 8b5b70241..99bdc70ef 100644 --- a/Scales/TimeScale.js +++ b/Scales/TimeScale.js @@ -2,7 +2,7 @@ function newTimeScale () { const MODULE_NAME = 'Time Scale' let thisObject = { - value: undefined, + scale: undefined, container: undefined, date: undefined, fitFunction: undefined, @@ -16,11 +16,11 @@ function newTimeScale () { finalize: finalize } - const DEFAULT_VALUE = 1 - const STEP_VALUE = 1 - const MIN_VALUE = 1 - const MAX_VALUE = 400 - const SNAP_THRESHOLD_VALUE = 0 + const DEFAULT_SCALE = 1 + const STEP_SCALE = 1 + const MIN_SCALE = 1 + const MAX_SCALE = 400 + const SNAP_THRESHOLD_SCALE = 0 thisObject.container = newContainer() thisObject.container.initialize(MODULE_NAME) @@ -74,11 +74,11 @@ function newTimeScale () { onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) onMouseNotOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) - thisObject.value = DEFAULT_VALUE + thisObject.scale = DEFAULT_SCALE readObjectState() let event = {} - event.value = thisObject.value + event.scale = thisObject.scale thisObject.container.eventHandler.raiseEvent('Time Scale Value Changed', event) } @@ -118,20 +118,20 @@ function newTimeScale () { delta = event.wheelDelta if (delta < 0) { - thisObject.value = thisObject.value - STEP_VALUE * morePower - if (thisObject.value < MIN_VALUE) { thisObject.value = MIN_VALUE } + thisObject.scale = thisObject.scale - STEP_SCALE * morePower + if (thisObject.scale < MIN_SCALE) { thisObject.scale = MIN_SCALE } } else { - thisObject.value = thisObject.value + STEP_VALUE * morePower - if (thisObject.value > MAX_VALUE) { thisObject.value = MAX_VALUE } + thisObject.scale = thisObject.scale + STEP_SCALE * morePower + if (thisObject.scale > MAX_SCALE) { thisObject.scale = MAX_SCALE } } if ( - thisObject.value <= DEFAULT_VALUE + SNAP_THRESHOLD_VALUE && - thisObject.value >= DEFAULT_VALUE - SNAP_THRESHOLD_VALUE + thisObject.scale <= DEFAULT_SCALE + SNAP_THRESHOLD_SCALE && + thisObject.scale >= DEFAULT_SCALE - SNAP_THRESHOLD_SCALE ) { - event.value = DEFAULT_VALUE + event.scale = DEFAULT_SCALE } else { - event.value = thisObject.value + event.scale = thisObject.scale } event.isUserAction = true @@ -149,8 +149,8 @@ function newTimeScale () { function saveObjectState () { try { let code = JSON.parse(thisObject.payload.node.code) - code.value = thisObject.value / MAX_VALUE * 100 - code.value = code.value.toFixed(2) + code.scale = thisObject.scale / MAX_SCALE * 100 + code.scale = code.scale.toFixed(2) thisObject.payload.node.code = JSON.stringify(code) } catch (err) { // we ignore errors here since most likely they will be parsing errors. @@ -161,24 +161,24 @@ function newTimeScale () { try { let code = JSON.parse(thisObject.payload.node.code) - if (isNaN(code.value) || code.value === null || code.value === undefined) { + if (isNaN(code.scale) || code.scale === null || code.scale === undefined) { saveObjectState() return } - code.value = code.value / 100 * MAX_VALUE - if (code.value < MIN_VALUE) { code.value = MIN_VALUE } - if (code.value > MAX_VALUE) { code.value = MAX_VALUE } + code.scale = code.scale / 100 * MAX_SCALE + if (code.scale < MIN_SCALE) { code.scale = MIN_SCALE } + if (code.scale > MAX_SCALE) { code.scale = MAX_SCALE } - if (code.value !== thisObject.value) { - thisObject.value = code.value + if (code.scale !== thisObject.scale) { + thisObject.scale = code.scale let event = {} if ( - thisObject.value <= DEFAULT_VALUE + SNAP_THRESHOLD_VALUE && - thisObject.value >= DEFAULT_VALUE - SNAP_THRESHOLD_VALUE + thisObject.scale <= DEFAULT_SCALE + SNAP_THRESHOLD_SCALE && + thisObject.scale >= DEFAULT_SCALE - SNAP_THRESHOLD_SCALE ) { - event.value = DEFAULT_VALUE + event.scale = DEFAULT_SCALE } else { - event.value = thisObject.value + event.scale = thisObject.scale } thisObject.container.eventHandler.raiseEvent('Time Scale Value Changed', event) } else { @@ -284,8 +284,8 @@ function newTimeScale () { const OPACITY = 0.2 const DISTANCE_BETWEEN_ARROWS = 10 const MIN_DISTANCE_FROM_CENTER = 110 - const CURRENT_VALUE_DISTANCE = MIN_DISTANCE_FROM_CENTER + thisObject.value - const MAX_DISTANCE_FROM_CENTER = MIN_DISTANCE_FROM_CENTER + MAX_VALUE + DISTANCE_BETWEEN_ARROWS + const CURRENT_SCALE_DISTANCE = MIN_DISTANCE_FROM_CENTER + thisObject.scale + const MAX_DISTANCE_FROM_CENTER = MIN_DISTANCE_FROM_CENTER + MAX_SCALE + DISTANCE_BETWEEN_ARROWS let ARROW_DIRECTION = 0 @@ -296,17 +296,17 @@ function newTimeScale () { function drawTwoArrows () { point1 = { - x: X_OFFSET - WIDTH / 2 * ARROW_DIRECTION + DISTANCE_BETWEEN_ARROWS / 2 * ARROW_DIRECTION + CURRENT_VALUE_DISTANCE * ARROW_DIRECTION, + x: X_OFFSET - WIDTH / 2 * ARROW_DIRECTION + DISTANCE_BETWEEN_ARROWS / 2 * ARROW_DIRECTION + CURRENT_SCALE_DISTANCE * ARROW_DIRECTION, y: Y_OFFSET - 0 } point2 = { - x: X_OFFSET + WIDTH / 2 * ARROW_DIRECTION + DISTANCE_BETWEEN_ARROWS / 2 * ARROW_DIRECTION + CURRENT_VALUE_DISTANCE * ARROW_DIRECTION, + x: X_OFFSET + WIDTH / 2 * ARROW_DIRECTION + DISTANCE_BETWEEN_ARROWS / 2 * ARROW_DIRECTION + CURRENT_SCALE_DISTANCE * ARROW_DIRECTION, y: Y_OFFSET + HEIGHT / 2 } point3 = { - x: X_OFFSET - WIDTH / 2 * ARROW_DIRECTION + DISTANCE_BETWEEN_ARROWS / 2 * ARROW_DIRECTION + CURRENT_VALUE_DISTANCE * ARROW_DIRECTION, + x: X_OFFSET - WIDTH / 2 * ARROW_DIRECTION + DISTANCE_BETWEEN_ARROWS / 2 * ARROW_DIRECTION + CURRENT_SCALE_DISTANCE * ARROW_DIRECTION, y: Y_OFFSET + HEIGHT } @@ -315,17 +315,17 @@ function newTimeScale () { point3 = thisObject.container.frame.frameThisPoint(point3) point4 = { - x: X_OFFSET - WIDTH / 2 * ARROW_DIRECTION - DISTANCE_BETWEEN_ARROWS / 2 * ARROW_DIRECTION + CURRENT_VALUE_DISTANCE * ARROW_DIRECTION, + x: X_OFFSET - WIDTH / 2 * ARROW_DIRECTION - DISTANCE_BETWEEN_ARROWS / 2 * ARROW_DIRECTION + CURRENT_SCALE_DISTANCE * ARROW_DIRECTION, y: Y_OFFSET - 0 } point5 = { - x: X_OFFSET + WIDTH / 2 * ARROW_DIRECTION - DISTANCE_BETWEEN_ARROWS / 2 * ARROW_DIRECTION + CURRENT_VALUE_DISTANCE * ARROW_DIRECTION, + x: X_OFFSET + WIDTH / 2 * ARROW_DIRECTION - DISTANCE_BETWEEN_ARROWS / 2 * ARROW_DIRECTION + CURRENT_SCALE_DISTANCE * ARROW_DIRECTION, y: Y_OFFSET + HEIGHT / 2 } point6 = { - x: X_OFFSET - WIDTH / 2 * ARROW_DIRECTION - DISTANCE_BETWEEN_ARROWS / 2 * ARROW_DIRECTION + CURRENT_VALUE_DISTANCE * ARROW_DIRECTION, + x: X_OFFSET - WIDTH / 2 * ARROW_DIRECTION - DISTANCE_BETWEEN_ARROWS / 2 * ARROW_DIRECTION + CURRENT_SCALE_DISTANCE * ARROW_DIRECTION, y: Y_OFFSET + HEIGHT } From d0addf76acba104234ee447365e499280e2622c0 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 19 Jan 2020 19:22:38 +0100 Subject: [PATCH 175/264] scale label at timeScale --- Scales/TimeScale.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Scales/TimeScale.js b/Scales/TimeScale.js index 99bdc70ef..8606d4fd6 100644 --- a/Scales/TimeScale.js +++ b/Scales/TimeScale.js @@ -49,6 +49,7 @@ function newTimeScale () { y: 0 } } + let scaleTimer = 0 return thisObject function finalize () { @@ -110,6 +111,7 @@ function newTimeScale () { function onMouseNotOver () { isMouseOver = false + scaleTimer = 0 } function onMouseWheel (event) { @@ -138,6 +140,7 @@ function newTimeScale () { thisObject.container.eventHandler.raiseEvent('Time Scale Value Changed', event) saveObjectState() + scaleTimer = 100 } function getContainer (point) { @@ -190,6 +193,7 @@ function newTimeScale () { } function physics () { + scaleTimer-- readObjectState() positioningphysics() } @@ -270,6 +274,11 @@ function newTimeScale () { let backgroundColor = UI_COLOR.BLACK + if (scaleTimer > 0) { + label2 = thisObject.scale.toFixed(0) + label3 = 'SCALE' + } + drawScaleDisplay(label1, label2, label3, 0, 0, 0, icon1, icon2, thisObject.container, backgroundColor) } From b75f8b80096f306befbd76e8be0bae3799a054d2 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 19 Jan 2020 19:25:40 +0100 Subject: [PATCH 176/264] Bug fixed --- Scales/RateScale.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Scales/RateScale.js b/Scales/RateScale.js index a6faab4f8..f35940b90 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -155,6 +155,7 @@ function newRateScale () { saveObjectState() offsetTimer = 100 + scaleTimer = 0 } else { if (event.buttons === 4) { morePower = 5 } // Mouse wheel pressed. delta = event.wheelDelta @@ -179,6 +180,7 @@ function newRateScale () { thisObject.container.eventHandler.raiseEvent('Rate Scale Value Changed', event) saveObjectState() + offsetTimer = 0 scaleTimer = 100 } } From 787d806af47cccbda3b1cb1accbdf4eeccb2266d Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 19 Jan 2020 21:01:57 +0100 Subject: [PATCH 177/264] upstream changes in rate scale --- ChartsSpace/TimeMachine.js | 2 ++ ChartsSpace/TimelineChart.js | 13 +++++++------ Scales/RateScale.js | 19 +++++++++++++++++++ 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index cfb8c4aa1..a182af623 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -212,6 +212,7 @@ function newTimeMachine () { moveToUserPosition(thisObject.container, timeMachineCoordinateSystem, true, false, event.mousePosition, true) } thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) + thisObject.container.eventHandler.raiseEvent('Upstream Rate Scale Value Changed', event) } function rateScaleMouseOver (event) { thisObject.container.eventHandler.raiseEvent('onMouseOver', event) @@ -407,6 +408,7 @@ function newTimeMachine () { timelineChart.container.connectToParent(thisObject.container, true, true, false, true, true, true, false, false, true) timelineChart.container.fitFunction = thisObject.container.fitFunction timelineChart.fitFunction = thisObject.fitFunction + timelineChart.container.frame.width = thisObject.container.frame.width timelineChart.container.frame.height = thisObject.container.frame.height timelineChart.container.frame.position.x = 0 timelineChart.container.frame.position.y = 0 diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index cf15cc0ca..58d54bb5b 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -40,6 +40,7 @@ function newTimelineChart () { let onMouseOverEventSuscriptionId let onMouseNotOverEventSuscriptionId let rateScaleValueEventSuscriptionId + let rateScaleUpstreamEventSuscriptionId let rateScaleMouseOverEventSuscriptionId let rateScaleOffsetEventSuscriptionId let timeFrameScaleEventSuscriptionId @@ -60,9 +61,6 @@ function newTimelineChart () { thisObject.container = newContainer() thisObject.container.initialize(MODULE_NAME) thisObject.container.detectMouseOver = true - - thisObject.container.frame.width = TIME_MACHINE_WIDTH - thisObject.container.frame.height = TIME_MACHINE_HEIGHT } function finalize () { @@ -122,6 +120,7 @@ function newTimelineChart () { thisObject.rateScale.container.eventHandler.stopListening(rateScaleOffsetEventSuscriptionId) thisObject.rateScale.container.eventHandler.stopListening(rateScaleValueEventSuscriptionId) thisObject.rateScale.container.eventHandler.stopListening(rateScaleMouseOverEventSuscriptionId) + thisObject.container.parentContainer.eventHandler.stopListening(rateScaleUpstreamEventSuscriptionId) thisObject.rateScale.finalize() thisObject.rateScale = undefined @@ -177,8 +176,13 @@ function newTimelineChart () { rateScaleOffsetEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('Rate Scale Offset Changed', rateScaleOffsetChanged) rateScaleValueEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('Rate Scale Value Changed', rateScaleValueChanged) rateScaleMouseOverEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('onMouseOverScale', rateScaleMouseOver) + rateScaleUpstreamEventSuscriptionId = thisObject.container.parentContainer.eventHandler.listenToEvent('Upstream Rate Scale Value Changed', rateScaleUpstreamChanged) thisObject.rateScale.initialize(timelineChartCoordinateSystem, thisObject.container.parentContainer) + function rateScaleUpstreamChanged (event) { + thisObject.rateScale.setScale(event.scale) + } + function rateScaleOffsetChanged (event) { thisObject.container.frame.offset.y = event.offset } @@ -186,9 +190,6 @@ function newTimelineChart () { function rateScaleValueChanged (event) { thisObject.container.frame.height = TIME_MACHINE_HEIGHT * event.scale recalculateCoordinateSystem() - if (event.isUserAction === true) { - // moveToUserPosition(thisObject.container, timelineChartCoordinateSystem, true, false, event.mousePosition, true) - } thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) } diff --git a/Scales/RateScale.js b/Scales/RateScale.js index f35940b90..585d62813 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -8,6 +8,7 @@ function newRateScale () { payload: undefined, scale: undefined, offset: undefined, + setScale: setScale, onMouseOverSomeTimeMachineContainer: onMouseOverSomeTimeMachineContainer, physics: physics, draw: draw, @@ -185,6 +186,24 @@ function newRateScale () { } } + function setScale (scale) { + thisObject.scale = scale + if ( + thisObject.scale <= DEFAULT_SCALE + SNAP_THRESHOLD_SCALE && + thisObject.scale >= DEFAULT_SCALE - SNAP_THRESHOLD_SCALE + ) { + event.scale = DEFAULT_SCALE + } else { + event.scale = thisObject.scale + } + event.isUserAction = true + thisObject.container.eventHandler.raiseEvent('Rate Scale Value Changed', event) + + saveObjectState() + offsetTimer = 0 + scaleTimer = 100 + } + function getContainer (point) { if (thisObject.container.frame.isThisPointHere(point, true) === true) { return thisObject.container From edc288e344c7b000a77f30c178a6b1479a625513 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 19 Jan 2020 21:35:30 +0100 Subject: [PATCH 178/264] limits on rate labels implemented --- ChartsSpace/TimeMachine.js | 2 +- ChartsSpace/TimelineChart.js | 2 +- Scales/RateScale.js | 20 +++++++++++++------- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index a182af623..b6d43ddb1 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -203,7 +203,7 @@ function newTimeMachine () { rateScaleValueEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('Rate Scale Value Changed', rateScaleValueChanged) rateScaleMouseOverEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('onMouseOverScale', rateScaleMouseOver) - thisObject.rateScale.initialize(timeMachineCoordinateSystem, thisObject.container) + thisObject.rateScale.initialize(timeMachineCoordinateSystem, thisObject.container, thisObject.container) function rateScaleValueChanged (event) { thisObject.container.frame.height = TIME_MACHINE_HEIGHT * event.scale diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 58d54bb5b..cb8495344 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -177,7 +177,7 @@ function newTimelineChart () { rateScaleValueEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('Rate Scale Value Changed', rateScaleValueChanged) rateScaleMouseOverEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('onMouseOverScale', rateScaleMouseOver) rateScaleUpstreamEventSuscriptionId = thisObject.container.parentContainer.eventHandler.listenToEvent('Upstream Rate Scale Value Changed', rateScaleUpstreamChanged) - thisObject.rateScale.initialize(timelineChartCoordinateSystem, thisObject.container.parentContainer) + thisObject.rateScale.initialize(timelineChartCoordinateSystem, thisObject.container.parentContainer, thisObject.container) function rateScaleUpstreamChanged (event) { thisObject.rateScale.setScale(event.scale) diff --git a/Scales/RateScale.js b/Scales/RateScale.js index 585d62813..a7f0e8e52 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -52,6 +52,7 @@ function newRateScale () { let timeLineCoordinateSystem let limitingContainer + let rateCalculationsContainer let mouse = { position: { @@ -76,12 +77,14 @@ function newRateScale () { timeLineCoordinateSystem = undefined limitingContainer = undefined + rateCalculationsContainer = undefined mouse = undefined } - function initialize (pTimeLineCoordinateSystem, pLimitingContainer) { + function initialize (pTimeLineCoordinateSystem, pLimitingContainer, pRateCalculationsContainer) { timeLineCoordinateSystem = pTimeLineCoordinateSystem limitingContainer = pLimitingContainer + rateCalculationsContainer = pRateCalculationsContainer onMouseWheelEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) @@ -326,12 +329,10 @@ function newRateScale () { /* Mouse Position Rate Calculation */ let ratePoint = { x: 0, - y: mouse.position.y + y: mouse.position.y + thisObject.offset } - let mouseRate = getRateFromPoint(ratePoint, limitingContainer, timeLineCoordinateSystem) - - thisObject.rate = mouseRate + thisObject.rate = getRateFromPoint(ratePoint, rateCalculationsContainer, timeLineCoordinateSystem) /* rateScale Positioning */ ratePoint = { @@ -369,10 +370,15 @@ function newRateScale () { function drawScaleBox () { if (thisObject.rate === undefined) { return } - let label = (thisObject.rate - Math.trunc(thisObject.rate)).toFixed(2) + let rate = thisObject.rate + + if (rate < timeLineCoordinateSystem.min.y) { rate = timeLineCoordinateSystem.min.y } + if (rate > timeLineCoordinateSystem.max.y) { rate = timeLineCoordinateSystem.max.y } + + let label = (rate - Math.trunc(rate)).toFixed(2) let labelArray = label.split('.') let label1 = thisObject.payload.node.payload.parentNode.name - let label2 = (Math.trunc(thisObject.rate)).toLocaleString() + let label2 = (Math.trunc(rate)).toLocaleString() let label3 = labelArray[1] let icon1 = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.payload.parentNode.type) From 8d1d887eff7d7e6c2283127ea6d0a058ee82cdb1 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 20 Jan 2020 09:30:14 +0100 Subject: [PATCH 179/264] tunning scales --- ChartsSpace/TimeMachine.js | 4 ++-- ChartsSpace/TimelineChart.js | 2 +- Globals.js | 4 ++-- Scales/RateScale.js | 12 ++++++------ Scales/TimeScale.js | 12 ++++++------ 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index b6d43ddb1..5baf9bb8c 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -184,7 +184,7 @@ function newTimeMachine () { thisObject.timeScale.initialize(timeMachineCoordinateSystem, thisObject.container) function timeScaleValueChanged (event) { - thisObject.container.frame.width = TIME_MACHINE_WIDTH * event.scale + thisObject.container.frame.width = TIME_MACHINE_WIDTH + TIME_MACHINE_WIDTH * event.scale recalculateCoordinateSystem() if (event.isUserAction === true) { moveToUserPosition(thisObject.container, timeMachineCoordinateSystem, false, true, event.mousePosition, true) @@ -206,7 +206,7 @@ function newTimeMachine () { thisObject.rateScale.initialize(timeMachineCoordinateSystem, thisObject.container, thisObject.container) function rateScaleValueChanged (event) { - thisObject.container.frame.height = TIME_MACHINE_HEIGHT * event.scale + thisObject.container.frame.height = TIME_MACHINE_HEIGHT + TIME_MACHINE_HEIGHT * event.scale recalculateCoordinateSystem() if (event.isUserAction === true) { moveToUserPosition(thisObject.container, timeMachineCoordinateSystem, true, false, event.mousePosition, true) diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index cb8495344..d8107082b 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -188,7 +188,7 @@ function newTimelineChart () { } function rateScaleValueChanged (event) { - thisObject.container.frame.height = TIME_MACHINE_HEIGHT * event.scale + thisObject.container.frame.height = TIME_MACHINE_HEIGHT + TIME_MACHINE_HEIGHT * event.scale recalculateCoordinateSystem() thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) } diff --git a/Globals.js b/Globals.js index 66c535e1e..e3d45800f 100644 --- a/Globals.js +++ b/Globals.js @@ -188,8 +188,8 @@ const PERIOD_01_MIN = "01-min"; We define here the size of the chartSpace. It has to bee enough big in order to accomodate all the charts we expect to display in this space. */ -const TIME_MACHINE_WIDTH = 2000; -const TIME_MACHINE_HEIGHT = 200 / 25; +const TIME_MACHINE_WIDTH = 250; +const TIME_MACHINE_HEIGHT = 250 / 50; function toRadians(angle) { return angle * (Math.PI / 180); diff --git a/Scales/RateScale.js b/Scales/RateScale.js index a7f0e8e52..91ee28952 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -18,17 +18,17 @@ function newRateScale () { finalize: finalize } - const DEFAULT_SCALE = 25 + const DEFAULT_SCALE = 50 const STEP_SCALE = 1 - const MIN_SCALE = 1 + const MIN_SCALE = 0 const MAX_SCALE = 100 - const SNAP_THRESHOLD_SCALE = 2 + const SNAP_THRESHOLD_SCALE = 1 const DEFAULT_OFFSET = 0 const STEP_OFFSET = 1 const MIN_OFFSET = -1000 const MAX_OFFSET = 1000 - const SNAP_THRESHOLD_OFFSET = 4 + const SNAP_THRESHOLD_OFFSET = 3 thisObject.container = newContainer() thisObject.container.initialize(MODULE_NAME) @@ -217,7 +217,7 @@ function newRateScale () { try { let code = JSON.parse(thisObject.payload.node.code) code.scale = thisObject.scale / MAX_SCALE * 100 - code.scale = code.scale.toFixed(2) + code.scale = code.scale.toFixed(0) code.offset = thisObject.offset thisObject.payload.node.code = JSON.stringify(code) } catch (err) { @@ -392,7 +392,7 @@ function newRateScale () { } if (scaleTimer > 0) { - label2 = thisObject.scale.toFixed(0) + label2 = (thisObject.scale / MAX_SCALE * 100).toFixed(0) label3 = 'SCALE' } diff --git a/Scales/TimeScale.js b/Scales/TimeScale.js index 8606d4fd6..5d2d193fb 100644 --- a/Scales/TimeScale.js +++ b/Scales/TimeScale.js @@ -16,10 +16,10 @@ function newTimeScale () { finalize: finalize } - const DEFAULT_SCALE = 1 - const STEP_SCALE = 1 - const MIN_SCALE = 1 - const MAX_SCALE = 400 + const DEFAULT_SCALE = 0 + const STEP_SCALE = 2.5 + const MIN_SCALE = 0 + const MAX_SCALE = 250 const SNAP_THRESHOLD_SCALE = 0 thisObject.container = newContainer() @@ -153,7 +153,7 @@ function newTimeScale () { try { let code = JSON.parse(thisObject.payload.node.code) code.scale = thisObject.scale / MAX_SCALE * 100 - code.scale = code.scale.toFixed(2) + code.scale = code.scale.toFixed(0) thisObject.payload.node.code = JSON.stringify(code) } catch (err) { // we ignore errors here since most likely they will be parsing errors. @@ -275,7 +275,7 @@ function newTimeScale () { let backgroundColor = UI_COLOR.BLACK if (scaleTimer > 0) { - label2 = thisObject.scale.toFixed(0) + label2 = (thisObject.scale / MAX_SCALE * 100).toFixed(0) label3 = 'SCALE' } From cf603ce8cdb21838537c25e34854c25a52b4fe27 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 20 Jan 2020 09:52:55 +0100 Subject: [PATCH 180/264] Bug fixed with time scale affecting rate scale --- ChartsSpace/TimelineChart.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index d8107082b..61b51f716 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -43,6 +43,7 @@ function newTimelineChart () { let rateScaleUpstreamEventSuscriptionId let rateScaleMouseOverEventSuscriptionId let rateScaleOffsetEventSuscriptionId + let rateScaleUpstreamDimensionsEventSuscriptionId let timeFrameScaleEventSuscriptionId let timeFrameScaleMouseOverEventSuscriptionId @@ -121,6 +122,7 @@ function newTimelineChart () { thisObject.rateScale.container.eventHandler.stopListening(rateScaleValueEventSuscriptionId) thisObject.rateScale.container.eventHandler.stopListening(rateScaleMouseOverEventSuscriptionId) thisObject.container.parentContainer.eventHandler.stopListening(rateScaleUpstreamEventSuscriptionId) + thisObject.container.parentContainer.eventHandler.stopListening(rateScaleUpstreamDimensionsEventSuscriptionId) thisObject.rateScale.finalize() thisObject.rateScale = undefined @@ -177,8 +179,15 @@ function newTimelineChart () { rateScaleValueEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('Rate Scale Value Changed', rateScaleValueChanged) rateScaleMouseOverEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('onMouseOverScale', rateScaleMouseOver) rateScaleUpstreamEventSuscriptionId = thisObject.container.parentContainer.eventHandler.listenToEvent('Upstream Rate Scale Value Changed', rateScaleUpstreamChanged) + rateScaleUpstreamDimensionsEventSuscriptionId = thisObject.container.parentContainer.eventHandler.listenToEvent('Dimmensions Changed', rateScaleUpstreamDimensioinsChanged) thisObject.rateScale.initialize(timelineChartCoordinateSystem, thisObject.container.parentContainer, thisObject.container) + function rateScaleUpstreamDimensioinsChanged () { + thisObject.container.frame.height = TIME_MACHINE_HEIGHT + TIME_MACHINE_HEIGHT * thisObject.rateScale.scale + recalculateCoordinateSystem() + thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) + } + function rateScaleUpstreamChanged (event) { thisObject.rateScale.setScale(event.scale) } From b38a91c59193fed8c41b1f13d86fa3873c052a05 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 20 Jan 2020 10:14:28 +0100 Subject: [PATCH 181/264] Automatic changing time frame only with shift key --- ChartsSpace/ViewPort.js | 3 ++- Scales/TimeFrameScale.js | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ChartsSpace/ViewPort.js b/ChartsSpace/ViewPort.js index 7a66442cf..01b7d5627 100644 --- a/ChartsSpace/ViewPort.js +++ b/ChartsSpace/ViewPort.js @@ -204,7 +204,8 @@ function newViewport () { let newEvent = { newLevel: thisObject.zoomTargetLevel, newPosition: position, - type: undefined + type: undefined, + shiftKey: event.shiftKey } if (amount > 0) { diff --git a/Scales/TimeFrameScale.js b/Scales/TimeFrameScale.js index e6e49e99b..7477ccb7b 100644 --- a/Scales/TimeFrameScale.js +++ b/Scales/TimeFrameScale.js @@ -179,6 +179,7 @@ function newTimeFrameScale () { function onViewportZoomChanged (event) { if (event !== undefined) { // it is undefined when the level is just being animated. + if (event.shiftKey === false) { return } // with no shft key pressed, no automatic change in scale let currentTimeFrame = thisObject.timeFrame let timeFrame = recalculatePeriod(event.newLevel) if (timeFrame !== currentTimeFrame) { From 0c8ff0fd800c3d650f030eba982da5bf84b80a3f Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 20 Jan 2020 11:13:33 +0100 Subject: [PATCH 182/264] bug fixed when reloading with daily files --- ChartsSpace/TimelineChart.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 61b51f716..8bba45db6 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -139,7 +139,7 @@ function newTimelineChart () { timeMachineCoordinateSystem = pTimeMachineCoordinateSystem timeFrame = INITIAL_TIME_PERIOD - datetime = NEW_SESSION_INITIAL_DATE + recalculateCurrentDatetime() /* Event Subscriptions - we need this events to be fired first here and then in active Plotters. */ onViewportPositionChangedEventSuscriptionId = canvas.chartSpace.viewport.eventHandler.listenToEvent('Position Changed', onViewportPositionChanged) @@ -168,6 +168,7 @@ function newTimelineChart () { thisObject.plotterManager.payload = thisObject.payload thisObject.plotterManager.initialize(thisObject.layersManager, DEFAULT_EXCHANGE, DEFAULT_MARKET) thisObject.plotterManager.setTimeFrame(timeFrame) + thisObject.plotterManager.setDatetime(datetime) } function initializeRateScale () { From 05debc3b55075ce9f73010177bdb52bd05acc44f Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 20 Jan 2020 14:58:49 +0100 Subject: [PATCH 183/264] Bug fixed with scales with no offset --- Scales/RateScale.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Scales/RateScale.js b/Scales/RateScale.js index 91ee28952..8e9360c05 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -233,6 +233,10 @@ function newRateScale () { saveObjectState() return } + if (isNaN(code.offset) || code.offset === null || code.offset === undefined) { + saveObjectState() + return + } code.scale = code.scale / 100 * MAX_SCALE if (code.scale < MIN_SCALE) { code.scale = MIN_SCALE } if (code.scale > MAX_SCALE) { code.scale = MAX_SCALE } From ca6463c264d8575815138fb6aaf4d092156ee09b Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 20 Jan 2020 15:26:51 +0100 Subject: [PATCH 184/264] min and max value of rate scales --- ChartsSpace/TimeMachine.js | 2 +- ChartsSpace/TimelineChart.js | 2 +- ChartsSpace/ViewPort.js | 4 ++-- Globals.js | 2 +- Plotter.js | 2 +- Project.njsproj | 2 +- Scales/RateScale.js | 42 +++++++++++++++++++++++++----------- Scales/TimeFrameScale.js | 10 ++++----- Scales/TimeScale.js | 14 ++++++------ Utilities.js | 28 ++++++++++++------------ 10 files changed, 62 insertions(+), 46 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 5baf9bb8c..6ab58e459 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -526,7 +526,7 @@ function newTimeMachine () { let maxValue = { x: MAX_PLOTABLE_DATE.valueOf(), - y: nextPorwerOf10(USDT_BTC_HTH) / 4 + y: nextPorwerOf10(MAX_DEFAULT_RATE_SCALE_VALUE) / 4 } timeMachineCoordinateSystem.initialize( diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 8bba45db6..05a1bbf65 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -455,7 +455,7 @@ function newTimelineChart () { let maxValue = { x: MAX_PLOTABLE_DATE.valueOf(), - y: nextPorwerOf10(USDT_BTC_HTH) / 4 + y: nextPorwerOf10(MAX_DEFAULT_RATE_SCALE_VALUE) / 4 } timelineChartCoordinateSystem.initialize( diff --git a/ChartsSpace/ViewPort.js b/ChartsSpace/ViewPort.js index 01b7d5627..354c43747 100644 --- a/ChartsSpace/ViewPort.js +++ b/ChartsSpace/ViewPort.js @@ -135,11 +135,11 @@ function newViewport () { function physics () { animationPhysics() - positioningphysics() + positioningPhysics() readObjectState() } - function positioningphysics () { + function positioningPhysics () { if (thisObject.payload === undefined) { return } /* Save the position at the frame lavel */ let frame = {} diff --git a/Globals.js b/Globals.js index e3d45800f..bb8d53ef0 100644 --- a/Globals.js +++ b/Globals.js @@ -117,7 +117,7 @@ const DEFAULT_CONFIG_TEXT = '// Write your config here' const DEFAULT_FORMULA_TEXT = '// Write your formula here' const DEFAULT_CODE_TEXT = '// Write your code here' -const USDT_BTC_HTH = 19900; // This is needed to know the scale of the market time line. +const MAX_DEFAULT_RATE_SCALE_VALUE = 19900; // This is needed to know the scale of the market time line. const WIDHTER_VOLUME_BAR_BASE_FACTOR = 2.5; const LESS_WIDHTER_VOLUME_BAR_TOP_FACTOR = 1 / 4; diff --git a/Plotter.js b/Plotter.js index 2f73675b7..13b35c216 100644 --- a/Plotter.js +++ b/Plotter.js @@ -450,7 +450,7 @@ function newPlotter () { let maxValue = { x: MAX_PLOTABLE_DATE.valueOf(), - y: nextPorwerOf10(USDT_BTC_HTH) / 4 // TODO: This 4 is temporary + y: nextPorwerOf10(MAX_DEFAULT_RATE_SCALE_VALUE) / 4 // TODO: This 4 is temporary } coordinateSystem.initialize( diff --git a/Project.njsproj b/Project.njsproj index 99fe110d0..3dedf7ed3 100644 --- a/Project.njsproj +++ b/Project.njsproj @@ -158,7 +158,7 @@ - + Code diff --git a/Scales/RateScale.js b/Scales/RateScale.js index 8e9360c05..822bcd31c 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -8,6 +8,8 @@ function newRateScale () { payload: undefined, scale: undefined, offset: undefined, + minValue: undefined, + maxValue: undefined, setScale: setScale, onMouseOverSomeTimeMachineContainer: onMouseOverSomeTimeMachineContainer, physics: physics, @@ -50,7 +52,7 @@ function newRateScale () { let onMouseOverEventSubscriptionId let onMouseNotOverEventSubscriptionId - let timeLineCoordinateSystem + let coordinateSystem let limitingContainer let rateCalculationsContainer @@ -75,14 +77,14 @@ function newRateScale () { thisObject.fitFunction = undefined thisObject.payload = undefined - timeLineCoordinateSystem = undefined + coordinateSystem = undefined limitingContainer = undefined rateCalculationsContainer = undefined mouse = undefined } - function initialize (pTimeLineCoordinateSystem, pLimitingContainer, pRateCalculationsContainer) { - timeLineCoordinateSystem = pTimeLineCoordinateSystem + function initialize (pCoordinateSystem, pLimitingContainer, pRateCalculationsContainer) { + coordinateSystem = pCoordinateSystem limitingContainer = pLimitingContainer rateCalculationsContainer = pRateCalculationsContainer @@ -233,10 +235,7 @@ function newRateScale () { saveObjectState() return } - if (isNaN(code.offset) || code.offset === null || code.offset === undefined) { - saveObjectState() - return - } + code.scale = code.scale / 100 * MAX_SCALE if (code.scale < MIN_SCALE) { code.scale = MIN_SCALE } if (code.scale > MAX_SCALE) { code.scale = MAX_SCALE } @@ -258,6 +257,11 @@ function newRateScale () { return } + if (isNaN(code.offset) || code.offset === null || code.offset === undefined) { + saveObjectState() + return + } + if (code.offset < MIN_OFFSET) { code.offset = MIN_OFFSET } if (code.offset > MAX_OFFSET) { code.offset = MAX_OFFSET } @@ -277,6 +281,18 @@ function newRateScale () { saveObjectState() return } + + if (isNaN(code.minValue) || code.minValue === null || code.minValue === undefined) { + saveObjectState() + return + } + if (isNaN(code.maxValue) || code.maxValue === null || code.maxValue === undefined) { + saveObjectState() + return + } + + coordinateSystem.min.y = code.minValue + coordinateSystem.max.y = code.maxValue } catch (err) { // we ignore errors here since most likely they will be parsing errors. } @@ -286,10 +302,10 @@ function newRateScale () { offsetTimer-- scaleTimer-- readObjectState() - positioningphysics() + positioningPhysics() } - function positioningphysics () { + function positioningPhysics () { /* Container Limits */ let upCorner = { @@ -336,7 +352,7 @@ function newRateScale () { y: mouse.position.y + thisObject.offset } - thisObject.rate = getRateFromPoint(ratePoint, rateCalculationsContainer, timeLineCoordinateSystem) + thisObject.rate = getRateFromPoint(ratePoint, rateCalculationsContainer, coordinateSystem) /* rateScale Positioning */ ratePoint = { @@ -376,8 +392,8 @@ function newRateScale () { let rate = thisObject.rate - if (rate < timeLineCoordinateSystem.min.y) { rate = timeLineCoordinateSystem.min.y } - if (rate > timeLineCoordinateSystem.max.y) { rate = timeLineCoordinateSystem.max.y } + if (rate < coordinateSystem.min.y) { rate = coordinateSystem.min.y } + if (rate > coordinateSystem.max.y) { rate = coordinateSystem.max.y } let label = (rate - Math.trunc(rate)).toFixed(2) let labelArray = label.split('.') diff --git a/Scales/TimeFrameScale.js b/Scales/TimeFrameScale.js index 7477ccb7b..6792db3a5 100644 --- a/Scales/TimeFrameScale.js +++ b/Scales/TimeFrameScale.js @@ -32,7 +32,7 @@ function newTimeFrameScale () { let onMouseOverEventSubscriptionId let onMouseNotOverEventSubscriptionId - let timeLineCoordinateSystem + let coordinateSystem let limitingContainer let mouse = { @@ -69,8 +69,8 @@ function newTimeFrameScale () { thisObject.payload = undefined } - function initialize (pTimeLineCoordinateSystem, pLimitingContainer) { - timeLineCoordinateSystem = pTimeLineCoordinateSystem + function initialize (pCoordinateSystem, pLimitingContainer) { + coordinateSystem = pCoordinateSystem limitingContainer = pLimitingContainer readObjectState() @@ -114,10 +114,10 @@ function newTimeFrameScale () { function physics () { readObjectState() - positioningphysics() + positioningPhysics() } - function positioningphysics () { + function positioningPhysics () { /* Container Limits */ let upCorner = { diff --git a/Scales/TimeScale.js b/Scales/TimeScale.js index 5d2d193fb..16a81aad0 100644 --- a/Scales/TimeScale.js +++ b/Scales/TimeScale.js @@ -40,7 +40,7 @@ function newTimeScale () { let onMouseOverEventSubscriptionId let onMouseNotOverEventSubscriptionId - let timeLineCoordinateSystem + let coordinateSystem let limitingContainer let mouse = { @@ -62,13 +62,13 @@ function newTimeScale () { thisObject.fitFunction = undefined thisObject.payload = undefined - timeLineCoordinateSystem = undefined + coordinateSystem = undefined limitingContainer = undefined mouse = undefined } - function initialize (pTimeLineCoordinateSystem, pLimitingContainer) { - timeLineCoordinateSystem = pTimeLineCoordinateSystem + function initialize (pCoordinateSystem, pLimitingContainer) { + coordinateSystem = pCoordinateSystem limitingContainer = pLimitingContainer onMouseWheelEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) @@ -195,10 +195,10 @@ function newTimeScale () { function physics () { scaleTimer-- readObjectState() - positioningphysics() + positioningPhysics() } - function positioningphysics () { + function positioningPhysics () { /* Container Limits */ let upCorner = { @@ -223,7 +223,7 @@ function newTimeScale () { y: 0 } - let mouseDate = getDateFromPoint(timePoint, limitingContainer, timeLineCoordinateSystem) + let mouseDate = getDateFromPoint(timePoint, limitingContainer, coordinateSystem) thisObject.date = new Date(mouseDate) diff --git a/Utilities.js b/Utilities.js index 5ec3e13b4..73029d645 100644 --- a/Utilities.js +++ b/Utilities.js @@ -82,30 +82,30 @@ function pad (str, max) { return str.length < max ? pad('0' + str, max) : str } -function getDateFromPoint (point, container, timeLineCoordinateSystem) { +function getDateFromPoint (point, container, coordinateSystem) { point = unTransformThisPoint(point, container) - point = timeLineCoordinateSystem.unInverseTransform(point, container.frame.height) + point = coordinateSystem.unInverseTransform(point, container.frame.height) let date = new Date(point.x) return date } -function getRateFromPoint (point, container, timeLineCoordinateSystem) { +function getRateFromPoint (point, container, coordinateSystem) { point = unTransformThisPoint(point, container) - point = timeLineCoordinateSystem.unInverseTransform(point, container.frame.height) + point = coordinateSystem.unInverseTransform(point, container.frame.height) return point.y } -function getMilisecondsFromPoint (point, container, timeLineCoordinateSystem) { +function getMilisecondsFromPoint (point, container, coordinateSystem) { point = unTransformThisPoint(point, container) - point = timeLineCoordinateSystem.unInverseTransform(point, container.frame.height) + point = coordinateSystem.unInverseTransform(point, container.frame.height) return point.x } -function saveUserPosition (container, timeLineCoordinateSystem, position) { +function saveUserPosition (container, coordinateSystem, position) { if (position === undefined) { position = { x: (canvas.chartSpace.viewport.visibleArea.bottomRight.x - canvas.chartSpace.viewport.visibleArea.topLeft.x) / 2, @@ -114,8 +114,8 @@ function saveUserPosition (container, timeLineCoordinateSystem, position) { } let userPosition = { - date: getDateFromPoint(position, container, timeLineCoordinateSystem), - rate: getRateFromPoint(position, container, timeLineCoordinateSystem), + date: getDateFromPoint(position, container, coordinateSystem), + rate: getRateFromPoint(position, container, coordinateSystem), market: DEFAULT_MARKET, zoom: canvas.chartSpace.viewport.zoomTargetLevel } @@ -123,14 +123,14 @@ function saveUserPosition (container, timeLineCoordinateSystem, position) { window.localStorage.setItem('userPosition', JSON.stringify(userPosition)) } -function getUserPosition (timeLineCoordinateSystem) { +function getUserPosition (coordinateSystem) { let savedPosition = window.localStorage.getItem('userPosition') let userPosition if (savedPosition === null) { userPosition = { date: (new Date()).toString(), - rate: timeLineCoordinateSystem.max.y / 2, + rate: coordinateSystem.max.y / 2, market: DEFAULT_MARKET, zoom: INITIAL_ZOOM_LEVEL } @@ -146,8 +146,8 @@ function getUserPosition (timeLineCoordinateSystem) { return userPosition } -function moveToUserPosition (container, timeLineCoordinateSystem, ignoreX, ignoreY, center, moveContainer) { - let userPosition = getUserPosition(timeLineCoordinateSystem) +function moveToUserPosition (container, coordinateSystem, ignoreX, ignoreY, center, moveContainer) { + let userPosition = getUserPosition(coordinateSystem) INITIAL_TIME_PERIOD = recalculatePeriod(userPosition.zoom) NEW_SESSION_INITIAL_DATE = new Date(userPosition.date) @@ -159,7 +159,7 @@ function moveToUserPosition (container, timeLineCoordinateSystem, ignoreX, ignor /* Put this po int in the coordinate system of the canvas.chartSpace.viewport */ - targetPoint = timeLineCoordinateSystem.transformThisPoint(targetPoint) + targetPoint = coordinateSystem.transformThisPoint(targetPoint) targetPoint = transformThisPoint(targetPoint, container) let centerPoint From 98384659d89c70d7d40b9889815a13d6da4e117c Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 21 Jan 2020 07:52:28 +0100 Subject: [PATCH 185/264] Adding Session Dependent Data --- Panels/Layer.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Panels/Layer.js b/Panels/Layer.js index 537a6ac99..032e52b97 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -127,8 +127,10 @@ function newLayer () { let functionLibraryProtocolNode = newProtocolNode() let lightingPath = '->Layer->' + - 'Data Product->Single Market Data->Market->' + - 'Market Base Asset->Asset->' + + 'Data Product->Single Market Data->' + + 'Session Independent Data->Session Based Data->' + + 'Session Instance->Backtesting Session->Paper Trading Session->Fordward Testing Session->Live Trading Session->' + + 'Market->Market Base Asset->Asset->' + 'Market Quoted Asset->Asset->' + 'Exchange Markets->Crypto Exchange->' + 'Product Definition->' + @@ -485,4 +487,3 @@ function newLayer () { drawIcon(icon4, 4.6 / 8, 2 / 10, 0, 0, 14, thisObject.container) } } - From 1e3b82ed22a96d72a12fa55cf6965d4c447abc30 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 21 Jan 2020 11:54:31 +0100 Subject: [PATCH 186/264] Simulation working again --- ChartsSpace/PlottersManager.js | 8 ++++++++ .../Workspace/FunctionLibraries/TaskFunctions.js | 2 +- Panels/Layer.js | 2 +- Panels/LayersPanel.js | 7 ++++--- Spaces/ChartSpace.js | 1 + 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/ChartsSpace/PlottersManager.js b/ChartsSpace/PlottersManager.js index 593248445..169e10ca7 100644 --- a/ChartsSpace/PlottersManager.js +++ b/ChartsSpace/PlottersManager.js @@ -150,6 +150,14 @@ function newPlottersManager () { let plotterModule = layer.definition.referenceParent.referenceParent.referenceParent let session + if (layer.definition.referenceParent.parentNode.parentNode !== undefined) { + if (layer.definition.referenceParent.parentNode.parentNode.type === 'Session Reference') { + if (layer.definition.referenceParent.parentNode.parentNode.referenceParent !== undefined) { + session = layer.definition.referenceParent.parentNode.parentNode.referenceParent + } + } + } + storage.initialize( dataMine, bot, diff --git a/DesignerSpace/Workspace/FunctionLibraries/TaskFunctions.js b/DesignerSpace/Workspace/FunctionLibraries/TaskFunctions.js index 9073bf7ff..3a1d3ca57 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/TaskFunctions.js +++ b/DesignerSpace/Workspace/FunctionLibraries/TaskFunctions.js @@ -29,7 +29,7 @@ function newTaskFunctions () { 'Indicator Bot Instance->' + 'Trading Bot Instance->' + 'Process Instance->' + - 'Market Instance->Market->Exchange Markets->Crypto Exchange->' + + 'Market Reference->Market->Exchange Markets->Crypto Exchange->' + 'Market Base Asset->Market Quoted Asset->Asset->' + 'Backtesting Session->Live Trading Session->Paper Trading Session->Fordward Testing Session->' + 'Process Definition->' + diff --git a/Panels/Layer.js b/Panels/Layer.js index 032e52b97..41eac1827 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -129,7 +129,7 @@ function newLayer () { '->Layer->' + 'Data Product->Single Market Data->' + 'Session Independent Data->Session Based Data->' + - 'Session Instance->Backtesting Session->Paper Trading Session->Fordward Testing Session->Live Trading Session->' + + 'Session Reference->Backtesting Session->Paper Trading Session->Fordward Testing Session->Live Trading Session->' + 'Market->Market Base Asset->Asset->' + 'Market Quoted Asset->Asset->' + 'Exchange Markets->Crypto Exchange->' + diff --git a/Panels/LayersPanel.js b/Panels/LayersPanel.js index f4c257052..2144c28f7 100644 --- a/Panels/LayersPanel.js +++ b/Panels/LayersPanel.js @@ -90,6 +90,7 @@ function newProductsPanel () { /* Now we create Product objects */ let layer = newLayer() layer.payload = layerNode.payload + layer.nodeId = layerNode.payload.node.id layer.fitFunction = thisObject.fitFunction /* Initialize it */ @@ -315,7 +316,7 @@ function newProductsPanel () { function turnOffUnusedLayers () { for (let i = 0; i < localLayers.length; i++) { let layer = localLayers[i] - removeLayer(layer.payload.node.id) + removeLayer(layer.nodeId) } } } @@ -334,8 +335,8 @@ function newProductsPanel () { } function drawHeader () { - let label1 = thisObject.payload.node.payload.parentNode.payload.parentNode.name.substring(0, 15) - let label2 = thisObject.payload.node.payload.parentNode.name.substring(0, 15) + let label1 = thisObject.payload.node.payload.parentNode.payload.parentNode.name.substring(0, 18) + let label2 = thisObject.payload.node.payload.parentNode.name.substring(0, 18) let label3 = '' let icon1 = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.payload.parentNode.payload.parentNode.type) diff --git a/Spaces/ChartSpace.js b/Spaces/ChartSpace.js index 25d105712..67b21038c 100644 --- a/Spaces/ChartSpace.js +++ b/Spaces/ChartSpace.js @@ -248,6 +248,7 @@ function newChartSpace () { } function syncWithDesigner () { + if (thisObject.payload.node === undefined) { return } syncWithDesignerLoop = syncWithDesignerLoop + 0.00000000001 if (thisObject.payload.node.timeMachines !== undefined) { From 07fb6435dd9a049c205940a831d7c44c73e12b94 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 21 Jan 2020 16:22:42 +0100 Subject: [PATCH 187/264] Removing Definition node --- .../Workspace/FunctionLibraries/ChainAttachDetach.js | 9 --------- .../Workspace/FunctionLibraries/SessionFunctions.js | 6 +++--- Spaces/FloatingSpace.js | 4 +++- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/DesignerSpace/Workspace/FunctionLibraries/ChainAttachDetach.js b/DesignerSpace/Workspace/FunctionLibraries/ChainAttachDetach.js index c147dd7a2..586a01dbd 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/ChainAttachDetach.js +++ b/DesignerSpace/Workspace/FunctionLibraries/ChainAttachDetach.js @@ -8,15 +8,6 @@ function newChainAttachDetach () { function chainDetachNode (node, rootNodes) { switch (node.type) { - case 'Definition': { - return - } - case 'Network': { - return - } - case 'Data Mine': { - return - } case 'Phase': { let payload = node.payload for (let i = 0; i < payload.parentNode.phases.length; i++) { diff --git a/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js b/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js index d7f2b61dc..1bd5f9c19 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js +++ b/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js @@ -30,7 +30,7 @@ function newSessionFunctions () { let key = node.name + '-' + node.type + '-' + node.id - let lightingPath = '->Definition->' + + let lightingPath = '' + 'Trading System->' + 'Parameters->' + 'Base Asset->Time Range->Time Frame->Slippage->Fee Structure->Exchange Account Key->' + @@ -46,12 +46,12 @@ function newSessionFunctions () { 'Situation->Condition->Javascript Code->' + 'Announcement->Telegram Bot->' - let definition = functionLibraryProtocolNode.getProtocolNode(node.payload.referenceParent, false, true, true, false, false, lightingPath) + let tradingSystem = functionLibraryProtocolNode.getProtocolNode(node.payload.referenceParent, false, true, true, false, false, lightingPath) /* Raise event to run the session */ let event = { session: JSON.stringify(functionLibraryProtocolNode.getProtocolNode(node, false, true, true)), - definition: JSON.stringify(definition), + tradingSystem: JSON.stringify(tradingSystem), uiCurrentValues: getUICurrentValues() } diff --git a/Spaces/FloatingSpace.js b/Spaces/FloatingSpace.js index 2c4ddef30..57f1f7b87 100644 --- a/Spaces/FloatingSpace.js +++ b/Spaces/FloatingSpace.js @@ -105,8 +105,10 @@ function newFloatingSpace () { /* Exceptions that are never considered far. */ if ( - payload.node.type === 'Definition' || + payload.node.type === 'Trading System' || payload.node.type === 'Network' || + payload.node.type === 'Crypto Ecosystem' || + payload.node.type === 'Charting System' || payload.node.type === 'Data Mine' ) { return false From d135e1aa4f31b1cbe5e3a16076b0d07a21463545 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 21 Jan 2020 18:38:00 +0100 Subject: [PATCH 188/264] Sending Keys the right way to task server --- ChartsSpace/TimeMachine.js | 6 +++--- .../Workspace/FunctionLibraries/SessionFunctions.js | 11 +++++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 6ab58e459..393e15bb0 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -459,7 +459,7 @@ function newTimeMachine () { function drawBackground () { if (thisObject.container.frame.isInViewPort()) { for (let i = 0; i < thisObject.timelineCharts.length; i++) { - let timelineChart = thisObject.timelineCharts[i] + let timelineChart = thisObject.timelineCharts[thisObject.timelineCharts.length - i - 1] timelineChart.drawBackground() } } @@ -468,7 +468,7 @@ function newTimeMachine () { function draw () { if (thisObject.container.frame.isInViewPort()) { for (let i = 0; i < thisObject.timelineCharts.length; i++) { - let timelineChart = thisObject.timelineCharts[i] + let timelineChart = thisObject.timelineCharts[thisObject.timelineCharts.length - i - 1] timelineChart.draw() } @@ -506,7 +506,7 @@ function newTimeMachine () { function drawForeground () { if (thisObject.container.frame.isInViewPort()) { for (let i = 0; i < thisObject.timelineCharts.length; i++) { - let timelineChart = thisObject.timelineCharts[i] + let timelineChart = thisObject.timelineCharts[thisObject.timelineCharts.length - i - 1] timelineChart.drawForeground() } diff --git a/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js b/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js index 1bd5f9c19..ac3abaa43 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js +++ b/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js @@ -33,7 +33,7 @@ function newSessionFunctions () { let lightingPath = '' + 'Trading System->' + 'Parameters->' + - 'Base Asset->Time Range->Time Frame->Slippage->Fee Structure->Exchange Account Key->' + + 'Base Asset->Time Range->Time Frame->Slippage->Fee Structure->Key Instance->Exchange Account Key->' + 'Strategy->' + 'Trigger Stage->Trigger On Event->Trigger Off Event->Take Position Event->' + 'Announcement->Telegram Bot->' + @@ -48,9 +48,16 @@ function newSessionFunctions () { let tradingSystem = functionLibraryProtocolNode.getProtocolNode(node.payload.referenceParent, false, true, true, false, false, lightingPath) + lightingPath = '' + + 'Backtesting Session->Paper Trading Session->Fordward Testing Session->Live Trading Session->' + + 'Parameters->' + + 'Base Asset->Time Range->Time Frame->Slippage->Fee Structure->Key Instance->Exchange Account Key->' + + let session = functionLibraryProtocolNode.getProtocolNode(node, false, true, true, false, false, lightingPath) + /* Raise event to run the session */ let event = { - session: JSON.stringify(functionLibraryProtocolNode.getProtocolNode(node, false, true, true)), + session: JSON.stringify(session), tradingSystem: JSON.stringify(tradingSystem), uiCurrentValues: getUICurrentValues() } From 2d25e1c45df6bb0520959d365648a57b07898a04 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 23 Jan 2020 17:16:54 +0100 Subject: [PATCH 189/264] more text --- FloatingSpace/UiObject.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index d59f9fdc9..0ebf646e7 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -1091,7 +1091,7 @@ function newUiObject () { let label if (radius > 6) { - const MAX_LABEL_LENGTH = 30 + const MAX_LABEL_LENGTH = 45 label = currentValue if (!isNaN(label)) { From 031c532bf38ae8d8208f52033d7892a8a9f97554 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 24 Jan 2020 08:57:58 +0100 Subject: [PATCH 190/264] bug fixed --- Utilities.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utilities.js b/Utilities.js index 73029d645..7b68ea56f 100644 --- a/Utilities.js +++ b/Utilities.js @@ -19,9 +19,9 @@ function loadFrame (payload, frame) { frame.width = payload.node.savedPayload.frame.width frame.height = payload.node.savedPayload.frame.height frame.radius = payload.node.savedPayload.frame.radius + payload.node.savedPayload.frame = undefined } } - payload.node.savedPayload.frame = undefined } function convertTimeFrameToName (pTimeFrame) { From fa1345ce43231f257b49beef7038e22ed74762ea Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 24 Jan 2020 10:45:43 +0100 Subject: [PATCH 191/264] removing the concept of subtypes --- Dashboard.js | 8 +-- .../FunctionLibraries/NodeCloning.js | 3 - .../FunctionLibraries/ProtocolNode.js | 2 - .../FunctionLibraries/TaskFunctions.js | 2 +- .../FunctionLibraries/UiObjectsFromNodes.js | 4 +- FloatingSpace/UiObject.js | 59 ++++--------------- 6 files changed, 16 insertions(+), 62 deletions(-) diff --git a/Dashboard.js b/Dashboard.js index 16e514b82..80373e057 100644 --- a/Dashboard.js +++ b/Dashboard.js @@ -32,12 +32,8 @@ function newDashboard () { APP_SCHEMA_ARRAY = getAppSchema() for (let i = 0; i < APP_SCHEMA_ARRAY.length; i++) { let nodeDefinition = APP_SCHEMA_ARRAY[i] - let key - if (nodeDefinition.subType !== undefined) { - key = nodeDefinition.type + '-' + nodeDefinition.subType - } else { - key = nodeDefinition.type - } + let key = nodeDefinition.type + APP_SCHEMA_MAP.set(key, nodeDefinition) } diff --git a/DesignerSpace/Workspace/FunctionLibraries/NodeCloning.js b/DesignerSpace/Workspace/FunctionLibraries/NodeCloning.js index 66fb01a3d..ab81e42a6 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/NodeCloning.js +++ b/DesignerSpace/Workspace/FunctionLibraries/NodeCloning.js @@ -23,7 +23,6 @@ function newNodeCloning () { if (nodeDefinition !== undefined) { let object = { type: node.type, - subType: node.subType, name: node.name, code: node.code } @@ -76,7 +75,6 @@ function newNodeCloning () { if (nodeDefinition !== undefined) { let object = { type: node.type, - subType: node.subType, name: node.name, code: node.code } @@ -159,7 +157,6 @@ function newNodeCloning () { if (node.payload.referenceParent !== undefined) { savedPayload.referenceParent = { type: node.payload.referenceParent.type, - subType: node.payload.referenceParent.subType, name: node.payload.referenceParent.name, id: node.payload.referenceParent.id } diff --git a/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js b/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js index 63e6ffb08..dc5ef92de 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js +++ b/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js @@ -18,7 +18,6 @@ function newProtocolNode () { if (removePersonalData === true && nodeDefinition.isPersonalData === true) { return } let object = { type: node.type, - subType: node.subType, name: node.name, code: node.code } @@ -174,7 +173,6 @@ function newProtocolNode () { if (node.payload.referenceParent !== undefined) { savedPayload.referenceParent = { type: node.payload.referenceParent.type, - subType: node.payload.referenceParent.subType, name: node.payload.referenceParent.name, id: node.payload.referenceParent.id } diff --git a/DesignerSpace/Workspace/FunctionLibraries/TaskFunctions.js b/DesignerSpace/Workspace/FunctionLibraries/TaskFunctions.js index 3a1d3ca57..9d248f052 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/TaskFunctions.js +++ b/DesignerSpace/Workspace/FunctionLibraries/TaskFunctions.js @@ -28,7 +28,7 @@ function newTaskFunctions () { 'Sensor Bot Instance->' + 'Indicator Bot Instance->' + 'Trading Bot Instance->' + - 'Process Instance->' + + 'Sensor Process Instance->Indicator Process Instance->Trading Process Instance->' + 'Market Reference->Market->Exchange Markets->Crypto Exchange->' + 'Market Base Asset->Market Quoted Asset->Asset->' + 'Backtesting Session->Live Trading Session->Paper Trading Session->Fordward Testing Session->' + diff --git a/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js b/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js index 9278eaa6a..591efb69a 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js +++ b/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js @@ -76,8 +76,8 @@ function newUiObjectsFromNodes () { for (let j = 0; j < nodeChildren.length; j++) { if (node.id === nodeChildren[j].id) { if (j > 0) { - chainParent = nodeChildren[j - 1] - } + chainParent = nodeChildren[j - 1] + } } } } diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index 0ebf646e7..2337df4aa 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -282,40 +282,18 @@ function newUiObject () { let nearbyFloatingObjects = thisObject.payload.floatingObject.nearbyFloatingObjects let compatibleTypes - let compatibleSubTypes - switch (thisObject.payload.node.type) { - case 'Process Instance': - switch (thisObject.payload.node.subType) { - case 'Sensor Process Instance': { - compatibleTypes = '->' + 'Sensor Bot Instance' + '->' - break - } - case 'Indicator Process Instance': { - compatibleTypes = '->' + 'Indicator Bot Instance' + '->' - break - } - case 'Trading Process Instance': { - compatibleTypes = '->' + 'Trading Bot Instance' + '->' - break - } - } - compatibleSubTypes = undefined - break - - default: - let nodeDefinition = APP_SCHEMA_MAP.get(thisObject.payload.node.type) - if (nodeDefinition !== undefined) { - if (nodeDefinition.chainAttachesTo !== undefined) { - compatibleTypes = nodeDefinition.chainAttachesTo.compatibleTypes - compatibleSubTypes = nodeDefinition.chainAttachesTo.compatibleSubTypes - } else { - return - } - } else { - return - } + let nodeDefinition = APP_SCHEMA_MAP.get(thisObject.payload.node.type) + if (nodeDefinition !== undefined) { + if (nodeDefinition.chainAttachesTo !== undefined) { + compatibleTypes = nodeDefinition.chainAttachesTo.compatibleTypes + } else { + return + } + } else { + return } + let foundCompatible = false chainAttachToNode = undefined isChainAttaching = false @@ -327,7 +305,7 @@ function newUiObject () { let nearbyNode = floatingObject.payload.node if (compatibleTypes.indexOf('->' + nearbyNode.type + '->') >= 0) { /* Discard App Schema defined objects with busy coonection ports */ - let nodeDefinition = APP_SCHEMA_MAP.get(thisObject.payload.node.type) + nodeDefinition = APP_SCHEMA_MAP.get(thisObject.payload.node.type) if (nodeDefinition !== undefined) { let mustContinue = false let parentNodeDefinition = APP_SCHEMA_MAP.get(nearbyNode.type) @@ -355,12 +333,6 @@ function newUiObject () { if (mustContinue === true) { continue } } - /* Here we check if the subtypes are compatible. */ - if (nearbyNode.subType !== undefined && compatibleSubTypes !== undefined) { - if (compatibleSubTypes.indexOf('->' + nearbyNode.subType + '->') < 0) { - continue - } - } /* Discard Phases without partent */ if (thisObject.payload.node.type === 'Phase' && nearbyNode.type === 'Phase' && nearbyNode.payload.parentNode === undefined) { continue } /* Control maxPhases */ @@ -463,13 +435,11 @@ function newUiObject () { let nearbyFloatingObjects = thisObject.payload.floatingObject.nearbyFloatingObjects let compatibleTypes - let compatibleSubTypes let nodeDefinition = APP_SCHEMA_MAP.get(thisObject.payload.node.type) if (nodeDefinition !== undefined) { if (nodeDefinition.referenceAttachesTo !== undefined) { compatibleTypes = nodeDefinition.referenceAttachesTo.compatibleTypes - compatibleSubTypes = nodeDefinition.referenceAttachesTo.compatibleSubTypes } else { return } @@ -487,13 +457,6 @@ function newUiObject () { let floatingObject = nearby[1] let nearbyNode = floatingObject.payload.node if (compatibleTypes.indexOf('->' + nearbyNode.type + '->') >= 0) { - /* Here we check if the subtypes are compatible. */ - if (nearbyNode.subType !== undefined && compatibleSubTypes !== undefined) { - if (compatibleSubTypes.indexOf('->' + nearbyNode.subType + '->') < 0) { - continue - } - } - if (foundCompatible === false) { if (distance < thisObject.container.frame.radius * 1.5 + floatingObject.container.frame.radius * 1.5) { nearbyNode.payload.uiObject.getReadyToReferenceAttach() From 59474ac38df495c71a929cbeb5e6d4595d6e29ee Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 24 Jan 2020 12:02:18 +0100 Subject: [PATCH 192/264] Multiple Title Sources --- FloatingSpace/UiObject.js | 2 +- FloatingSpace/UiObjectTitle.js | 67 ++++++++++++++++++++++++++-------- 2 files changed, 53 insertions(+), 16 deletions(-) diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index 2337df4aa..7749e78ce 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -646,7 +646,7 @@ function newUiObject () { nodeToUse = thisObject.payload.node.payload.referenceParent } } - if (nodeDefinition.alternativeIcons === 'Use Reference Gran Parent') { + if (nodeDefinition.alternativeIcons === 'Use Reference Grandparent') { if (thisObject.payload.node.payload.referenceParent !== undefined) { if (thisObject.payload.node.payload.referenceParent.payload.referenceParent !== undefined) { nodeToUse = thisObject.payload.node.payload.referenceParent.payload.referenceParent diff --git a/FloatingSpace/UiObjectTitle.js b/FloatingSpace/UiObjectTitle.js index 41ca0ebd8..3879c64ee 100644 --- a/FloatingSpace/UiObjectTitle.js +++ b/FloatingSpace/UiObjectTitle.js @@ -82,29 +82,67 @@ function newUiObjectTitle () { function physics () { if (thisObject.payload.title === undefined) { return } - let title = trimTitle(thisObject.payload.title) /* It is possible to override the default title by setting the APP SCHEMA property 'title' */ let nodeDefinition = APP_SCHEMA_MAP.get(thisObject.payload.node.type) if (nodeDefinition.title !== undefined) { - let nodeToUse = thisObject.payload.node - if (nodeDefinition.title === 'Use Reference Parent') { - if (thisObject.payload.node.payload.referenceParent !== undefined) { - nodeToUse = thisObject.payload.node.payload.referenceParent - } - } - if (nodeDefinition.title === 'Use Reference Gran Parent') { - if (thisObject.payload.node.payload.referenceParent !== undefined) { - if (thisObject.payload.node.payload.referenceParent.payload.referenceParent !== undefined) { - nodeToUse = thisObject.payload.node.payload.referenceParent.payload.referenceParent + thisObject.payload.title = '' + thisObject.payload.node.name = '' + let separator = '' + for (let i = 0; i < nodeDefinition.title.length; i++) { + let titleReference = nodeDefinition.title[i] + switch (titleReference) { + case 'Use Reference Parent': { + let nodeToUse = thisObject.payload.node.payload.referenceParent + if (nodeToUse !== undefined) { + thisObject.payload.title = thisObject.payload.title + separator + nodeToUse.payload.title + thisObject.payload.node.name = thisObject.payload.node.name + separator + nodeToUse.payload.node.name + } + break + } + case 'Use Reference Grandparent': { + let nodeToUse = thisObject.payload.node.payload.referenceParent + if (nodeToUse !== undefined) { + nodeToUse = thisObject.payload.node.payload.referenceParent.payload.referenceParent + if (nodeToUse !== undefined) { + thisObject.payload.title = thisObject.payload.title + separator + nodeToUse.payload.title + thisObject.payload.node.name = thisObject.payload.node.name + separator + nodeToUse.payload.node.name + } + } + break + } + case 'Use Reference Parent Parent': { + let nodeToUse = thisObject.payload.node.payload.referenceParent + if (nodeToUse !== undefined) { + nodeToUse = thisObject.payload.node.payload.referenceParent.payload.parentNode + if (nodeToUse !== undefined) { + thisObject.payload.title = thisObject.payload.title + separator + nodeToUse.payload.title + thisObject.payload.node.name = thisObject.payload.node.name + separator + nodeToUse.payload.node.name + } + } + break + } + case 'Use Reference Parent Parent Parent': { + let nodeToUse = thisObject.payload.node.payload.referenceParent + if (nodeToUse !== undefined) { + nodeToUse = thisObject.payload.node.payload.referenceParent.payload.parentNode + if (nodeToUse !== undefined) { + nodeToUse = thisObject.payload.node.payload.referenceParent.payload.parentNode.payload.parentNode + if (nodeToUse !== undefined) { + thisObject.payload.title = thisObject.payload.title + separator + nodeToUse.payload.title + thisObject.payload.node.name = thisObject.payload.node.name + separator + nodeToUse.payload.node.name + } + } + } + break } } + separator = ' ' } - thisObject.payload.title = nodeToUse.payload.title - thisObject.payload.node.name = nodeToUse.payload.node.name - title = trimTitle(thisObject.payload.title) } + let title = trimTitle(thisObject.payload.title) + /* Here we set the dimensions and position of this object */ const FRAME_HEIGHT = 25 const Y_OFFSET = -20 @@ -258,4 +296,3 @@ function newUiObjectTitle () { return title } } - From e86fc67188e97dc14b7935d7027ec1b6bbe2194a Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 24 Jan 2020 12:52:06 +0100 Subject: [PATCH 193/264] spawn position bug fixed --- DesignerSpace/Workspace/Workspace.js | 4 ++-- FloatingSpace/UiObjectConstructor.js | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/DesignerSpace/Workspace/Workspace.js b/DesignerSpace/Workspace/Workspace.js index 7f16509a3..93985c5ac 100644 --- a/DesignerSpace/Workspace/Workspace.js +++ b/DesignerSpace/Workspace/Workspace.js @@ -226,8 +226,8 @@ function newWorkspace () { /* It does not exist, so we recreeate it respecting the inner state of each object. */ let positionOffset = { - x: spawnPosition.x - droppedNode.savedPayload.targetPosition.x, - y: spawnPosition.y - droppedNode.savedPayload.targetPosition.y + x: spawnPosition.x - droppedNode.savedPayload.position.x, + y: spawnPosition.y - droppedNode.savedPayload.position.y } thisObject.workspaceNode.rootNodes.push(droppedNode) diff --git a/FloatingSpace/UiObjectConstructor.js b/FloatingSpace/UiObjectConstructor.js index 961f589bc..110015794 100644 --- a/FloatingSpace/UiObjectConstructor.js +++ b/FloatingSpace/UiObjectConstructor.js @@ -46,9 +46,6 @@ function newUiObjectConstructor () { y: payload.node.savedPayload.position.y } - // if (position.x === undefined) { position.x = spawnPosition.x } - // if (position.y === undefined) { position.y = spawnPosition.y } - floatingObject.setPosition(position) payload.node.savedPayload.position = undefined if (payload.node.savedPayload.floatingObject.isPinned === true) { From c6b7f06434d2605ccee86af0c5b050db3064076d Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 24 Jan 2020 16:04:32 +0100 Subject: [PATCH 194/264] Ordar of drawing --- ChartsSpace/PlottersManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChartsSpace/PlottersManager.js b/ChartsSpace/PlottersManager.js index 169e10ca7..bade2aeb6 100644 --- a/ChartsSpace/PlottersManager.js +++ b/ChartsSpace/PlottersManager.js @@ -304,7 +304,7 @@ function newPlottersManager () { if (connectors === undefined) { return } // We need to wait /* First the Product Plotters. */ for (let i = 0; i < connectors.length; i++) { - let connector = connectors[i] + let connector = connectors[connectors.length - i - 1] connector.plotter.draw() } } From e1cd7aee1b9544e3431bce72d20afc82902db7f7 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 25 Jan 2020 12:48:07 +0100 Subject: [PATCH 195/264] bug fixed --- FloatingSpace/UiObjectTitle.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/FloatingSpace/UiObjectTitle.js b/FloatingSpace/UiObjectTitle.js index 3879c64ee..b014cd958 100644 --- a/FloatingSpace/UiObjectTitle.js +++ b/FloatingSpace/UiObjectTitle.js @@ -94,7 +94,7 @@ function newUiObjectTitle () { switch (titleReference) { case 'Use Reference Parent': { let nodeToUse = thisObject.payload.node.payload.referenceParent - if (nodeToUse !== undefined) { + if (nodeToUse !== undefined && nodeToUse.payload !== undefined) { thisObject.payload.title = thisObject.payload.title + separator + nodeToUse.payload.title thisObject.payload.node.name = thisObject.payload.node.name + separator + nodeToUse.payload.node.name } @@ -102,7 +102,7 @@ function newUiObjectTitle () { } case 'Use Reference Grandparent': { let nodeToUse = thisObject.payload.node.payload.referenceParent - if (nodeToUse !== undefined) { + if (nodeToUse !== undefined && nodeToUse.payload !== undefined) { nodeToUse = thisObject.payload.node.payload.referenceParent.payload.referenceParent if (nodeToUse !== undefined) { thisObject.payload.title = thisObject.payload.title + separator + nodeToUse.payload.title @@ -113,9 +113,9 @@ function newUiObjectTitle () { } case 'Use Reference Parent Parent': { let nodeToUse = thisObject.payload.node.payload.referenceParent - if (nodeToUse !== undefined) { + if (nodeToUse !== undefined && nodeToUse.payload !== undefined) { nodeToUse = thisObject.payload.node.payload.referenceParent.payload.parentNode - if (nodeToUse !== undefined) { + if (nodeToUse !== undefined && nodeToUse.payload !== undefined) { thisObject.payload.title = thisObject.payload.title + separator + nodeToUse.payload.title thisObject.payload.node.name = thisObject.payload.node.name + separator + nodeToUse.payload.node.name } @@ -124,11 +124,11 @@ function newUiObjectTitle () { } case 'Use Reference Parent Parent Parent': { let nodeToUse = thisObject.payload.node.payload.referenceParent - if (nodeToUse !== undefined) { + if (nodeToUse !== undefined && nodeToUse.payload !== undefined) { nodeToUse = thisObject.payload.node.payload.referenceParent.payload.parentNode - if (nodeToUse !== undefined) { + if (nodeToUse !== undefined && nodeToUse.payload !== undefined) { nodeToUse = thisObject.payload.node.payload.referenceParent.payload.parentNode.payload.parentNode - if (nodeToUse !== undefined) { + if (nodeToUse !== undefined && nodeToUse.payload !== undefined) { thisObject.payload.title = thisObject.payload.title + separator + nodeToUse.payload.title thisObject.payload.node.name = thisObject.payload.node.name + separator + nodeToUse.payload.node.name } From 3abce3db4b0d00e90f00528adc5d20c3d71e4875 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 27 Jan 2020 14:54:54 +0100 Subject: [PATCH 196/264] more values --- FloatingSpace/UiObject.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index 7749e78ce..5b59afb7e 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -1054,7 +1054,7 @@ function newUiObject () { let label if (radius > 6) { - const MAX_LABEL_LENGTH = 45 + const MAX_LABEL_LENGTH = 55 label = currentValue if (!isNaN(label)) { From f203b2cb7f6445dca13a1ef953f4bcf5c7ffbdcf Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 27 Jan 2020 19:19:03 +0100 Subject: [PATCH 197/264] new icons --- Spaces/DesignerSpace.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Spaces/DesignerSpace.js b/Spaces/DesignerSpace.js index 971a8cd95..d8504cfab 100644 --- a/Spaces/DesignerSpace.js +++ b/Spaces/DesignerSpace.js @@ -217,7 +217,11 @@ function newDesignerSpace () { 'histogram', 'band', 'volume', - 'candles' + 'candles', + 'bitmex', + 'liquid', + 'hitbtc', + 'us-dollar' ] for (let i = 0; i < iconsNames.length; i++) { From b9c239bb2e4e94dc0e0c4e0554e2d152dea579aa Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 27 Jan 2020 21:16:36 +0100 Subject: [PATCH 198/264] key instance changed --- DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js | 4 ++-- DesignerSpace/Workspace/FunctionLibraries/TaskFunctions.js | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js b/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js index ac3abaa43..5892c001a 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js +++ b/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js @@ -33,7 +33,7 @@ function newSessionFunctions () { let lightingPath = '' + 'Trading System->' + 'Parameters->' + - 'Base Asset->Time Range->Time Frame->Slippage->Fee Structure->Key Instance->Exchange Account Key->' + + 'Base Asset->Time Range->Time Frame->Slippage->Fee Structure->' + 'Strategy->' + 'Trigger Stage->Trigger On Event->Trigger Off Event->Take Position Event->' + 'Announcement->Telegram Bot->' + @@ -51,7 +51,7 @@ function newSessionFunctions () { lightingPath = '' + 'Backtesting Session->Paper Trading Session->Fordward Testing Session->Live Trading Session->' + 'Parameters->' + - 'Base Asset->Time Range->Time Frame->Slippage->Fee Structure->Key Instance->Exchange Account Key->' + 'Base Asset->Time Range->Time Frame->Slippage->Fee Structure->' let session = functionLibraryProtocolNode.getProtocolNode(node, false, true, true, false, false, lightingPath) diff --git a/DesignerSpace/Workspace/FunctionLibraries/TaskFunctions.js b/DesignerSpace/Workspace/FunctionLibraries/TaskFunctions.js index 9d248f052..ff624cb88 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/TaskFunctions.js +++ b/DesignerSpace/Workspace/FunctionLibraries/TaskFunctions.js @@ -29,7 +29,9 @@ function newTaskFunctions () { 'Indicator Bot Instance->' + 'Trading Bot Instance->' + 'Sensor Process Instance->Indicator Process Instance->Trading Process Instance->' + - 'Market Reference->Market->Exchange Markets->Crypto Exchange->' + + 'Market Reference->' + + 'Key Instance->Exchange Account Key->' + + 'Market->Exchange Markets->Crypto Exchange->' + 'Market Base Asset->Market Quoted Asset->Asset->' + 'Backtesting Session->Live Trading Session->Paper Trading Session->Fordward Testing Session->' + 'Process Definition->' + From 5e7446a450b8b5a8bfc8e06dcc15553f0c392af9 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 28 Jan 2020 09:17:36 +0100 Subject: [PATCH 199/264] more space --- FloatingSpace/UiObject.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index 5b59afb7e..1950f6b5e 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -1054,7 +1054,7 @@ function newUiObject () { let label if (radius > 6) { - const MAX_LABEL_LENGTH = 55 + const MAX_LABEL_LENGTH = 65 label = currentValue if (!isNaN(label)) { From 28dfa73a15a831b108ab2f8f249b05fa57e5620e Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 28 Jan 2020 16:21:03 +0100 Subject: [PATCH 200/264] no opacity --- ChartsSpace/TimelineChart.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 05a1bbf65..e608a00a5 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -419,7 +419,7 @@ function newTimelineChart () { function drawChartsBackground () { /* We will paint some transparent background here. */ - let opacity = '0.1' + let opacity = '0.0' let fromPoint = { x: 0, From 525f5ab324e83a72386b992ee9601db1eb29fa6f Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 28 Jan 2020 18:22:17 +0100 Subject: [PATCH 201/264] title change --- SplashScreen.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SplashScreen.js b/SplashScreen.js index 6efbdf87d..d10e27a6b 100644 --- a/SplashScreen.js +++ b/SplashScreen.js @@ -125,7 +125,7 @@ function newSplashScreen () { fontSize = 15 - title = 'Trading Automation System' + title = 'People and Machines working together to create Superalgos' titlePoint = { x: thisObject.container.frame.width / 2 - title.length / 2 * fontSize * FONT_ASPECT_RATIO - 20, From fda985bc57ee676de5996fabae2a0b4e04ebb3a9 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 29 Jan 2020 10:25:07 +0100 Subject: [PATCH 202/264] showPanles functionality implemented --- ChartsSpace/PlottersManager.js | 6 +- Globals.js | 2 +- Panels/Layer.js | 102 +++++++++++++++++++++++++++------ Panels/LayersPanel.js | 3 +- Panels/PanelsVisibleButton.js | 83 +++++++++++++++++++++++++++ Panels/PlotterPanel.js | 7 ++- 6 files changed, 177 insertions(+), 26 deletions(-) create mode 100644 Panels/PanelsVisibleButton.js diff --git a/ChartsSpace/PlottersManager.js b/ChartsSpace/PlottersManager.js index bade2aeb6..fda2ff6c6 100644 --- a/ChartsSpace/PlottersManager.js +++ b/ChartsSpace/PlottersManager.js @@ -219,6 +219,8 @@ function newPlottersManager () { connector.plotter.onRecordChangeEventsSubscriptionId = connector.plotter.container.eventHandler.listenToEvent('Current Record Changed', plotterPanel.onRecordChange) connector.panels.push(plotterPanelHandle) } + + connector.layer.panels = connector.panels } connectors.push(connector) @@ -237,7 +239,7 @@ function newPlottersManager () { } function onLayerStatusChanged (layer) { - if (layer.status === PRODUCT_CARD_STATUS.LOADING) { + if (layer.status === LAYER_STATUS.LOADING) { /* Lets see if we can find the Plotter of this card on our Active Plotters list, other wise we will initialize it */ let found = false for (let i = 0; i < connectors.length; i++) { @@ -253,7 +255,7 @@ function newPlottersManager () { } } } - if (layer.status === PRODUCT_CARD_STATUS.OFF) { + if (layer.status === LAYER_STATUS.OFF) { /* If the plotter of this card is not on our Active Plotters list, then we remove it. */ for (let i = 0; i < connectors.length; i++) { let connector = connectors[i] diff --git a/Globals.js b/Globals.js index bb8d53ef0..08ad5c1b7 100644 --- a/Globals.js +++ b/Globals.js @@ -164,7 +164,7 @@ const BREAKPOINT_HEIGHT = 15; const SIDE_PANEL_WIDTH = 450 let COCKPIT_SPACE_POSITION = browserCanvas.height - COCKPIT_SPACE_HEIGHT -const PRODUCT_CARD_STATUS = { +const LAYER_STATUS = { ON: 'on', LOADING: 'loading', OFF: 'off' diff --git a/Panels/Layer.js b/Panels/Layer.js index 41eac1827..babf7ded3 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -6,10 +6,11 @@ function newLayer () { let thisObject = { container: undefined, - status: PRODUCT_CARD_STATUS.OFF, + status: LAYER_STATUS.OFF, fitFunction: undefined, payload: undefined, definition: undefined, + panels: undefined, physics: physics, draw: draw, turnOff: turnOff, @@ -73,6 +74,7 @@ function newLayer () { thisObject.eventHandler = newEventHandler() let imagesLoaded = 0 let onMouseClickEventSuscriptionId + let panelsVisibleButton return thisObject @@ -85,6 +87,7 @@ function newLayer () { thisObject.fitFunction = undefined thisObject.payload = undefined thisObject.definition = undefined + thisObject.panels = undefined timeFrame = undefined datetime = undefined @@ -102,6 +105,8 @@ function newLayer () { singleFileProgressBar = undefined fileSequenceProgressBar = undefined + panelsVisibleButton = undefined + thisObject.container.eventHandler.stopListening(onMouseClickEventSuscriptionId) } @@ -114,7 +119,6 @@ function newLayer () { thisObject.container.isClickeable = true /* Lets set the basic dimensions of this thisObject. */ - let position = { x: 0, y: 0 @@ -173,6 +177,12 @@ function newLayer () { } function getContainer (point) { + if (panelsVisibleButton !== undefined) { + let container = panelsVisibleButton.getContainer(point) + if (container !== undefined) { + return container + } + } if (thisObject.container.frame.isThisPointHere(point, true) === true) { return thisObject.container } @@ -242,31 +252,31 @@ function newLayer () { } function turnOff () { - if (thisObject.status !== PRODUCT_CARD_STATUS.OFF) { + if (thisObject.status !== LAYER_STATUS.OFF) { resetProgressBars() - changeStatusTo(PRODUCT_CARD_STATUS.OFF) + changeStatusTo(LAYER_STATUS.OFF) } } function turnOn () { - if (thisObject.status === PRODUCT_CARD_STATUS.OFF) { + if (thisObject.status === LAYER_STATUS.OFF) { resetProgressBars() - changeStatusTo(PRODUCT_CARD_STATUS.LOADING) + changeStatusTo(LAYER_STATUS.LOADING) } } function onMouseClick (event) { switch (thisObject.status) { - case PRODUCT_CARD_STATUS.ON: + case LAYER_STATUS.ON: resetProgressBars() - changeStatusTo(PRODUCT_CARD_STATUS.OFF) + changeStatusTo(LAYER_STATUS.OFF) break - case PRODUCT_CARD_STATUS.OFF: + case LAYER_STATUS.OFF: resetProgressBars() - changeStatusTo(PRODUCT_CARD_STATUS.LOADING) + changeStatusTo(LAYER_STATUS.LOADING) break - case PRODUCT_CARD_STATUS.LOADING: - changeStatusTo(PRODUCT_CARD_STATUS.OFF) + case LAYER_STATUS.LOADING: + changeStatusTo(LAYER_STATUS.OFF) break } } @@ -294,6 +304,49 @@ function newLayer () { } function physics () { + statusPhysics() + childrenPhysics() + } + + function childrenPhysics () { + /* Panels Visible Button Setup */ + if (thisObject.status === LAYER_STATUS.ON) { + if (panelsVisibleButton === undefined) { + if (thisObject.panels !== undefined) { + if (thisObject.panels.length > 0) { + panelsVisibleButton = newPanelsVisibleButton() + + try { + let code = JSON.parse(thisObject.payload.node.code) + if (code.showPanels !== undefined) { + if (code.showPanels === true || code.showPanels === false) { + panelsVisibleButton.showPanels = code.showPanels + } + } + + thisObject.payload.node.code = JSON.stringify(code) + } catch (err) { + // we ignore errors here since most likely they will be parsing errors. + } + + panelsVisibleButton.initialize(thisObject.panels) + panelsVisibleButton.container.connectToParent(thisObject.container) + } + } + } else { + /* Saving the new status at the node config */ + try { + let code = JSON.parse(thisObject.payload.node.code) + code.showPanels = panelsVisibleButton.showPanels + thisObject.payload.node.code = JSON.stringify(code) + } catch (err) { + // we ignore errors here since most likely they will be parsing errors. + } + } + } + } + + function statusPhysics () { /* We retrieve the stored status at the config. */ try { let code = JSON.parse(thisObject.payload.node.code) @@ -301,18 +354,18 @@ function newLayer () { if (storedValue !== undefined) { if (storedValue !== thisObject.status) { - if (storedValue === PRODUCT_CARD_STATUS.ON) { + if (storedValue === LAYER_STATUS.ON) { resetProgressBars() - changeStatusTo(PRODUCT_CARD_STATUS.LOADING) + changeStatusTo(LAYER_STATUS.LOADING) } - if (storedValue === PRODUCT_CARD_STATUS.OFF) { + if (storedValue === LAYER_STATUS.OFF) { resetProgressBars() - changeStatusTo(PRODUCT_CARD_STATUS.OFF) + changeStatusTo(LAYER_STATUS.OFF) } } } else { resetProgressBars() - changeStatusTo(PRODUCT_CARD_STATUS.OFF) + changeStatusTo(LAYER_STATUS.OFF) } } catch (err) { // we ignore errors here since most likely they will be parsing errors. @@ -320,11 +373,11 @@ function newLayer () { /* Check when the loading finishes */ if ( - thisObject.status === PRODUCT_CARD_STATUS.LOADING && + thisObject.status === LAYER_STATUS.LOADING && marketFileProgressBar.value === 100 && dailyFileProgressBar.value === 100 ) { - changeStatusTo(PRODUCT_CARD_STATUS.ON) + changeStatusTo(LAYER_STATUS.ON) } } @@ -332,6 +385,14 @@ function newLayer () { if (thisObject.status !== newStatus) { thisObject.status = newStatus + if (thisObject.status === LAYER_STATUS.OFF) { + if (panelsVisibleButton !== undefined) { + panelsVisibleButton.finalize() + panelsVisibleButton = undefined + } + } + + /* Saving the new status at the node config */ try { let code = JSON.parse(thisObject.payload.node.code) code.status = thisObject.status @@ -347,6 +408,9 @@ function newLayer () { function draw () { drawLayer() + if (panelsVisibleButton !== undefined) { + panelsVisibleButton.draw() + } } function drawLayer () { diff --git a/Panels/LayersPanel.js b/Panels/LayersPanel.js index 2144c28f7..f48ad51f5 100644 --- a/Panels/LayersPanel.js +++ b/Panels/LayersPanel.js @@ -192,7 +192,7 @@ function newProductsPanel () { let onProducts = [] for (let i = 0; i < thisObject.layers.length; i++) { - if (thisObject.layers[i].status === PRODUCT_CARD_STATUS.LOADING) { + if (thisObject.layers[i].status === LAYER_STATUS.LOADING) { onProducts.push(thisObject.layers[i]) } } @@ -409,4 +409,3 @@ function newProductsPanel () { } } } - diff --git a/Panels/PanelsVisibleButton.js b/Panels/PanelsVisibleButton.js new file mode 100644 index 000000000..fe8d20e08 --- /dev/null +++ b/Panels/PanelsVisibleButton.js @@ -0,0 +1,83 @@ +function newPanelsVisibleButton () { + let thisObject = { + container: undefined, + fitFunction: undefined, + parentContainer: undefined, + panels: undefined, + showPanels: true, + draw: draw, + getContainer: getContainer, // returns the inner most container that holds the point received by parameter. + initialize: initialize, + finalize: finalize + } + + /* Cointainer stuff */ + thisObject.container = newContainer() + thisObject.container.name = 'Panels Visible Button' + thisObject.container.initialize() + thisObject.container.isClickeable = true + thisObject.container.frame.containerName = 'Panels Visible Button' + + let onMouseClickEventSuscriptionId + return thisObject + + function finalize () { + thisObject.container.eventHandler.stopListening(onMouseClickEventSuscriptionId) + thisObject.container.finalize() + thisObject.container = undefined + thisObject.fitFunction = undefined + thisObject.parentContainer = undefined + thisObject.panels = undefined + } + + function initialize (panels) { + thisObject.panels = panels + setPanelVisibility() + + thisObject.container.frame.width = 25 + thisObject.container.frame.height = 25 + + let position = { + x: thisObject.container.frame.width * 1 / 8, + y: 45 + } + + thisObject.container.frame.position = position + + /* Lets listen to our own events to react when we have a Mouse Click */ + onMouseClickEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick) + } + + function onMouseClick (event) { + if (thisObject.showPanels === false) { + thisObject.showPanels = true + } else { + thisObject.showPanels = false + } + setPanelVisibility() + } + + function setPanelVisibility () { + for (let i = 0; i < thisObject.panels.length; i++) { + panel = canvas.panelsSpace.getPanel(thisObject.panels[i]) + panel.isVisible = thisObject.showPanels + } + } + + function getContainer (point) { + if (thisObject.container.frame.isThisPointHere(point, true) === true) { + return thisObject.container + } + } + + function draw () { + let icon + if (thisObject.showPanels === true) { + icon = canvas.designerSpace.iconCollection.get('plotter-panel') + } else { + icon = canvas.designerSpace.iconCollection.get('social-bot') + } + + drawIcon(icon, 1 / 2, 1 / 2, 0, 0, 14, thisObject.container) + } +} diff --git a/Panels/PlotterPanel.js b/Panels/PlotterPanel.js index f578e95c8..28d38f488 100644 --- a/Panels/PlotterPanel.js +++ b/Panels/PlotterPanel.js @@ -9,6 +9,7 @@ function newPlotterPanel () { let thisObject = { fitFunction: undefined, container: undefined, + isVisible: true, onRecordChange: onRecordChange, draw: draw, getContainer: getContainer, @@ -30,6 +31,7 @@ function newPlotterPanel () { thisObject.container.finalize() thisObject.container = undefined thisObject.fitFunction = undefined + thisObject.isVisible = undefined heightFactor = undefined currentRecord = undefined @@ -56,6 +58,7 @@ function newPlotterPanel () { } function getContainer (point) { + if (thisObject.isVisible !== true) { return } let container container = panelTabButton.getContainer(point) @@ -80,10 +83,10 @@ function newPlotterPanel () { } function draw () { + if (thisObject.isVisible !== true) { return } + thisObject.container.frame.draw(false, false, true, thisObject.fitFunction) - plotCurrentRecordData() - panelTabButton.draw() } From 6ed3d64519cec5a2979778cce26c0dc7da97c755 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 29 Jan 2020 11:48:31 +0100 Subject: [PATCH 203/264] not visible panels dont count on positioning physics --- ChartsSpace/TimeMachine.js | 19 +++++++++++++++---- Panels/LayersPanel.js | 1 + Spaces/ChartSpace.js | 2 +- Spaces/PanelsSpace.js | 31 ++++++++++++++++++++++++++----- 4 files changed, 43 insertions(+), 10 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 393e15bb0..72e23cbf1 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -329,10 +329,21 @@ function newTimeMachine () { } function physics () { - thisObjectPhysics() - childrenPhysics() - syncWithDesigner() - saveFrame(thisObject.payload, thisObject.container.frame) + if (thisObject.container.frame.isInViewPort()) { + thisObjectPhysics() + childrenPhysics() + syncWithDesigner() + saveFrame(thisObject.payload, thisObject.container.frame) + } + panelPhysics() + } + + function panelPhysics () { + if (thisObject.container.frame.isInViewPort()) { + canvas.panelsSpace.makeVisible(thisObject.payload.node.id) + } else { + canvas.panelsSpace.makeInvisible(thisObject.payload.node.id) + } } function syncWithDesigner () { diff --git a/Panels/LayersPanel.js b/Panels/LayersPanel.js index f48ad51f5..2b0fc501e 100644 --- a/Panels/LayersPanel.js +++ b/Panels/LayersPanel.js @@ -5,6 +5,7 @@ function newProductsPanel () { container: undefined, layers: [], payload: undefined, + isVisible: true, getLoadingLayers: getLoadingLayers, physics: physics, draw: draw, diff --git a/Spaces/ChartSpace.js b/Spaces/ChartSpace.js index 67b21038c..dced0c410 100644 --- a/Spaces/ChartSpace.js +++ b/Spaces/ChartSpace.js @@ -332,11 +332,11 @@ function newChartSpace () { } if (timeMachine.container.frame.isInViewPort()) { - timeMachine.physics() thisObject.inViewport.set(timeMachine.payload.node.id, timeMachine) } else { thisObject.inViewport.delete(timeMachine.payload.node.id) } + timeMachine.physics() } } diff --git a/Spaces/PanelsSpace.js b/Spaces/PanelsSpace.js index 4be89c240..eef432453 100644 --- a/Spaces/PanelsSpace.js +++ b/Spaces/PanelsSpace.js @@ -8,6 +8,8 @@ function newPanelsSpace () { let thisObject = { visible: true, container: undefined, + makeVisible: makeVisible, + makeInvisible: makeInvisible, createNewPanel: createNewPanel, destroyPanel: destroyPanel, getPanel: getPanel, @@ -73,6 +75,24 @@ function newPanelsSpace () { return panel.handle } + function makeVisible (owner) { + for (let i = 0; i < thisObject.panels.length; i++) { + let panel = thisObject.panels[i] + if (panel.owner === owner) { + panel.isVisible = true + } + } + } + + function makeInvisible (owner) { + for (let i = 0; i < thisObject.panels.length; i++) { + let panel = thisObject.panels[i] + if (panel.owner === owner) { + panel.isVisible = false + } + } + } + function destroyPanel (pPanelHandle) { for (let i = 0; i < thisObject.panels.length; i++) { let panel = thisObject.panels[i] @@ -264,11 +284,12 @@ function newPanelsSpace () { for (let i = 0; i < currentIndex; i++) { let panel = thisObject.panels[i] - - if (isThisPointInsideThisFrame(corner1, panel.container.frame) === true) { return true } - if (isThisPointInsideThisFrame(corner2, panel.container.frame) === true) { return true } - if (isThisPointInsideThisFrame(corner3, panel.container.frame) === true) { return true } - if (isThisPointInsideThisFrame(corner4, panel.container.frame) === true) { return true } + if (panel.isVisible === true) { + if (isThisPointInsideThisFrame(corner1, panel.container.frame) === true) { return true } + if (isThisPointInsideThisFrame(corner2, panel.container.frame) === true) { return true } + if (isThisPointInsideThisFrame(corner3, panel.container.frame) === true) { return true } + if (isThisPointInsideThisFrame(corner4, panel.container.frame) === true) { return true } + } } function isThisPointInsideThisFrame (point, frame) { From 43628bfa29533b798cd781b64b4d8a357dbad43a Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 29 Jan 2020 12:28:51 +0100 Subject: [PATCH 204/264] IMplementing savePropertyAtNodeConfig --- ChartsSpace/TimeMachine.js | 4 ++-- Panels/Layer.js | 36 +++++++----------------------------- Panels/LayersPanel.js | 2 +- Spaces/PanelsSpace.js | 13 +++++++------ Utilities.js | 18 ++++++++++++++++++ 5 files changed, 35 insertions(+), 38 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 72e23cbf1..f484a5cd3 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -340,9 +340,9 @@ function newTimeMachine () { function panelPhysics () { if (thisObject.container.frame.isInViewPort()) { - canvas.panelsSpace.makeVisible(thisObject.payload.node.id) + canvas.panelsSpace.makeVisible(thisObject.payload.node.id, 'Layers Panel') } else { - canvas.panelsSpace.makeInvisible(thisObject.payload.node.id) + canvas.panelsSpace.makeInvisible(thisObject.payload.node.id, 'Layers Panel') } } diff --git a/Panels/Layer.js b/Panels/Layer.js index babf7ded3..85300f606 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -316,17 +316,11 @@ function newLayer () { if (thisObject.panels.length > 0) { panelsVisibleButton = newPanelsVisibleButton() - try { - let code = JSON.parse(thisObject.payload.node.code) - if (code.showPanels !== undefined) { - if (code.showPanels === true || code.showPanels === false) { - panelsVisibleButton.showPanels = code.showPanels - } + let storedValue = loadPropertyFromNodeConfig(thisObject.payload, 'showPanels') + if (storedValue !== undefined) { + if (storedValue === true || storedValue === false) { + panelsVisibleButton.showPanels = storedValue } - - thisObject.payload.node.code = JSON.stringify(code) - } catch (err) { - // we ignore errors here since most likely they will be parsing errors. } panelsVisibleButton.initialize(thisObject.panels) @@ -334,14 +328,7 @@ function newLayer () { } } } else { - /* Saving the new status at the node config */ - try { - let code = JSON.parse(thisObject.payload.node.code) - code.showPanels = panelsVisibleButton.showPanels - thisObject.payload.node.code = JSON.stringify(code) - } catch (err) { - // we ignore errors here since most likely they will be parsing errors. - } + savePropertyAtNodeConfig(thisObject.payload, 'showPanels', panelsVisibleButton.showPanels) } } } @@ -349,8 +336,7 @@ function newLayer () { function statusPhysics () { /* We retrieve the stored status at the config. */ try { - let code = JSON.parse(thisObject.payload.node.code) - let storedValue = code.status + let storedValue = loadPropertyFromNodeConfig(thisObject.payload, 'status') if (storedValue !== undefined) { if (storedValue !== thisObject.status) { @@ -392,15 +378,7 @@ function newLayer () { } } - /* Saving the new status at the node config */ - try { - let code = JSON.parse(thisObject.payload.node.code) - code.status = thisObject.status - thisObject.payload.node.code = JSON.stringify(code) - } catch (err) { - // we ignore errors here since most likely they will be parsing errors. - } - + savePropertyAtNodeConfig(thisObject.payload, 'status', thisObject.status) let eventData = thisObject thisObject.container.eventHandler.raiseEvent('Status Changed', eventData) } diff --git a/Panels/LayersPanel.js b/Panels/LayersPanel.js index 2b0fc501e..34c4d5711 100644 --- a/Panels/LayersPanel.js +++ b/Panels/LayersPanel.js @@ -1,4 +1,4 @@ -function newProductsPanel () { +function newLayersPanel () { let thisObject = { name: 'Layers Panel', fitFunction: undefined, diff --git a/Spaces/PanelsSpace.js b/Spaces/PanelsSpace.js index eef432453..30b1b2b0e 100644 --- a/Spaces/PanelsSpace.js +++ b/Spaces/PanelsSpace.js @@ -42,9 +42,10 @@ function newPanelsSpace () { case 'Layers Panel': { - panel = newProductsPanel() + panel = newLayersPanel() panel.fitFunction = canvas.chartSpace.fitFunction panel.container.isVisibleFunction = canvas.chartSpace.isThisPointVisible + panel.type = 'Layers Panel' break } case 'Plotter Panel': @@ -62,7 +63,7 @@ function newPanelsSpace () { panel.session = pSession panel.initialize() } - + panel.type = 'Plotter Panel' break } } @@ -75,19 +76,19 @@ function newPanelsSpace () { return panel.handle } - function makeVisible (owner) { + function makeVisible (owner, type) { for (let i = 0; i < thisObject.panels.length; i++) { let panel = thisObject.panels[i] - if (panel.owner === owner) { + if (panel.owner === owner && panel.type === type) { panel.isVisible = true } } } - function makeInvisible (owner) { + function makeInvisible (owner, type) { for (let i = 0; i < thisObject.panels.length; i++) { let panel = thisObject.panels[i] - if (panel.owner === owner) { + if (panel.owner === owner && panel.type === type) { panel.isVisible = false } } diff --git a/Utilities.js b/Utilities.js index 7b68ea56f..46ae2b890 100644 --- a/Utilities.js +++ b/Utilities.js @@ -1,3 +1,21 @@ +function savePropertyAtNodeConfig (payload, propertyName, value) { + try { + let code = JSON.parse(payload.node.code) + code[propertyName] = value + payload.node.code = JSON.stringify(code) + } catch (err) { + // we ignore errors here since most likely they will be parsing errors. + } +} + +function loadPropertyFromNodeConfig (payload, propertyName) { + try { + let code = JSON.parse(payload.node.code) + return code[propertyName] + } catch (err) { + // we ignore errors here since most likely they will be parsing errors. + } +} function saveFrame (payload, frame) { payload.frame = { From 237e02ff1fed49cf51f3a777ab9d77b1aba88e95 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 29 Jan 2020 12:50:50 +0100 Subject: [PATCH 205/264] Layers Manager remembering visible layers --- Panels/LayersPanel.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Panels/LayersPanel.js b/Panels/LayersPanel.js index 34c4d5711..5bcd308ed 100644 --- a/Panels/LayersPanel.js +++ b/Panels/LayersPanel.js @@ -75,6 +75,12 @@ function newLayersPanel () { panelTabButton.initialize() onMouseWheelEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) + + let storedValue = loadPropertyFromNodeConfig(thisObject.payload, 'visibleLayers') + if (storedValue >= 0 && storedValue <= 20) { + desiredVisibleLayers = storedValue + } + isInitialized = true } @@ -135,6 +141,7 @@ function newLayersPanel () { } desiredPanelHeight = (layerHeight + LAYER_SEPARATION) * desiredVisibleLayers + heatherHeight + footerHeight calculateVisbleLayers() + savePropertyAtNodeConfig(thisObject.payload, 'visibleLayers', desiredVisibleLayers) } function panelSizePhysics () { From b3dff9066c20f5c5e8fc000c66b836a89a96cf87 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 29 Jan 2020 14:44:47 +0100 Subject: [PATCH 206/264] Panel Positioning Improved --- Spaces/PanelsSpace.js | 130 +++++++++++++++++------------------------- 1 file changed, 52 insertions(+), 78 deletions(-) diff --git a/Spaces/PanelsSpace.js b/Spaces/PanelsSpace.js index 30b1b2b0e..873e56141 100644 --- a/Spaces/PanelsSpace.js +++ b/Spaces/PanelsSpace.js @@ -146,15 +146,10 @@ function newPanelsSpace () { let panel = thisObject.panels[i] /* setting the speed of the panel */ - let ACCELERATION = 0.1 // This is resting speed. if (panel.container.speed === undefined) { panel.container.speed = { - x: 1, - y: 1 - } - panel.container.resistance = { - x: 0, - y: 0 + x: 2, + y: 2 } } @@ -170,26 +165,29 @@ function newPanelsSpace () { let verticalLine = (canvas.chartSpace.viewport.visibleArea.topRight.x - canvas.chartSpace.viewport.visibleArea.topLeft.x) / 2 + canvas.chartSpace.viewport.visibleArea.topLeft.x let horizontalLine = (canvas.chartSpace.viewport.visibleArea.bottomRight.y - canvas.chartSpace.viewport.visibleArea.topRight.y) * 2 / 3 + canvas.chartSpace.viewport.visibleArea.topRight.y + if (centerPoint.x < verticalLine && centerPoint.y < horizontalLine) { + panel.gravitatesTowards = 'topLeft' + } + if (centerPoint.x >= verticalLine && centerPoint.y < horizontalLine) { + panel.gravitatesTowards = 'topRight' + } + if (centerPoint.x < verticalLine && centerPoint.y >= horizontalLine) { + panel.gravitatesTowards = 'bottomLeft' + } + if (centerPoint.x >= verticalLine && centerPoint.y >= horizontalLine) { + panel.gravitatesTowards = 'bottomRight' + } + /* According to the quadrant we push the panels to the sides */ if (centerPoint.x < verticalLine) { panel.container.frame.position.x = panel.container.frame.position.x - panel.container.speed.x - if (isOverlapping(i, panel.container) === true) { - panel.container.frame.position.x = panel.container.frame.position.x + panel.container.speed.x * 3 - accelerateOnX() - } else { - desAccelerateOnX() - } + isOverlapping(i, panel.container) if (panel.container.frame.position.x < 0) { panel.container.frame.position.x = 0 } } else { panel.container.frame.position.x = panel.container.frame.position.x + panel.container.speed.x - if (isOverlapping(i, panel.container) === true) { - panel.container.frame.position.x = panel.container.frame.position.x - panel.container.speed.x * 3 - accelerateOnX() - } else { - desAccelerateOnX() - } + isOverlapping(i, panel.container) if (panel.container.frame.position.x + panel.container.frame.width > browserCanvas.width) { panel.container.frame.position.x = browserCanvas.width - panel.container.frame.width } @@ -197,71 +195,18 @@ function newPanelsSpace () { if (panel.container.frame.height <= canvas.chartSpace.viewport.visibleArea.bottomRight.y - canvas.chartSpace.viewport.visibleArea.topRight.y) { if (centerPoint.y < horizontalLine) { panel.container.frame.position.y = panel.container.frame.position.y - panel.container.speed.y - if (isOverlapping(i, panel.container) === true) { - panel.container.frame.position.y = panel.container.frame.position.y + panel.container.speed.y * 3 - accelerateOnY() - } else { - desAccelerateOnY() - } + isOverlapping(i, panel.container) if (panel.container.frame.position.y < canvas.chartSpace.viewport.visibleArea.topLeft.y) { panel.container.frame.position.y = canvas.chartSpace.viewport.visibleArea.topLeft.y } } else { panel.container.frame.position.y = panel.container.frame.position.y + panel.container.speed.y - if (isOverlapping(i, panel.container) === true) { - panel.container.frame.position.y = panel.container.frame.position.y - panel.container.speed.y * 3 - accelerateOnY() - } else { - desAccelerateOnY() - } + isOverlapping(i, panel.container) if (panel.container.frame.position.y + panel.container.frame.height > canvas.chartSpace.viewport.visibleArea.bottomRight.y) { panel.container.frame.position.y = canvas.chartSpace.viewport.visibleArea.bottomRight.y - panel.container.frame.height } } } - - function accelerateOnX () { - panel.container.speed.x = panel.container.speed.x + ACCELERATION - if (panel.container.speed.x > ACCELERATION * 10) { - panel.container.speed.x = ACCELERATION * 10 - } - panel.container.resistance.x = panel.container.resistance.x + 1 - } - function desAccelerateOnX () { - if (panel.container.resistance.x < -3) { - panel.container.resistance.x = 0 - panel.container.speed.x = ACCELERATION * 5 - return - } - panel.container.speed.x = panel.container.speed.x - ACCELERATION - if (panel.container.speed.x < ACCELERATION) { - panel.container.speed.x = ACCELERATION * 1 - } - panel.container.resistance.x = panel.container.resistance.x - 1 - } - function accelerateOnY () { - if (panel.container.resistance.y > 5) { - panel.container.resistance.y = 0 - return - } - panel.container.speed.y = panel.container.speed.y + ACCELERATION - if (panel.container.speed.y > ACCELERATION * 10) { - panel.container.speed.y = ACCELERATION * 5 - } - panel.container.resistance.y = panel.container.resistance.y + 1 - } - function desAccelerateOnY () { - if (panel.container.resistance.y < -3) { - panel.container.resistance.y = 0 - panel.container.speed.y = ACCELERATION * 10 - return - } - panel.container.speed.y = panel.container.speed.y - ACCELERATION - if (panel.container.speed.y < ACCELERATION) { - panel.container.speed.y = ACCELERATION * 1 - } - panel.container.resistance.y = panel.container.resistance.y - 1 - } } } @@ -286,10 +231,39 @@ function newPanelsSpace () { for (let i = 0; i < currentIndex; i++) { let panel = thisObject.panels[i] if (panel.isVisible === true) { - if (isThisPointInsideThisFrame(corner1, panel.container.frame) === true) { return true } - if (isThisPointInsideThisFrame(corner2, panel.container.frame) === true) { return true } - if (isThisPointInsideThisFrame(corner3, panel.container.frame) === true) { return true } - if (isThisPointInsideThisFrame(corner4, panel.container.frame) === true) { return true } + if (isThisPointInsideThisFrame(corner1, panel.container.frame) === true) { + pushOut(currentContainer, panel.container, panel.gravitatesTowards) + } + if (isThisPointInsideThisFrame(corner2, panel.container.frame) === true) { + pushOut(currentContainer, panel.container, panel.gravitatesTowards) + } + if (isThisPointInsideThisFrame(corner3, panel.container.frame) === true) { + pushOut(currentContainer, panel.container, panel.gravitatesTowards) + } + if (isThisPointInsideThisFrame(corner4, panel.container.frame) === true) { + pushOut(currentContainer, panel.container, panel.gravitatesTowards) + } + } + } + + function pushOut (currentContainer, controlContainer, corner) { + switch (corner) { + case 'topLeft': { + currentContainer.frame.position.x = controlContainer.frame.position.x + controlContainer.frame.width + break + } + case 'topRight': { + currentContainer.frame.position.x = controlContainer.frame.position.x - currentContainer.frame.width + break + } + case 'bottomLeft': { + currentContainer.frame.position.x = controlContainer.frame.position.x + controlContainer.frame.width + break + } + case 'bottomRight': { + currentContainer.frame.position.x = controlContainer.frame.position.x - currentContainer.frame.width + break + } } } From 39d9cfe716117e71d9eb649d213660b2c8963b53 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 29 Jan 2020 15:05:49 +0100 Subject: [PATCH 207/264] no more button --- Panels/PanelTabButton.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Panels/PanelTabButton.js b/Panels/PanelTabButton.js index 1105e1372..fd7a48993 100644 --- a/Panels/PanelTabButton.js +++ b/Panels/PanelTabButton.js @@ -88,6 +88,7 @@ function newPanelTabButton () { } function draw () { + return if (isInitialized === false) { return } drawButton() @@ -113,6 +114,7 @@ function newPanelTabButton () { } function getContainer (point) { + return let container /* First we check if thisObject point is inside thisObject space. */ From 2488756d154735516ede25f8c5279cfd0ffca3ad Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 29 Jan 2020 17:23:03 +0100 Subject: [PATCH 208/264] Timemachine Background --- ChartsSpace/TimeMachine.js | 5 +++++ ChartsSpace/TimelineChart.js | 29 +---------------------------- Utilities.js | 24 ++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 28 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index f484a5cd3..30ebe0d87 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -468,6 +468,7 @@ function newTimeMachine () { } function drawBackground () { + drawChartsBackground() if (thisObject.container.frame.isInViewPort()) { for (let i = 0; i < thisObject.timelineCharts.length; i++) { let timelineChart = thisObject.timelineCharts[thisObject.timelineCharts.length - i - 1] @@ -476,6 +477,10 @@ function newTimeMachine () { } } + function drawChartsBackground () { + drawContainerBackground(thisObject.container, UI_COLOR.WHITE, 0.5, thisObject.fitFunction) + } + function draw () { if (thisObject.container.frame.isInViewPort()) { for (let i = 0; i < thisObject.timelineCharts.length; i++) { diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index e608a00a5..218bcd74a 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -417,34 +417,7 @@ function newTimelineChart () { } function drawChartsBackground () { - /* We will paint some transparent background here. */ - - let opacity = '0.0' - - let fromPoint = { - x: 0, - y: 0 - } - - let toPoint = { - x: thisObject.container.frame.width, - y: thisObject.container.frame.height - } - - fromPoint = transformThisPoint(fromPoint, thisObject.container) - toPoint = transformThisPoint(toPoint, thisObject.container) - - fromPoint = thisObject.fitFunction(fromPoint) - toPoint = thisObject.fitFunction(toPoint) - - browserCanvasContext.beginPath() - - browserCanvasContext.rect(fromPoint.x, fromPoint.y, toPoint.x - fromPoint.x, toPoint.y - fromPoint.y) - browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', ' + opacity + ')' - - browserCanvasContext.closePath() - - browserCanvasContext.fill() + drawContainerBackground(thisObject.container, UI_COLOR.WHITE, 0, thisObject.fitFunction) } function recalculateCoordinateSystem () { diff --git a/Utilities.js b/Utilities.js index 46ae2b890..7749bc532 100644 --- a/Utilities.js +++ b/Utilities.js @@ -1,3 +1,27 @@ +function drawContainerBackground (container, color, opacity, fitFunction) { + let fromPoint = { + x: 0, + y: 0 + } + + let toPoint = { + x: container.frame.width, + y: container.frame.height + } + + fromPoint = transformThisPoint(fromPoint, container) + toPoint = transformThisPoint(toPoint, container) + + fromPoint = fitFunction(fromPoint) + toPoint = fitFunction(toPoint) + + browserCanvasContext.beginPath() + browserCanvasContext.rect(fromPoint.x, fromPoint.y, toPoint.x - fromPoint.x, toPoint.y - fromPoint.y) + browserCanvasContext.fillStyle = 'rgba(' + color + ', ' + opacity + ')' + browserCanvasContext.closePath() + browserCanvasContext.fill() +} + function savePropertyAtNodeConfig (payload, propertyName, value) { try { let code = JSON.parse(payload.node.code) From 0764b3d6865ca7492a3dd9604cdb2518021e5c0b Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 29 Jan 2020 18:55:10 +0100 Subject: [PATCH 209/264] Panels remmebering position --- Panels/LayersPanel.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Panels/LayersPanel.js b/Panels/LayersPanel.js index 5bcd308ed..4d2d08bf7 100644 --- a/Panels/LayersPanel.js +++ b/Panels/LayersPanel.js @@ -81,6 +81,7 @@ function newLayersPanel () { desiredVisibleLayers = storedValue } + loadFrame(thisObject.payload, thisObject.container.frame) isInitialized = true } @@ -257,7 +258,7 @@ function newLayersPanel () { function physics () { if (isInitialized === false) { return } - + saveFrame(thisObject.payload, thisObject.container.frame) /* The overall idea here is that we need to keep syncronized the panel with the layers that are defined at the Designer. Users can connect or disconnect any objext resulting in changes in which From ea336e81a4b55d1af236d4bf19022a02a26dacc1 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 29 Jan 2020 19:00:52 +0100 Subject: [PATCH 210/264] Beta --- SplashScreen.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SplashScreen.js b/SplashScreen.js index d10e27a6b..9768aaa82 100644 --- a/SplashScreen.js +++ b/SplashScreen.js @@ -125,7 +125,7 @@ function newSplashScreen () { fontSize = 15 - title = 'People and Machines working together to create Superalgos' + title = 'Beta' titlePoint = { x: thisObject.container.frame.width / 2 - title.length / 2 * fontSize * FONT_ASPECT_RATIO - 20, From d930314e88a863dc68e5f3308c8b9504f4a0b3fb Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 29 Jan 2020 19:22:39 +0100 Subject: [PATCH 211/264] time machine border --- ChartsSpace/TimeMachine.js | 10 ++++++++-- Frame.js | 18 ++++++++---------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 30ebe0d87..e523d0f5e 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -493,8 +493,6 @@ function newTimeMachine () { if (thisObject.timeFrameScale !== undefined) { thisObject.timeFrameScale.draw() } if (thisObject.rateScale !== undefined) { thisObject.rateScale.draw() } } - - thisObject.container.frame.draw(false, true, false, thisObject.fitFunction) } else { let icon = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.type) if (icon !== undefined) { @@ -531,6 +529,14 @@ function newTimeMachine () { if (thisObject.timeFrameScale !== undefined) { thisObject.timeFrameScale.drawForeground() } if (thisObject.rateScale !== undefined) { thisObject.rateScale.drawForeground() } } + + let style = { + color: UI_COLOR.BLACK, + opacity: 1, + lineWidth: 1, + lineDash: [1, 3] + } + thisObject.container.frame.draw(false, true, false, thisObject.fitFunction, style) } } diff --git a/Frame.js b/Frame.js index 0c4023664..ed8a0a25d 100644 --- a/Frame.js +++ b/Frame.js @@ -237,9 +237,9 @@ function newFrame () { } } - function draw (drawGrid, drawBorders, drawBackground, fitFunction) { + function draw (drawGrid, drawBorders, drawBackground, fitFunction, style) { if (drawBorders === true) { - borders(fitFunction) + borders(fitFunction, style) } if (drawGrid === true) { @@ -331,7 +331,7 @@ function newFrame () { browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y) } - function borders (fitFunction) { + function borders (fitFunction, style) { /* Lest get the important points of the drawing so as to apply the needed transformations. */ let point1 @@ -359,8 +359,7 @@ function newFrame () { y: thisObject.height } - /* Now the transformations. */ - + /* Now the transformations. */ point1 = transformThisPoint(point1, thisObject.container) point2 = transformThisPoint(point2, thisObject.container) point3 = transformThisPoint(point3, thisObject.container) @@ -373,8 +372,7 @@ function newFrame () { point4 = fitFunction(point4) } - /* Lets start the drawing. */ - + /* Lets start the drawing. */ browserCanvasContext.beginPath() browserCanvasContext.moveTo(point1.x, point1.y) browserCanvasContext.lineTo(point2.x, point2.y) @@ -383,9 +381,9 @@ function newFrame () { browserCanvasContext.lineTo(point1.x, point1.y) browserCanvasContext.closePath() - browserCanvasContext.strokeStyle = 'rgba(150, 150, 150, 1)' - browserCanvasContext.lineWidth = 1 - browserCanvasContext.setLineDash([0, 0]) + browserCanvasContext.strokeStyle = 'rgba(' + style.color + ', ' + style.opacity + ')' + browserCanvasContext.lineWidth = style.lineWidth + browserCanvasContext.setLineDash(style.lineDash) browserCanvasContext.stroke() browserCanvasContext.closePath() From 3969730c160bbd8f82823a29b752e5e470634119 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 29 Jan 2020 20:13:20 +0100 Subject: [PATCH 212/264] Limiting Scales when time machine cointainer gets small --- ChartsSpace/TimeMachine.js | 18 +++++++++--------- ChartsSpace/TimelineChart.js | 12 ++++++------ Scales/RateScale.js | 9 +++++++++ Scales/TimeFrameScale.js | 7 +++++++ Scales/TimeScale.js | 7 +++++++ 5 files changed, 38 insertions(+), 15 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index e523d0f5e..864a269eb 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -249,7 +249,7 @@ function newTimeMachine () { function getContainer (point, purpose) { let container - if (thisObject.rateScale !== undefined) { + if (thisObject.rateScale !== undefined && thisObject.rateScale.isVisible === true) { container = thisObject.rateScale.getContainer(point) if (container !== undefined) { if (container.isForThisPurpose(purpose)) { @@ -258,7 +258,7 @@ function newTimeMachine () { } } - if (thisObject.timeScale !== undefined) { + if (thisObject.timeScale !== undefined && thisObject.timeScale.isVisible === true) { container = thisObject.timeScale.getContainer(point) if (container !== undefined) { if (container.isForThisPurpose(purpose)) { @@ -267,7 +267,7 @@ function newTimeMachine () { } } - if (thisObject.timeFrameScale !== undefined) { + if (thisObject.timeFrameScale !== undefined && thisObject.rateScale.isVisible === true) { container = thisObject.timeFrameScale.getContainer(point) if (container !== undefined) { if (container.isForThisPurpose(purpose)) { @@ -489,9 +489,9 @@ function newTimeMachine () { } if (drawScales === true) { - if (thisObject.timeScale !== undefined) { thisObject.timeScale.draw() } - if (thisObject.timeFrameScale !== undefined) { thisObject.timeFrameScale.draw() } - if (thisObject.rateScale !== undefined) { thisObject.rateScale.draw() } + if (thisObject.timeScale !== undefined && thisObject.timeScale.isVisible === true) { thisObject.timeScale.draw() } + if (thisObject.timeFrameScale !== undefined && thisObject.timeFrameScale.isVisible === true) { thisObject.timeFrameScale.draw() } + if (thisObject.rateScale !== undefined && thisObject.rateScale.isVisible === true) { thisObject.rateScale.draw() } } } else { let icon = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.type) @@ -525,9 +525,9 @@ function newTimeMachine () { } if (drawScales === true) { - if (thisObject.timeScale !== undefined) { thisObject.timeScale.drawForeground() } - if (thisObject.timeFrameScale !== undefined) { thisObject.timeFrameScale.drawForeground() } - if (thisObject.rateScale !== undefined) { thisObject.rateScale.drawForeground() } + if (thisObject.timeScale !== undefined && thisObject.timeScale.isVisible === true) { thisObject.timeScale.drawForeground() } + if (thisObject.timeFrameScale !== undefined && thisObject.timeFrameScale.isVisible === true) { thisObject.timeFrameScale.drawForeground() } + if (thisObject.rateScale !== undefined && thisObject.rateScale.isVisible === true) { thisObject.rateScale.drawForeground() } } let style = { diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 218bcd74a..602c9b7f6 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -314,7 +314,7 @@ function newTimelineChart () { function getContainer (point, purpose) { let container - if (thisObject.rateScale !== undefined) { + if (thisObject.rateScale !== undefined && thisObject.rateScale.isVisible === true) { container = thisObject.rateScale.getContainer(point) if (container !== undefined) { if (container.isForThisPurpose(purpose)) { @@ -323,7 +323,7 @@ function newTimelineChart () { } } - if (thisObject.timeFrameScale !== undefined) { + if (thisObject.timeFrameScale !== undefined && thisObject.timeFrameScale.isVisible === true) { container = thisObject.timeFrameScale.getContainer(point) if (container !== undefined) { if (container.isForThisPurpose(purpose)) { @@ -401,8 +401,8 @@ function newTimelineChart () { function draw () { if (thisObject.container.frame.isInViewPort()) { if (drawScales === true) { - if (thisObject.timeFrameScale !== undefined) { thisObject.timeFrameScale.draw() } - if (thisObject.rateScale !== undefined) { thisObject.rateScale.draw() } + if (thisObject.timeFrameScale !== undefined && thisObject.timeFrameScale.isVisible === true) { thisObject.timeFrameScale.draw() } + if (thisObject.rateScale !== undefined && thisObject.rateScale.isVisible === true) { thisObject.rateScale.draw() } } } } @@ -410,8 +410,8 @@ function newTimelineChart () { function drawForeground () { if (thisObject.container.frame.isInViewPort()) { if (drawScales === true) { - if (thisObject.timeFrameScale !== undefined) { thisObject.timeFrameScale.drawForeground() } - if (thisObject.rateScale !== undefined) { thisObject.rateScale.drawForeground() } + if (thisObject.timeFrameScale !== undefined && thisObject.timeFrameScale.isVisible === true) { thisObject.timeFrameScale.drawForeground() } + if (thisObject.rateScale !== undefined && thisObject.rateScale.isVisible === true) { thisObject.rateScale.drawForeground() } } } } diff --git a/Scales/RateScale.js b/Scales/RateScale.js index 822bcd31c..3f4009f87 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -10,6 +10,7 @@ function newRateScale () { offset: undefined, minValue: undefined, maxValue: undefined, + isVisible: true, setScale: setScale, onMouseOverSomeTimeMachineContainer: onMouseOverSomeTimeMachineContainer, physics: physics, @@ -371,6 +372,14 @@ function newRateScale () { thisObject.container.frame.position.y = ratePoint.y - thisObject.container.frame.height thisObject.container.frame.position.x = ratePoint.x - thisObject.container.frame.width + + thisObject.isVisible = true + if (thisObject.container.frame.position.y + thisObject.container.frame.height * 2 > bottonCorner.y || + thisObject.container.frame.position.y - thisObject.container.frame.height * 1 < upCorner.y || + thisObject.container.frame.position.x < upCorner.x + ) { + thisObject.isVisible = false + } } function draw () { diff --git a/Scales/TimeFrameScale.js b/Scales/TimeFrameScale.js index 6792db3a5..d62cf737e 100644 --- a/Scales/TimeFrameScale.js +++ b/Scales/TimeFrameScale.js @@ -6,6 +6,7 @@ function newTimeFrameScale () { container: undefined, fitFunction: undefined, payload: undefined, + isVisible: true, onMouseOverSomeTimeMachineContainer: onMouseOverSomeTimeMachineContainer, draw: draw, drawForeground: drawForeground, @@ -175,6 +176,12 @@ function newTimeFrameScale () { thisObject.container.frame.position.x = timePoint.x thisObject.container.frame.position.y = timePoint.y - thisObject.container.frame.height + + thisObject.isVisible = true + if (thisObject.container.frame.position.y + thisObject.container.frame.height > bottonCorner.y || + thisObject.container.frame.position.y - thisObject.container.frame.height * 3 < upCorner.y) { + thisObject.isVisible = false + } } function onViewportZoomChanged (event) { diff --git a/Scales/TimeScale.js b/Scales/TimeScale.js index 16a81aad0..b39ceb13d 100644 --- a/Scales/TimeScale.js +++ b/Scales/TimeScale.js @@ -7,6 +7,7 @@ function newTimeScale () { date: undefined, fitFunction: undefined, payload: undefined, + isVisible: true, onMouseOverSomeTimeMachineContainer: onMouseOverSomeTimeMachineContainer, physics: physics, draw: draw, @@ -244,6 +245,12 @@ function newTimeScale () { thisObject.container.frame.position.x = timePoint.x thisObject.container.frame.position.y = timePoint.y + + thisObject.isVisible = true + if (thisObject.container.frame.position.y + thisObject.container.frame.height * 4 > bottonCorner.y || + thisObject.container.frame.position.y < upCorner.y) { + thisObject.isVisible = false + } } function draw () { From 79291b179c2ed7732b42c26bdb650cb4127ac0fb Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 30 Jan 2020 16:10:13 +0100 Subject: [PATCH 213/264] cleaning --- ChartsSpace/TimeMachine.js | 2 +- ChartsSpace/TimelineChart.js | 2 +- Scales/TimeFrameScale.js | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 864a269eb..fb656eda9 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -226,7 +226,7 @@ function newTimeMachine () { timeFrameScaleEventSuscriptionId = thisObject.timeFrameScale.container.eventHandler.listenToEvent('Time Frame Value Changed', timeFrameScaleValueChanged) timeFrameScaleMouseOverEventSuscriptionId = thisObject.timeFrameScale.container.eventHandler.listenToEvent('onMouseOverScale', timeFrameScaleMouseOver) - thisObject.timeFrameScale.initialize(timeMachineCoordinateSystem, thisObject.container) + thisObject.timeFrameScale.initialize(thisObject.container) function timeFrameScaleValueChanged (event) { let currentTimeFrame = timeFrame diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 602c9b7f6..32558abba 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -215,7 +215,7 @@ function newTimelineChart () { timeFrameScaleEventSuscriptionId = thisObject.timeFrameScale.container.eventHandler.listenToEvent('Time Frame Value Changed', timeFrameScaleValueChanged) timeFrameScaleMouseOverEventSuscriptionId = thisObject.timeFrameScale.container.eventHandler.listenToEvent('onMouseOverScale', timeFrameScaleMouseOver) - thisObject.timeFrameScale.initialize(timeMachineCoordinateSystem, thisObject.container.parentContainer) + thisObject.timeFrameScale.initialize(thisObject.container.parentContainer) function timeFrameScaleValueChanged (event) { let currentTimeFrame = timeFrame diff --git a/Scales/TimeFrameScale.js b/Scales/TimeFrameScale.js index d62cf737e..c685ba88c 100644 --- a/Scales/TimeFrameScale.js +++ b/Scales/TimeFrameScale.js @@ -33,7 +33,6 @@ function newTimeFrameScale () { let onMouseOverEventSubscriptionId let onMouseNotOverEventSubscriptionId - let coordinateSystem let limitingContainer let mouse = { @@ -70,8 +69,7 @@ function newTimeFrameScale () { thisObject.payload = undefined } - function initialize (pCoordinateSystem, pLimitingContainer) { - coordinateSystem = pCoordinateSystem + function initialize (pLimitingContainer) { limitingContainer = pLimitingContainer readObjectState() From 37debc55cfa882d08d43d8de4eebefd394aa9d5f Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 30 Jan 2020 16:22:01 +0100 Subject: [PATCH 214/264] finalizing --- ChartsSpace/TimeMachine.js | 7 +++---- ChartsSpace/TimelineChart.js | 9 ++++++--- Scales/TimeFrameScale.js | 3 +++ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index fb656eda9..2a2bc8ff8 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -92,15 +92,14 @@ function newTimeMachine () { } thisObject.timelineCharts = undefined - timelineChartsMap = undefined - thisObject.fitFunction = undefined - thisObject.container.finalize() thisObject.container = undefined - thisObject.payload = undefined + mouse = undefined + timelineChartsMap = undefined + timeMachineCoordinateSystem = undefined } function finalizeTimeScale () { diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 32558abba..37df76eea 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -32,7 +32,6 @@ function newTimelineChart () { let timelineChartCoordinateSystem = newCoordinateSystem() let layersPanel - let layersPanelHandle let onViewportPositionChangedEventSuscriptionId @@ -81,13 +80,17 @@ function newTimelineChart () { canvas.chartSpace.viewport.eventHandler.stopListening(onViewportZoomChangedEventSuscriptionId) thisObject.container.eventHandler.stopListening(onMouseOverEventSuscriptionId) thisObject.container.eventHandler.stopListening(onMouseNotOverEventSuscriptionId) - thisObject.container.finalize() thisObject.container = undefined - thisObject.payload = undefined + mouse = undefined logger = undefined + + timeMachineCoordinateSystem = undefined + timelineChartCoordinateSystem = undefined + layersPanel = undefined + layersPanelHandle = undefined } function finalizeLayersManager () { diff --git a/Scales/TimeFrameScale.js b/Scales/TimeFrameScale.js index c685ba88c..7354b7a8f 100644 --- a/Scales/TimeFrameScale.js +++ b/Scales/TimeFrameScale.js @@ -67,6 +67,9 @@ function newTimeFrameScale () { thisObject.container = undefined thisObject.fitFunction = undefined thisObject.payload = undefined + + limitingContainer = undefined + mouse = undefined } function initialize (pLimitingContainer) { From addfff4585b8ed0a46c2a48c6597d213211b962f Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 30 Jan 2020 16:46:17 +0100 Subject: [PATCH 215/264] More cleaning --- ChartsSpace/PlottersManager.js | 8 -------- ChartsSpace/TimelineChart.js | 2 +- Panels/LayersPanel.js | 14 -------------- 3 files changed, 1 insertion(+), 23 deletions(-) diff --git a/ChartsSpace/PlottersManager.js b/ChartsSpace/PlottersManager.js index fda2ff6c6..465aa7404 100644 --- a/ChartsSpace/PlottersManager.js +++ b/ChartsSpace/PlottersManager.js @@ -86,14 +86,6 @@ function newPlottersManager () { /* Listen to the event of change of status */ onLayerStatusChangedEventSuscriptionId = layersPanel.container.eventHandler.listenToEvent('Layer Status Changed', onLayerStatusChanged) - - /* Lets get all the cards that needs to be loaded. */ - let loadingLayers = layersPanel.getLoadingLayers() - - for (let i = 0; i < loadingLayers.length; i++) { - /* For each one, we will initialize the associated plotter. */ - initializePlotter(loadingLayers[i]) - } } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err.stack) } } diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 37df76eea..1f63d2651 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -169,7 +169,7 @@ function newTimelineChart () { thisObject.plotterManager.fitFunction = thisObject.fitFunction thisObject.plotterManager.payload = thisObject.payload - thisObject.plotterManager.initialize(thisObject.layersManager, DEFAULT_EXCHANGE, DEFAULT_MARKET) + thisObject.plotterManager.initialize(thisObject.layersManager) thisObject.plotterManager.setTimeFrame(timeFrame) thisObject.plotterManager.setDatetime(datetime) } diff --git a/Panels/LayersPanel.js b/Panels/LayersPanel.js index 4d2d08bf7..4e47d0cd4 100644 --- a/Panels/LayersPanel.js +++ b/Panels/LayersPanel.js @@ -6,7 +6,6 @@ function newLayersPanel () { layers: [], payload: undefined, isVisible: true, - getLoadingLayers: getLoadingLayers, physics: physics, draw: draw, getContainer: getContainer, @@ -196,19 +195,6 @@ function newLayersPanel () { thisObject.container.eventHandler.raiseEvent('Layer Status Changed', layer) } - function getLoadingLayers () { - /* Returns all thisObject.layers which status is LOADING */ - let onProducts = [] - - for (let i = 0; i < thisObject.layers.length; i++) { - if (thisObject.layers[i].status === LAYER_STATUS.LOADING) { - onProducts.push(thisObject.layers[i]) - } - } - - return onProducts - } - function getContainer (point) { let container From 09309d6e9c2c86460b7c22fe79c594341d0a98a4 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 30 Jan 2020 19:13:01 +0100 Subject: [PATCH 216/264] coordinateSystem going down to Plotters --- ChartsSpace/CoordinateSystem.js | 33 +++++---- ChartsSpace/PlottersManager.js | 31 +++++---- ChartsSpace/TimelineChart.js | 6 ++ Plotter.js | 29 +++----- Scales/RateScale.js | 115 +++++++++++++++++--------------- 5 files changed, 110 insertions(+), 104 deletions(-) diff --git a/ChartsSpace/CoordinateSystem.js b/ChartsSpace/CoordinateSystem.js index 93e261fda..e99fedc33 100644 --- a/ChartsSpace/CoordinateSystem.js +++ b/ChartsSpace/CoordinateSystem.js @@ -12,6 +12,7 @@ function newCoordinateSystem () { min: undefined, max: undefined, scale: undefined, + recalculateScale: recalculateScale, transformThisPoint: transformThisPoint, transformThisPoint2: transformThisPoint2, unInverseTransform: unInverseTransform, @@ -21,44 +22,42 @@ function newCoordinateSystem () { initialize: initialize } - var min = { + thisObject.min = { x: 0, y: 0 } - - var max = { + thisObject.max = { x: 0, y: 0 } - - var scale = { + thisObject.scale = { x: 0, y: 0 } - thisObject.min = min - thisObject.max = max - thisObject.scale = scale - let maxHeight + let maxWidth return thisObject - function initialize (minValue, maxValue, maxWidth, pMaxHeight) { - /* Defines the min and max value of rate that we are going to transport to the available screen at the center position. */ - + function initialize (minValue, maxValue, pMaxWidth, pMaxHeight) { + /* Defines the min and max value of rate that we are going to transport to the available screen at the center position. */ thisObject.min.x = minValue.x // * 0.999; // 0.1% less thisObject.max.x = maxValue.x // * 1.001; // 0.1% more thisObject.min.y = minValue.y // * 0.999; // 0.1% less thisObject.max.y = maxValue.y // * 1.001; // 0.1% more - /* Defines the initial Zoom level at center position. */ - - thisObject.scale.x = maxWidth / (thisObject.max.x - thisObject.min.x) - thisObject.scale.y = pMaxHeight / (thisObject.max.y - thisObject.min.y) - + maxWidth = pMaxWidth maxHeight = pMaxHeight + + recalculateScale() + } + + function recalculateScale () { + /* Defines the initial Zoom level at center position. */ + thisObject.scale.x = maxWidth / (thisObject.max.x - thisObject.min.x) + thisObject.scale.y = maxHeight / (thisObject.max.y - thisObject.min.y) } function initializeX (minValue, maxValue, maxWidth) { diff --git a/ChartsSpace/PlottersManager.js b/ChartsSpace/PlottersManager.js index 465aa7404..007969d77 100644 --- a/ChartsSpace/PlottersManager.js +++ b/ChartsSpace/PlottersManager.js @@ -15,6 +15,7 @@ function newPlottersManager () { payload: undefined, setDatetime: setDatetime, setTimeFrame: setTimeFrame, + setCoordinateSystem: setCoordinateSystem, draw: draw, getContainer: getContainer, initialize: initialize, @@ -22,10 +23,9 @@ function newPlottersManager () { } let initializationReady = false - let layersPanel - let onLayerStatusChangedEventSuscriptionId + let coordinateSystem setupContainer() return thisObject @@ -37,6 +37,7 @@ function newPlottersManager () { function finalize () { layersPanel.container.eventHandler.stopListening(onLayerStatusChangedEventSuscriptionId) + layersPanel = undefined for (let i = 0; i < connectors.length; i++) { let connector = connectors[i] @@ -61,12 +62,10 @@ function newPlottersManager () { connector = undefined } connectors = [] - - layersPanel = undefined + coordinateSystem = undefined thisObject.container.finalize() thisObject.container = undefined - thisObject.payload = undefined } @@ -80,15 +79,11 @@ function newPlottersManager () { } function initialize (pLayersPanel) { - try { - /* Remember the Layers Panel */ - layersPanel = pLayersPanel + /* Remember the Layers Panel */ + layersPanel = pLayersPanel - /* Listen to the event of change of status */ - onLayerStatusChangedEventSuscriptionId = layersPanel.container.eventHandler.listenToEvent('Layer Status Changed', onLayerStatusChanged) - } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err.stack) } - } + /* Listen to the event of change of status */ + onLayerStatusChangedEventSuscriptionId = layersPanel.container.eventHandler.listenToEvent('Layer Status Changed', onLayerStatusChanged) } function initializePlotter (layer) { @@ -178,7 +173,7 @@ function newPlottersManager () { plotter.container.frame.position.x = thisObject.container.frame.width / 2 - plotter.container.frame.width / 2 plotter.container.frame.position.y = thisObject.container.frame.height / 2 - plotter.container.frame.height / 2 plotter.fitFunction = thisObject.fitFunction - plotter.initialize(storage, datetime, timeFrame, onPlotterInizialized, product) + plotter.initialize(storage, datetime, timeFrame, coordinateSystem, onPlotterInizialized, product) function onPlotterInizialized () { try { @@ -291,6 +286,14 @@ function newPlottersManager () { } } + function setCoordinateSystem (pCoordinateSystem) { + coordinateSystem = pCoordinateSystem + for (let i = 0; i < connectors.length; i++) { + let connector = connectors[i] + connector.plotter.setCoordinateSystem(coordinateSystem) + } + } + function getContainer (point) { } diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 1f63d2651..1d783deb2 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -30,6 +30,7 @@ function newTimelineChart () { let timeMachineCoordinateSystem let timelineChartCoordinateSystem = newCoordinateSystem() + let coordinateSystem let layersPanel let layersPanelHandle @@ -89,6 +90,7 @@ function newTimelineChart () { timeMachineCoordinateSystem = undefined timelineChartCoordinateSystem = undefined + coordinateSystem = undefined layersPanel = undefined layersPanelHandle = undefined } @@ -140,6 +142,7 @@ function newTimelineChart () { /* We load the logow we will need for the background. */ timeMachineCoordinateSystem = pTimeMachineCoordinateSystem + coordinateSystem = timeMachineCoordinateSystem timeFrame = INITIAL_TIME_PERIOD recalculateCurrentDatetime() @@ -172,6 +175,7 @@ function newTimelineChart () { thisObject.plotterManager.initialize(thisObject.layersManager) thisObject.plotterManager.setTimeFrame(timeFrame) thisObject.plotterManager.setDatetime(datetime) + thisObject.plotterManager.setCoordinateSystem(coordinateSystem) } function initializeRateScale () { @@ -371,9 +375,11 @@ function newTimelineChart () { } if (thisObject.payload.node.rateScale === undefined && thisObject.rateScale !== undefined) { finalizeRateScale() + coordinateSystem = timeMachineCoordinateSystem } if (thisObject.payload.node.rateScale !== undefined && thisObject.rateScale === undefined) { initializeRateScale() + coordinateSystem = timelineChartCoordinateSystem } if (thisObject.payload.node.timeFrameScale === undefined && thisObject.timeFrameScale !== undefined) { finalizeTimeFrameScale() diff --git a/Plotter.js b/Plotter.js index 13b35c216..76ce16e0f 100644 --- a/Plotter.js +++ b/Plotter.js @@ -6,32 +6,23 @@ function newPlotter () { logger.fileName = MODULE_NAME let thisObject = { - - /* Events declared outside the plotter. */ - + currentRecord: undefined, + container: undefined, onDailyFileLoaded: onDailyFileLoaded, - - // Main functions and properties. - initialize: initialize, finalize: finalize, - container: undefined, getContainer: getContainer, setTimeFrame: setTimeFrame, setDatetime: setDatetime, - recalculateScale: recalculateScale, - draw: draw, - - // Secondary functions and properties. - - currentRecord: undefined // ---> Check Here + setCoordinateSystem: setCoordinateSystem, + draw: draw } let container = newContainer() container.initialize() thisObject.container = container - let coordinateSystem = newCoordinateSystem() // Needed to be able to plot on the timeline. + let coordinateSystem let slotCoordinateSystem // Needed to be able to plot on a slot over the timeline. let plotterModuleConfig let slotHeight = (canvas.chartSpace.viewport.visibleArea.bottomRight.y - canvas.chartSpace.viewport.visibleArea.topLeft.y) / 10 // This is the amount of slots available @@ -96,7 +87,7 @@ function newPlotter () { } } - function initialize (pStorage, pDatetime, pTimeFrame, callBackFunction, pProductDefinition) { + function initialize (pStorage, pDatetime, pTimeFrame, pCoordinateSystem, callBackFunction, pProductDefinition) { try { /* Store the information received. */ marketFiles = pStorage.marketFiles[0] @@ -104,14 +95,13 @@ function newPlotter () { datetime = pDatetime timeFrame = pTimeFrame + coordinateSystem = pCoordinateSystem productDefinition = pProductDefinition /* We need a Market File in order to calculate the Y scale, since this scale depends on actual data. */ marketFile = marketFiles.getFile(ONE_DAY_IN_MILISECONDS) // This file is the one processed faster. - recalculateScale() - /* Now we set the right files according to current Period. */ marketFile = marketFiles.getFile(pTimeFrame) fileCursor = dailyFiles.getFileCursor(pTimeFrame) @@ -127,7 +117,6 @@ function newPlotter () { /* Get ready for plotting. */ recalculate() dimmensionsChangedEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('Dimmensions Changed', function () { - recalculateScale() recalculate() }) @@ -209,6 +198,10 @@ function newPlotter () { datetime = pDatetime } + function setCoordinateSystem (pCoordinateSystem) { + coordinateSystem = pCoordinateSystem + } + function onDailyFileLoaded (event) { try { if (event.currentValue === event.totalValue) { diff --git a/Scales/RateScale.js b/Scales/RateScale.js index 3f4009f87..21a749462 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -89,6 +89,9 @@ function newRateScale () { limitingContainer = pLimitingContainer rateCalculationsContainer = pRateCalculationsContainer + thisObject.minValue = coordinateSystem.min.y + thisObject.maxValue = coordinateSystem.max.y + onMouseWheelEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) onMouseNotOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) @@ -222,6 +225,8 @@ function newRateScale () { code.scale = thisObject.scale / MAX_SCALE * 100 code.scale = code.scale.toFixed(0) code.offset = thisObject.offset + code.minValue = thisObject.minValue + code.maxValue = thisObject.maxValue thisObject.payload.node.code = JSON.stringify(code) } catch (err) { // we ignore errors here since most likely they will be parsing errors. @@ -233,67 +238,61 @@ function newRateScale () { let code = JSON.parse(thisObject.payload.node.code) if (isNaN(code.scale) || code.scale === null || code.scale === undefined) { - saveObjectState() - return - } - - code.scale = code.scale / 100 * MAX_SCALE - if (code.scale < MIN_SCALE) { code.scale = MIN_SCALE } - if (code.scale > MAX_SCALE) { code.scale = MAX_SCALE } - - if (code.scale !== thisObject.scale) { - thisObject.scale = code.scale - let event = {} - if ( - thisObject.scale <= DEFAULT_SCALE + SNAP_THRESHOLD_SCALE && - thisObject.scale >= DEFAULT_SCALE - SNAP_THRESHOLD_SCALE - ) { - event.scale = DEFAULT_SCALE - } else { - event.scale = thisObject.scale - } - thisObject.container.eventHandler.raiseEvent('Rate Scale Value Changed', event) + // not using this value } else { - saveObjectState() - return + code.scale = code.scale / 100 * MAX_SCALE + if (code.scale < MIN_SCALE) { code.scale = MIN_SCALE } + if (code.scale > MAX_SCALE) { code.scale = MAX_SCALE } + + if (code.scale !== thisObject.scale) { + thisObject.scale = code.scale + let event = {} + if ( + thisObject.scale <= DEFAULT_SCALE + SNAP_THRESHOLD_SCALE && + thisObject.scale >= DEFAULT_SCALE - SNAP_THRESHOLD_SCALE + ) { + event.scale = DEFAULT_SCALE + } else { + event.scale = thisObject.scale + } + thisObject.container.eventHandler.raiseEvent('Rate Scale Value Changed', event) + } } if (isNaN(code.offset) || code.offset === null || code.offset === undefined) { - saveObjectState() - return - } - - if (code.offset < MIN_OFFSET) { code.offset = MIN_OFFSET } - if (code.offset > MAX_OFFSET) { code.offset = MAX_OFFSET } - - if (code.offset !== thisObject.offset) { - thisObject.offset = code.offset - let event = {} - if ( - thisObject.offset <= DEFAULT_OFFSET + SNAP_THRESHOLD_OFFSET && - thisObject.offset >= DEFAULT_OFFSET - SNAP_THRESHOLD_OFFSET - ) { - event.offset = 0 - } else { - event.offset = -thisObject.offset - } - thisObject.container.eventHandler.raiseEvent('Rate Scale Offset Changed', event) + // not using this value } else { - saveObjectState() - return + if (code.offset < MIN_OFFSET) { code.offset = MIN_OFFSET } + if (code.offset > MAX_OFFSET) { code.offset = MAX_OFFSET } + + if (code.offset !== thisObject.offset) { + thisObject.offset = code.offset + let event = {} + if ( + thisObject.offset <= DEFAULT_OFFSET + SNAP_THRESHOLD_OFFSET && + thisObject.offset >= DEFAULT_OFFSET - SNAP_THRESHOLD_OFFSET + ) { + event.offset = 0 + } else { + event.offset = -thisObject.offset + } + thisObject.container.eventHandler.raiseEvent('Rate Scale Offset Changed', event) + } } - if (isNaN(code.minValue) || code.minValue === null || code.minValue === undefined) { - saveObjectState() - return + if ( + (isNaN(code.minValue) || code.minValue === null || code.minValue === undefined) || + (isNaN(code.maxValue) || code.maxValue === null || code.maxValue === undefined) + ) { + // not using this value + } else { + thisObject.minValue = code.minValue + thisObject.maxValue = code.maxValue + coordinateSystem.min.y = code.minValue + coordinateSystem.max.y = code.maxValue + coordinateSystem.recalculateScale() } - if (isNaN(code.maxValue) || code.maxValue === null || code.maxValue === undefined) { - saveObjectState() - return - } - - coordinateSystem.min.y = code.minValue - coordinateSystem.max.y = code.maxValue + saveObjectState() // this overrides any invalid value at the config. } catch (err) { // we ignore errors here since most likely they will be parsing errors. } @@ -401,8 +400,14 @@ function newRateScale () { let rate = thisObject.rate - if (rate < coordinateSystem.min.y) { rate = coordinateSystem.min.y } - if (rate > coordinateSystem.max.y) { rate = coordinateSystem.max.y } + if (rate < coordinateSystem.min.y) { + rate = coordinateSystem.min.y + coordinateSystem.recalculateScale() + } + if (rate > coordinateSystem.max.y) { + rate = coordinateSystem.max.y + coordinateSystem.recalculateScale() + } let label = (rate - Math.trunc(rate)).toFixed(2) let labelArray = label.split('.') From 54828c0c901e808f2169be0bc8e06cd79f8617a1 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 30 Jan 2020 20:53:13 +0100 Subject: [PATCH 217/264] tyding --- ChartsSpace/TimelineChart.js | 6 +----- Globals.js | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 1d783deb2..dd83c16fd 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -303,11 +303,7 @@ function newTimelineChart () { } center = unTransformThisPoint(center, thisObject.container) - if (thisObject.rateScale === undefined) { - center = timeMachineCoordinateSystem.unInverseTransform(center, thisObject.container.frame.height) - } else { - center = timelineChartCoordinateSystem.unInverseTransform(center, thisObject.container.frame.height) - } + center = coordinateSystem.unInverseTransform(center, thisObject.container.frame.height) let newDate = new Date(center.x) diff --git a/Globals.js b/Globals.js index 08ad5c1b7..60d77a30e 100644 --- a/Globals.js +++ b/Globals.js @@ -117,7 +117,7 @@ const DEFAULT_CONFIG_TEXT = '// Write your config here' const DEFAULT_FORMULA_TEXT = '// Write your formula here' const DEFAULT_CODE_TEXT = '// Write your code here' -const MAX_DEFAULT_RATE_SCALE_VALUE = 19900; // This is needed to know the scale of the market time line. +const MAX_DEFAULT_RATE_SCALE_VALUE = 35000; // This is needed to know the scale of the market time line. const WIDHTER_VOLUME_BAR_BASE_FACTOR = 2.5; const LESS_WIDHTER_VOLUME_BAR_TOP_FACTOR = 1 / 4; From 39dbc4db475057537b79ba0edeb22186e835e6b8 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 30 Jan 2020 21:10:36 +0100 Subject: [PATCH 218/264] relocation of the origin of datetime --- ChartsSpace/TimeMachine.js | 103 ++++++++++++++++++++++++----------- ChartsSpace/TimelineChart.js | 54 +++--------------- 2 files changed, 80 insertions(+), 77 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 2a2bc8ff8..c8c5be462 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -45,6 +45,8 @@ function newTimeMachine () { let syncWithDesignerLoop = 0 let timelineChartsMap = new Map() + let onViewportPositionChangedEventSuscriptionId + let onViewportZoomChangedEventSuscriptionId let onMouseOverEventSuscriptionId let onMouseNotOverEventSuscriptionId let timeScaleValueEventSuscriptionId @@ -70,6 +72,9 @@ function newTimeMachine () { } function finalize () { + canvas.chartSpace.viewport.eventHandler.stopListening(onViewportPositionChangedEventSuscriptionId) + canvas.chartSpace.viewport.eventHandler.stopListening(onViewportZoomChangedEventSuscriptionId) + if (thisObject.timeScale !== undefined) { finalizeTimeScale() } @@ -134,45 +139,48 @@ function newTimeMachine () { loadFrame(thisObject.payload, thisObject.container.frame) recalculateCoordinateSystem() + recalculateCurrentDatetime() onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) - - function onMouseOver (event) { - drawScales = true - - mouse.position.x = event.x - mouse.position.y = event.y - - if (thisObject.timeScale !== undefined) { - thisObject.timeScale.onMouseOverSomeTimeMachineContainer(event) - } - if (thisObject.rateScale !== undefined) { - thisObject.rateScale.onMouseOverSomeTimeMachineContainer(event) - } - if (thisObject.timeFrameScale !== undefined) { - thisObject.timeFrameScale.onMouseOverSomeTimeMachineContainer(event) - } - } - onMouseNotOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) - function onMouseNotOver (event) { - drawScales = false - - if (thisObject.timeScale !== undefined) { - thisObject.timeScale.visible = false - } - if (thisObject.rateScale !== undefined) { - thisObject.rateScale.visible = false - } - if (thisObject.timeFrameScale !== undefined) { - thisObject.timeFrameScale.visible = false - } - } + onViewportPositionChangedEventSuscriptionId = canvas.chartSpace.viewport.eventHandler.listenToEvent('Position Changed', onViewportPositionChanged) + onViewportZoomChangedEventSuscriptionId = canvas.chartSpace.viewport.eventHandler.listenToEvent('Zoom Changed', onViewportZoomChanged) callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) } + function onMouseOver (event) { + drawScales = true + + mouse.position.x = event.x + mouse.position.y = event.y + + if (thisObject.timeScale !== undefined) { + thisObject.timeScale.onMouseOverSomeTimeMachineContainer(event) + } + if (thisObject.rateScale !== undefined) { + thisObject.rateScale.onMouseOverSomeTimeMachineContainer(event) + } + if (thisObject.timeFrameScale !== undefined) { + thisObject.timeFrameScale.onMouseOverSomeTimeMachineContainer(event) + } + } + + function onMouseNotOver (event) { + drawScales = false + + if (thisObject.timeScale !== undefined) { + thisObject.timeScale.visible = false + } + if (thisObject.rateScale !== undefined) { + thisObject.rateScale.visible = false + } + if (thisObject.timeFrameScale !== undefined) { + thisObject.timeFrameScale.visible = false + } + } + function initializeTimeScale () { thisObject.timeScale = newTimeScale() thisObject.timeScale.fitFunction = thisObject.fitFunction @@ -291,6 +299,39 @@ function newTimeMachine () { } } + function onViewportZoomChanged (event) { + if (thisObject.container.frame.isInViewPort()) { + recalculateCurrentDatetime() + } + } + + function onViewportPositionChanged () { + if (thisObject.container.frame.isInViewPort()) { + recalculateCurrentDatetime() + } + } + + function recalculateCurrentDatetime () { + /* + The view port was moved or the view port zoom level was changed and the center of the screen points to a different datetime that we + must calculate. + */ + let center = { + x: (canvas.chartSpace.viewport.visibleArea.bottomRight.x - canvas.chartSpace.viewport.visibleArea.bottomLeft.x) / 2, + y: (canvas.chartSpace.viewport.visibleArea.bottomRight.y - canvas.chartSpace.viewport.visibleArea.topRight.y) / 2 + } + + center = unTransformThisPoint(center, thisObject.container) + center = timeMachineCoordinateSystem.unInverseTransform(center, thisObject.container.frame.height) + + datetime = new Date(center.x) + + for (let i = 0; i < thisObject.timelineCharts.length; i++) { + let timelineChart = thisObject.timelineCharts[i] + timelineChart.setDatetime(datetime) + } + } + function fitFunction (point, fullVisible, margin, topMargin, bottomMargin) { /* We prevent a point to be out of the container AND out of the Chart Space in general */ diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index dd83c16fd..0b2ba2c25 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -18,6 +18,7 @@ function newTimelineChart () { layersManager: undefined, plotterManager: undefined, upstreamTimeFrame: undefined, + setDatetime: setDatetime, setTimeFrame: setTimeFrame, physics: physics, draw: draw, @@ -35,8 +36,6 @@ function newTimelineChart () { let layersPanel let layersPanelHandle - let onViewportPositionChangedEventSuscriptionId - let onViewportZoomChangedEventSuscriptionId let onMouseOverEventSuscriptionId let onMouseNotOverEventSuscriptionId let rateScaleValueEventSuscriptionId @@ -77,8 +76,6 @@ function newTimelineChart () { finalizeTimeFrameScale() } - canvas.chartSpace.viewport.eventHandler.stopListening(onViewportPositionChangedEventSuscriptionId) - canvas.chartSpace.viewport.eventHandler.stopListening(onViewportZoomChangedEventSuscriptionId) thisObject.container.eventHandler.stopListening(onMouseOverEventSuscriptionId) thisObject.container.eventHandler.stopListening(onMouseNotOverEventSuscriptionId) thisObject.container.finalize() @@ -145,11 +142,6 @@ function newTimelineChart () { coordinateSystem = timeMachineCoordinateSystem timeFrame = INITIAL_TIME_PERIOD - recalculateCurrentDatetime() - - /* Event Subscriptions - we need this events to be fired first here and then in active Plotters. */ - onViewportPositionChangedEventSuscriptionId = canvas.chartSpace.viewport.eventHandler.listenToEvent('Position Changed', onViewportPositionChanged) - onViewportZoomChangedEventSuscriptionId = canvas.chartSpace.viewport.eventHandler.listenToEvent('Zoom Changed', onViewportZoomChanged) onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) onMouseNotOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) @@ -247,6 +239,13 @@ function newTimelineChart () { } } + function setDatetime (pDatetime) { + datetime = pDatetime + if (thisObject.plotterManager !== undefined) { + thisObject.plotterManager.setDatetime(datetime) + } + } + function onMouseOver (event) { /* This event gets to the timelinechart container because it inherits it from the time machine container, which is the one raising Mouse Over and Mouse not Over Events to its children. */ drawScales = true @@ -277,43 +276,6 @@ function newTimelineChart () { } } - function onViewportZoomChanged (event) { - if (thisObject.container.frame.isInViewPort()) { - recalculateCurrentDatetime() - } - } - - function onViewportPositionChanged () { - if (thisObject.container.frame.isInViewPort()) { - recalculateCurrentDatetime() - } - } - - function recalculateCurrentDatetime () { - /* - - The view port was moved or the view port zoom level was changed and the center of the screen points to a different datetime that we - must calculate. - - */ - - let center = { - x: (canvas.chartSpace.viewport.visibleArea.bottomRight.x - canvas.chartSpace.viewport.visibleArea.bottomLeft.x) / 2, - y: (canvas.chartSpace.viewport.visibleArea.bottomRight.y - canvas.chartSpace.viewport.visibleArea.topRight.y) / 2 - } - - center = unTransformThisPoint(center, thisObject.container) - center = coordinateSystem.unInverseTransform(center, thisObject.container.frame.height) - - let newDate = new Date(center.x) - - datetime = newDate - - if (thisObject.plotterManager !== undefined) { - thisObject.plotterManager.setDatetime(datetime) - } - } - function getContainer (point, purpose) { let container From 4b5613db1f6fd9d1afe20c63eaeec5435d3262cb Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 30 Jan 2020 21:34:56 +0100 Subject: [PATCH 219/264] removing old way of knowing user position from the plotter --- Plotter.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Plotter.js b/Plotter.js index 76ce16e0f..f65044c5b 100644 --- a/Plotter.js +++ b/Plotter.js @@ -42,7 +42,9 @@ function newPlotter () { let productDefinition // Here we store a snapshot of the product definition which references this plotter. let records = [] // We will have the information to be plotted here. + let userPositionDate + let onMouseOverEventSuscriptionId let zoomChangedEventSubscriptionId let offsetChangedEventSubscriptionId let dragFinishedEventSubscriptionId @@ -57,6 +59,7 @@ function newPlotter () { function finalize () { try { /* Stop listening to the necesary events. */ + thisObject.container.eventHandler.stopListening(onMouseOverEventSuscriptionId) canvas.chartSpace.viewport.eventHandler.stopListening(zoomChangedEventSubscriptionId) canvas.chartSpace.viewport.eventHandler.stopListening(offsetChangedEventSubscriptionId) canvas.eventHandler.stopListening(dragFinishedEventSubscriptionId) @@ -113,6 +116,7 @@ function newPlotter () { marketFilesUpdatedEventSubscriptionId = marketFiles.eventHandler.listenToEvent('Files Updated', onMarketFilesUpdated) dailyFilesUpdatedEventSubscriptionId = dailyFiles.eventHandler.listenToEvent('Files Updated', onDailyFilesUpdated) onDisplaceEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onDisplace', onDisplace) + onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) /* Get ready for plotting. */ recalculate() @@ -127,6 +131,11 @@ function newPlotter () { } } + function onMouseOver (event) { + let userPosition = getDateFromPoint(event, thisObject.container, coordinateSystem) + userPositionDate = userPosition.valueOf() + } + function onMarketFilesUpdated () { try { let newMarketFile = marketFiles.getFile(timeFrame) @@ -476,9 +485,6 @@ function newPlotter () { function plotChart () { try { - let userPosition = getUserPosition() - let userPositionDate = userPosition.point.x - /* Clean the pannel at places where there is no record. */ let currentRecord = { data: undefined From 1e4238ea3ccda90aa973e978be169be6b0e22493 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 30 Jan 2020 23:28:40 +0100 Subject: [PATCH 220/264] changes in ratescale working --- ChartsSpace/CoordinateSystem.js | 21 +++++----- ChartsSpace/TimeMachine.js | 14 +++++-- Scales/RateScale.js | 21 +++------- Utilities.js | 74 +++++++-------------------------- 4 files changed, 40 insertions(+), 90 deletions(-) diff --git a/ChartsSpace/CoordinateSystem.js b/ChartsSpace/CoordinateSystem.js index e99fedc33..5fc9728fe 100644 --- a/ChartsSpace/CoordinateSystem.js +++ b/ChartsSpace/CoordinateSystem.js @@ -11,6 +11,8 @@ function newCoordinateSystem () { let thisObject = { min: undefined, max: undefined, + maxHeight: undefined, + maxWidth: undefined, scale: undefined, recalculateScale: recalculateScale, transformThisPoint: transformThisPoint, @@ -35,9 +37,6 @@ function newCoordinateSystem () { y: 0 } - let maxHeight - let maxWidth - return thisObject function initialize (minValue, maxValue, pMaxWidth, pMaxHeight) { @@ -48,23 +47,23 @@ function newCoordinateSystem () { thisObject.min.y = minValue.y // * 0.999; // 0.1% less thisObject.max.y = maxValue.y // * 1.001; // 0.1% more - maxWidth = pMaxWidth - maxHeight = pMaxHeight + thisObject.maxWidth = pMaxWidth + thisObject.maxHeight = pMaxHeight recalculateScale() } function recalculateScale () { /* Defines the initial Zoom level at center position. */ - thisObject.scale.x = maxWidth / (thisObject.max.x - thisObject.min.x) - thisObject.scale.y = maxHeight / (thisObject.max.y - thisObject.min.y) + thisObject.scale.x = thisObject.maxWidth / (thisObject.max.x - thisObject.min.x) + thisObject.scale.y = thisObject.maxHeight / (thisObject.max.y - thisObject.min.y) } function initializeX (minValue, maxValue, maxWidth) { thisObject.min.x = minValue.x // * 0.999; // 0.1% less thisObject.max.x = maxValue.x // * 1.001; // 0.1% more - thisObject.scale.x = maxWidth / (thisObject.max.x - thisObject.min.x) + thisObject.scale.x = thisObject.maxWidth / (thisObject.max.x - thisObject.min.x) } function initializeY (minValue, maxValue, pMaxHeight) { @@ -73,7 +72,7 @@ function newCoordinateSystem () { thisObject.scale.y = pMaxHeight / (thisObject.max.y - thisObject.min.y) - maxHeight = pMaxHeight + thisObject.maxHeight = pMaxHeight } function transformThisPoint (point) { @@ -92,7 +91,7 @@ function newCoordinateSystem () { point = { x: (point.x - thisObject.min.x) * thisObject.scale.x, - y: maxHeight - (point.y - thisObject.min.y) * thisObject.scale.y + y: thisObject.maxHeight - (point.y - thisObject.min.y) * thisObject.scale.y } return point @@ -101,7 +100,7 @@ function newCoordinateSystem () { function transformThisPoint2 (point) { point = { x: (point.x - thisObject.min.x) * thisObject.scale.x, - y: (maxHeight - point.y - thisObject.min.y) * thisObject.scale.y + y: (thisObject.maxHeight - point.y - thisObject.min.y) * thisObject.scale.y } return point diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index c8c5be462..6b9246f10 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -194,7 +194,7 @@ function newTimeMachine () { thisObject.container.frame.width = TIME_MACHINE_WIDTH + TIME_MACHINE_WIDTH * event.scale recalculateCoordinateSystem() if (event.isUserAction === true) { - moveToUserPosition(thisObject.container, timeMachineCoordinateSystem, false, true, event.mousePosition, true) + // moveToUserPosition(thisObject.container, previousCoordinateSystem, timeMachineCoordinateSystem, false, true, event.mousePosition, true) } thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) } @@ -213,10 +213,16 @@ function newTimeMachine () { thisObject.rateScale.initialize(timeMachineCoordinateSystem, thisObject.container, thisObject.container) function rateScaleValueChanged (event) { - thisObject.container.frame.height = TIME_MACHINE_HEIGHT + TIME_MACHINE_HEIGHT * event.scale - recalculateCoordinateSystem() if (event.isUserAction === true) { - moveToUserPosition(thisObject.container, timeMachineCoordinateSystem, true, false, event.mousePosition, true) + let currentDate = getDateFromPoint(event.mousePosition, thisObject.container, timeMachineCoordinateSystem) + let currentRate = getRateFromPoint(event.mousePosition, thisObject.container, timeMachineCoordinateSystem) + + thisObject.container.frame.height = TIME_MACHINE_HEIGHT + TIME_MACHINE_HEIGHT * event.scale + recalculateCoordinateSystem() + moveToUserPosition(thisObject.container, currentDate, currentRate, timeMachineCoordinateSystem, true, false, event.mousePosition, true) + } else { + thisObject.container.frame.height = TIME_MACHINE_HEIGHT + TIME_MACHINE_HEIGHT * event.scale + recalculateCoordinateSystem() } thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) thisObject.container.eventHandler.raiseEvent('Upstream Rate Scale Value Changed', event) diff --git a/Scales/RateScale.js b/Scales/RateScale.js index 21a749462..9d367f1ca 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -177,26 +177,17 @@ function newRateScale () { if (thisObject.scale > MAX_SCALE) { thisObject.scale = MAX_SCALE } } - if ( - thisObject.scale <= DEFAULT_SCALE + SNAP_THRESHOLD_SCALE && - thisObject.scale >= DEFAULT_SCALE - SNAP_THRESHOLD_SCALE - ) { - event.scale = DEFAULT_SCALE - } else { - event.scale = thisObject.scale - } - - event.isUserAction = true - thisObject.container.eventHandler.raiseEvent('Rate Scale Value Changed', event) - - saveObjectState() - offsetTimer = 0 - scaleTimer = 100 + finishScaleChange(event) } } function setScale (scale) { thisObject.scale = scale + let event = {} + finishScaleChange(event) + } + + function finishScaleChange (event) { if ( thisObject.scale <= DEFAULT_SCALE + SNAP_THRESHOLD_SCALE && thisObject.scale >= DEFAULT_SCALE - SNAP_THRESHOLD_SCALE diff --git a/Utilities.js b/Utilities.js index 7749bc532..77f3bc643 100644 --- a/Utilities.js +++ b/Utilities.js @@ -188,76 +188,30 @@ function getUserPosition (coordinateSystem) { return userPosition } -function moveToUserPosition (container, coordinateSystem, ignoreX, ignoreY, center, moveContainer) { - let userPosition = getUserPosition(coordinateSystem) - - INITIAL_TIME_PERIOD = recalculatePeriod(userPosition.zoom) - NEW_SESSION_INITIAL_DATE = new Date(userPosition.date) - +function moveToUserPosition (container, currentDate, currentRate, coordinateSystem, ignoreX, ignoreY, mousePosition) { let targetPoint = { - x: (new Date(userPosition.date)).valueOf(), - y: userPosition.rate + x: currentDate.valueOf(), + y: currentRate } - /* Put this po int in the coordinate system of the canvas.chartSpace.viewport */ - + /* Put this point in the coordinate system of the canvas.chartSpace.viewport */ targetPoint = coordinateSystem.transformThisPoint(targetPoint) targetPoint = transformThisPoint(targetPoint, container) - let centerPoint - if (center !== undefined) { - centerPoint = { - x: center.x, - y: center.y - } - } else { - centerPoint = { - x: (canvas.chartSpace.viewport.visibleArea.bottomRight.x - canvas.chartSpace.viewport.visibleArea.topLeft.x) / 2, - y: (canvas.chartSpace.viewport.visibleArea.bottomRight.y - canvas.chartSpace.viewport.visibleArea.topLeft.y) / 2 - } - } - - /* When we are moving the container, it needs to consider the zooming of the viewport */ - /* Lets calculate the displace vector, from the point we want at the center, to the current center. */ - let displaceVector - if (moveContainer === true) { - let targetCopy = { - x: targetPoint.x, - y: targetPoint.y - } - let targetNoZoom - targetNoZoom = canvas.chartSpace.viewport.unTransformThisPoint(targetCopy) + let targetNoZoom = canvas.chartSpace.viewport.unTransformThisPoint(targetPoint) + let mouseNoZoom = canvas.chartSpace.viewport.unTransformThisPoint(mousePosition) - let centerCopy = { - x: centerPoint.x, - y: centerPoint.y - } - - let centerNoZoom - centerNoZoom = canvas.chartSpace.viewport.unTransformThisPoint(centerCopy) - - displaceVector = { - x: centerNoZoom.x - targetNoZoom.x, - y: centerNoZoom.y - targetNoZoom.y - } - - if (ignoreX) { displaceVector.x = 0 } - if (ignoreY) { displaceVector.y = 0 } - - container.displace(displaceVector) - } else { - displaceVector = { - x: centerPoint.x - targetPoint.x, - y: centerPoint.y - targetPoint.y - } - - if (ignoreX) { displaceVector.x = 0 } - if (ignoreY) { displaceVector.y = 0 } - - canvas.chartSpace.viewport.displace(displaceVector) + displaceVector = { + x: mouseNoZoom.x - targetNoZoom.x, + y: mouseNoZoom.y - targetNoZoom.y } + + if (ignoreX) { displaceVector.x = 0 } + if (ignoreY) { displaceVector.y = 0 } + + container.displace(displaceVector) } function removeTime (datetime) { From d109ef8a980d0645ff75a784ac370ef104a42642 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 30 Jan 2020 23:33:33 +0100 Subject: [PATCH 221/264] Cleaning User Position Concept --- ChartsSpace/TimeMachine.js | 13 ++++++++---- ChartsSpace/TimelineChart.js | 3 --- Utilities.js | 41 ------------------------------------ 3 files changed, 9 insertions(+), 48 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 6b9246f10..5cecead76 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -191,10 +191,15 @@ function newTimeMachine () { thisObject.timeScale.initialize(timeMachineCoordinateSystem, thisObject.container) function timeScaleValueChanged (event) { - thisObject.container.frame.width = TIME_MACHINE_WIDTH + TIME_MACHINE_WIDTH * event.scale - recalculateCoordinateSystem() if (event.isUserAction === true) { - // moveToUserPosition(thisObject.container, previousCoordinateSystem, timeMachineCoordinateSystem, false, true, event.mousePosition, true) + let currentDate = getDateFromPoint(event.mousePosition, thisObject.container, timeMachineCoordinateSystem) + let currentRate = getRateFromPoint(event.mousePosition, thisObject.container, timeMachineCoordinateSystem) + thisObject.container.frame.width = TIME_MACHINE_WIDTH + TIME_MACHINE_WIDTH * event.scale + recalculateCoordinateSystem() + moveToUserPosition(thisObject.container, currentDate, currentRate, timeMachineCoordinateSystem, false, true, event.mousePosition) + } else { + thisObject.container.frame.width = TIME_MACHINE_WIDTH + TIME_MACHINE_WIDTH * event.scale + recalculateCoordinateSystem() } thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event) } @@ -219,7 +224,7 @@ function newTimeMachine () { thisObject.container.frame.height = TIME_MACHINE_HEIGHT + TIME_MACHINE_HEIGHT * event.scale recalculateCoordinateSystem() - moveToUserPosition(thisObject.container, currentDate, currentRate, timeMachineCoordinateSystem, true, false, event.mousePosition, true) + moveToUserPosition(thisObject.container, currentDate, currentRate, timeMachineCoordinateSystem, true, false, event.mousePosition) } else { thisObject.container.frame.height = TIME_MACHINE_HEIGHT + TIME_MACHINE_HEIGHT * event.scale recalculateCoordinateSystem() diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 0b2ba2c25..8ff2e5d0b 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -228,7 +228,6 @@ function newTimelineChart () { function timeFrameScaleMouseOver (event) { thisObject.container.eventHandler.raiseEvent('onChildrenMouseOver', event) - saveUserPosition(thisObject.container, timeMachineCoordinateSystem, event) } } @@ -260,8 +259,6 @@ function newTimelineChart () { mouse.position.x = event.x mouse.position.y = event.y - - saveUserPosition(thisObject.container, timeMachineCoordinateSystem, event) } function onMouseNotOver (event) { diff --git a/Utilities.js b/Utilities.js index 77f3bc643..4d5b70c94 100644 --- a/Utilities.js +++ b/Utilities.js @@ -147,47 +147,6 @@ function getMilisecondsFromPoint (point, container, coordinateSystem) { return point.x } -function saveUserPosition (container, coordinateSystem, position) { - if (position === undefined) { - position = { - x: (canvas.chartSpace.viewport.visibleArea.bottomRight.x - canvas.chartSpace.viewport.visibleArea.topLeft.x) / 2, - y: (canvas.chartSpace.viewport.visibleArea.bottomRight.y - canvas.chartSpace.viewport.visibleArea.topLeft.y) / 2 - } - } - - let userPosition = { - date: getDateFromPoint(position, container, coordinateSystem), - rate: getRateFromPoint(position, container, coordinateSystem), - market: DEFAULT_MARKET, - zoom: canvas.chartSpace.viewport.zoomTargetLevel - } - - window.localStorage.setItem('userPosition', JSON.stringify(userPosition)) -} - -function getUserPosition (coordinateSystem) { - let savedPosition = window.localStorage.getItem('userPosition') - let userPosition - - if (savedPosition === null) { - userPosition = { - date: (new Date()).toString(), - rate: coordinateSystem.max.y / 2, - market: DEFAULT_MARKET, - zoom: INITIAL_ZOOM_LEVEL - } - } else { - userPosition = JSON.parse(savedPosition) - } - - userPosition.point = { - x: (new Date(userPosition.date)).valueOf(), - y: userPosition.rate - } - - return userPosition -} - function moveToUserPosition (container, currentDate, currentRate, coordinateSystem, ignoreX, ignoreY, mousePosition) { let targetPoint = { x: currentDate.valueOf(), From d82947263856620d7098bfeed484f6927068e715 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 30 Jan 2020 23:53:02 +0100 Subject: [PATCH 222/264] Bug Fixed --- ChartsSpace/TimeMachine.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 5cecead76..6584f7f6e 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -601,6 +601,16 @@ function newTimeMachine () { x: MAX_PLOTABLE_DATE.valueOf(), y: nextPorwerOf10(MAX_DEFAULT_RATE_SCALE_VALUE) / 4 } +/* + if (thisObject.timeScale !== undefined) { + minValue.y = thisObject.rateScale.minValue + maxValue.y = thisObject.rateScale.maxValue + } + */ + if (thisObject.rateScale !== undefined) { + minValue.y = thisObject.rateScale.minValue + maxValue.y = thisObject.rateScale.maxValue + } timeMachineCoordinateSystem.initialize( minValue, From ded51e5381c93185c8d1ec49e669f6200e887a39 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 31 Jan 2020 09:47:28 +0100 Subject: [PATCH 223/264] TimeScale acepting from and to in scale configuration --- ChartsSpace/TimeMachine.js | 8 ++--- Scales/RateScale.js | 6 ++-- Scales/TimeScale.js | 61 +++++++++++++++++++++++++------------- 3 files changed, 47 insertions(+), 28 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 6584f7f6e..a046f350c 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -601,12 +601,12 @@ function newTimeMachine () { x: MAX_PLOTABLE_DATE.valueOf(), y: nextPorwerOf10(MAX_DEFAULT_RATE_SCALE_VALUE) / 4 } -/* + if (thisObject.timeScale !== undefined) { - minValue.y = thisObject.rateScale.minValue - maxValue.y = thisObject.rateScale.maxValue + minValue.x = thisObject.timeScale.fromDate + maxValue.x = thisObject.timeScale.toDate } - */ + if (thisObject.rateScale !== undefined) { minValue.y = thisObject.rateScale.minValue maxValue.y = thisObject.rateScale.maxValue diff --git a/Scales/RateScale.js b/Scales/RateScale.js index 9d367f1ca..232c4c309 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -218,7 +218,7 @@ function newRateScale () { code.offset = thisObject.offset code.minValue = thisObject.minValue code.maxValue = thisObject.maxValue - thisObject.payload.node.code = JSON.stringify(code) + thisObject.payload.node.code = JSON.stringify(code, null, 4) } catch (err) { // we ignore errors here since most likely they will be parsing errors. } @@ -279,8 +279,8 @@ function newRateScale () { } else { thisObject.minValue = code.minValue thisObject.maxValue = code.maxValue - coordinateSystem.min.y = code.minValue - coordinateSystem.max.y = code.maxValue + coordinateSystem.min.y = thisObject.minValue + coordinateSystem.max.y = thisObject.maxValue coordinateSystem.recalculateScale() } saveObjectState() // this overrides any invalid value at the config. diff --git a/Scales/TimeScale.js b/Scales/TimeScale.js index b39ceb13d..ccbe3cbc2 100644 --- a/Scales/TimeScale.js +++ b/Scales/TimeScale.js @@ -8,6 +8,8 @@ function newTimeScale () { fitFunction: undefined, payload: undefined, isVisible: true, + fromDate: undefined, + toDate: undefined, onMouseOverSomeTimeMachineContainer: onMouseOverSomeTimeMachineContainer, physics: physics, draw: draw, @@ -72,6 +74,9 @@ function newTimeScale () { coordinateSystem = pCoordinateSystem limitingContainer = pLimitingContainer + thisObject.fromDate = coordinateSystem.min.x + thisObject.toDate = coordinateSystem.max.x + onMouseWheelEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) onMouseNotOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) @@ -155,7 +160,9 @@ function newTimeScale () { let code = JSON.parse(thisObject.payload.node.code) code.scale = thisObject.scale / MAX_SCALE * 100 code.scale = code.scale.toFixed(0) - thisObject.payload.node.code = JSON.stringify(code) + code.fromDate = (new Date(thisObject.fromDate)).toISOString() + code.toDate = (new Date(thisObject.toDate)).toISOString() + thisObject.payload.node.code = JSON.stringify(code, null, 4) } catch (err) { // we ignore errors here since most likely they will be parsing errors. } @@ -166,28 +173,40 @@ function newTimeScale () { let code = JSON.parse(thisObject.payload.node.code) if (isNaN(code.scale) || code.scale === null || code.scale === undefined) { - saveObjectState() - return - } - code.scale = code.scale / 100 * MAX_SCALE - if (code.scale < MIN_SCALE) { code.scale = MIN_SCALE } - if (code.scale > MAX_SCALE) { code.scale = MAX_SCALE } - - if (code.scale !== thisObject.scale) { - thisObject.scale = code.scale - let event = {} - if ( - thisObject.scale <= DEFAULT_SCALE + SNAP_THRESHOLD_SCALE && - thisObject.scale >= DEFAULT_SCALE - SNAP_THRESHOLD_SCALE - ) { - event.scale = DEFAULT_SCALE - } else { - event.scale = thisObject.scale - } - thisObject.container.eventHandler.raiseEvent('Time Scale Value Changed', event) + // not using this value } else { - saveObjectState() + code.scale = code.scale / 100 * MAX_SCALE + if (code.scale < MIN_SCALE) { code.scale = MIN_SCALE } + if (code.scale > MAX_SCALE) { code.scale = MAX_SCALE } + + if (code.scale !== thisObject.scale) { + thisObject.scale = code.scale + let event = {} + if ( + thisObject.scale <= DEFAULT_SCALE + SNAP_THRESHOLD_SCALE && + thisObject.scale >= DEFAULT_SCALE - SNAP_THRESHOLD_SCALE + ) { + event.scale = DEFAULT_SCALE + } else { + event.scale = thisObject.scale + } + thisObject.container.eventHandler.raiseEvent('Time Scale Value Changed', event) + } } + + if ( + (isNaN(Date.parse(code.fromDate)) || code.fromDate === null || code.fromDate === undefined) || + (isNaN(Date.parse(code.toDate)) || code.toDate === null || code.toDate === undefined) + ) { + // not using this value + } else { + thisObject.fromDate = Date.parse(code.fromDate) + thisObject.toDate = Date.parse(code.toDate) + coordinateSystem.min.x = thisObject.fromDate + coordinateSystem.max.x = thisObject.toDate + coordinateSystem.recalculateScale() + } + saveObjectState() // this overrides any invalid value at the config. } catch (err) { // we ignore errors here since most likely they will be parsing errors. } From 58cfd502e2762be3195d056e7099b03d2eea2dd3 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 31 Jan 2020 11:04:02 +0100 Subject: [PATCH 224/264] limits on Plotter points --- Plotter.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/Plotter.js b/Plotter.js index f65044c5b..3f5d2b1d4 100644 --- a/Plotter.js +++ b/Plotter.js @@ -262,7 +262,10 @@ function newPlotter () { } } - if (record.begin >= farLeftDate.valueOf() && record.end <= farRightDate.valueOf()) { + if ( + (record.begin >= farLeftDate.valueOf() && record.end <= farRightDate.valueOf()) && + (record.begin >= coordinateSystem.min.x && record.end <= coordinateSystem.max.x) + ) { record.previous = previous jsonifiedArray.push(record) previous = record @@ -516,6 +519,12 @@ function newPlotter () { beginPoint = transformThisPoint(beginPoint, thisObject.container) endPoint = transformThisPoint(endPoint, thisObject.container) + beginPoint = canvas.chartSpace.viewport.fitIntoVisibleArea(beginPoint) + endPoint = canvas.chartSpace.viewport.fitIntoVisibleArea(endPoint) + + beginPoint = thisObject.fitFunction(beginPoint) + endPoint = thisObject.fitFunction(endPoint) + if (endPoint.x < canvas.chartSpace.viewport.visibleArea.bottomLeft.x || beginPoint.x > canvas.chartSpace.viewport.visibleArea.bottomRight.x) { continue } @@ -565,13 +574,9 @@ function newPlotter () { That means that the first thing we allways need to do is to trasform these points to the coordinate system of the timeline. */ dataPoint = coordinateSystem.transformThisPoint(dataPoint) - - /* - The browser canvas object does not care about our timeline and its coordinate system. In order to draw on a html canvas we - need the points to be converted into the canvas coordinate system. - Next we transform again to the screen coordinate system. - */ dataPoint = transformThisPoint(dataPoint, thisObject.container) + dataPoint = canvas.chartSpace.viewport.fitIntoVisibleArea(dataPoint) + dataPoint = thisObject.fitFunction(dataPoint) /* Store the data point at the local map */ dataPoints.set(point.id, dataPoint) From 9cc7e1ccd9fa1d9e836f2d53ff2b78328fdd50a0 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 31 Jan 2020 11:33:07 +0100 Subject: [PATCH 225/264] Coordinate System raising events when scale changes --- ChartsSpace/CoordinateSystem.js | 15 ++++++++++++++- ChartsSpace/TimeMachine.js | 2 ++ ChartsSpace/TimelineChart.js | 1 + Plotter.js | 18 ++++++++++++++++++ Scales/RateScale.js | 14 +++++++------- Scales/TimeScale.js | 12 +++++++----- 6 files changed, 49 insertions(+), 13 deletions(-) diff --git a/ChartsSpace/CoordinateSystem.js b/ChartsSpace/CoordinateSystem.js index 5fc9728fe..a8757a1b7 100644 --- a/ChartsSpace/CoordinateSystem.js +++ b/ChartsSpace/CoordinateSystem.js @@ -14,6 +14,7 @@ function newCoordinateSystem () { maxHeight: undefined, maxWidth: undefined, scale: undefined, + eventHandler: undefined, recalculateScale: recalculateScale, transformThisPoint: transformThisPoint, transformThisPoint2: transformThisPoint2, @@ -21,7 +22,8 @@ function newCoordinateSystem () { inverseTransformUncappedY: inverseTransformUncappedY, initializeX: initializeX, initializeY: initializeY, - initialize: initialize + initialize: initialize, + finalize: finalize } thisObject.min = { @@ -37,8 +39,16 @@ function newCoordinateSystem () { y: 0 } + thisObject.eventHandler = newEventHandler() + thisObject.eventHandler.name = 'Coordinate System' + return thisObject + function finalize () { + thisObject.eventHandler.finalize() + thisObject.eventHandler = undefined + } + function initialize (minValue, maxValue, pMaxWidth, pMaxHeight) { /* Defines the min and max value of rate that we are going to transport to the available screen at the center position. */ thisObject.min.x = minValue.x // * 0.999; // 0.1% less @@ -57,6 +67,9 @@ function newCoordinateSystem () { /* Defines the initial Zoom level at center position. */ thisObject.scale.x = thisObject.maxWidth / (thisObject.max.x - thisObject.min.x) thisObject.scale.y = thisObject.maxHeight / (thisObject.max.y - thisObject.min.y) + + thisObject.eventHandler.raiseEvent('Scale Changed') + console.log('Scale Changed') } function initializeX (minValue, maxValue, maxWidth) { diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index a046f350c..0534784bb 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -104,6 +104,8 @@ function newTimeMachine () { mouse = undefined timelineChartsMap = undefined + + timeMachineCoordinateSystem.finalize() timeMachineCoordinateSystem = undefined } diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 8ff2e5d0b..fb39a1a36 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -86,6 +86,7 @@ function newTimelineChart () { logger = undefined timeMachineCoordinateSystem = undefined + timelineChartCoordinateSystem.finalize() timelineChartCoordinateSystem = undefined coordinateSystem = undefined layersPanel = undefined diff --git a/Plotter.js b/Plotter.js index 3f5d2b1d4..d3797b9f7 100644 --- a/Plotter.js +++ b/Plotter.js @@ -52,6 +52,7 @@ function newPlotter () { let marketFilesUpdatedEventSubscriptionId let dailyFilesUpdatedEventSubscriptionId let onDisplaceEventSubscriptionId + let scaleChangedEventSubscriptionId let logged = false return thisObject @@ -78,6 +79,7 @@ function newPlotter () { marketFile = undefined fileCursor = undefined + finalizeCoordinateSystem() coordinateSystem = undefined slotCoordinateSystem = undefined plotterModuleConfig = undefined @@ -99,6 +101,7 @@ function newPlotter () { datetime = pDatetime timeFrame = pTimeFrame coordinateSystem = pCoordinateSystem + initializeCoordinateSystem() productDefinition = pProductDefinition @@ -131,6 +134,19 @@ function newPlotter () { } } + function initializeCoordinateSystem () { + scaleChangedEventSubscriptionId = coordinateSystem.eventHandler.listenToEvent('Scale Changed', onScaleChanged) + } + + function finalizeCoordinateSystem () { + coordinateSystem.eventHandler.stopListening(scaleChangedEventSubscriptionId) + } + + function onScaleChanged () { + mustRecalculateDataPoints = true + recalculate() + } + function onMouseOver (event) { let userPosition = getDateFromPoint(event, thisObject.container, coordinateSystem) userPositionDate = userPosition.valueOf() @@ -208,7 +224,9 @@ function newPlotter () { } function setCoordinateSystem (pCoordinateSystem) { + finalizeCoordinateSystem() coordinateSystem = pCoordinateSystem + initializeCoordinateSystem() } function onDailyFileLoaded (event) { diff --git a/Scales/RateScale.js b/Scales/RateScale.js index 232c4c309..907c8f484 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -277,11 +277,13 @@ function newRateScale () { ) { // not using this value } else { - thisObject.minValue = code.minValue - thisObject.maxValue = code.maxValue - coordinateSystem.min.y = thisObject.minValue - coordinateSystem.max.y = thisObject.maxValue - coordinateSystem.recalculateScale() + if (thisObject.minValue !== code.minValue || thisObject.maxValue !== code.maxValue) { + thisObject.minValue = code.minValue + thisObject.maxValue = code.maxValue + coordinateSystem.min.y = thisObject.minValue + coordinateSystem.max.y = thisObject.maxValue + coordinateSystem.recalculateScale() + } } saveObjectState() // this overrides any invalid value at the config. } catch (err) { @@ -393,11 +395,9 @@ function newRateScale () { if (rate < coordinateSystem.min.y) { rate = coordinateSystem.min.y - coordinateSystem.recalculateScale() } if (rate > coordinateSystem.max.y) { rate = coordinateSystem.max.y - coordinateSystem.recalculateScale() } let label = (rate - Math.trunc(rate)).toFixed(2) diff --git a/Scales/TimeScale.js b/Scales/TimeScale.js index ccbe3cbc2..7e822a723 100644 --- a/Scales/TimeScale.js +++ b/Scales/TimeScale.js @@ -200,11 +200,13 @@ function newTimeScale () { ) { // not using this value } else { - thisObject.fromDate = Date.parse(code.fromDate) - thisObject.toDate = Date.parse(code.toDate) - coordinateSystem.min.x = thisObject.fromDate - coordinateSystem.max.x = thisObject.toDate - coordinateSystem.recalculateScale() + if (thisObject.fromDate !== Date.parse(code.fromDate) || thisObject.toDate !== Date.parse(code.toDate)) { + thisObject.fromDate = Date.parse(code.fromDate) + thisObject.toDate = Date.parse(code.toDate) + coordinateSystem.min.x = thisObject.fromDate + coordinateSystem.max.x = thisObject.toDate + coordinateSystem.recalculateScale() + } } saveObjectState() // this overrides any invalid value at the config. } catch (err) { From 68ec9905e167e09986aa2352a8b36c5b10fe9794 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 31 Jan 2020 12:11:36 +0100 Subject: [PATCH 226/264] bug fixed --- ChartsSpace/CoordinateSystem.js | 1 - Plotter.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/ChartsSpace/CoordinateSystem.js b/ChartsSpace/CoordinateSystem.js index a8757a1b7..6edfffcab 100644 --- a/ChartsSpace/CoordinateSystem.js +++ b/ChartsSpace/CoordinateSystem.js @@ -69,7 +69,6 @@ function newCoordinateSystem () { thisObject.scale.y = thisObject.maxHeight / (thisObject.max.y - thisObject.min.y) thisObject.eventHandler.raiseEvent('Scale Changed') - console.log('Scale Changed') } function initializeX (minValue, maxValue, maxWidth) { diff --git a/Plotter.js b/Plotter.js index d3797b9f7..8df54aa92 100644 --- a/Plotter.js +++ b/Plotter.js @@ -282,7 +282,7 @@ function newPlotter () { if ( (record.begin >= farLeftDate.valueOf() && record.end <= farRightDate.valueOf()) && - (record.begin >= coordinateSystem.min.x && record.end <= coordinateSystem.max.x) + (record.end >= coordinateSystem.min.x && record.begin <= coordinateSystem.max.x) ) { record.previous = previous jsonifiedArray.push(record) From 5bd3d1712d94a2318589c692586c3044f7fd5c95 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 31 Jan 2020 12:22:12 +0100 Subject: [PATCH 227/264] Bug Fixed --- ChartsSpace/TimeMachine.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 0534784bb..cba761905 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -287,7 +287,7 @@ function newTimeMachine () { } } - if (thisObject.timeFrameScale !== undefined && thisObject.rateScale.isVisible === true) { + if (thisObject.timeFrameScale !== undefined && thisObject.timeFrameScale.isVisible === true) { container = thisObject.timeFrameScale.getContainer(point) if (container !== undefined) { if (container.isForThisPurpose(purpose)) { From 4d22ec8bc9e91db3dd431ea320b05d22c40655bf Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 31 Jan 2020 13:53:22 +0100 Subject: [PATCH 228/264] Bug Fixed saving layer maneger object --- Panels/LayersPanel.js | 65 ++++++++++++++++++++++++++++++------------- Utilities.js | 2 +- 2 files changed, 47 insertions(+), 20 deletions(-) diff --git a/Panels/LayersPanel.js b/Panels/LayersPanel.js index 4e47d0cd4..f0664604b 100644 --- a/Panels/LayersPanel.js +++ b/Panels/LayersPanel.js @@ -28,13 +28,13 @@ function newLayersPanel () { let panelTabButton let visible = true - let heatherHeight = 40 + let headerHeight = 40 let footerHeight = 10 let layerHeight = 70 let desiredVisibleLayers = 5 let posibleVisibleLayers = 5 - let desiredPanelHeight = (layerHeight + LAYER_SEPARATION) * desiredVisibleLayers + heatherHeight + footerHeight - let posiblePanelHeight = (layerHeight + LAYER_SEPARATION) * posibleVisibleLayers + heatherHeight + footerHeight + let desiredPanelHeight = (layerHeight + LAYER_SEPARATION) * desiredVisibleLayers + headerHeight + footerHeight + let posiblePanelHeight = (layerHeight + LAYER_SEPARATION) * posibleVisibleLayers + headerHeight + footerHeight let onMouseWheelEventSuscriptionId return thisObject @@ -58,7 +58,7 @@ function newLayersPanel () { thisObject.container.name = thisObject.payload.node.name thisObject.container.frame.containerName = thisObject.container.name thisObject.container.frame.width = UI_PANEL.WIDTH.NORMAL - thisObject.container.frame.height = heatherHeight + thisObject.container.frame.height = headerHeight let position = { x: canvas.chartSpace.viewport.visibleArea.topLeft.x, @@ -75,15 +75,36 @@ function newLayersPanel () { onMouseWheelEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) - let storedValue = loadPropertyFromNodeConfig(thisObject.payload, 'visibleLayers') - if (storedValue >= 0 && storedValue <= 20) { - desiredVisibleLayers = storedValue - } - + readObjectState() loadFrame(thisObject.payload, thisObject.container.frame) isInitialized = true } + function saveObjectState () { + savePropertyAtNodeConfig(thisObject.payload, 'visibleLayers', desiredVisibleLayers) + } + + function readObjectState () { + let storedValue = loadPropertyFromNodeConfig(thisObject.payload, 'visibleLayers') + + if (isNaN(storedValue) || storedValue === null || storedValue === undefined) { + // not using this value + saveObjectState() // this overrides any invalid value at the config. + return + } else { + if (storedValue < 0) { storedValue = 0 } + if (storedValue > thisObject.layers.length) { + storedValue = thisObject.layers.length + } + + if (storedValue !== desiredVisibleLayers) { + desiredVisibleLayers = storedValue + desiredPanelHeight = (layerHeight + LAYER_SEPARATION) * desiredVisibleLayers + headerHeight + footerHeight + calculateVisbleLayers() + } + } + } + function removeLayer (id) { let layer = layersMap.get(id) layersMap.delete(id) @@ -132,38 +153,38 @@ function newLayersPanel () { delta = 1 } - if (event.y - thisObject.container.frame.position.y - CURRENT_TOP_MARGIN < heatherHeight) { + if (event.y - thisObject.container.frame.position.y - CURRENT_TOP_MARGIN < headerHeight) { // Mouse wheel over the header, not a layer desiredVisibleLayers = desiredVisibleLayers + delta if (desiredVisibleLayers < 0) { desiredVisibleLayers = 0 } if (desiredVisibleLayers > thisObject.layers.length) { desiredVisibleLayers = thisObject.layers.length } } else { firstVisibleLayer = firstVisibleLayer + delta } - desiredPanelHeight = (layerHeight + LAYER_SEPARATION) * desiredVisibleLayers + heatherHeight + footerHeight + desiredPanelHeight = (layerHeight + LAYER_SEPARATION) * desiredVisibleLayers + headerHeight + footerHeight calculateVisbleLayers() - savePropertyAtNodeConfig(thisObject.payload, 'visibleLayers', desiredVisibleLayers) + saveObjectState() } function panelSizePhysics () { let viewPortHeight = canvas.chartSpace.viewport.visibleArea.bottomLeft.y - canvas.chartSpace.viewport.visibleArea.topLeft.y - if (viewPortHeight < heatherHeight) { + if (viewPortHeight < headerHeight) { visible = false } else { visible = true } if (desiredPanelHeight > viewPortHeight) { - posibleVisibleLayers = Math.trunc((viewPortHeight - heatherHeight - footerHeight) / (layerHeight + LAYER_SEPARATION)) + posibleVisibleLayers = Math.trunc((viewPortHeight - headerHeight - footerHeight) / (layerHeight + LAYER_SEPARATION)) } else { posibleVisibleLayers = desiredVisibleLayers } if (thisObject.layers.length < posibleVisibleLayers) { posibleVisibleLayers = thisObject.layers.length } if (posibleVisibleLayers === 0) { - posiblePanelHeight = (layerHeight + LAYER_SEPARATION) * posibleVisibleLayers + heatherHeight + posiblePanelHeight = (layerHeight + LAYER_SEPARATION) * posibleVisibleLayers + headerHeight } else { - posiblePanelHeight = (layerHeight + LAYER_SEPARATION) * posibleVisibleLayers + heatherHeight + footerHeight + posiblePanelHeight = (layerHeight + LAYER_SEPARATION) * posibleVisibleLayers + headerHeight + footerHeight } thisObject.container.frame.height = posiblePanelHeight @@ -183,7 +204,7 @@ function newLayersPanel () { let layer = thisObject.layers[i] layer.container.frame.position.x = 0 - layer.container.frame.position.y = (layerHeight + LAYER_SEPARATION) * visibleLayers.length + heatherHeight + layer.container.frame.position.y = (layerHeight + LAYER_SEPARATION) * visibleLayers.length + headerHeight /* Add to Visible Product Array */ visibleLayers.push(layer) @@ -242,9 +263,15 @@ function newLayersPanel () { } } + function syncWithConfigPhysics () { + readObjectState() + } + function physics () { if (isInitialized === false) { return } saveFrame(thisObject.payload, thisObject.container.frame) + syncWithConfigPhysics() + /* The overall idea here is that we need to keep syncronized the panel with the layers that are defined at the Designer. Users can connect or disconnect any objext resulting in changes in which @@ -363,7 +390,7 @@ function newLayersPanel () { let xOffset = 4 let barTopPoint = { x: thisObject.container.frame.width - xOffset, - y: heatherHeight + y: headerHeight } let barBottomPoint = { x: thisObject.container.frame.width - xOffset, @@ -373,7 +400,7 @@ function newLayersPanel () { let handleHeight = (posibleVisibleLayers * (layerHeight + LAYER_SEPARATION)) * ratio let handleTopPoint = { x: thisObject.container.frame.width - xOffset, - y: heatherHeight + (layerHeight + LAYER_SEPARATION) * ratio * (firstVisibleLayer - 1) + y: headerHeight + (layerHeight + LAYER_SEPARATION) * ratio * (firstVisibleLayer - 1) } let handleBottomPoint = { x: thisObject.container.frame.width - xOffset, diff --git a/Utilities.js b/Utilities.js index 4d5b70c94..d9c134816 100644 --- a/Utilities.js +++ b/Utilities.js @@ -26,7 +26,7 @@ function savePropertyAtNodeConfig (payload, propertyName, value) { try { let code = JSON.parse(payload.node.code) code[propertyName] = value - payload.node.code = JSON.stringify(code) + payload.node.code = JSON.stringify(code, null, 4) } catch (err) { // we ignore errors here since most likely they will be parsing errors. } From 7acda5ae2d02ffdd5d29a1dc69bc628f02b9da4a Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 31 Jan 2020 15:34:23 +0100 Subject: [PATCH 229/264] layers panels remembering if location --- Panels/LayersPanel.js | 50 +++++++++++----- Panels/PanelTabButton.js | 119 ++++++++++++++++++++++----------------- Spaces/PanelsSpace.js | 44 ++++++++++----- 3 files changed, 132 insertions(+), 81 deletions(-) diff --git a/Panels/LayersPanel.js b/Panels/LayersPanel.js index f0664604b..4cb74d0a7 100644 --- a/Panels/LayersPanel.js +++ b/Panels/LayersPanel.js @@ -6,6 +6,7 @@ function newLayersPanel () { layers: [], payload: undefined, isVisible: true, + panelTabButton: undefined, physics: physics, draw: draw, getContainer: getContainer, @@ -25,7 +26,6 @@ function newLayersPanel () { let firstVisibleLayer = 1 const LAYER_SEPARATION = 0 - let panelTabButton let visible = true let headerHeight = 40 @@ -42,8 +42,8 @@ function newLayersPanel () { function finalize () { thisObject.container.eventHandler.stopListening(onMouseWheelEventSuscriptionId) - panelTabButton.finalize() - panelTabButton = undefined + thisObject.panelTabButton.finalize() + thisObject.panelTabButton = undefined layersMap = undefined visibleLayers = undefined @@ -67,11 +67,11 @@ function newLayersPanel () { thisObject.container.frame.position = position - panelTabButton = newPanelTabButton() - panelTabButton.parentContainer = thisObject.container - panelTabButton.container.frame.parentFrame = thisObject.container.frame - panelTabButton.fitFunction = thisObject.fitFunction - panelTabButton.initialize() + thisObject.panelTabButton = newPanelTabButton() + thisObject.panelTabButton.parentContainer = thisObject.container + thisObject.panelTabButton.container.frame.parentFrame = thisObject.container.frame + thisObject.panelTabButton.fitFunction = thisObject.fitFunction + thisObject.panelTabButton.initialize() onMouseWheelEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) @@ -80,16 +80,22 @@ function newLayersPanel () { isInitialized = true } - function saveObjectState () { + function saveObjectStateVisibleLayers () { savePropertyAtNodeConfig(thisObject.payload, 'visibleLayers', desiredVisibleLayers) } + function saveObjectStatePanelLocation () { + savePropertyAtNodeConfig(thisObject.payload, 'panelLocation', thisObject.panelTabButton.status) + } + function readObjectState () { - let storedValue = loadPropertyFromNodeConfig(thisObject.payload, 'visibleLayers') + let storedValue + + storedValue = loadPropertyFromNodeConfig(thisObject.payload, 'visibleLayers') if (isNaN(storedValue) || storedValue === null || storedValue === undefined) { // not using this value - saveObjectState() // this overrides any invalid value at the config. + saveObjectStateVisibleLayers() // this overrides any invalid value at the config. return } else { if (storedValue < 0) { storedValue = 0 } @@ -103,6 +109,21 @@ function newLayersPanel () { calculateVisbleLayers() } } + + storedValue = loadPropertyFromNodeConfig(thisObject.payload, 'panelLocation') + + if (storedValue === null || storedValue === undefined) { + // not using this value + saveObjectStatePanelLocation() // this overrides any invalid value at the config. + return + } else { + if (storedValue !== 'up' && storedValue !== 'down') { + saveObjectStatePanelLocation() // this overrides any invalid value at the config. + return + } + thisObject.panelTabButton.setStatus(storedValue) + saveObjectStatePanelLocation() + } } function removeLayer (id) { @@ -162,7 +183,7 @@ function newLayersPanel () { } desiredPanelHeight = (layerHeight + LAYER_SEPARATION) * desiredVisibleLayers + headerHeight + footerHeight calculateVisbleLayers() - saveObjectState() + saveObjectStateVisibleLayers() } function panelSizePhysics () { @@ -219,7 +240,7 @@ function newLayersPanel () { function getContainer (point) { let container - container = panelTabButton.getContainer(point) + container = thisObject.panelTabButton.getContainer(point) if (container !== undefined) { return container } /* First we check if thisObject point is inside thisObject space. */ @@ -269,6 +290,7 @@ function newLayersPanel () { function physics () { if (isInitialized === false) { return } + thisObject.panelTabButton.physics() saveFrame(thisObject.payload, thisObject.container.frame) syncWithConfigPhysics() @@ -353,7 +375,7 @@ function newLayersPanel () { visibleLayers[i].draw() } drawScrollBar() - panelTabButton.draw() + thisObject.panelTabButton.draw() } function drawHeader () { diff --git a/Panels/PanelTabButton.js b/Panels/PanelTabButton.js index fd7a48993..484fa66a8 100644 --- a/Panels/PanelTabButton.js +++ b/Panels/PanelTabButton.js @@ -3,6 +3,9 @@ function newPanelTabButton () { container: undefined, fitFunction: undefined, parentContainer: undefined, + status: undefined, + setStatus: setStatus, + physics: physics, draw: draw, getContainer: getContainer, // returns the inner most container that holds the point received by parameter. initialize: initialize, @@ -19,9 +22,9 @@ function newPanelTabButton () { thisObject.container.frame.containerName = 'Panel Tab Button' /* Animation to hide the pannel */ - let tabStatus = 'visible' - let visiblePosition = {} - let hiddenPosition = {} + thisObject.status = 'up' + let upPosition = {} + let downPosition = {} let transitionPosition = {} let onMouseClickEventSuscriptionId @@ -34,9 +37,9 @@ function newPanelTabButton () { thisObject.fitFunction = undefined thisObject.parentContainer = undefined - tabStatus = undefined - visiblePosition = undefined - hiddenPosition = undefined + thisObject.status = undefined + upPosition = undefined + downPosition = undefined transitionPosition = undefined } @@ -45,20 +48,20 @@ function newPanelTabButton () { thisObject.container.frame.height = 10 var position = { - x: thisObject.parentContainer.frame.width - 15, - y: 2 + x: thisObject.parentContainer.frame.width - 14, + y: 1 } thisObject.container.frame.position = position - visiblePosition.x = thisObject.parentContainer.frame.position.x - visiblePosition.y = thisObject.parentContainer.frame.position.y + upPosition.x = thisObject.parentContainer.frame.position.x + upPosition.y = thisObject.parentContainer.frame.position.y - hiddenPosition.x = thisObject.parentContainer.frame.position.x - hiddenPosition.y = canvas.chartSpace.viewport.visibleArea.bottomRight.y + downPosition.x = thisObject.parentContainer.frame.position.x + downPosition.y = canvas.chartSpace.viewport.visibleArea.bottomRight.y - transitionPosition.x = visiblePosition.x - transitionPosition.y = visiblePosition.y + transitionPosition.x = upPosition.x + transitionPosition.y = upPosition.y /* Lets listen to our own events to react when we have a Mouse Click */ onMouseClickEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick) @@ -66,55 +69,65 @@ function newPanelTabButton () { isInitialized = true } + function setStatus (value) { + if (value === 'up' && thisObject.status === 'down') { + thisObject.status = 'going up' + } + if (value === 'down' && thisObject.status === 'up') { + thisObject.status = 'going down' + } + } + function onMouseClick (event) { - if (tabStatus === 'visible') { - visiblePosition.x = thisObject.parentContainer.frame.position.x - visiblePosition.y = thisObject.parentContainer.frame.position.y + if (thisObject.status === 'up') { + transitionPosition.x = upPosition.x + transitionPosition.y = upPosition.y - hiddenPosition.x = thisObject.parentContainer.frame.position.x - hiddenPosition.y = canvas.chartSpace.viewport.visibleArea.bottomRight.y - - transitionPosition.x = visiblePosition.x - transitionPosition.y = visiblePosition.y - - thisObject.parentContainer.isDraggeable = false - thisObject.parentContainer.isWheelable = false - tabStatus = 'going down' + thisObject.status = 'going down' } else { - thisObject.parentContainer.isDraggeable = true - thisObject.parentContainer.isWheelable = true - tabStatus = 'going up' + transitionPosition.x = downPosition.x + transitionPosition.y = downPosition.y + + thisObject.status = 'going up' + } + } + + function physics () { + if (isInitialized === false) { return } + + upPosition.x = thisObject.parentContainer.frame.position.x + upPosition.y = canvas.chartSpace.viewport.visibleArea.topRight.y + + downPosition.x = thisObject.parentContainer.frame.position.x + downPosition.y = canvas.chartSpace.viewport.visibleArea.bottomRight.y + + if (thisObject.status === 'going down') { + if (transitionPosition.y < downPosition.y) { + transitionPosition.y = transitionPosition.y + 50 + thisObject.parentContainer.frame.position.y = transitionPosition.y + } else { + thisObject.parentContainer.frame.position.y = downPosition.y + thisObject.status = 'down' + } + } + if (thisObject.status === 'going up') { + if (transitionPosition.y > upPosition.y) { + transitionPosition.y = transitionPosition.y - 50 + thisObject.parentContainer.frame.position.y = transitionPosition.y + } else { + thisObject.parentContainer.frame.position.y = upPosition.y + thisObject.status = 'up' + } } } function draw () { - return if (isInitialized === false) { return } drawButton() - - if (tabStatus === 'going down') { - if (transitionPosition.y < hiddenPosition.y) { - transitionPosition.y = transitionPosition.y + 50 - thisObject.parentContainer.frame.position.y = transitionPosition.y - } else { - thisObject.parentContainer.frame.position.y = hiddenPosition.y - tabStatus = 'hidden' - } - } - if (tabStatus === 'going up') { - if (transitionPosition.y > visiblePosition.y) { - transitionPosition.y = transitionPosition.y - 50 - thisObject.parentContainer.frame.position.y = transitionPosition.y - } else { - thisObject.parentContainer.frame.position.y = visiblePosition.y - tabStatus = 'visible' - } - } } function getContainer (point) { - return let container /* First we check if thisObject point is inside thisObject space. */ @@ -135,8 +148,8 @@ function newPanelTabButton () { let point2 let point3 - switch (tabStatus) { - case 'visible': { + switch (thisObject.status) { + case 'up': { point1 = { x: 3, y: 3 @@ -190,7 +203,7 @@ function newPanelTabButton () { break } - case 'hidden': { + case 'down': { point1 = { x: 3, y: thisObject.container.frame.height - 3 diff --git a/Spaces/PanelsSpace.js b/Spaces/PanelsSpace.js index 873e56141..52f4fa087 100644 --- a/Spaces/PanelsSpace.js +++ b/Spaces/PanelsSpace.js @@ -163,23 +163,39 @@ function newPanelsSpace () { /* Lets see which quadrant the panel is at */ let verticalLine = (canvas.chartSpace.viewport.visibleArea.topRight.x - canvas.chartSpace.viewport.visibleArea.topLeft.x) / 2 + canvas.chartSpace.viewport.visibleArea.topLeft.x - let horizontalLine = (canvas.chartSpace.viewport.visibleArea.bottomRight.y - canvas.chartSpace.viewport.visibleArea.topRight.y) * 2 / 3 + canvas.chartSpace.viewport.visibleArea.topRight.y + let horizontalLine = (canvas.chartSpace.viewport.visibleArea.bottomRight.y - canvas.chartSpace.viewport.visibleArea.topRight.y) / 2 + canvas.chartSpace.viewport.visibleArea.topRight.y - if (centerPoint.x < verticalLine && centerPoint.y < horizontalLine) { - panel.gravitatesTowards = 'topLeft' - } - if (centerPoint.x >= verticalLine && centerPoint.y < horizontalLine) { - panel.gravitatesTowards = 'topRight' - } - if (centerPoint.x < verticalLine && centerPoint.y >= horizontalLine) { - panel.gravitatesTowards = 'bottomLeft' - } - if (centerPoint.x >= verticalLine && centerPoint.y >= horizontalLine) { - panel.gravitatesTowards = 'bottomRight' + if (panel.panelTabButton !== undefined) { + if (panel.panelTabButton.status === 'up') { + if (centerPoint.x < verticalLine) { + panel.gravitatesTowards = 'topLeft' + } else { + panel.gravitatesTowards = 'topRight' + } + } else { + if (centerPoint.x < verticalLine) { + panel.gravitatesTowards = 'bottomLeft' + } else { + panel.gravitatesTowards = 'bottomRight' + } + } + } else { + if (centerPoint.x < verticalLine && centerPoint.y < horizontalLine) { + panel.gravitatesTowards = 'topLeft' + } + if (centerPoint.x >= verticalLine && centerPoint.y < horizontalLine) { + panel.gravitatesTowards = 'topRight' + } + if (centerPoint.x < verticalLine && centerPoint.y >= horizontalLine) { + panel.gravitatesTowards = 'bottomLeft' + } + if (centerPoint.x >= verticalLine && centerPoint.y >= horizontalLine) { + panel.gravitatesTowards = 'bottomRight' + } } /* According to the quadrant we push the panels to the sides */ - if (centerPoint.x < verticalLine) { + if (panel.gravitatesTowards === 'topLeft' || panel.gravitatesTowards === 'bottomLeft') { panel.container.frame.position.x = panel.container.frame.position.x - panel.container.speed.x isOverlapping(i, panel.container) if (panel.container.frame.position.x < 0) { @@ -193,7 +209,7 @@ function newPanelsSpace () { } } if (panel.container.frame.height <= canvas.chartSpace.viewport.visibleArea.bottomRight.y - canvas.chartSpace.viewport.visibleArea.topRight.y) { - if (centerPoint.y < horizontalLine) { + if (panel.gravitatesTowards === 'topLeft' || panel.gravitatesTowards === 'topRight') { panel.container.frame.position.y = panel.container.frame.position.y - panel.container.speed.y isOverlapping(i, panel.container) if (panel.container.frame.position.y < canvas.chartSpace.viewport.visibleArea.topLeft.y) { From 7b9f8bd38b480fcbc5f0f299d93a2fec1466f1da Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 31 Jan 2020 15:38:00 +0100 Subject: [PATCH 230/264] bug fixed --- Panels/LayersPanel.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Panels/LayersPanel.js b/Panels/LayersPanel.js index 4cb74d0a7..6e8226a1c 100644 --- a/Panels/LayersPanel.js +++ b/Panels/LayersPanel.js @@ -60,12 +60,13 @@ function newLayersPanel () { thisObject.container.frame.width = UI_PANEL.WIDTH.NORMAL thisObject.container.frame.height = headerHeight - let position = { + let position = { // Default position x: canvas.chartSpace.viewport.visibleArea.topLeft.x, - y: canvas.chartSpace.viewport.visibleArea.topLeft.y// canvas.chartSpace.viewport.visibleArea.bottomLeft.y - thisObject.container.frame.height + y: canvas.chartSpace.viewport.visibleArea.topLeft.y } thisObject.container.frame.position = position + loadFrame(thisObject.payload, thisObject.container.frame) thisObject.panelTabButton = newPanelTabButton() thisObject.panelTabButton.parentContainer = thisObject.container @@ -76,7 +77,7 @@ function newLayersPanel () { onMouseWheelEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) readObjectState() - loadFrame(thisObject.payload, thisObject.container.frame) + isInitialized = true } From cae4fbada37c40e01f7b9a76f66480ad837f7319 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 31 Jan 2020 17:09:29 +0100 Subject: [PATCH 231/264] Rate at timeline chart corrected --- ChartsSpace/TimelineChart.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index fb39a1a36..dc847a7a0 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -45,6 +45,7 @@ function newTimelineChart () { let rateScaleUpstreamDimensionsEventSuscriptionId let timeFrameScaleEventSuscriptionId let timeFrameScaleMouseOverEventSuscriptionId + let scaleChangedEventSubscriptionId let drawScales = false let mouse = { @@ -64,6 +65,8 @@ function newTimelineChart () { } function finalize () { + coordinateSystem.eventHandler.stopListening(timelineChartCoordinateSystem) + if (thisObject.layersManager !== undefined) { finalizeLayersManager() } @@ -141,11 +144,13 @@ function newTimelineChart () { timeMachineCoordinateSystem = pTimeMachineCoordinateSystem coordinateSystem = timeMachineCoordinateSystem + onScaleChanged() timeFrame = INITIAL_TIME_PERIOD onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) onMouseNotOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) + scaleChangedEventSubscriptionId = timeMachineCoordinateSystem.eventHandler.listenToEvent('Scale Changed', onScaleChanged) } function initializeLayersManager () { @@ -232,6 +237,12 @@ function newTimelineChart () { } } + function onScaleChanged () { + timelineChartCoordinateSystem.min.x = timeMachineCoordinateSystem.min.x + timelineChartCoordinateSystem.max.x = timeMachineCoordinateSystem.max.x + timelineChartCoordinateSystem.recalculateScale() + } + function setTimeFrame (pTimeFrame) { timeFrame = pTimeFrame if (thisObject.plotterManager !== undefined) { @@ -387,15 +398,20 @@ function newTimelineChart () { function recalculateCoordinateSystem () { let minValue = { - x: MIN_PLOTABLE_DATE.valueOf(), + x: timelineChartCoordinateSystem.min.x, y: 0 } let maxValue = { - x: MAX_PLOTABLE_DATE.valueOf(), + x: timelineChartCoordinateSystem.max.x, y: nextPorwerOf10(MAX_DEFAULT_RATE_SCALE_VALUE) / 4 } + if (thisObject.rateScale !== undefined) { + minValue.y = thisObject.rateScale.minValue + maxValue.y = thisObject.rateScale.maxValue + } + timelineChartCoordinateSystem.initialize( minValue, maxValue, From c993a3fff9e6d437a2a1841f8be4cb4b39268cb3 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 31 Jan 2020 17:20:15 +0100 Subject: [PATCH 232/264] do not sync scales --- ChartsSpace/TimelineChart.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index dc847a7a0..7eeeeee52 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -195,7 +195,7 @@ function newTimelineChart () { } function rateScaleUpstreamChanged (event) { - thisObject.rateScale.setScale(event.scale) + // thisObject.rateScale.setScale(event.scale) } function rateScaleOffsetChanged (event) { From 69518c1e139f6e6c02e3240bacb268c3c0750a75 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 2 Feb 2020 11:43:54 +0100 Subject: [PATCH 233/264] slot concept erased --- ChartsSpace/TimelineChart.js | 5 ++++- Plotter.js | 21 +-------------------- 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 7eeeeee52..dac033820 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -199,7 +199,10 @@ function newTimelineChart () { } function rateScaleOffsetChanged (event) { - thisObject.container.frame.offset.y = event.offset + if (thisObject.container.frame.offset.y !== event.offset) { + thisObject.container.frame.offset.y = event.offset + thisObject.container.eventHandler.raiseEvent('onDisplace') + } } function rateScaleValueChanged (event) { diff --git a/Plotter.js b/Plotter.js index 8df54aa92..97b818a28 100644 --- a/Plotter.js +++ b/Plotter.js @@ -23,7 +23,6 @@ function newPlotter () { thisObject.container = container let coordinateSystem - let slotCoordinateSystem // Needed to be able to plot on a slot over the timeline. let plotterModuleConfig let slotHeight = (canvas.chartSpace.viewport.visibleArea.bottomRight.y - canvas.chartSpace.viewport.visibleArea.topLeft.y) / 10 // This is the amount of slots available let mustRecalculateDataPoints = false @@ -81,7 +80,6 @@ function newPlotter () { finalizeCoordinateSystem() coordinateSystem = undefined - slotCoordinateSystem = undefined plotterModuleConfig = undefined slotHeight = undefined mustRecalculateDataPoints = undefined @@ -482,23 +480,6 @@ function newPlotter () { thisObject.container.frame.width, thisObject.container.frame.height ) - - /* In case the plotter is configured to a certain slot, we calculate the slot coordinate system too. */ - if (productDefinition.referenceParent.code === undefined) { return } - plotterModuleConfig = productDefinition.referenceParent.code - if (plotterModuleConfig.slot === undefined) { return } - - slotCoordinateSystem = newCoordinateSystem() - - minValue.y = plotterModuleConfig.slot.minValue - maxValue.y = plotterModuleConfig.slot.maxValue - - slotCoordinateSystem.initialize( - minValue, - maxValue, - thisObject.container.frame.width, - slotHeight - ) } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] recalculateScale -> err = ' + err.stack) } } @@ -602,7 +583,7 @@ function newPlotter () { if (plotterModuleConfig !== undefined) { if (plotterModuleConfig.slot !== undefined) { /* We reset the y coordinate since it will be transformed with another coordinate system to fit into a slot. */ - dataPoint.y = (-1) * y * slotCoordinateSystem.scale.y + (plotterModuleConfig.slot.number - 1) * slotHeight + canvas.chartSpace.viewport.visibleArea.topLeft.y + dataPoint.y = (-1) * y * coordinateSystem.scale.y + (plotterModuleConfig.slot.number - 1) * slotHeight + canvas.chartSpace.viewport.visibleArea.topLeft.y } } } From c737a7416826aa6d4ef13827a1108af71fc68eda Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 2 Feb 2020 12:35:10 +0100 Subject: [PATCH 234/264] Scales only visible if there is at least one layer on --- ChartsSpace/PlottersManager.js | 41 +++++++++++++++++----------------- ChartsSpace/TimelineChart.js | 2 ++ Scales/RateScale.js | 15 +++++++++++-- Scales/TimeFrameScale.js | 15 +++++++++++-- 4 files changed, 49 insertions(+), 24 deletions(-) diff --git a/ChartsSpace/PlottersManager.js b/ChartsSpace/PlottersManager.js index 007969d77..3b245cf99 100644 --- a/ChartsSpace/PlottersManager.js +++ b/ChartsSpace/PlottersManager.js @@ -4,8 +4,6 @@ function newPlottersManager () { const logger = newWebDebugLog() logger.fileName = MODULE_NAME - let connectors = [] - let timeFrame = INITIAL_TIME_PERIOD let datetime = NEW_SESSION_INITIAL_DATE @@ -13,6 +11,7 @@ function newPlottersManager () { fitFunction: undefined, container: undefined, payload: undefined, + connectors: [], setDatetime: setDatetime, setTimeFrame: setTimeFrame, setCoordinateSystem: setCoordinateSystem, @@ -22,6 +21,8 @@ function newPlottersManager () { finalize: finalize } + thisObject.connectors = [] + let initializationReady = false let layersPanel let onLayerStatusChangedEventSuscriptionId @@ -39,8 +40,8 @@ function newPlottersManager () { layersPanel.container.eventHandler.stopListening(onLayerStatusChangedEventSuscriptionId) layersPanel = undefined - for (let i = 0; i < connectors.length; i++) { - let connector = connectors[i] + for (let i = 0; i < thisObject.connectors.length; i++) { + let connector = thisObject.connectors[i] /* Then the panels. */ for (let j = 0; j < connector.panels.length; j++) { canvas.panelsSpace.destroyPanel(connector.panels[j]) @@ -61,7 +62,7 @@ function newPlottersManager () { connector = undefined } - connectors = [] + thisObject.connectors = [] coordinateSystem = undefined thisObject.container.finalize() @@ -210,7 +211,7 @@ function newPlottersManager () { connector.layer.panels = connector.panels } - connectors.push(connector) + thisObject.connectors.push(connector) } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] initializePlotter -> onProductStorageInitialized -> onPlotterInizialized -> err = ' + err.stack) } } @@ -229,8 +230,8 @@ function newPlottersManager () { if (layer.status === LAYER_STATUS.LOADING) { /* Lets see if we can find the Plotter of this card on our Active Plotters list, other wise we will initialize it */ let found = false - for (let i = 0; i < connectors.length; i++) { - let connector = connectors[i] + for (let i = 0; i < thisObject.connectors.length; i++) { + let connector = thisObject.connectors[i] if (connector.layer.payload.node.id === layer.payload.node.id) { found = true } @@ -244,8 +245,8 @@ function newPlottersManager () { } if (layer.status === LAYER_STATUS.OFF) { /* If the plotter of this card is not on our Active Plotters list, then we remove it. */ - for (let i = 0; i < connectors.length; i++) { - let connector = connectors[i] + for (let i = 0; i < thisObject.connectors.length; i++) { + let connector = thisObject.connectors[i] if (connector.layer.payload.node.id === layer.payload.node.id) { /* Then the panels. */ for (let j = 0; j < connector.panels.length; j++) { @@ -259,7 +260,7 @@ function newPlottersManager () { connector.plotter.finalize() } finalizeStorage(connector.storage) - connectors.splice(i, 1) // Delete item from array. + thisObject.connectors.splice(i, 1) // Delete item from array. return // We already found the product woth changes and processed it. } } @@ -268,8 +269,8 @@ function newPlottersManager () { function setTimeFrame (pTimeFrame) { timeFrame = pTimeFrame - for (let i = 0; i < connectors.length; i++) { - let connector = connectors[i] + for (let i = 0; i < thisObject.connectors.length; i++) { + let connector = thisObject.connectors[i] connector.layer.setTimeFrame(timeFrame) connector.storage.setTimeFrame(timeFrame) connector.plotter.setTimeFrame(timeFrame) @@ -278,8 +279,8 @@ function newPlottersManager () { function setDatetime (pDatetime) { datetime = pDatetime - for (let i = 0; i < connectors.length; i++) { - let connector = connectors[i] + for (let i = 0; i < thisObject.connectors.length; i++) { + let connector = thisObject.connectors[i] connector.layer.setDatetime(pDatetime) connector.storage.setDatetime(pDatetime) connector.plotter.setDatetime(pDatetime) @@ -288,8 +289,8 @@ function newPlottersManager () { function setCoordinateSystem (pCoordinateSystem) { coordinateSystem = pCoordinateSystem - for (let i = 0; i < connectors.length; i++) { - let connector = connectors[i] + for (let i = 0; i < thisObject.connectors.length; i++) { + let connector = thisObject.connectors[i] connector.plotter.setCoordinateSystem(coordinateSystem) } } @@ -298,10 +299,10 @@ function newPlottersManager () { } function draw () { - if (connectors === undefined) { return } // We need to wait + if (thisObject.connectors === undefined) { return } // We need to wait /* First the Product Plotters. */ - for (let i = 0; i < connectors.length; i++) { - let connector = connectors[connectors.length - i - 1] + for (let i = 0; i < thisObject.connectors.length; i++) { + let connector = thisObject.connectors[thisObject.connectors.length - i - 1] connector.plotter.draw() } } diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index dac033820..fa6b444aa 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -361,9 +361,11 @@ function newTimelineChart () { function childrenPhysics () { if (thisObject.rateScale !== undefined) { + thisObject.rateScale.layersOn = thisObject.plotterManager.connectors.length thisObject.rateScale.physics() } if (thisObject.timeFrameScale !== undefined) { + thisObject.timeFrameScale.layersOn = thisObject.plotterManager.connectors.length thisObject.timeFrameScale.physics() } } diff --git a/Scales/RateScale.js b/Scales/RateScale.js index 907c8f484..9536a0b82 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -11,6 +11,7 @@ function newRateScale () { minValue: undefined, maxValue: undefined, isVisible: true, + layersOn: undefined, setScale: setScale, onMouseOverSomeTimeMachineContainer: onMouseOverSomeTimeMachineContainer, physics: physics, @@ -323,13 +324,17 @@ function newRateScale () { if (thisObject.payload.parentNode.type === 'Timeline Chart') { if (thisObject.payload.parentNode.payload.parentNode !== undefined) { if (thisObject.payload.parentNode.payload.parentNode.rateScale !== undefined) { - displaceFactor++ + if (thisObject.payload.parentNode.payload.parentNode.rateScale.payload.isVisible === true) { + displaceFactor++ + } } for (let i = 0; i < thisObject.payload.parentNode.payload.parentNode.timelineCharts.length; i++) { let timelineChart = thisObject.payload.parentNode.payload.parentNode.timelineCharts[i] if (timelineChart.rateScale !== undefined) { if (thisObject.payload.node.id !== timelineChart.rateScale.id) { - displaceFactor++ + if (timelineChart.rateScale.payload.isVisible === true) { + displaceFactor++ + } } else { break } @@ -366,11 +371,17 @@ function newRateScale () { thisObject.container.frame.position.x = ratePoint.x - thisObject.container.frame.width thisObject.isVisible = true + thisObject.payload.isVisible = true if (thisObject.container.frame.position.y + thisObject.container.frame.height * 2 > bottonCorner.y || thisObject.container.frame.position.y - thisObject.container.frame.height * 1 < upCorner.y || thisObject.container.frame.position.x < upCorner.x ) { thisObject.isVisible = false + thisObject.payload.isVisible = false + } + if (thisObject.layersOn === 0) { + thisObject.isVisible = false + thisObject.payload.isVisible = false } } diff --git a/Scales/TimeFrameScale.js b/Scales/TimeFrameScale.js index 7354b7a8f..444a2c6e5 100644 --- a/Scales/TimeFrameScale.js +++ b/Scales/TimeFrameScale.js @@ -7,6 +7,7 @@ function newTimeFrameScale () { fitFunction: undefined, payload: undefined, isVisible: true, + layersOn: undefined, onMouseOverSomeTimeMachineContainer: onMouseOverSomeTimeMachineContainer, draw: draw, drawForeground: drawForeground, @@ -144,13 +145,17 @@ function newTimeFrameScale () { if (thisObject.payload.parentNode.type === 'Timeline Chart') { if (thisObject.payload.parentNode.payload.parentNode !== undefined) { if (thisObject.payload.parentNode.payload.parentNode.timeFrameScale !== undefined) { - displaceFactor++ + if (thisObject.payload.parentNode.payload.parentNode.timeFrameScale.payload.isVisible === true) { + displaceFactor++ + } } for (let i = 0; i < thisObject.payload.parentNode.payload.parentNode.timelineCharts.length; i++) { let timelineChart = thisObject.payload.parentNode.payload.parentNode.timelineCharts[i] if (timelineChart.timeFrameScale !== undefined) { if (thisObject.payload.node.id !== timelineChart.timeFrameScale.id) { - displaceFactor++ + if (timelineChart.timeFrameScale.payload.isVisible === true) { + displaceFactor++ + } } else { break } @@ -179,9 +184,15 @@ function newTimeFrameScale () { thisObject.container.frame.position.y = timePoint.y - thisObject.container.frame.height thisObject.isVisible = true + thisObject.payload.isVisible = true if (thisObject.container.frame.position.y + thisObject.container.frame.height > bottonCorner.y || thisObject.container.frame.position.y - thisObject.container.frame.height * 3 < upCorner.y) { thisObject.isVisible = false + thisObject.payload.isVisible = false + } + if (thisObject.layersOn === 0) { + thisObject.isVisible = false + thisObject.payload.isVisible = false } } From c33cca3166612493106180ca720151881ca94cb8 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 4 Feb 2020 11:32:15 +0100 Subject: [PATCH 235/264] Multiple isTensed Values --- .../FunctionLibraries/NodeCloning.js | 2 +- .../FunctionLibraries/ProtocolNode.js | 2 +- FloatingSpace/CircularMenu.js | 1 + FloatingSpace/CircularMenuItem.js | 11 ++++++-- FloatingSpace/FloatingObject.js | 27 +++++++++++++------ FloatingSpace/UiObject.js | 2 +- FloatingSpace/UiObjectConstructor.js | 12 +++------ Globals.js | 8 ++++++ 8 files changed, 44 insertions(+), 21 deletions(-) diff --git a/DesignerSpace/Workspace/FunctionLibraries/NodeCloning.js b/DesignerSpace/Workspace/FunctionLibraries/NodeCloning.js index ab81e42a6..a0cb778ae 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/NodeCloning.js +++ b/DesignerSpace/Workspace/FunctionLibraries/NodeCloning.js @@ -145,7 +145,7 @@ function newNodeCloning () { isPinned: node.payload.floatingObject.isPinned, isFrozen: (node.payload.floatingObject.isFrozen && node.payload.floatingObject.frozenManually), isCollapsed: (node.payload.floatingObject.isCollapsed && node.payload.floatingObject.collapsedManually), - isTensed: (node.payload.floatingObject.isTensed && node.payload.floatingObject.tensedManually) + isTensed: (node.payload.floatingObject.isTensed) }, uiObject: { isRunning: node.payload.uiObject.isRunning, diff --git a/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js b/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js index dc5ef92de..9dc8afba4 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js +++ b/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js @@ -148,7 +148,7 @@ function newProtocolNode () { isPinned: node.payload.floatingObject.isPinned, isFrozen: (node.payload.floatingObject.isFrozen && node.payload.floatingObject.frozenManually), isCollapsed: (node.payload.floatingObject.isCollapsed && node.payload.floatingObject.collapsedManually), - isTensed: (node.payload.floatingObject.isTensed && node.payload.floatingObject.tensedManually) + isTensed: (node.payload.floatingObject.isTensed) }, uiObject: { isRunning: node.payload.uiObject.isRunning, diff --git a/FloatingSpace/CircularMenu.js b/FloatingSpace/CircularMenu.js index ab9b5a958..0e81863c4 100644 --- a/FloatingSpace/CircularMenu.js +++ b/FloatingSpace/CircularMenu.js @@ -83,6 +83,7 @@ function newCircularMenu () { menuItem.disableIfPropertyIsDefined = menuItemInitialValue.disableIfPropertyIsDefined menuItem.propertyToCheckFor = menuItemInitialValue.propertyToCheckFor menuItem.ring = menuItemInitialValue.ring + menuItem.icons = menuItemInitialValue.icons if (menuItem.label === undefined) { menuItem.type = 'Icon Only' diff --git a/FloatingSpace/CircularMenuItem.js b/FloatingSpace/CircularMenuItem.js index f377c8c45..d088385e6 100644 --- a/FloatingSpace/CircularMenuItem.js +++ b/FloatingSpace/CircularMenuItem.js @@ -9,6 +9,7 @@ function newCircularMenuItem () { confirmationLabel: undefined, iconOn: undefined, iconOff: undefined, + icons: undefined, currentIcon: undefined, disableIfPropertyIsDefined: undefined, propertyToCheckFor: undefined, @@ -92,6 +93,7 @@ function newCircularMenuItem () { thisObject.container = undefined thisObject.iconOn = undefined thisObject.iconOff = undefined + thisObject.icons = undefined thisObject.currentIcon = undefined thisObject.payload = undefined thisObject.actionFunction = undefined @@ -208,8 +210,13 @@ function newCircularMenuItem () { thisObject.iconOn = canvas.designerSpace.iconByUiObjectType.get(thisObject.relatedUiObject) thisObject.iconOff = canvas.designerSpace.iconByUiObjectType.get(thisObject.relatedUiObject) } else { - thisObject.iconOn = canvas.designerSpace.iconCollection.get(thisObject.iconPathOn) - thisObject.iconOff = canvas.designerSpace.iconCollection.get(thisObject.iconPathOff) + if (thisObject.iconPathOn !== undefined && thisObject.iconPathOff !== undefined) { + thisObject.iconOn = canvas.designerSpace.iconCollection.get(thisObject.iconPathOn) + thisObject.iconOff = canvas.designerSpace.iconCollection.get(thisObject.iconPathOff) + } else { + thisObject.iconOn = canvas.designerSpace.iconCollection.get(thisObject.icons[thisObject.actionStatus()]) + thisObject.iconOff = canvas.designerSpace.iconCollection.get(thisObject.icons[thisObject.actionStatus()]) + } } } diff --git a/FloatingSpace/FloatingObject.js b/FloatingSpace/FloatingObject.js index 95da8d8f8..885ae9ca7 100644 --- a/FloatingSpace/FloatingObject.js +++ b/FloatingSpace/FloatingObject.js @@ -22,7 +22,7 @@ function newFloatingObject () { targetRadius: 0, // This is the target radius of the floating object with zoom applied. It should be animated until reaching this value. isPinned: false, isFrozen: false, - isTensed: false, + isTensed: TENSION_LEVEL.NO_TENSION, isCollapsed: false, isParentCollapsed: false, frozenManually: false, @@ -165,13 +165,24 @@ function newFloatingObject () { } function tensionToggle () { - if (thisObject.isTensed !== true) { - thisObject.isTensed = true - thisObject.tensedManually = true - } else { - thisObject.isTensed = false - thisObject.tensedManually = false + switch (thisObject.isTensed) { + case TENSION_LEVEL.NO_TENSION: + thisObject.isTensed = TENSION_LEVEL.LEVEL_360 + break + case TENSION_LEVEL.LEVEL_360: + thisObject.isTensed = TENSION_LEVEL.LEVEL_180 + break + case TENSION_LEVEL.LEVEL_180: + thisObject.isTensed = TENSION_LEVEL.LEVEL_90 + break + case TENSION_LEVEL.LEVEL_90: + thisObject.isTensed = TENSION_LEVEL.LEVEL_45 + break + case TENSION_LEVEL.LEVEL_45: + thisObject.isTensed = TENSION_LEVEL.NO_TENSION + break } + return thisObject.isTensed } @@ -212,7 +223,7 @@ function newFloatingObject () { function tensionPhysics () { /* Tension Effect */ - if (thisObject.isTensed === true) { + if (thisObject.isTensed !== TENSION_LEVEL.NO_TENSION) { let parent = thisObject.payload.chainParent if (parent === undefined) { return } if (parent.payload === undefined) { return } diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index 1950f6b5e..5a20e5464 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -864,7 +864,7 @@ function newUiObject () { /* Target Line */ let LINE_STYLE = UI_COLOR.TITANIUM_YELLOW - if (thisObject.payload.floatingObject.isTensed === true) { + if (thisObject.payload.floatingObject.isTensed !== TENSION_LEVEL.NO_TENSION) { LINE_STYLE = UI_COLOR.GOLDEN_ORANGE } if (thisObject.payload.floatingObject.isFrozen === true) { diff --git a/FloatingSpace/UiObjectConstructor.js b/FloatingSpace/UiObjectConstructor.js index 110015794..1eed3a137 100644 --- a/FloatingSpace/UiObjectConstructor.js +++ b/FloatingSpace/UiObjectConstructor.js @@ -57,16 +57,12 @@ function newUiObjectConstructor () { if (payload.node.savedPayload.floatingObject.isCollapsed === true) { floatingObject.collapseToggle() } - if (payload.node.savedPayload.floatingObject.isTensed === true) { - floatingObject.tensionToggle() - } + floatingObject.isTensed = payload.node.savedPayload.floatingObject.isTensed } /* For brand new objects being created directly by the user, we will make them inherit some properties from their parents. */ if (userAddingNew === true) { - if (payload.parentNode.payload.floatingObject.isTensed === true) { - floatingObject.tensionToggle() - } + floatingObject.isTensed = payload.parentNode.payload.floatingObject.isTensed } let uiObject = newUiObject() @@ -146,8 +142,7 @@ function newUiObjectConstructor () { currentStatus: true, label: undefined, visible: true, - iconPathOn: 'menu-tensor-fixed-angles', - iconPathOff: 'menu-tensor-free-angles', + icons: ['menu-tensor-free-angles', 'menu-tensor-fixed-angles', 'menu-share', 'compass', 'broken-link'], rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -315,6 +310,7 @@ function newUiObjectConstructor () { switch (payload.node.type) { case 'Workspace': { level_0() + floatingObject.isTensed = TENSION_LEVEL.LEVEL_360 break } diff --git a/Globals.js b/Globals.js index 60d77a30e..92d054bd2 100644 --- a/Globals.js +++ b/Globals.js @@ -51,6 +51,14 @@ const GET_CONTAINER_PURPOSE = { DRAGGING: 4 } +const TENSION_LEVEL = { + NO_TENSION: 0, + LEVEL_360: 1, + LEVEL_180: 2, + LEVEL_90: 3, + LEVEL_45: 4 +} + /* User Interface Panels */ UI_PANEL = { From 567fecbc9c46cdae9e44a78efa3f015696e58cf9 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 4 Feb 2020 11:36:45 +0100 Subject: [PATCH 236/264] isTensed to tensionLevel --- .../FunctionLibraries/NodeCloning.js | 2 +- .../FunctionLibraries/ProtocolNode.js | 2 +- FloatingSpace/FloatingObject.js | 20 +++++++++---------- FloatingSpace/UiObject.js | 2 +- FloatingSpace/UiObjectConstructor.js | 6 +++--- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/DesignerSpace/Workspace/FunctionLibraries/NodeCloning.js b/DesignerSpace/Workspace/FunctionLibraries/NodeCloning.js index a0cb778ae..0e1332a7f 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/NodeCloning.js +++ b/DesignerSpace/Workspace/FunctionLibraries/NodeCloning.js @@ -145,7 +145,7 @@ function newNodeCloning () { isPinned: node.payload.floatingObject.isPinned, isFrozen: (node.payload.floatingObject.isFrozen && node.payload.floatingObject.frozenManually), isCollapsed: (node.payload.floatingObject.isCollapsed && node.payload.floatingObject.collapsedManually), - isTensed: (node.payload.floatingObject.isTensed) + tensionLevel: (node.payload.floatingObject.tensionLevel) }, uiObject: { isRunning: node.payload.uiObject.isRunning, diff --git a/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js b/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js index 9dc8afba4..3cb36839a 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js +++ b/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js @@ -148,7 +148,7 @@ function newProtocolNode () { isPinned: node.payload.floatingObject.isPinned, isFrozen: (node.payload.floatingObject.isFrozen && node.payload.floatingObject.frozenManually), isCollapsed: (node.payload.floatingObject.isCollapsed && node.payload.floatingObject.collapsedManually), - isTensed: (node.payload.floatingObject.isTensed) + tensionLevel: (node.payload.floatingObject.tensionLevel) }, uiObject: { isRunning: node.payload.uiObject.isRunning, diff --git a/FloatingSpace/FloatingObject.js b/FloatingSpace/FloatingObject.js index 885ae9ca7..a87910832 100644 --- a/FloatingSpace/FloatingObject.js +++ b/FloatingSpace/FloatingObject.js @@ -22,7 +22,7 @@ function newFloatingObject () { targetRadius: 0, // This is the target radius of the floating object with zoom applied. It should be animated until reaching this value. isPinned: false, isFrozen: false, - isTensed: TENSION_LEVEL.NO_TENSION, + tensionLevel: TENSION_LEVEL.NO_TENSION, isCollapsed: false, isParentCollapsed: false, frozenManually: false, @@ -139,7 +139,7 @@ function newFloatingObject () { } function getTensionStatus () { - return thisObject.isTensed + return thisObject.tensionLevel } function freezeToggle () { @@ -165,25 +165,25 @@ function newFloatingObject () { } function tensionToggle () { - switch (thisObject.isTensed) { + switch (thisObject.tensionLevel) { case TENSION_LEVEL.NO_TENSION: - thisObject.isTensed = TENSION_LEVEL.LEVEL_360 + thisObject.tensionLevel = TENSION_LEVEL.LEVEL_360 break case TENSION_LEVEL.LEVEL_360: - thisObject.isTensed = TENSION_LEVEL.LEVEL_180 + thisObject.tensionLevel = TENSION_LEVEL.LEVEL_180 break case TENSION_LEVEL.LEVEL_180: - thisObject.isTensed = TENSION_LEVEL.LEVEL_90 + thisObject.tensionLevel = TENSION_LEVEL.LEVEL_90 break case TENSION_LEVEL.LEVEL_90: - thisObject.isTensed = TENSION_LEVEL.LEVEL_45 + thisObject.tensionLevel = TENSION_LEVEL.LEVEL_45 break case TENSION_LEVEL.LEVEL_45: - thisObject.isTensed = TENSION_LEVEL.NO_TENSION + thisObject.tensionLevel = TENSION_LEVEL.NO_TENSION break } - return thisObject.isTensed + return thisObject.tensionLevel } function physics () { @@ -223,7 +223,7 @@ function newFloatingObject () { function tensionPhysics () { /* Tension Effect */ - if (thisObject.isTensed !== TENSION_LEVEL.NO_TENSION) { + if (thisObject.tensionLevel !== TENSION_LEVEL.NO_TENSION) { let parent = thisObject.payload.chainParent if (parent === undefined) { return } if (parent.payload === undefined) { return } diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index 5a20e5464..c79b26d5f 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -864,7 +864,7 @@ function newUiObject () { /* Target Line */ let LINE_STYLE = UI_COLOR.TITANIUM_YELLOW - if (thisObject.payload.floatingObject.isTensed !== TENSION_LEVEL.NO_TENSION) { + if (thisObject.payload.floatingObject.tensionLevel !== TENSION_LEVEL.NO_TENSION) { LINE_STYLE = UI_COLOR.GOLDEN_ORANGE } if (thisObject.payload.floatingObject.isFrozen === true) { diff --git a/FloatingSpace/UiObjectConstructor.js b/FloatingSpace/UiObjectConstructor.js index 1eed3a137..43b77b0a6 100644 --- a/FloatingSpace/UiObjectConstructor.js +++ b/FloatingSpace/UiObjectConstructor.js @@ -57,12 +57,12 @@ function newUiObjectConstructor () { if (payload.node.savedPayload.floatingObject.isCollapsed === true) { floatingObject.collapseToggle() } - floatingObject.isTensed = payload.node.savedPayload.floatingObject.isTensed + floatingObject.tensionLevel = payload.node.savedPayload.floatingObject.tensionLevel } /* For brand new objects being created directly by the user, we will make them inherit some properties from their parents. */ if (userAddingNew === true) { - floatingObject.isTensed = payload.parentNode.payload.floatingObject.isTensed + floatingObject.tensionLevel = payload.parentNode.payload.floatingObject.tensionLevel } let uiObject = newUiObject() @@ -310,7 +310,7 @@ function newUiObjectConstructor () { switch (payload.node.type) { case 'Workspace': { level_0() - floatingObject.isTensed = TENSION_LEVEL.LEVEL_360 + floatingObject.tensionLevel = TENSION_LEVEL.LEVEL_360 break } From 052cf3e7c2c6cf88a9b20cc54b2db696ddd80f2d Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 4 Feb 2020 12:27:16 +0100 Subject: [PATCH 237/264] Tension level functionality completed --- FloatingSpace/FloatingObject.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/FloatingSpace/FloatingObject.js b/FloatingSpace/FloatingObject.js index a87910832..f9f6091ab 100644 --- a/FloatingSpace/FloatingObject.js +++ b/FloatingSpace/FloatingObject.js @@ -223,7 +223,7 @@ function newFloatingObject () { function tensionPhysics () { /* Tension Effect */ - if (thisObject.tensionLevel !== TENSION_LEVEL.NO_TENSION) { + if (thisObject.tensionLevel !== TENSION_LEVEL.NO_TENSION && thisObject.isOnFocus !== true) { let parent = thisObject.payload.chainParent if (parent === undefined) { return } if (parent.payload === undefined) { return } @@ -234,6 +234,22 @@ function newFloatingObject () { let axisCount = parentChildren.childrenCount let axisIndex = parentChildren.childIndex let baseAngle = 0 + let tensionLevelAngle + + switch (thisObject.tensionLevel) { + case TENSION_LEVEL.LEVEL_360: + tensionLevelAngle = 360 + break + case TENSION_LEVEL.LEVEL_180: + tensionLevelAngle = 180 + break + case TENSION_LEVEL.LEVEL_90: + tensionLevelAngle = 90 + break + case TENSION_LEVEL.LEVEL_45: + tensionLevelAngle = 45 + break + } if (axisIndex === undefined) { axisCount = 1 @@ -253,9 +269,10 @@ function newFloatingObject () { } } - let angleStep = 360 / axisCount + let separatorAngle = (360 - tensionLevelAngle) / 2 + let angleStep = tensionLevelAngle / axisCount - thisObject.payload.angle = baseAngle + (axisIndex - 1) * angleStep + thisObject.payload.angle = baseAngle + separatorAngle + (axisIndex - 1) * angleStep if (thisObject.payload.angle >= 360) { thisObject.payload.angle = thisObject.payload.angle - 360 } From 511783c5186b943766d7a8ba75eca1998b2ef942 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 4 Feb 2020 14:26:27 +0100 Subject: [PATCH 238/264] Bug Fixed time machines position not remembered when out of view port --- ChartsSpace/TimeMachine.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index cba761905..38ba6ac2b 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -382,11 +382,11 @@ function newTimeMachine () { } function physics () { + saveFrame(thisObject.payload, thisObject.container.frame) if (thisObject.container.frame.isInViewPort()) { thisObjectPhysics() childrenPhysics() syncWithDesigner() - saveFrame(thisObject.payload, thisObject.container.frame) } panelPhysics() } From 9dde60975ca3a6a2146bc6cba8cd8f6cb0879698 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 4 Feb 2020 16:43:24 +0100 Subject: [PATCH 239/264] Task remembering their running status --- Dashboard.js | 2 +- .../FunctionLibraries/UiObjectsFromNodes.js | 18 ++++++++++++ FloatingSpace/CircularProgressBar.js | 6 ++-- FloatingSpace/UiObject.js | 28 ++++++++++++++++--- 4 files changed, 47 insertions(+), 7 deletions(-) diff --git a/Dashboard.js b/Dashboard.js index 80373e057..3d82092d0 100644 --- a/Dashboard.js +++ b/Dashboard.js @@ -88,7 +88,7 @@ function newDashboard () { function setBrowserEvents () { window.onbeforeunload = onBrowserClosed function onBrowserClosed () { - canvas.designerSpace.workspace.stopAllRunningTasks() + // canvas.designerSpace.workspace.stopAllRunningTasks() } } } diff --git a/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js b/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js index 591efb69a..fc5e63278 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js +++ b/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js @@ -9,11 +9,13 @@ function newUiObjectsFromNodes () { let mapOfReferenceChildren = new Map() let mapOfNodes + let tasksToRun return thisObject function recreateWorkspace (node) { mapOfNodes = new Map() + tasksToRun = [] /* Create the workspace UI OBject and then continue with the root nodes. */ createUiObject(false, 'Workspace', node.name, node, undefined, undefined, 'Workspace') @@ -25,6 +27,16 @@ function newUiObjectsFromNodes () { } tryToConnectChildrenWithReferenceParents() + + setTimeout(runTasks, 70000) // We need to wait all tasks that were potentially running to stop + } + + function runTasks () { + for (let i = 0; i < tasksToRun.length; i++) { + let node = tasksToRun[i] + node.payload.uiObject.menu.internalClick('Run Task') + } + tasksToRun = undefined } function tryToConnectChildrenWithReferenceParents () { @@ -362,5 +374,11 @@ function newUiObjectsFromNodes () { canvas.floatingSpace.uiObjectConstructor.createUiObject(userAddingNew, payload) mapOfNodes.set(node.id, node) + + if (userAddingNew === false && uiObjectType === 'Task' && node.savedPayload !== undefined) { + if (node.savedPayload.uiObject.isRunning === true) { + tasksToRun.push(node) + } + } } } diff --git a/FloatingSpace/CircularProgressBar.js b/FloatingSpace/CircularProgressBar.js index 43a6e00c2..f7cc46136 100644 --- a/FloatingSpace/CircularProgressBar.js +++ b/FloatingSpace/CircularProgressBar.js @@ -23,13 +23,13 @@ function newCircularProgressBar () { let opacityCounters = [] - let eventSubscriptionHeartbeat + let eventSubscriptionIdHeartbeat return thisObject function finalize () { let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id - systemEventHandler.stopListening(key, eventSubscriptionHeartbeat) + systemEventHandler.stopListening(key, eventSubscriptionIdHeartbeat) thisObject.container = undefined thisObject.payload = undefined @@ -52,6 +52,8 @@ function newCircularProgressBar () { } function onHeartBeat (message) { + if (thisObject.payload === undefined) { return } + if (thisObject.payload.uiObject === undefined) { return } opacityCounters[message.event.seconds] = 2000 thisObject.payload.uiObject.setValue(message.event.processingDate) } diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index c79b26d5f..13e20192f 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -94,9 +94,16 @@ function newUiObject () { let currentValue = 0 let rightDragging = false + let eventSubscriptionIdHeartbeat + let eventSubscriptionIdOnStopped + return thisObject function finalize () { + let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id + systemEventHandler.stopListening(key, eventSubscriptionIdHeartbeat, 'UiObject') + systemEventHandler.stopListening(key, eventSubscriptionIdOnStopped, 'UiObject') + thisObject.container.eventHandler.stopListening(selfFocusEventSubscriptionId) thisObject.container.eventHandler.stopListening(selfNotFocuskEventSubscriptionId) thisObject.container.eventHandler.stopListening(selfDisplaceEventSubscriptionId) @@ -589,11 +596,19 @@ function newUiObject () { thisObject.circularProgressBar.fitFunction = thisObject.fitFunction thisObject.circularProgressBar.container = thisObject.container - /* We will wait to the event that the execution was terminated in order to call back the menu item */ + /* We will wait to hear the first onHeartBeat in order to confirm the execution was really started */ let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id - systemEventHandler.listenToEvent(key, 'Running', undefined, key, undefined, onRunning) + systemEventHandler.listenToEvent(key, 'Heartbeat', undefined, 'UiObject', onResponse, onHeartBeat) + + function onResponse (message) { + eventSubscriptionIdHeartbeat = message.eventSubscriptionId + } + + function onHeartBeat () { + if (thisObject.payload === undefined) { return } + let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id + systemEventHandler.stopListening(key, eventSubscriptionIdHeartbeat, 'UiObject') - function onRunning () { if (callBackFunction !== undefined) { callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) } @@ -621,9 +636,14 @@ function newUiObject () { function stop (callBackFunction, event) { /* We will wait to the event that the execution was terminated in order to call back the menu item */ let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id - systemEventHandler.listenToEvent(key, 'Stopped', undefined, key, undefined, onStopped) + systemEventHandler.listenToEvent(key, 'Stopped', undefined, 'UiObject', onResponse, onStopped) + + function onResponse (message) { + eventSubscriptionIdOnStopped = message.eventSubscriptionId + } function onStopped () { + if (thisObject.payload === undefined) { return } if (callBackFunction !== undefined) { callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE, event) } From d37092b4fdf6df5836768b6acf28810d0cd1c8b8 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 4 Feb 2020 17:35:26 +0100 Subject: [PATCH 240/264] look and feel improvement --- FloatingSpace/CircularProgressBar.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FloatingSpace/CircularProgressBar.js b/FloatingSpace/CircularProgressBar.js index f7cc46136..c07977aef 100644 --- a/FloatingSpace/CircularProgressBar.js +++ b/FloatingSpace/CircularProgressBar.js @@ -106,12 +106,12 @@ function newCircularProgressBar () { browserCanvasContext.closePath() browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.GOLDEN_ORANGE + ', ' + OPACITY * 2 + ')' - browserCanvasContext.lineWidth = 6 + opacityCounters[i] / 100 + browserCanvasContext.lineWidth = 6 + opacityCounters[i] / 100 / 2 browserCanvasContext.setLineDash([3, 4]) browserCanvasContext.stroke() browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.DARK_TURQUOISE + ', ' + OPACITY + ')' - browserCanvasContext.lineWidth = 0 + opacityCounters[i] / 100 + browserCanvasContext.lineWidth = 0 + opacityCounters[i] / 100 / 2 browserCanvasContext.setLineDash([3, 4]) browserCanvasContext.stroke() } From 7c7e11a31189d17976966dea58bc4c0a3545ba35 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 4 Feb 2020 17:41:24 +0100 Subject: [PATCH 241/264] Improvement, zero time to reconnect --- .../Workspace/FunctionLibraries/UiObjectsFromNodes.js | 8 ++++++-- DesignerSpace/Workspace/Workspace.js | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js b/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js index fc5e63278..5df4ecd6a 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js +++ b/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js @@ -13,7 +13,7 @@ function newUiObjectsFromNodes () { return thisObject - function recreateWorkspace (node) { + function recreateWorkspace (node, replacingCurrentWorkspace) { mapOfNodes = new Map() tasksToRun = [] @@ -28,7 +28,11 @@ function newUiObjectsFromNodes () { tryToConnectChildrenWithReferenceParents() - setTimeout(runTasks, 70000) // We need to wait all tasks that were potentially running to stop + if (replacingCurrentWorkspace === true) { + setTimeout(runTasks, 70000) // We need to wait all tasks that were potentially running to stop + } else { + runTasks() + } } function runTasks () { diff --git a/DesignerSpace/Workspace/Workspace.js b/DesignerSpace/Workspace/Workspace.js index 93985c5ac..d0912847e 100644 --- a/DesignerSpace/Workspace/Workspace.js +++ b/DesignerSpace/Workspace/Workspace.js @@ -132,7 +132,7 @@ function newWorkspace () { workingAtTask++ break case 4: - functionLibraryUiObjectsFromNodes.recreateWorkspace(thisObject.workspaceNode) + functionLibraryUiObjectsFromNodes.recreateWorkspace(thisObject.workspaceNode, true) workingAtTask++ break case 5: From 2ce2d8b800ed50ee67ebc1d72ce7f4cede8bc74a Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 4 Feb 2020 18:21:37 +0100 Subject: [PATCH 242/264] Restarting Sessions --- .../FunctionLibraries/UiObjectsFromNodes.js | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js b/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js index 5df4ecd6a..40466a029 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js +++ b/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js @@ -10,12 +10,14 @@ function newUiObjectsFromNodes () { let mapOfReferenceChildren = new Map() let mapOfNodes let tasksToRun + let sessionsToRun return thisObject function recreateWorkspace (node, replacingCurrentWorkspace) { mapOfNodes = new Map() tasksToRun = [] + sessionsToRun = [] /* Create the workspace UI OBject and then continue with the root nodes. */ createUiObject(false, 'Workspace', node.name, node, undefined, undefined, 'Workspace') @@ -29,9 +31,14 @@ function newUiObjectsFromNodes () { tryToConnectChildrenWithReferenceParents() if (replacingCurrentWorkspace === true) { - setTimeout(runTasks, 70000) // We need to wait all tasks that were potentially running to stop + // We need to wait all tasks that were potentially running to stop + setTimeout(runTasks, 70000) + // We give a few seconds for the tasks to start + setTimeout(runSessions, 80000) } else { runTasks() + // We give a few seconds for the tasks to start + setTimeout(runSessions, 10000) } } @@ -43,6 +50,14 @@ function newUiObjectsFromNodes () { tasksToRun = undefined } + function runSessions () { + for (let i = 0; i < sessionsToRun.length; i++) { + let node = sessionsToRun[i] + node.payload.uiObject.menu.internalClick('Run Session') + } + sessionsToRun = undefined + } + function tryToConnectChildrenWithReferenceParents () { /* We reconstruct here the reference relationships. */ for (const [key, node] of mapOfNodes) { @@ -379,10 +394,20 @@ function newUiObjectsFromNodes () { mapOfNodes.set(node.id, node) + /* Check if there are tasks to run */ if (userAddingNew === false && uiObjectType === 'Task' && node.savedPayload !== undefined) { if (node.savedPayload.uiObject.isRunning === true) { tasksToRun.push(node) } + } + + /* Check if there are sessions to run */ + if (userAddingNew === false && node.savedPayload !== undefined) { + if (uiObjectType === 'Live Trading Session' || uiObjectType === 'Fordward Testing Session' || uiObjectType === 'Backtesting Session' || uiObjectType === 'Paper Trading Session') { + if (node.savedPayload.uiObject.isRunning === true) { + sessionsToRun.push(node) + } + } } } } From 1617a92e3259915537a36f0da81167ba11f5b555 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 5 Feb 2020 09:51:38 +0100 Subject: [PATCH 243/264] Distance to Parent Implemented --- .../FunctionLibraries/NodeCloning.js | 3 +- .../FunctionLibraries/ProtocolNode.js | 3 +- FloatingSpace/FloatingObject.js | 62 ++++++++++++++++--- FloatingSpace/UiObjectConstructor.js | 27 +++++++- Globals.js | 8 +++ 5 files changed, 91 insertions(+), 12 deletions(-) diff --git a/DesignerSpace/Workspace/FunctionLibraries/NodeCloning.js b/DesignerSpace/Workspace/FunctionLibraries/NodeCloning.js index 0e1332a7f..c4493f979 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/NodeCloning.js +++ b/DesignerSpace/Workspace/FunctionLibraries/NodeCloning.js @@ -145,7 +145,8 @@ function newNodeCloning () { isPinned: node.payload.floatingObject.isPinned, isFrozen: (node.payload.floatingObject.isFrozen && node.payload.floatingObject.frozenManually), isCollapsed: (node.payload.floatingObject.isCollapsed && node.payload.floatingObject.collapsedManually), - tensionLevel: (node.payload.floatingObject.tensionLevel) + tensionLevel: (node.payload.floatingObject.tensionLevel), + distanceToParent: (node.payload.floatingObject.distanceToParent) }, uiObject: { isRunning: node.payload.uiObject.isRunning, diff --git a/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js b/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js index 3cb36839a..55e481f85 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js +++ b/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js @@ -148,7 +148,8 @@ function newProtocolNode () { isPinned: node.payload.floatingObject.isPinned, isFrozen: (node.payload.floatingObject.isFrozen && node.payload.floatingObject.frozenManually), isCollapsed: (node.payload.floatingObject.isCollapsed && node.payload.floatingObject.collapsedManually), - tensionLevel: (node.payload.floatingObject.tensionLevel) + tensionLevel: (node.payload.floatingObject.tensionLevel), + distanceToParent: (node.payload.floatingObject.distanceToParent) }, uiObject: { isRunning: node.payload.uiObject.isRunning, diff --git a/FloatingSpace/FloatingObject.js b/FloatingSpace/FloatingObject.js index f9f6091ab..5b2a3eec7 100644 --- a/FloatingSpace/FloatingObject.js +++ b/FloatingSpace/FloatingObject.js @@ -22,7 +22,8 @@ function newFloatingObject () { targetRadius: 0, // This is the target radius of the floating object with zoom applied. It should be animated until reaching this value. isPinned: false, isFrozen: false, - tensionLevel: TENSION_LEVEL.NO_TENSION, + tensionLevel: TENSION_LEVEL.LEVEL_90, + distanceToParent: DISTANCE_TO_PARENT.SAME, isCollapsed: false, isParentCollapsed: false, frozenManually: false, @@ -30,13 +31,15 @@ function newFloatingObject () { getPinStatus: getPinStatus, getFreezeStatus: getFreezeStatus, getCollapseStatus: getCollapseStatus, - getTensionStatus: getTensionStatus, + getTensionLevel: getTensionLevel, + getDistanceToParent: getDistanceToParent, nearbyFloatingObjects: [], setPosition: setPosition, pinToggle: pinToggle, freezeToggle: freezeToggle, collapseToggle: collapseToggle, tensionToggle: tensionToggle, + distanceToParentToggle: distanceToParentToggle, physics: physics, initializeMass: initializeMass, initializeRadius: initializeRadius, @@ -138,10 +141,14 @@ function newFloatingObject () { return thisObject.isCollapsed } - function getTensionStatus () { + function getTensionLevel () { return thisObject.tensionLevel } + function getDistanceToParent () { + return thisObject.distanceToParent + } + function freezeToggle () { if (thisObject.isFrozen !== true) { thisObject.isFrozen = true @@ -186,6 +193,28 @@ function newFloatingObject () { return thisObject.tensionLevel } + function distanceToParentToggle () { + switch (thisObject.distanceToParent) { + case DISTANCE_TO_PARENT.NOT_FIXED: + thisObject.distanceToParent = DISTANCE_TO_PARENT.QUARTER + break + case DISTANCE_TO_PARENT.QUARTER: + thisObject.distanceToParent = DISTANCE_TO_PARENT.HALF + break + case DISTANCE_TO_PARENT.HALF: + thisObject.distanceToParent = DISTANCE_TO_PARENT.SAME + break + case DISTANCE_TO_PARENT.SAME: + thisObject.distanceToParent = DISTANCE_TO_PARENT.DOUBLE + break + case DISTANCE_TO_PARENT.DOUBLE: + thisObject.distanceToParent = DISTANCE_TO_PARENT.NOT_FIXED + break + } + + return thisObject.distanceToParent + } + function physics () { collapsePhysics() if (canvas.floatingSpace.isItFar(thisObject.payload)) { return } @@ -229,13 +258,30 @@ function newFloatingObject () { if (parent.payload === undefined) { return } if (parent.payload.position === undefined) { return } - let distanceToChainParent = Math.sqrt(Math.pow(parent.payload.position.x - thisObject.container.frame.position.x, 2) + Math.pow(parent.payload.position.y - thisObject.container.frame.position.y, 2)) // ... we calculate the distance ... + let distanceToParent = Math.sqrt(Math.pow(parent.payload.position.x - thisObject.container.frame.position.x, 2) + Math.pow(parent.payload.position.y - thisObject.container.frame.position.y, 2)) // ... we calculate the distance ... let parentChildren = canvas.designerSpace.workspace.nodeChildren.childrenCount(parent, thisObject.payload.node) let axisCount = parentChildren.childrenCount let axisIndex = parentChildren.childIndex let baseAngle = 0 let tensionLevelAngle + if (parent.payload.distance !== undefined) { + switch (thisObject.distanceToParent) { + case DISTANCE_TO_PARENT.QUARTER: + distanceToParent = parent.payload.distance / 4 + break + case DISTANCE_TO_PARENT.HALF: + distanceToParent = parent.payload.distance / 2 + break + case DISTANCE_TO_PARENT.SAME: + distanceToParent = parent.payload.distance + break + case DISTANCE_TO_PARENT.DOUBLE: + distanceToParent = parent.payload.distance * 2 + break + } + } + switch (thisObject.tensionLevel) { case TENSION_LEVEL.LEVEL_360: tensionLevelAngle = 360 @@ -277,11 +323,13 @@ function newFloatingObject () { thisObject.payload.angle = thisObject.payload.angle - 360 } - if (distanceToChainParent > 2000) { return } // this is introduced to avoid edges cases when importing workspaces. + thisObject.payload.distance = distanceToParent + + if (distanceToParent > 2000) { return } // this is introduced to avoid edges cases when importing workspaces. newPosition = { - x: parent.payload.position.x + distanceToChainParent * Math.cos(toRadians(thisObject.payload.angle)), - y: parent.payload.position.y + distanceToChainParent * Math.sin(toRadians(thisObject.payload.angle)) + x: parent.payload.position.x + distanceToParent * Math.cos(toRadians(thisObject.payload.angle)), + y: parent.payload.position.y + distanceToParent * Math.sin(toRadians(thisObject.payload.angle)) } if (isNaN(newPosition.x) === false) { thisObject.container.frame.position.x = newPosition.x diff --git a/FloatingSpace/UiObjectConstructor.js b/FloatingSpace/UiObjectConstructor.js index 43b77b0a6..76f7b0518 100644 --- a/FloatingSpace/UiObjectConstructor.js +++ b/FloatingSpace/UiObjectConstructor.js @@ -57,12 +57,18 @@ function newUiObjectConstructor () { if (payload.node.savedPayload.floatingObject.isCollapsed === true) { floatingObject.collapseToggle() } - floatingObject.tensionLevel = payload.node.savedPayload.floatingObject.tensionLevel + if (payload.node.savedPayload.floatingObject.tensionLevel !== undefined) { + floatingObject.tensionLevel = payload.node.savedPayload.floatingObject.tensionLevel + } + if (payload.node.savedPayload.floatingObject.distanceToParent !== undefined) { + floatingObject.distanceToParent = payload.node.savedPayload.floatingObject.distanceToParent + } } /* For brand new objects being created directly by the user, we will make them inherit some properties from their parents. */ if (userAddingNew === true) { floatingObject.tensionLevel = payload.parentNode.payload.floatingObject.tensionLevel + floatingObject.distanceToParent = payload.parentNode.payload.floatingObject.distanceToParent } let uiObject = newUiObject() @@ -136,9 +142,9 @@ function newUiObjectConstructor () { ) menuItemsInitialValues.push( { - action: 'Tense / Untense', + action: 'Change Tension Level', actionFunction: floatingObject.tensionToggle, - actionStatus: floatingObject.getTensionStatus, + actionStatus: floatingObject.getTensionLevel, currentStatus: true, label: undefined, visible: true, @@ -149,6 +155,21 @@ function newUiObjectConstructor () { ring: 1 } ) + menuItemsInitialValues.push( + { + action: 'change Distance to Paarent', + actionFunction: floatingObject.distanceToParentToggle, + actionStatus: floatingObject.getDistanceToParent, + currentStatus: true, + label: undefined, + visible: true, + icons: ['headphones', 'competition', 'analysis-1', 'stage-open-postion-rate', 'stop'], + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + ring: 1 + } + ) menuItemsInitialValues.push( { action: 'Freeze / Unfreeze', diff --git a/Globals.js b/Globals.js index 92d054bd2..5101af2d7 100644 --- a/Globals.js +++ b/Globals.js @@ -59,6 +59,14 @@ const TENSION_LEVEL = { LEVEL_45: 4 } +const DISTANCE_TO_PARENT = { + NOT_FIXED: 0, + QUARTER: 1, + HALF: 2, + SAME: 3, + DOUBLE: 4 +} + /* User Interface Panels */ UI_PANEL = { From 2220698a922d1c9aa50491e4c9bab0cceb23413f Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 5 Feb 2020 11:35:42 +0100 Subject: [PATCH 244/264] tension replaced by angleToParent --- .../FunctionLibraries/NodeCloning.js | 2 +- .../FunctionLibraries/ProtocolNode.js | 2 +- FloatingSpace/FloatingObject.js | 74 ++++++++++--------- FloatingSpace/UiObject.js | 2 +- FloatingSpace/UiObjectConstructor.js | 22 +++--- Globals.js | 15 ++-- 6 files changed, 61 insertions(+), 56 deletions(-) diff --git a/DesignerSpace/Workspace/FunctionLibraries/NodeCloning.js b/DesignerSpace/Workspace/FunctionLibraries/NodeCloning.js index c4493f979..72d458dcf 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/NodeCloning.js +++ b/DesignerSpace/Workspace/FunctionLibraries/NodeCloning.js @@ -145,7 +145,7 @@ function newNodeCloning () { isPinned: node.payload.floatingObject.isPinned, isFrozen: (node.payload.floatingObject.isFrozen && node.payload.floatingObject.frozenManually), isCollapsed: (node.payload.floatingObject.isCollapsed && node.payload.floatingObject.collapsedManually), - tensionLevel: (node.payload.floatingObject.tensionLevel), + angleToParent: (node.payload.floatingObject.angleToParent), distanceToParent: (node.payload.floatingObject.distanceToParent) }, uiObject: { diff --git a/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js b/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js index 55e481f85..4eaf8ec8c 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js +++ b/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js @@ -148,7 +148,7 @@ function newProtocolNode () { isPinned: node.payload.floatingObject.isPinned, isFrozen: (node.payload.floatingObject.isFrozen && node.payload.floatingObject.frozenManually), isCollapsed: (node.payload.floatingObject.isCollapsed && node.payload.floatingObject.collapsedManually), - tensionLevel: (node.payload.floatingObject.tensionLevel), + angleToParent: (node.payload.floatingObject.angleToParent), distanceToParent: (node.payload.floatingObject.distanceToParent) }, uiObject: { diff --git a/FloatingSpace/FloatingObject.js b/FloatingSpace/FloatingObject.js index 5b2a3eec7..1ab90778f 100644 --- a/FloatingSpace/FloatingObject.js +++ b/FloatingSpace/FloatingObject.js @@ -22,7 +22,7 @@ function newFloatingObject () { targetRadius: 0, // This is the target radius of the floating object with zoom applied. It should be animated until reaching this value. isPinned: false, isFrozen: false, - tensionLevel: TENSION_LEVEL.LEVEL_90, + angleToParent: ANGLE_TO_PARENT.RANGE_90, distanceToParent: DISTANCE_TO_PARENT.SAME, isCollapsed: false, isParentCollapsed: false, @@ -31,14 +31,14 @@ function newFloatingObject () { getPinStatus: getPinStatus, getFreezeStatus: getFreezeStatus, getCollapseStatus: getCollapseStatus, - getTensionLevel: getTensionLevel, + getAngleToParent: getAngleToParent, getDistanceToParent: getDistanceToParent, nearbyFloatingObjects: [], setPosition: setPosition, pinToggle: pinToggle, freezeToggle: freezeToggle, collapseToggle: collapseToggle, - tensionToggle: tensionToggle, + angleToParentToggle: angleToParentToggle, distanceToParentToggle: distanceToParentToggle, physics: physics, initializeMass: initializeMass, @@ -141,8 +141,8 @@ function newFloatingObject () { return thisObject.isCollapsed } - function getTensionLevel () { - return thisObject.tensionLevel + function getAngleToParent () { + return thisObject.angleToParent } function getDistanceToParent () { @@ -171,26 +171,26 @@ function newFloatingObject () { return thisObject.isCollapsed } - function tensionToggle () { - switch (thisObject.tensionLevel) { - case TENSION_LEVEL.NO_TENSION: - thisObject.tensionLevel = TENSION_LEVEL.LEVEL_360 + function angleToParentToggle () { + switch (thisObject.angleToParent) { + case ANGLE_TO_PARENT.NOT_FIXED: + thisObject.angleToParent = ANGLE_TO_PARENT.RANGE_360 break - case TENSION_LEVEL.LEVEL_360: - thisObject.tensionLevel = TENSION_LEVEL.LEVEL_180 + case ANGLE_TO_PARENT.RANGE_360: + thisObject.angleToParent = ANGLE_TO_PARENT.RANGE_180 break - case TENSION_LEVEL.LEVEL_180: - thisObject.tensionLevel = TENSION_LEVEL.LEVEL_90 + case ANGLE_TO_PARENT.RANGE_180: + thisObject.angleToParent = ANGLE_TO_PARENT.RANGE_90 break - case TENSION_LEVEL.LEVEL_90: - thisObject.tensionLevel = TENSION_LEVEL.LEVEL_45 + case ANGLE_TO_PARENT.RANGE_90: + thisObject.angleToParent = ANGLE_TO_PARENT.RANGE_45 break - case TENSION_LEVEL.LEVEL_45: - thisObject.tensionLevel = TENSION_LEVEL.NO_TENSION + case ANGLE_TO_PARENT.RANGE_45: + thisObject.angleToParent = ANGLE_TO_PARENT.NOT_FIXED break } - return thisObject.tensionLevel + return thisObject.angleToParent } function distanceToParentToggle () { @@ -205,6 +205,9 @@ function newFloatingObject () { thisObject.distanceToParent = DISTANCE_TO_PARENT.SAME break case DISTANCE_TO_PARENT.SAME: + thisObject.distanceToParent = DISTANCE_TO_PARENT.SAME_HALF + break + case DISTANCE_TO_PARENT.SAME_HALF: thisObject.distanceToParent = DISTANCE_TO_PARENT.DOUBLE break case DISTANCE_TO_PARENT.DOUBLE: @@ -221,7 +224,7 @@ function newFloatingObject () { thisObjectPhysics() thisObject.payload.uiObject.physics() frozenPhysics() - tensionPhysics() + positionContraintsPhysics() } function frozenPhysics () { @@ -249,10 +252,8 @@ function newFloatingObject () { } } - function tensionPhysics () { - /* Tension Effect */ - - if (thisObject.tensionLevel !== TENSION_LEVEL.NO_TENSION && thisObject.isOnFocus !== true) { + function positionContraintsPhysics () { + if (thisObject.angleToParent !== ANGLE_TO_PARENT.NOT_FIXED && thisObject.isOnFocus !== true) { let parent = thisObject.payload.chainParent if (parent === undefined) { return } if (parent.payload === undefined) { return } @@ -263,7 +264,7 @@ function newFloatingObject () { let axisCount = parentChildren.childrenCount let axisIndex = parentChildren.childIndex let baseAngle = 0 - let tensionLevelAngle + let angleToParentAngle if (parent.payload.distance !== undefined) { switch (thisObject.distanceToParent) { @@ -276,24 +277,27 @@ function newFloatingObject () { case DISTANCE_TO_PARENT.SAME: distanceToParent = parent.payload.distance break + case DISTANCE_TO_PARENT.SAME_HALF: + distanceToParent = parent.payload.distance * 1.5 + break case DISTANCE_TO_PARENT.DOUBLE: distanceToParent = parent.payload.distance * 2 break } } - switch (thisObject.tensionLevel) { - case TENSION_LEVEL.LEVEL_360: - tensionLevelAngle = 360 + switch (thisObject.angleToParent) { + case ANGLE_TO_PARENT.RANGE_360: + angleToParentAngle = 360 break - case TENSION_LEVEL.LEVEL_180: - tensionLevelAngle = 180 + case ANGLE_TO_PARENT.RANGE_180: + angleToParentAngle = 180 break - case TENSION_LEVEL.LEVEL_90: - tensionLevelAngle = 90 + case ANGLE_TO_PARENT.RANGE_90: + angleToParentAngle = 90 break - case TENSION_LEVEL.LEVEL_45: - tensionLevelAngle = 45 + case ANGLE_TO_PARENT.RANGE_45: + angleToParentAngle = 45 break } @@ -315,8 +319,8 @@ function newFloatingObject () { } } - let separatorAngle = (360 - tensionLevelAngle) / 2 - let angleStep = tensionLevelAngle / axisCount + let separatorAngle = (360 - angleToParentAngle) / 2 + let angleStep = angleToParentAngle / axisCount thisObject.payload.angle = baseAngle + separatorAngle + (axisIndex - 1) * angleStep if (thisObject.payload.angle >= 360) { diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index 13e20192f..d33a094cb 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -884,7 +884,7 @@ function newUiObject () { /* Target Line */ let LINE_STYLE = UI_COLOR.TITANIUM_YELLOW - if (thisObject.payload.floatingObject.tensionLevel !== TENSION_LEVEL.NO_TENSION) { + if (thisObject.payload.floatingObject.angleToParent !== ANGLE_TO_PARENT.NOT_FIXED) { LINE_STYLE = UI_COLOR.GOLDEN_ORANGE } if (thisObject.payload.floatingObject.isFrozen === true) { diff --git a/FloatingSpace/UiObjectConstructor.js b/FloatingSpace/UiObjectConstructor.js index 76f7b0518..69bf7cd23 100644 --- a/FloatingSpace/UiObjectConstructor.js +++ b/FloatingSpace/UiObjectConstructor.js @@ -57,8 +57,8 @@ function newUiObjectConstructor () { if (payload.node.savedPayload.floatingObject.isCollapsed === true) { floatingObject.collapseToggle() } - if (payload.node.savedPayload.floatingObject.tensionLevel !== undefined) { - floatingObject.tensionLevel = payload.node.savedPayload.floatingObject.tensionLevel + if (payload.node.savedPayload.floatingObject.angleToParent !== undefined) { + floatingObject.angleToParent = payload.node.savedPayload.floatingObject.angleToParent } if (payload.node.savedPayload.floatingObject.distanceToParent !== undefined) { floatingObject.distanceToParent = payload.node.savedPayload.floatingObject.distanceToParent @@ -67,7 +67,7 @@ function newUiObjectConstructor () { /* For brand new objects being created directly by the user, we will make them inherit some properties from their parents. */ if (userAddingNew === true) { - floatingObject.tensionLevel = payload.parentNode.payload.floatingObject.tensionLevel + floatingObject.angleToParent = payload.parentNode.payload.floatingObject.angleToParent floatingObject.distanceToParent = payload.parentNode.payload.floatingObject.distanceToParent } @@ -143,8 +143,8 @@ function newUiObjectConstructor () { menuItemsInitialValues.push( { action: 'Change Tension Level', - actionFunction: floatingObject.tensionToggle, - actionStatus: floatingObject.getTensionLevel, + actionFunction: floatingObject.angleToParentToggle, + actionStatus: floatingObject.getAngleToParent, currentStatus: true, label: undefined, visible: true, @@ -163,7 +163,7 @@ function newUiObjectConstructor () { currentStatus: true, label: undefined, visible: true, - icons: ['headphones', 'competition', 'analysis-1', 'stage-open-postion-rate', 'stop'], + icons: ['headphones', 'competition', 'analysis-1', 'stage-open-postion-rate', 'stop', 'pyramid'], rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -331,7 +331,7 @@ function newUiObjectConstructor () { switch (payload.node.type) { case 'Workspace': { level_0() - floatingObject.tensionLevel = TENSION_LEVEL.LEVEL_360 + floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_360 break } @@ -391,7 +391,7 @@ function newUiObjectConstructor () { floatingObject.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)' if (payload.node.savedPayload === undefined) { - // floatingObject.tensionToggle() + // floatingObject.angleToParentToggle() } } function level_2 () { @@ -406,7 +406,7 @@ function newUiObjectConstructor () { floatingObject.fillStyle = 'rgba(' + UI_COLOR.GREEN + ', 1)' if (payload.node.savedPayload === undefined) { - // floatingObject.tensionToggle() + // floatingObject.angleToParentToggle() } } function level_3 () { @@ -421,7 +421,7 @@ function newUiObjectConstructor () { floatingObject.fillStyle = 'rgba(' + UI_COLOR.RUSTED_RED + ', 1)' if (payload.node.savedPayload === undefined) { - // floatingObject.tensionToggle() + // floatingObject.angleToParentToggle() } } function level_4 () { @@ -436,7 +436,7 @@ function newUiObjectConstructor () { floatingObject.fillStyle = 'rgba(' + UI_COLOR.TITANIUM_YELLOW + ', 1)' if (payload.node.savedPayload === undefined) { - // floatingObject.tensionToggle() + // floatingObject.angleToParentToggle() } } function level_5 () { diff --git a/Globals.js b/Globals.js index 5101af2d7..cdae47db0 100644 --- a/Globals.js +++ b/Globals.js @@ -51,12 +51,12 @@ const GET_CONTAINER_PURPOSE = { DRAGGING: 4 } -const TENSION_LEVEL = { - NO_TENSION: 0, - LEVEL_360: 1, - LEVEL_180: 2, - LEVEL_90: 3, - LEVEL_45: 4 +const ANGLE_TO_PARENT = { + NOT_FIXED: 0, + RANGE_360: 1, + RANGE_180: 2, + RANGE_90: 3, + RANGE_45: 4 } const DISTANCE_TO_PARENT = { @@ -64,7 +64,8 @@ const DISTANCE_TO_PARENT = { QUARTER: 1, HALF: 2, SAME: 3, - DOUBLE: 4 + SAME_HALF: 4, + DOUBLE: 5 } /* User Interface Panels */ From 28ca5287099caa32cc97d0095c57af224f7cf5b8 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 5 Feb 2020 11:43:23 +0100 Subject: [PATCH 245/264] better names --- FloatingSpace/FloatingObject.js | 32 ++++++++++++++++---------------- Globals.js | 10 +++++----- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/FloatingSpace/FloatingObject.js b/FloatingSpace/FloatingObject.js index 1ab90778f..9f711f886 100644 --- a/FloatingSpace/FloatingObject.js +++ b/FloatingSpace/FloatingObject.js @@ -23,7 +23,7 @@ function newFloatingObject () { isPinned: false, isFrozen: false, angleToParent: ANGLE_TO_PARENT.RANGE_90, - distanceToParent: DISTANCE_TO_PARENT.SAME, + distanceToParent: DISTANCE_TO_PARENT.PARENT_100X, isCollapsed: false, isParentCollapsed: false, frozenManually: false, @@ -196,21 +196,21 @@ function newFloatingObject () { function distanceToParentToggle () { switch (thisObject.distanceToParent) { case DISTANCE_TO_PARENT.NOT_FIXED: - thisObject.distanceToParent = DISTANCE_TO_PARENT.QUARTER + thisObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_025X break - case DISTANCE_TO_PARENT.QUARTER: - thisObject.distanceToParent = DISTANCE_TO_PARENT.HALF + case DISTANCE_TO_PARENT.PARENT_025X: + thisObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_050X break - case DISTANCE_TO_PARENT.HALF: - thisObject.distanceToParent = DISTANCE_TO_PARENT.SAME + case DISTANCE_TO_PARENT.PARENT_050X: + thisObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_100X break - case DISTANCE_TO_PARENT.SAME: - thisObject.distanceToParent = DISTANCE_TO_PARENT.SAME_HALF + case DISTANCE_TO_PARENT.PARENT_100X: + thisObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_150X break - case DISTANCE_TO_PARENT.SAME_HALF: - thisObject.distanceToParent = DISTANCE_TO_PARENT.DOUBLE + case DISTANCE_TO_PARENT.PARENT_150X: + thisObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_200X break - case DISTANCE_TO_PARENT.DOUBLE: + case DISTANCE_TO_PARENT.PARENT_200X: thisObject.distanceToParent = DISTANCE_TO_PARENT.NOT_FIXED break } @@ -268,19 +268,19 @@ function newFloatingObject () { if (parent.payload.distance !== undefined) { switch (thisObject.distanceToParent) { - case DISTANCE_TO_PARENT.QUARTER: + case DISTANCE_TO_PARENT.PARENT_025X: distanceToParent = parent.payload.distance / 4 break - case DISTANCE_TO_PARENT.HALF: + case DISTANCE_TO_PARENT.PARENT_050X: distanceToParent = parent.payload.distance / 2 break - case DISTANCE_TO_PARENT.SAME: + case DISTANCE_TO_PARENT.PARENT_100X: distanceToParent = parent.payload.distance break - case DISTANCE_TO_PARENT.SAME_HALF: + case DISTANCE_TO_PARENT.PARENT_150X: distanceToParent = parent.payload.distance * 1.5 break - case DISTANCE_TO_PARENT.DOUBLE: + case DISTANCE_TO_PARENT.PARENT_200X: distanceToParent = parent.payload.distance * 2 break } diff --git a/Globals.js b/Globals.js index cdae47db0..22a3d5d2d 100644 --- a/Globals.js +++ b/Globals.js @@ -61,11 +61,11 @@ const ANGLE_TO_PARENT = { const DISTANCE_TO_PARENT = { NOT_FIXED: 0, - QUARTER: 1, - HALF: 2, - SAME: 3, - SAME_HALF: 4, - DOUBLE: 5 + PARENT_025X: 1, + PARENT_050X: 2, + PARENT_100X: 3, + PARENT_150X: 4, + PARENT_200X: 5 } /* User Interface Panels */ From d4028177daac885e8f8c115747c99ed76cebe14a Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 5 Feb 2020 13:53:18 +0100 Subject: [PATCH 246/264] warm up concept removed, bug fixed when dropping workspaces --- DesignerSpace/Workspace/Workspace.js | 1 - FloatingSpace/FloatingLayer.js | 4 ++-- FloatingSpace/FloatingObject.js | 3 ++- Spaces/FloatingSpace.js | 19 +------------------ 4 files changed, 5 insertions(+), 22 deletions(-) diff --git a/DesignerSpace/Workspace/Workspace.js b/DesignerSpace/Workspace/Workspace.js index d0912847e..9c2bb4721 100644 --- a/DesignerSpace/Workspace/Workspace.js +++ b/DesignerSpace/Workspace/Workspace.js @@ -140,7 +140,6 @@ function newWorkspace () { workingAtTask++ break case 6: - canvas.floatingSpace.warmUp() workingAtTask = 0 circularProgressBar.visible = false break diff --git a/FloatingSpace/FloatingLayer.js b/FloatingSpace/FloatingLayer.js index 3d2bef34f..993581c8b 100644 --- a/FloatingSpace/FloatingLayer.js +++ b/FloatingSpace/FloatingLayer.js @@ -263,7 +263,9 @@ function newFloatingLayer () { for (let i = 0; i < visibleFloatingObjects.length; i++) { let floatingObject = visibleFloatingObjects[i] + floatingObject.physics() + /* From here on, only if they are not too far. */ if (canvas.floatingSpace.isItFar(floatingObject.payload)) { continue } if (floatingObject.positionLocked === false) { @@ -341,8 +343,6 @@ function newFloatingLayer () { // We let the Floating Object animate the physics loops by itself. checkBoundaries(floatingObject) - floatingObject.physics() - /* Collision Control */ for (let k = i + 1; k < visibleFloatingObjects.length; k++) { diff --git a/FloatingSpace/FloatingObject.js b/FloatingSpace/FloatingObject.js index 9f711f886..b84f43764 100644 --- a/FloatingSpace/FloatingObject.js +++ b/FloatingSpace/FloatingObject.js @@ -220,10 +220,11 @@ function newFloatingObject () { function physics () { collapsePhysics() + frozenPhysics() + /* From here on, only if they are not too far. */ if (canvas.floatingSpace.isItFar(thisObject.payload)) { return } thisObjectPhysics() thisObject.payload.uiObject.physics() - frozenPhysics() positionContraintsPhysics() } diff --git a/Spaces/FloatingSpace.js b/Spaces/FloatingSpace.js index 57f1f7b87..6422a85f0 100644 --- a/Spaces/FloatingSpace.js +++ b/Spaces/FloatingSpace.js @@ -19,7 +19,6 @@ function newFloatingSpace () { fitIntoVisibleArea: fitIntoVisibleArea, isThisPointVisible: isThisPointVisible, isItFar: isItFar, - warmUp: warmUp, makeVisible: makeVisible, makeInvisible: makeInvisible, draw: draw, @@ -39,7 +38,6 @@ function newFloatingSpace () { let devicePixelRatio = window.devicePixelRatio const SPACE_SIZE = 50000 - const WARM_UP_LIMIT = 10000 thisObject.container.frame.width = SPACE_SIZE thisObject.container.frame.height = SPACE_SIZE @@ -47,7 +45,6 @@ function newFloatingSpace () { thisObject.container.frame.position.y = browserCanvas.height / 2 - thisObject.container.frame.height / 2 let visible = false - let warmingUpCounter = 0 const PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT = 25 let eventSubscriptionId @@ -76,24 +73,10 @@ function newFloatingSpace () { eventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) } - function warmUp () { - warmingUpCounter = 0 - } - function isItFar (payload, dontCheckParent) { /* If for any reason the paylaod is undefined we return false */ if (payload === undefined) { return false } - /* - We need a warm up in order to allow all objects to stabilize into a consistant state. - After that we will start evaluating which ones are too far from the current user view. - */ - - if (warmingUpCounter < WARM_UP_LIMIT) { - warmingUpCounter++ - return false - } - let radarFactor = 2 // How big is the margin /* If the chain parent is not far, they we dont consither this far. */ @@ -262,7 +245,7 @@ function newFloatingSpace () { } function physics () { - if (visible === true || warmingUpCounter < WARM_UP_LIMIT) { + if (visible === true) { browserZoomPhysics() thisObject.floatingLayer.physics() } From 8ee203f7f3ff831de0d257b85e9c87465e5986aa Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 5 Feb 2020 14:52:54 +0100 Subject: [PATCH 247/264] new icons --- FloatingSpace/UiObjectConstructor.js | 4 ++-- Spaces/DesignerSpace.js | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/FloatingSpace/UiObjectConstructor.js b/FloatingSpace/UiObjectConstructor.js index 69bf7cd23..0054c8b61 100644 --- a/FloatingSpace/UiObjectConstructor.js +++ b/FloatingSpace/UiObjectConstructor.js @@ -148,7 +148,7 @@ function newUiObjectConstructor () { currentStatus: true, label: undefined, visible: true, - icons: ['menu-tensor-free-angles', 'menu-tensor-fixed-angles', 'menu-share', 'compass', 'broken-link'], + icons: ['menu-tensor-free-angles', 'angle-to-parent-360', 'angle-to-parent-180', 'angle-to-parent-090', 'angle-to-parent-045'], rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -163,7 +163,7 @@ function newUiObjectConstructor () { currentStatus: true, label: undefined, visible: true, - icons: ['headphones', 'competition', 'analysis-1', 'stage-open-postion-rate', 'stop', 'pyramid'], + icons: ['headphones', 'distance-to-parent-025', 'distance-to-parent-050', 'distance-to-parent-100', 'distance-to-parent-150', 'distance-to-parent-200'], rawRadius: 8, targetRadius: 0, currentRadius: 0, diff --git a/Spaces/DesignerSpace.js b/Spaces/DesignerSpace.js index d8504cfab..86045cb00 100644 --- a/Spaces/DesignerSpace.js +++ b/Spaces/DesignerSpace.js @@ -221,7 +221,17 @@ function newDesignerSpace () { 'bitmex', 'liquid', 'hitbtc', - 'us-dollar' + 'us-dollar', + 'distance-to-parent-200', + 'distance-to-parent-150', + 'distance-to-parent-100', + 'distance-to-parent-050', + 'distance-to-parent-025', + 'angle-to-parent-360', + 'angle-to-parent-180', + 'angle-to-parent-090', + 'angle-to-parent-045', + 'angle-to-parent-000' ] for (let i = 0; i < iconsNames.length; i++) { From b55c22d8bb32555918f03d1dc33a3916d6631f9e Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 5 Feb 2020 17:54:01 +0100 Subject: [PATCH 248/264] Charting Space refactoring --- FloatingSpace/UiObjectConstructor.js | 4 ++-- Panels/LayersPanel.js | 2 +- README.md | 2 +- Spaces/ChartSpace.js | 4 ++-- Spaces/DesignerSpace.js | 3 ++- Spaces/FloatingSpace.js | 2 +- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/FloatingSpace/UiObjectConstructor.js b/FloatingSpace/UiObjectConstructor.js index 0054c8b61..1df4c95a6 100644 --- a/FloatingSpace/UiObjectConstructor.js +++ b/FloatingSpace/UiObjectConstructor.js @@ -148,7 +148,7 @@ function newUiObjectConstructor () { currentStatus: true, label: undefined, visible: true, - icons: ['menu-tensor-free-angles', 'angle-to-parent-360', 'angle-to-parent-180', 'angle-to-parent-090', 'angle-to-parent-045'], + icons: ['angle-to-parent-000', 'angle-to-parent-360', 'angle-to-parent-180', 'angle-to-parent-090', 'angle-to-parent-045'], rawRadius: 8, targetRadius: 0, currentRadius: 0, @@ -163,7 +163,7 @@ function newUiObjectConstructor () { currentStatus: true, label: undefined, visible: true, - icons: ['headphones', 'distance-to-parent-025', 'distance-to-parent-050', 'distance-to-parent-100', 'distance-to-parent-150', 'distance-to-parent-200'], + icons: ['distance-to-parent-000', 'distance-to-parent-025', 'distance-to-parent-050', 'distance-to-parent-100', 'distance-to-parent-150', 'distance-to-parent-200'], rawRadius: 8, targetRadius: 0, currentRadius: 0, diff --git a/Panels/LayersPanel.js b/Panels/LayersPanel.js index 6e8226a1c..98684a18e 100644 --- a/Panels/LayersPanel.js +++ b/Panels/LayersPanel.js @@ -299,7 +299,7 @@ function newLayersPanel () { The overall idea here is that we need to keep syncronized the panel with the layers that are defined at the Designer. Users can connect or disconnect any objext resulting in changes in which are valid layers and which not at any point in time. So what we do here is trying to keep the panel - only with the layers that are connected to the Charting System hiriarcy. + only with the layers that are connected to the Charting Space hiriarcy. To achieve this, first we are going to move all session related cards to a local array. Then we are going to check for layers at the designer, and will move back the cards which still have layers well diff --git a/README.md b/README.md index 82b465066..1c81a53d9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Welcome to the Canvas App -The Canvas App provides a visual environment for the _Charting System_ and the _Designer_. +The Canvas App provides a visual environment for the _Charting Space_ and the _Designer_. **Installation (for developers):** To install the Canvas App, you need to install AAWeb, following [this guide](https://github.com/Superalgos/AAWeb/blob/develop/README.md). diff --git a/Spaces/ChartSpace.js b/Spaces/ChartSpace.js index dced0c410..41394e27b 100644 --- a/Spaces/ChartSpace.js +++ b/Spaces/ChartSpace.js @@ -87,14 +87,14 @@ function newChartSpace () { let rootNodes = canvas.designerSpace.workspace.workspaceNode.rootNodes for (let i = 0; i < rootNodes.length; i++) { let rootNode = rootNodes[i] - if (rootNode.type === 'Charting System') { + if (rootNode.type === 'Charting Space') { thisObject.payload = rootNode.payload } } thisObject.viewport = newViewport() if (thisObject.payload.node.viewport === undefined) { - if (ERROR_LOG === true) { logger.write('[WARN] initialize -> There must exist a Viewport node attached to the Charting System node in order for the Viewport save its properties. ') } + if (ERROR_LOG === true) { logger.write('[WARN] initialize -> There must exist a Viewport node attached to the Charting Space node in order for the Viewport save its properties. ') } } else { thisObject.viewport.payload = thisObject.payload.node.viewport.payload } diff --git a/Spaces/DesignerSpace.js b/Spaces/DesignerSpace.js index 86045cb00..1618ab0b1 100644 --- a/Spaces/DesignerSpace.js +++ b/Spaces/DesignerSpace.js @@ -178,7 +178,7 @@ function newDesignerSpace () { 'crypto-exchanges', 'crypto-exchange', 'exchange-markets', - 'charting-system', + 'charting-space', 'time-line-chart', 'time-frame-scale', 'time-scale', @@ -227,6 +227,7 @@ function newDesignerSpace () { 'distance-to-parent-100', 'distance-to-parent-050', 'distance-to-parent-025', + 'distance-to-parent-000', 'angle-to-parent-360', 'angle-to-parent-180', 'angle-to-parent-090', diff --git a/Spaces/FloatingSpace.js b/Spaces/FloatingSpace.js index 6422a85f0..0737e8ed0 100644 --- a/Spaces/FloatingSpace.js +++ b/Spaces/FloatingSpace.js @@ -91,7 +91,7 @@ function newFloatingSpace () { payload.node.type === 'Trading System' || payload.node.type === 'Network' || payload.node.type === 'Crypto Ecosystem' || - payload.node.type === 'Charting System' || + payload.node.type === 'Charting Space' || payload.node.type === 'Data Mine' ) { return false From 2f4de2d4971bbab252178f76ebfb2957d39e252d Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 6 Feb 2020 09:27:55 +0100 Subject: [PATCH 249/264] Concept of current values removed --- ChartsSpace/TimeMachine.js | 14 ------------- .../FunctionLibraries/SessionFunctions.js | 20 +------------------ Scales/TimeFrameScale.js | 1 - 3 files changed, 1 insertion(+), 34 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 38ba6ac2b..02c872aed 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -384,7 +384,6 @@ function newTimeMachine () { function physics () { saveFrame(thisObject.payload, thisObject.container.frame) if (thisObject.container.frame.isInViewPort()) { - thisObjectPhysics() childrenPhysics() syncWithDesigner() } @@ -490,19 +489,6 @@ function newTimeMachine () { } } - function thisObjectPhysics () { - /* Screen Corner Date Calculation */ - - let point = { - x: 0, - y: 0 - } - - let cornerDate = getDateFromPoint(point, thisObject.container, timeMachineCoordinateSystem) - cornerDate = new Date(cornerDate) - window.localStorage.setItem('Date @ Screen Corner', cornerDate.toUTCString()) - } - function childrenPhysics () { if (thisObject.timeScale !== undefined) { thisObject.timeScale.physics() diff --git a/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js b/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js index 5892c001a..fe40011be 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js +++ b/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js @@ -58,28 +58,10 @@ function newSessionFunctions () { /* Raise event to run the session */ let event = { session: JSON.stringify(session), - tradingSystem: JSON.stringify(tradingSystem), - uiCurrentValues: getUICurrentValues() + tradingSystem: JSON.stringify(tradingSystem) } systemEventHandler.raiseEvent(key, 'Run Session', event) - - function getUICurrentValues () { - let dateAtScreenCorner = new Date(window.localStorage.getItem('Date @ Screen Corner')) - let currentTimeFrame = JSON.parse(window.localStorage.getItem('Current Time Frame')) - - let timeFramesMasterArray = [marketFilesPeriods, dailyFilePeriods] - let timeFrameArray = timeFramesMasterArray[currentTimeFrame.filePeriodIndex] - let timeFrame = timeFrameArray[currentTimeFrame.timeFrameIndex][1] - - let uiCurrentValues = { - initialDatetime: dateAtScreenCorner, - timeFrame: timeFrame, - timestamp: (new Date()).valueOf() - } - - return uiCurrentValues - } } function stopSession (node, functionLibraryProtocolNode, callBackFunction) { diff --git a/Scales/TimeFrameScale.js b/Scales/TimeFrameScale.js index 444a2c6e5..0f684274f 100644 --- a/Scales/TimeFrameScale.js +++ b/Scales/TimeFrameScale.js @@ -299,7 +299,6 @@ function newTimeFrameScale () { let event = {} event.timeFrame = thisObject.timeFrame thisObject.container.eventHandler.raiseEvent('Time Frame Value Changed', event) - window.localStorage.setItem('Current Time Frame', JSON.stringify({filePeriodIndex: filePeriodIndex, timeFrameIndex: timeFrameIndex})) } function draw () { From 501b7f0f542e2b6088d7cdba0475c91c7a1007d6 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 6 Feb 2020 10:12:33 +0100 Subject: [PATCH 250/264] no chart system node handling --- Spaces/ChartSpace.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Spaces/ChartSpace.js b/Spaces/ChartSpace.js index 41394e27b..3bb31a98e 100644 --- a/Spaces/ChartSpace.js +++ b/Spaces/ChartSpace.js @@ -92,9 +92,15 @@ function newChartSpace () { } } + if (thisObject.payload === undefined) { + if (ERROR_LOG === true) { logger.write('[WARN] initialize -> There must exist a Charting Space at the Designer Space in order to enable Charts. PLease create one and refreash your browser. ') } + return + } + thisObject.viewport = newViewport() if (thisObject.payload.node.viewport === undefined) { if (ERROR_LOG === true) { logger.write('[WARN] initialize -> There must exist a Viewport node attached to the Charting Space node in order for the Viewport save its properties. ') } + return } else { thisObject.viewport.payload = thisObject.payload.node.viewport.payload } From dd90ad174b49bf74ba04fa11a0efef138581cf90 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 6 Feb 2020 13:38:08 +0100 Subject: [PATCH 251/264] bug fixed --- Spaces/ChartSpace.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Spaces/ChartSpace.js b/Spaces/ChartSpace.js index 3bb31a98e..d5cc45486 100644 --- a/Spaces/ChartSpace.js +++ b/Spaces/ChartSpace.js @@ -254,6 +254,7 @@ function newChartSpace () { } function syncWithDesigner () { + if (thisObject.payload === undefined) { return } if (thisObject.payload.node === undefined) { return } syncWithDesignerLoop = syncWithDesignerLoop + 0.00000000001 From 3aa774fdc91f7382b8ffb5d4ffd7b19a5b12743b Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 6 Feb 2020 16:44:17 +0100 Subject: [PATCH 252/264] less time to see status --- FloatingSpace/CircularMenuItem.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/FloatingSpace/CircularMenuItem.js b/FloatingSpace/CircularMenuItem.js index d088385e6..4a66f3679 100644 --- a/FloatingSpace/CircularMenuItem.js +++ b/FloatingSpace/CircularMenuItem.js @@ -320,7 +320,7 @@ function newCircularMenuItem () { } } else { if (thisObject.workFailedLabel != undefined) { - setStatus(thisObject.workFailedLabel, UI_COLOR.TITANIUM_YELLOW, 500, STATUS_PRIMARY_WORK_FAILED) + setStatus(thisObject.workFailedLabel, UI_COLOR.TITANIUM_YELLOW, 250, STATUS_PRIMARY_WORK_FAILED) } } } else { @@ -331,7 +331,7 @@ function newCircularMenuItem () { } } else { if (thisObject.workFailedLabel != undefined) { - setStatus(thisObject.workFailedLabel, UI_COLOR.TITANIUM_YELLOW, 500, STATUS_PRIMARY_WORK_FAILED) + setStatus(thisObject.workFailedLabel, UI_COLOR.TITANIUM_YELLOW, 250, STATUS_PRIMARY_WORK_FAILED) } } } @@ -343,7 +343,7 @@ function newCircularMenuItem () { } } else { if (thisObject.secondaryWorkFailedLabel != undefined) { - setStatus(thisObject.secondaryWorkFailedLabel, UI_COLOR.TITANIUM_YELLOW, 500, STATUS_SECONDARY_WORK_FAILED) + setStatus(thisObject.secondaryWorkFailedLabel, UI_COLOR.TITANIUM_YELLOW, 250, STATUS_SECONDARY_WORK_FAILED) } } } From 831d9293bd65f45d1f598f0c141d3c9a476d70dc Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 7 Feb 2020 11:32:20 +0100 Subject: [PATCH 253/264] Missing nodes --- DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js b/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js index fe40011be..460b6227b 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js +++ b/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js @@ -34,6 +34,7 @@ function newSessionFunctions () { 'Trading System->' + 'Parameters->' + 'Base Asset->Time Range->Time Frame->Slippage->Fee Structure->' + + 'Exchange Account Asset->Asset->' + 'Strategy->' + 'Trigger Stage->Trigger On Event->Trigger Off Event->Take Position Event->' + 'Announcement->Telegram Bot->' + @@ -51,7 +52,8 @@ function newSessionFunctions () { lightingPath = '' + 'Backtesting Session->Paper Trading Session->Fordward Testing Session->Live Trading Session->' + 'Parameters->' + - 'Base Asset->Time Range->Time Frame->Slippage->Fee Structure->' + 'Base Asset->Time Range->Time Frame->Slippage->Fee Structure->' + + 'Exchange Account Asset->Asset->' let session = functionLibraryProtocolNode.getProtocolNode(node, false, true, true, false, false, lightingPath) From 99d6177cccdd0eed7799864f62104add31e74b3e Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 7 Feb 2020 12:50:26 +0100 Subject: [PATCH 254/264] helps debugging --- .../Workspace/FunctionLibraries/SessionFunctions.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js b/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js index 460b6227b..3423ced72 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js +++ b/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js @@ -64,6 +64,11 @@ function newSessionFunctions () { } systemEventHandler.raiseEvent(key, 'Run Session', event) + + if (node.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode === undefined) { + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) + return + } } function stopSession (node, functionLibraryProtocolNode, callBackFunction) { From f20bd3b4d977dcc5421f1c555a345820599cc079 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 7 Feb 2020 13:33:03 +0100 Subject: [PATCH 255/264] bug fixed --- DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js b/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js index 3423ced72..5b967b29d 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js +++ b/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js @@ -45,7 +45,8 @@ function newSessionFunctions () { 'Stop->Take Profit->' + 'Phase->Formula->Next Phase Event->' + 'Situation->Condition->Javascript Code->' + - 'Announcement->Telegram Bot->' + 'Announcement->Telegram Bot->' + + 'Close Stage->Close Execution->' let tradingSystem = functionLibraryProtocolNode.getProtocolNode(node.payload.referenceParent, false, true, true, false, false, lightingPath) From ffc24c749f57294c0035b24efafc01523c41b52e Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 7 Feb 2020 16:26:47 +0100 Subject: [PATCH 256/264] new icons --- Spaces/DesignerSpace.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Spaces/DesignerSpace.js b/Spaces/DesignerSpace.js index 1618ab0b1..bbf20057f 100644 --- a/Spaces/DesignerSpace.js +++ b/Spaces/DesignerSpace.js @@ -232,7 +232,13 @@ function newDesignerSpace () { 'angle-to-parent-180', 'angle-to-parent-090', 'angle-to-parent-045', - 'angle-to-parent-000' + 'angle-to-parent-000', + 'data-mining', + 'initial-definition', + 'next-phase-event', + 'testing-environment', + 'production-environment', + 'task-manager' ] for (let i = 0; i < iconsNames.length; i++) { From febf48333e1a9cb35bfebb6a0e8c43e836dcdac7 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 7 Feb 2020 16:44:26 +0100 Subject: [PATCH 257/264] position corrected --- CockpitSpace/AssetBalances.js | 6 ++---- CockpitSpace/Speedometer.js | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/CockpitSpace/AssetBalances.js b/CockpitSpace/AssetBalances.js index d9fa9ff85..6cb267ef4 100644 --- a/CockpitSpace/AssetBalances.js +++ b/CockpitSpace/AssetBalances.js @@ -37,9 +37,6 @@ function newQuotedAssetalances () { for (let i = 0; i < 2; i++) { let speedometer = newSpeedometer() - speedometer.container.frame.position.x = thisObject.container.frame.width / 2 - speedometer.container.frame.width / 2 - speedometer.container.frame.position.y = thisObject.container.frame.height / 2 - speedometer.container.frame.height / 2 - speedometer.initialize() thisObject.speedometers.push(speedometer) } @@ -109,7 +106,7 @@ function newQuotedAssetalances () { label = 'ASSET BALANCES' xOffset = label.length / 2 * fontSize * FONT_ASPECT_RATIO - yOffset = -45 + yOffset = -45 + 9 labelPoint = { x: 0 - xOffset + (thisObject.paramsArray[1].LEFT_OFFSET - thisObject.paramsArray[0].LEFT_OFFSET) / 2 + thisObject.paramsArray[0].LEFT_OFFSET - 20, @@ -120,3 +117,4 @@ function newQuotedAssetalances () { browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y) } } + diff --git a/CockpitSpace/Speedometer.js b/CockpitSpace/Speedometer.js index 93178ab38..7a2f0a857 100644 --- a/CockpitSpace/Speedometer.js +++ b/CockpitSpace/Speedometer.js @@ -51,13 +51,13 @@ function newSpeedometer () { } function drawAssetCircle () { - const RED_LINE_HIGHT = 5 + const RED_LINE_HIGHT = 2 const RADIUS = 50 const OPACITY = 1 let centerPoint = { x: thisObject.params.LEFT_OFFSET, - y: COCKPIT_SPACE_POSITION - COCKPIT_SPACE_HEIGHT / 2 + y: COCKPIT_SPACE_POSITION - COCKPIT_SPACE_HEIGHT / 2 - 9 } browserCanvasContext.beginPath() From 9a1ee54857aefd200220dd7b94aee6702a19587d Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 8 Feb 2020 11:09:37 +0100 Subject: [PATCH 258/264] improvement when reference attaching --- FloatingSpace/UiObject.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index d33a094cb..daa0022bf 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -1321,7 +1321,7 @@ function newUiObject () { browserCanvasContext.beginPath() browserCanvasContext.arc(visiblePosition.x, visiblePosition.y, VISIBLE_RADIUS, 0, Math.PI * 2, true) browserCanvasContext.closePath() - browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.LIGHT_GREY + ', ' + OPACITY + ')' + browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.GOLDEN_ORANGE + ', ' + OPACITY + ')' browserCanvasContext.lineWidth = 10 browserCanvasContext.setLineDash([10, 90]) browserCanvasContext.stroke() @@ -1329,7 +1329,7 @@ function newUiObject () { browserCanvasContext.beginPath() browserCanvasContext.arc(visiblePosition.x, visiblePosition.y, VISIBLE_RADIUS, 0, Math.PI * 2, true) browserCanvasContext.closePath() - browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.LIGHT_GREY + ', ' + OPACITY + ')' + browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.GOLDEN_ORANGE + ', ' + OPACITY + ')' browserCanvasContext.lineWidth = 5 browserCanvasContext.setLineDash([5, 45]) browserCanvasContext.stroke() @@ -1337,7 +1337,7 @@ function newUiObject () { browserCanvasContext.beginPath() browserCanvasContext.arc(visiblePosition.x, visiblePosition.y, VISIBLE_RADIUS, 0, Math.PI * 2, true) browserCanvasContext.closePath() - browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.LIGHT_GREY + ', ' + OPACITY + ')' + browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.GOLDEN_ORANGE + ', ' + OPACITY + ')' browserCanvasContext.lineWidth = 1 browserCanvasContext.setLineDash([2, 8]) browserCanvasContext.stroke() @@ -1370,7 +1370,7 @@ function newUiObject () { if (icon !== undefined) { if (icon.canDrawIcon === true) { let additionalImageSize = 0 - if (thisObject.isExecuting === true) { additionalImageSize = 20 } + if (thisObject.isExecuting === true || isReadyToReferenceAttach === true || isReadyToChainAttach === true) { additionalImageSize = 20 } let totalImageSize = additionalImageSize + thisObject.payload.floatingObject.currentImageSize browserCanvasContext.drawImage( From 59620fac4089eb78b244ccd3617ca33e7b3cdccb Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 8 Feb 2020 12:35:29 +0100 Subject: [PATCH 259/264] fix --- FloatingSpace/FloatingObject.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FloatingSpace/FloatingObject.js b/FloatingSpace/FloatingObject.js index b84f43764..bc83446dd 100644 --- a/FloatingSpace/FloatingObject.js +++ b/FloatingSpace/FloatingObject.js @@ -330,7 +330,7 @@ function newFloatingObject () { thisObject.payload.distance = distanceToParent - if (distanceToParent > 2000) { return } // this is introduced to avoid edges cases when importing workspaces. + if (distanceToParent > 2000 || thisObject.isPinned === true) { return } // this is introduced to avoid edges cases when importing workspaces. newPosition = { x: parent.payload.position.x + distanceToParent * Math.cos(toRadians(thisObject.payload.angle)), From 40310dec5cf4213b5d833a1b1ce78b956c3564d7 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 8 Feb 2020 15:52:44 +0100 Subject: [PATCH 260/264] new icons --- Spaces/DesignerSpace.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Spaces/DesignerSpace.js b/Spaces/DesignerSpace.js index bbf20057f..add5dd2f2 100644 --- a/Spaces/DesignerSpace.js +++ b/Spaces/DesignerSpace.js @@ -238,7 +238,10 @@ function newDesignerSpace () { 'next-phase-event', 'testing-environment', 'production-environment', - 'task-manager' + 'task-manager', + 'session-based-data', + 'session-independent-data', + 'session-reference' ] for (let i = 0; i < iconsNames.length; i++) { From 313c678a5f8debe01370de22526df19c1fa4182f Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 8 Feb 2020 20:44:06 +0100 Subject: [PATCH 261/264] Bug fixed --- FloatingSpace/CircularProgressBar.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FloatingSpace/CircularProgressBar.js b/FloatingSpace/CircularProgressBar.js index c07977aef..0e59f3cf5 100644 --- a/FloatingSpace/CircularProgressBar.js +++ b/FloatingSpace/CircularProgressBar.js @@ -78,11 +78,11 @@ function newCircularProgressBar () { } } - function drawBackground (pFloatingObject) { + function drawForeground (pFloatingObject) { } - function drawForeground (pFloatingObject) { + function drawBackground (pFloatingObject) { const VISIBLE_RADIUS = thisObject.container.frame.radius * 2 let visiblePosition = { From 82569df89b6fd93be4ea1edff44e3d418ff8bf1f Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 8 Feb 2020 20:59:39 +0100 Subject: [PATCH 262/264] Bug Fixed --- FloatingSpace/UiObject.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index daa0022bf..d4cd7c42e 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -868,10 +868,12 @@ function newUiObject () { if (thisObject.payload.chainParent === undefined) { return } let targetPoint = { - x: thisObject.payload.targetPosition.x, - y: thisObject.payload.targetPosition.y + x: thisObject.payload.chainParent.payload.floatingObject.container.frame.position.x, + y: thisObject.payload.chainParent.payload.floatingObject.container.frame.position.y } + targetPoint = thisObject.container.frame.frameThisPoint(targetPoint) + let position = { x: 0, y: 0 @@ -881,8 +883,6 @@ function newUiObject () { position = thisObject.container.frame.frameThisPoint(position) if (thisObject.container.frame.radius > 1) { - /* Target Line */ - let LINE_STYLE = UI_COLOR.TITANIUM_YELLOW if (thisObject.payload.floatingObject.angleToParent !== ANGLE_TO_PARENT.NOT_FIXED) { LINE_STYLE = UI_COLOR.GOLDEN_ORANGE @@ -911,8 +911,6 @@ function newUiObject () { } if (thisObject.container.frame.radius > 0.5) { - /* Target Spot */ - let radius = 1 browserCanvasContext.beginPath() @@ -945,8 +943,6 @@ function newUiObject () { let LINE_STYLE = UI_COLOR.GREY if (thisObject.container.frame.radius > 1) { - /* Target Line */ - browserCanvasContext.beginPath() browserCanvasContext.moveTo(position.x, position.y) browserCanvasContext.lineTo(targetPoint.x, targetPoint.y) @@ -967,8 +963,6 @@ function newUiObject () { } if (thisObject.container.frame.radius > 0.5) { - /* Target Spot */ - let radius = 1 browserCanvasContext.beginPath() From 65e0c0344d9e7cd2297d8597b8d24238a164f825 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 8 Feb 2020 21:05:04 +0100 Subject: [PATCH 263/264] Cleaning --- FloatingSpace/FloatingLayer.js | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/FloatingSpace/FloatingLayer.js b/FloatingSpace/FloatingLayer.js index 993581c8b..621404fbb 100644 --- a/FloatingSpace/FloatingLayer.js +++ b/FloatingSpace/FloatingLayer.js @@ -288,18 +288,6 @@ function newFloatingLayer () { } switch (floatingObject.type) { - - case 'Profile Ball': { - payload.targetPosition = floatingObject.payload.profile.position - payload.visible = floatingObject.payload.profile.visible - break - } - case 'Note': { - payload.targetPosition = floatingObject.payload.notes[floatingObject.payloadNoteIndex].position - payload.visible = floatingObject.payload.notes[floatingObject.payloadNoteIndex].visible - - break - } case 'UI Object': { payload.targetPosition = floatingObject.payload.targetPosition payload.visible = floatingObject.payload.visible @@ -559,15 +547,6 @@ function newFloatingLayer () { } switch (floatingObject2.type) { - - case 'Profile Ball': { - payload.targetPosition = floatingObject2.payload.profile.position - break - } - case 'Note': { - payload.targetPosition = floatingObject2.payload.notes[floatingObject2.payloadNoteIndex].position - break - } case 'UI Object': { payload.targetPosition = floatingObject2.payload.targetPosition break From 579bf9c968223f7612c306d539214c9615462cc1 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 8 Feb 2020 21:13:29 +0100 Subject: [PATCH 264/264] Bug Fix --- FloatingSpace/UiObject.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index d4cd7c42e..77996ee22 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -872,8 +872,6 @@ function newUiObject () { y: thisObject.payload.chainParent.payload.floatingObject.container.frame.position.y } - targetPoint = thisObject.container.frame.frameThisPoint(targetPoint) - let position = { x: 0, y: 0