21 files changed
+407
-169
No files matched your search
@@ -131,7 +131,7 @@ function newCanvas () {
|
||||
|
||||
thisObject.animation = animation
|
||||
/* Low Level Infraestructure First */
|
||||
animation.addCallBackFunction('System Event Handler Physics', systemEventHandler.physics)
|
||||
animation.addCallBackFunction('System Event Handler Physics', eventsServerClient.physics)
|
||||
|
||||
/* Spcaces Physics */
|
||||
animation.addCallBackFunction('CockpitSpace Physics', thisObject.cockpitSpace.physics)
|
||||
@@ -353,41 +353,49 @@ function newCanvas () {
|
||||
|
||||
if (event.shiftKey === true && (event.ctrlKey === true || event.metaKey === true) && event.code === 'ArrowUp') {
|
||||
thisObject.cockpitSpace.toTop()
|
||||
event.preventDefault()
|
||||
return
|
||||
}
|
||||
|
||||
if (event.shiftKey === true && (event.ctrlKey === true || event.metaKey === true) && event.code === 'ArrowDown') {
|
||||
thisObject.cockpitSpace.toBottom()
|
||||
event.preventDefault()
|
||||
return
|
||||
}
|
||||
|
||||
if (event.shiftKey === true && (event.ctrlKey === true || event.metaKey === true) && event.code === 'ArrowLeft') {
|
||||
thisObject.cockpitSpace.moveUp()
|
||||
event.preventDefault()
|
||||
return
|
||||
}
|
||||
|
||||
if (event.shiftKey === true && (event.ctrlKey === true || event.metaKey === true) && event.code === 'ArrowRight') {
|
||||
thisObject.cockpitSpace.moveDown()
|
||||
event.preventDefault()
|
||||
return
|
||||
}
|
||||
|
||||
if (event.shiftKey === true && event.ctrlKey === false && event.code === 'ArrowLeft') {
|
||||
if (event.shiftKey === true && (event.ctrlKey === false && event.metaKey === false) && event.code === 'ArrowLeft') {
|
||||
canvas.chartingSpace.oneScreenLeft()
|
||||
event.preventDefault()
|
||||
return
|
||||
}
|
||||
|
||||
if (event.shiftKey === true && event.ctrlKey === false && event.code === 'ArrowRight') {
|
||||
if (event.shiftKey === true && (event.ctrlKey === false && event.metaKey === false) && event.code === 'ArrowRight') {
|
||||
canvas.chartingSpace.oneScreenRight()
|
||||
event.preventDefault()
|
||||
return
|
||||
}
|
||||
|
||||
if (event.shiftKey === true && event.code === 'ArrowUp') {
|
||||
if (event.shiftKey === true && (event.ctrlKey === false && event.metaKey === false) && event.code === 'ArrowUp') {
|
||||
canvas.chartingSpace.oneScreenUp()
|
||||
event.preventDefault()
|
||||
return
|
||||
}
|
||||
|
||||
if (event.shiftKey === true && event.code === 'ArrowDown') {
|
||||
if (event.shiftKey === true && (event.ctrlKey === false && event.metaKey === false) && event.code === 'ArrowDown') {
|
||||
canvas.chartingSpace.oneScreenDown()
|
||||
event.preventDefault()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -396,6 +404,7 @@ function newCanvas () {
|
||||
dragVector.downX = dragVector.downX + displaceVector.x
|
||||
dragVector.downY = dragVector.downY + displaceVector.y
|
||||
checkDrag()
|
||||
event.preventDefault()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -404,22 +413,25 @@ function newCanvas () {
|
||||
dragVector.downX = dragVector.downX + displaceVector.x
|
||||
dragVector.downY = dragVector.downY + displaceVector.y
|
||||
checkDrag()
|
||||
event.preventDefault()
|
||||
return
|
||||
}
|
||||
|
||||
if ((event.ctrlKey === true || event.metaKey === true) && event.code === 'ArrowUp') {
|
||||
if ((event.ctrlKey === true || event.metaKey === true) && event.shiftKey === false && event.code === 'ArrowUp') {
|
||||
let displaceVector = canvas.floatingSpace.oneScreenUp()
|
||||
dragVector.downX = dragVector.downX + displaceVector.x
|
||||
dragVector.downY = dragVector.downY + displaceVector.y
|
||||
checkDrag()
|
||||
event.preventDefault()
|
||||
return
|
||||
}
|
||||
|
||||
if ((event.ctrlKey === true || event.metaKey === true) && event.code === 'ArrowDown') {
|
||||
if ((event.ctrlKey === true || event.metaKey === true) && event.shiftKey === false && event.code === 'ArrowDown') {
|
||||
let displaceVector = canvas.floatingSpace.oneScreenDown()
|
||||
dragVector.downX = dragVector.downX + displaceVector.x
|
||||
dragVector.downY = dragVector.downY + displaceVector.y
|
||||
checkDrag()
|
||||
event.preventDefault()
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,10 @@ function newCoordinateSystem () {
|
||||
let thisObject = {
|
||||
min: undefined,
|
||||
max: undefined,
|
||||
parentMin: undefined,
|
||||
parentMax: undefined,
|
||||
childrenMin: undefined,
|
||||
childrenMax: undefined,
|
||||
maxHeight: undefined,
|
||||
maxWidth: undefined,
|
||||
scale: undefined,
|
||||
@@ -24,6 +28,8 @@ function newCoordinateSystem () {
|
||||
HORIZONTAL_MARGIN_INVERSE_FACTOR: 0.20,
|
||||
VERTICAL_MARGIN_INVERSE_FACTOR: 0.10,
|
||||
physics: physics,
|
||||
reportParentXValue: reportParentXValue,
|
||||
reportParentYValue: reportParentYValue,
|
||||
reportXValue: reportXValue,
|
||||
reportYValue: reportYValue,
|
||||
zoomX: zoomX,
|
||||
@@ -47,6 +53,23 @@ function newCoordinateSystem () {
|
||||
x: 0,
|
||||
y: 0
|
||||
}
|
||||
thisObject.parentMin = {
|
||||
x: 0,
|
||||
y: 0
|
||||
}
|
||||
thisObject.parentMax = {
|
||||
x: 0,
|
||||
y: 0
|
||||
}
|
||||
thisObject.childrenMin = {
|
||||
x: 0,
|
||||
y: 0
|
||||
}
|
||||
thisObject.childrenMax = {
|
||||
x: 0,
|
||||
y: 0
|
||||
}
|
||||
|
||||
thisObject.scale = {
|
||||
x: 0,
|
||||
y: 0
|
||||
@@ -57,11 +80,12 @@ function newCoordinateSystem () {
|
||||
|
||||
let newXMax = -VERY_LARGE_NUMBER
|
||||
let newXMin = VERY_LARGE_NUMBER
|
||||
let noXValueReported = true
|
||||
|
||||
let newYMax = -VERY_LARGE_NUMBER
|
||||
let newYMin = VERY_LARGE_NUMBER
|
||||
let noYValueReported = true
|
||||
|
||||
let parentMinChanged = false
|
||||
let parentMaxChanged = false
|
||||
|
||||
return thisObject
|
||||
|
||||
@@ -84,59 +108,140 @@ function newCoordinateSystem () {
|
||||
recalculateScale()
|
||||
}
|
||||
|
||||
function reportXValue (value) {
|
||||
if (thisObject.autoMinXScale === true) {
|
||||
if (value < newXMin && value !== 0) {
|
||||
newXMin = value
|
||||
}
|
||||
}
|
||||
if (thisObject.autoMaxXScale === true) {
|
||||
if (value > newXMax && value !== 0) {
|
||||
newXMax = value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function reportYValue (value) {
|
||||
if (thisObject.autoMinYScale === true) {
|
||||
if (value < newYMin) {
|
||||
newYMin = value
|
||||
}
|
||||
}
|
||||
if (thisObject.autoMaxYScale === true) {
|
||||
if (value > newYMax) {
|
||||
newYMax = value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function reportParentXValue (min, max) {
|
||||
if (thisObject.autoMinXScale === true) {
|
||||
if (thisObject.parentMin.x !== min) {
|
||||
thisObject.parentMin.x = min
|
||||
}
|
||||
}
|
||||
if (thisObject.autoMaxXScale === true) {
|
||||
if (thisObject.parentMax.x !== max) {
|
||||
thisObject.parentMax.x = max
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function reportParentYValue (min, max) {
|
||||
if (thisObject.autoMinYScale === true) {
|
||||
if (thisObject.parentMin.y !== min) {
|
||||
thisObject.parentMin.y = min
|
||||
}
|
||||
}
|
||||
if (thisObject.autoMaxYScale === true) {
|
||||
if (thisObject.parentMax.y !== max) {
|
||||
thisObject.parentMax.y = max
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function physics () {
|
||||
let mustRecalculate = false
|
||||
|
||||
if ((thisObject.autoMinXScale === true || thisObject.autoMaxXScale === true) && noXValueReported === false) {
|
||||
if (thisObject.autoMaxXScale === true && thisObject.max.x !== newXMax) {
|
||||
thisObject.max.x = newXMax
|
||||
mustRecalculate = true
|
||||
if ((thisObject.autoMinXScale === true || thisObject.autoMaxXScale === true)) {
|
||||
if (thisObject.autoMaxXScale === true && thisObject.childrenMax.x !== newXMax && newXMax !== -VERY_LARGE_NUMBER) {
|
||||
thisObject.childrenMax.x = newXMax
|
||||
}
|
||||
|
||||
if (thisObject.autoMaxXScale === true) {
|
||||
newXMax = -VERY_LARGE_NUMBER
|
||||
}
|
||||
|
||||
if (thisObject.autoMinXScale === true && thisObject.min.x !== newXMin) {
|
||||
thisObject.min.x = newXMin
|
||||
if (thisObject.autoMinXScale === true && thisObject.childrenMin.x !== newXMin && newXMin !== VERY_LARGE_NUMBER) {
|
||||
thisObject.childrenMin.x = newXMin
|
||||
newXMin = VERY_LARGE_NUMBER
|
||||
mustRecalculate = true
|
||||
}
|
||||
|
||||
if (thisObject.autoMinXScale === true) {
|
||||
newXMin = VERY_LARGE_NUMBER
|
||||
}
|
||||
|
||||
/* Reseting this to start over at each cycle. */
|
||||
noXValueReported = true
|
||||
|
||||
if (mustRecalculate === true) {
|
||||
thisObject.eventHandler.raiseEvent('X-Range Changed')
|
||||
}
|
||||
}
|
||||
|
||||
if ((thisObject.autoMinYScale === true || thisObject.autoMaxYScale === true) && noYValueReported === false) {
|
||||
if (thisObject.autoMaxYScale === true && thisObject.max.y !== newYMax) {
|
||||
thisObject.max.y = newYMax
|
||||
mustRecalculate = true
|
||||
if ((thisObject.autoMinYScale === true || thisObject.autoMaxYScale === true)) {
|
||||
if (thisObject.autoMaxYScale === true && thisObject.childrenMax.y !== newYMax && newYMax !== -VERY_LARGE_NUMBER) {
|
||||
thisObject.childrenMax.y = newYMax
|
||||
}
|
||||
|
||||
if (thisObject.autoMaxYScale === true) {
|
||||
newYMax = -VERY_LARGE_NUMBER
|
||||
}
|
||||
|
||||
if (thisObject.autoMinYScale === true && thisObject.min.y !== newYMin) {
|
||||
thisObject.min.y = newYMin
|
||||
if (thisObject.autoMinYScale === true && thisObject.childrenMin.y !== newYMin && newYMin !== VERY_LARGE_NUMBER) {
|
||||
thisObject.childrenMin.y = newYMin
|
||||
newYMin = VERY_LARGE_NUMBER
|
||||
mustRecalculate = true
|
||||
}
|
||||
|
||||
if (thisObject.autoMinYScale === true) {
|
||||
newYMin = VERY_LARGE_NUMBER
|
||||
}
|
||||
}
|
||||
|
||||
/* Reseting this to start over at each cycle. */
|
||||
noYValueReported = true
|
||||
/* Here we will see if any of the children or parent values modify the current status quo */
|
||||
/* Min */
|
||||
let minX = Math.min(thisObject.childrenMin.x, thisObject.parentMin.x)
|
||||
let minY = Math.min(thisObject.childrenMin.y, thisObject.parentMin.y)
|
||||
let maxX = Math.max(thisObject.childrenMax.x, thisObject.parentMax.x)
|
||||
let maxY = Math.max(thisObject.childrenMax.y, thisObject.parentMax.y)
|
||||
|
||||
if (thisObject.parentMin.x === 0) {
|
||||
minX = thisObject.childrenMin.x
|
||||
}
|
||||
|
||||
if (thisObject.parentMin.y === 0) {
|
||||
minY = thisObject.childrenMin.y
|
||||
}
|
||||
|
||||
if (thisObject.parentMax.x === 0) {
|
||||
maxX = thisObject.childrenMax.x
|
||||
}
|
||||
|
||||
if (thisObject.parentMax.y === 0) {
|
||||
maxY = thisObject.childrenMax.y
|
||||
}
|
||||
|
||||
if (minX !== 0 && thisObject.min.x !== minX && thisObject.autoMinXScale === true) {
|
||||
thisObject.min.x = minX
|
||||
mustRecalculate = true
|
||||
}
|
||||
|
||||
if (minY !== 0 && thisObject.min.y !== minY && thisObject.autoMinYScale === true) {
|
||||
thisObject.min.y = minY
|
||||
mustRecalculate = true
|
||||
}
|
||||
|
||||
if (maxX !== 0 && thisObject.max.x !== maxX && thisObject.autoMaxXScale === true) {
|
||||
thisObject.max.x = maxX
|
||||
mustRecalculate = true
|
||||
}
|
||||
|
||||
if (maxY !== 0 && thisObject.max.y !== maxY && thisObject.autoMaxYScale === true) {
|
||||
thisObject.max.y = maxY
|
||||
mustRecalculate = true
|
||||
}
|
||||
|
||||
if (mustRecalculate === true) {
|
||||
@@ -144,26 +249,11 @@ function newCoordinateSystem () {
|
||||
}
|
||||
}
|
||||
|
||||
function reportXValue (value) {
|
||||
if (thisObject.autoMinXScale === true) {
|
||||
if (value < newXMin) { newXMin = value }
|
||||
noXValueReported = false
|
||||
}
|
||||
if (thisObject.autoMaxXScale === true) {
|
||||
if (value > newXMax) { newXMax = value }
|
||||
noXValueReported = false
|
||||
}
|
||||
}
|
||||
function recalculateScale (event) {
|
||||
thisObject.scale.x = thisObject.maxWidth * thisObject.HORIZONTAL_MARGIN_FACTOR / (thisObject.max.x - thisObject.min.x)
|
||||
thisObject.scale.y = thisObject.maxHeight * thisObject.VERTICAL_MARGIN_FACTOR / (thisObject.max.y - thisObject.min.y)
|
||||
|
||||
function reportYValue (value) {
|
||||
if (thisObject.autoMinYScale === true) {
|
||||
if (value < newYMin) { newYMin = value }
|
||||
noYValueReported = false
|
||||
}
|
||||
if (thisObject.autoMaxYScale === true) {
|
||||
if (value > newYMax) { newYMax = value }
|
||||
noYValueReported = false
|
||||
}
|
||||
thisObject.eventHandler.raiseEvent('Scale Changed', event)
|
||||
}
|
||||
|
||||
function zoomX (factor, mousePosition, container) {
|
||||
@@ -175,9 +265,18 @@ function newCoordinateSystem () {
|
||||
let max = thisObject.max.x - diff * factor * rightDistance / (container.frame.width / 2)
|
||||
|
||||
if (min < max) {
|
||||
thisObject.min.x = min
|
||||
thisObject.max.x = max
|
||||
thisObject.recalculateScale()
|
||||
let mustRecalculate = false
|
||||
if (thisObject.autoMinXScale === false) {
|
||||
thisObject.min.x = min
|
||||
mustRecalculate = true
|
||||
}
|
||||
if (thisObject.autoMaxXScale === false) {
|
||||
thisObject.max.x = max
|
||||
mustRecalculate = true
|
||||
}
|
||||
if (mustRecalculate === true) {
|
||||
thisObject.recalculateScale()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,19 +289,21 @@ function newCoordinateSystem () {
|
||||
let max = thisObject.max.y - diff * factor * topDistance / (container.frame.height / 2)
|
||||
|
||||
if (min < max) {
|
||||
thisObject.min.y = min
|
||||
thisObject.max.y = max
|
||||
thisObject.recalculateScale()
|
||||
let mustRecalculate = false
|
||||
if (thisObject.autoMinYScale === false) {
|
||||
thisObject.min.y = min
|
||||
mustRecalculate = true
|
||||
}
|
||||
if (thisObject.autoMaxYScale === false) {
|
||||
thisObject.max.y = max
|
||||
mustRecalculate = true
|
||||
}
|
||||
if (mustRecalculate === true) {
|
||||
thisObject.recalculateScale()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function recalculateScale (event) {
|
||||
thisObject.scale.x = thisObject.maxWidth * thisObject.HORIZONTAL_MARGIN_FACTOR / (thisObject.max.x - thisObject.min.x)
|
||||
thisObject.scale.y = thisObject.maxHeight * thisObject.VERTICAL_MARGIN_FACTOR / (thisObject.max.y - thisObject.min.y)
|
||||
|
||||
thisObject.eventHandler.raiseEvent('Scale Changed', event)
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
@@ -130,11 +130,13 @@ function newEdgeEditor () {
|
||||
}
|
||||
|
||||
function onDragStarted (event) {
|
||||
if (doubleClickCounter > 0) {
|
||||
onDoubleClick(event)
|
||||
return
|
||||
} else {
|
||||
doubleClickCounter = 50
|
||||
if (event.buttons === 1) {
|
||||
if (doubleClickCounter > 0) {
|
||||
onDoubleClick(event)
|
||||
return
|
||||
} else {
|
||||
doubleClickCounter = 50
|
||||
}
|
||||
}
|
||||
|
||||
mouseWhenDragStarted = {
|
||||
|
||||
@@ -80,7 +80,7 @@ function newPlottersManager () {
|
||||
}
|
||||
|
||||
function initialize (pLayersPanel) {
|
||||
/* Remember the Layers Panel */
|
||||
/* Remember this */
|
||||
layersPanel = pLayersPanel
|
||||
|
||||
/* Listen to the event of change of status */
|
||||
@@ -244,7 +244,7 @@ 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. */
|
||||
/* If the plotter of this card is not on our Active Plotters list, then we remove it. */
|
||||
for (let i = 0; i < thisObject.connectors.length; i++) {
|
||||
let connector = thisObject.connectors[i]
|
||||
if (connector.layer.payload.node.id === layer.payload.node.id) {
|
||||
|
||||
@@ -36,6 +36,7 @@ function newTimeMachine () {
|
||||
}
|
||||
|
||||
let timeMachineCoordinateSystem = newCoordinateSystem()
|
||||
timeMachineCoordinateSystem.name = 'TIME MACHINE'
|
||||
|
||||
let mouse = {
|
||||
position: {
|
||||
|
||||
@@ -31,6 +31,8 @@ function newTimelineChart () {
|
||||
|
||||
let timeMachineCoordinateSystem
|
||||
let timelineChartCoordinateSystem = newCoordinateSystem()
|
||||
timelineChartCoordinateSystem.name = 'TIMELINE CHART'
|
||||
|
||||
let coordinateSystem
|
||||
|
||||
let layersPanel
|
||||
@@ -43,7 +45,6 @@ function newTimelineChart () {
|
||||
let timeFrameScaleEventSuscriptionId
|
||||
let timeFrameScaleMouseOverEventSuscriptionId
|
||||
let scaleChangedEventSubscriptionId
|
||||
let xRangeChangedEventSubscriptionId
|
||||
|
||||
let drawScales = false
|
||||
let mouse = {
|
||||
@@ -63,8 +64,7 @@ function newTimelineChart () {
|
||||
}
|
||||
|
||||
function finalize () {
|
||||
coordinateSystem.eventHandler.stopListening(scaleChangedEventSubscriptionId)
|
||||
timelineChartCoordinateSystem.eventHandler.stopListening(xRangeChangedEventSubscriptionId)
|
||||
timeMachineCoordinateSystem.eventHandler.stopListening(scaleChangedEventSubscriptionId)
|
||||
|
||||
if (thisObject.layersManager !== undefined) {
|
||||
finalizeLayersManager()
|
||||
@@ -147,7 +147,6 @@ function newTimelineChart () {
|
||||
onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver)
|
||||
onMouseNotOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver)
|
||||
scaleChangedEventSubscriptionId = timeMachineCoordinateSystem.eventHandler.listenToEvent('Scale Changed', onScaleChanged)
|
||||
xRangeChangedEventSubscriptionId = timelineChartCoordinateSystem.eventHandler.listenToEvent('X-Range Changed', xRangeChanged)
|
||||
}
|
||||
|
||||
function initializeCoordinateSystem () {
|
||||
@@ -234,15 +233,6 @@ function newTimelineChart () {
|
||||
}
|
||||
}
|
||||
|
||||
function xRangeChanged (event) {
|
||||
if (thisObject.rateScale !== undefined) {
|
||||
/* We need to re trasmit the changes on the x Range of the timelinechart coordinate system to the time machine coordinate system so that its scale is syncronized. */
|
||||
timeMachineCoordinateSystem.min.x = timelineChartCoordinateSystem.min.x
|
||||
timeMachineCoordinateSystem.max.x = timelineChartCoordinateSystem.max.x
|
||||
timeMachineCoordinateSystem.recalculateScale()
|
||||
}
|
||||
}
|
||||
|
||||
function onScaleChanged (event) {
|
||||
if (thisObject.rateScale !== undefined) {
|
||||
thisObject.rateScale.onUpstreamScaleChanged(event)
|
||||
@@ -330,9 +320,14 @@ function newTimelineChart () {
|
||||
}
|
||||
|
||||
function thisObjectPhysics () {
|
||||
timelineChartCoordinateSystem.reportXValue(timeMachineCoordinateSystem.min.x)
|
||||
timelineChartCoordinateSystem.reportXValue(timeMachineCoordinateSystem.max.x)
|
||||
timelineChartCoordinateSystem.physics()
|
||||
/* Only if the plotter manager has some layer turned on, we will pass the min and max upstream. */
|
||||
if (thisObject.plotterManager !== undefined && thisObject.plotterManager.connectors.length > 0) {
|
||||
timelineChartCoordinateSystem.reportParentXValue(timeMachineCoordinateSystem.min.x, timeMachineCoordinateSystem.max.x)
|
||||
timelineChartCoordinateSystem.physics()
|
||||
|
||||
timeMachineCoordinateSystem.reportXValue(timelineChartCoordinateSystem.childrenMin.x)
|
||||
timeMachineCoordinateSystem.reportXValue(timelineChartCoordinateSystem.childrenMax.x)
|
||||
}
|
||||
}
|
||||
|
||||
function syncWithDesignerLayersManager () {
|
||||
|
||||
@@ -92,12 +92,12 @@ function newCCXTFunctions () {
|
||||
|
||||
if (queryParams !== undefined) {
|
||||
if (queryParams.baseAsset !== undefined) {
|
||||
if (market.base.indexOf(queryParams.baseAsset) >= 0) {
|
||||
if (market.base.indexOf(queryParams.baseAsset) < 0) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
if (queryParams.quotedAsset !== undefined) {
|
||||
if (market.quote.indexOf(queryParams.quotedAsset) >= 0) {
|
||||
if (market.quote.indexOf(queryParams.quotedAsset) < 0) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
@@ -115,9 +115,6 @@ function newCCXTFunctions () {
|
||||
let newAsseet = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Asset')
|
||||
newAsseet.name = name
|
||||
newAsseet.code = '{ \n\"codeName\": \"' + name + '\"\n}'
|
||||
newAsseet.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_360
|
||||
newAsseet.payload.floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_200X
|
||||
newAsseet.payload.floatingObject.arrangementStyle = ARRANGEMENT_STYLE.CONCAVE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,11 @@ function newNodeDeleter () {
|
||||
}
|
||||
|
||||
function deleteUIObject (node, rootNodes) {
|
||||
/* First we restore the reference parent to its default state */
|
||||
if (node.payload !== undefined && node.payload.referenceParent !== undefined && node.payload.referenceParent.payload !== undefined && node.payload.referenceParent.payload.uiObject !== undefined) {
|
||||
node.payload.referenceParent.payload.uiObject.isShowing = false
|
||||
}
|
||||
|
||||
let nodeDefinition = APP_SCHEMA_MAP.get(node.type)
|
||||
if (nodeDefinition !== undefined) {
|
||||
/* Remove all of its own children nodes. */
|
||||
|
||||
@@ -19,6 +19,10 @@ function newReferenceAttachDetach () {
|
||||
}
|
||||
|
||||
function completeDetachment (node) {
|
||||
if (node.payload.referenceParent.payload !== undefined && node.payload.referenceParent.payload.uiObject !== undefined) {
|
||||
node.payload.referenceParent.payload.uiObject.isShowing = false
|
||||
}
|
||||
|
||||
node.payload.referenceParent = undefined
|
||||
if (node.savedPayload !== undefined) {
|
||||
node.savedPayload.referenceParent = undefined
|
||||
|
||||
@@ -65,7 +65,7 @@ function newSessionFunctions () {
|
||||
tradingSystem: JSON.stringify(tradingSystem)
|
||||
}
|
||||
|
||||
systemEventHandler.raiseEvent(key, 'Run Session', event)
|
||||
eventsServerClient.raiseEvent(key, 'Run Session', event)
|
||||
|
||||
if (node.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode === undefined) {
|
||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||
@@ -75,7 +75,7 @@ function newSessionFunctions () {
|
||||
|
||||
function stopSession (node, functionLibraryProtocolNode, callBackFunction) {
|
||||
let key = node.name + '-' + node.type + '-' + node.id
|
||||
systemEventHandler.raiseEvent(key, 'Stop Session')
|
||||
eventsServerClient.raiseEvent(key, 'Stop Session')
|
||||
|
||||
node.payload.uiObject.stop(callBackFunction)
|
||||
}
|
||||
|
||||
@@ -68,12 +68,12 @@ function newTaskFunctions () {
|
||||
|
||||
if (node.payload.parentNode === undefined) {
|
||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||
systemEventHandler.raiseEvent('Task Server', 'Debug Task Started', event)
|
||||
eventsServerClient.raiseEvent('Task Server', 'Debug Task Started', event)
|
||||
return
|
||||
}
|
||||
|
||||
node.payload.uiObject.run(callBackFunction)
|
||||
systemEventHandler.raiseEvent('Task Manager', 'Run Task', event)
|
||||
eventsServerClient.raiseEvent('Task Manager', 'Run Task', event)
|
||||
}
|
||||
|
||||
function stopTask (node, functionLibraryProtocolNode, callBackFunction) {
|
||||
@@ -83,7 +83,7 @@ function newTaskFunctions () {
|
||||
}
|
||||
|
||||
node.payload.uiObject.stop(callBackFunction)
|
||||
systemEventHandler.raiseEvent('Task Manager', 'Stop Task', event)
|
||||
eventsServerClient.raiseEvent('Task Manager', 'Stop Task', event)
|
||||
|
||||
if (node.bot === undefined) { return }
|
||||
if (node.bot.processes.length === 0) { return }
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
function newSystemEventHandler () {
|
||||
function newEventsServerClient () {
|
||||
/* Web Sockets Connection */
|
||||
|
||||
const MODULE_NAME = 'System Event Handler'
|
||||
@@ -24,6 +24,9 @@ function newSystemEventHandler () {
|
||||
|
||||
let eventListeners = new Map()
|
||||
let responseWaiters = new Map()
|
||||
let commandsWaitingConfirmation = new Map()
|
||||
let commandsSentByTimestamp = new Map()
|
||||
let nonce = 0
|
||||
|
||||
return thisObject
|
||||
|
||||
@@ -53,13 +56,25 @@ function newSystemEventHandler () {
|
||||
responseWaiters.set(command.callerId, responseCallBack)
|
||||
}
|
||||
|
||||
if (WEB_SOCKETS_CONNECTION.readyState === 1) { // 1 means connected and ready.
|
||||
WEB_SOCKETS_CONNECTION.send(JSON.stringify(command))
|
||||
if (WEB_SOCKETS_CONNECTION.readyState === 1) {
|
||||
// 1 means connected and ready.
|
||||
sendToWebSocketServer(command)
|
||||
} else {
|
||||
console.log('WebSocket message could not be sent because the connection was not ready. Message = ' + JSON.stringify(command))
|
||||
}
|
||||
}
|
||||
|
||||
function sendToWebSocketServer (command) {
|
||||
nonce++
|
||||
let stringNonce = nonce.toString()
|
||||
let timestamp = (new Date()).valueOf()
|
||||
commandsWaitingConfirmation.set(stringNonce, command)
|
||||
commandsSentByTimestamp.set(stringNonce, timestamp)
|
||||
|
||||
let messageToWebSocketServer = 'Web Browser' + '|*|' + stringNonce + '|*|' + JSON.stringify(command)
|
||||
WEB_SOCKETS_CONNECTION.send(messageToWebSocketServer)
|
||||
}
|
||||
|
||||
function createEventHandler (eventHandlerName, callerId, responseCallBack) {
|
||||
let eventCommand = {
|
||||
action: 'createEventHandler',
|
||||
@@ -110,6 +125,23 @@ function newSystemEventHandler () {
|
||||
sendCommand(eventCommand, responseCallBack)
|
||||
}
|
||||
|
||||
function retryCommandsPhysics () {
|
||||
commandsSentByTimestamp.forEach(checkTimestamp)
|
||||
|
||||
function checkTimestamp (timestamp, nonce) {
|
||||
const MILISECONDS_TO_WAIT_FOR_RETRYING_A_COMMAND = 10000
|
||||
let now = (new Date()).valueOf()
|
||||
|
||||
if ((now - timestamp) > MILISECONDS_TO_WAIT_FOR_RETRYING_A_COMMAND) {
|
||||
let command = commandsWaitingConfirmation.get(nonce)
|
||||
commandsWaitingConfirmation.delete(nonce)
|
||||
commandsSentByTimestamp.delete(nonce)
|
||||
|
||||
sendToWebSocketServer(command)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function physics () {
|
||||
if (WEB_SOCKETS_CONNECTION !== undefined) {
|
||||
if (WEB_SOCKETS_CONNECTION.readyState === 3) { // Connection closed. May happen after computer goes to sleep.
|
||||
@@ -122,15 +154,16 @@ function newSystemEventHandler () {
|
||||
|
||||
if (thisObject.isConnected() !== true) {
|
||||
canvas.cockpitSpace.setStatus('Connection with the local backend lost. Please check that all localhost servers are running.', 100, canvas.cockpitSpace.statusTypes.WARNING)
|
||||
} else {
|
||||
retryCommandsPhysics()
|
||||
}
|
||||
|
||||
DEBUG.variable4 = 'Commands Waiting For Confirmation from WS Server: ' + commandsWaitingConfirmation.size
|
||||
}
|
||||
|
||||
function setuptWebSockets (callBackFunction) {
|
||||
try {
|
||||
WEB_SOCKETS_CONNECTION = new WebSocket(WEB_SOCKETS_URL)
|
||||
WEB_SOCKETS_CONNECTION.onopen = () => {
|
||||
console.log('Websocket connection opened.')
|
||||
}
|
||||
WEB_SOCKETS_CONNECTION.onerror = error => {
|
||||
console.log('WebSocket error:' + JSON.stringify(error))
|
||||
}
|
||||
@@ -165,6 +198,12 @@ function newSystemEventHandler () {
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if (message.action === 'Acknowledge') {
|
||||
commandsWaitingConfirmation.delete(message.nonce)
|
||||
commandsSentByTimestamp.delete(message.nonce)
|
||||
return
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] setuptWebSockets -> err = ' + err.stack) }
|
||||
@@ -32,7 +32,7 @@ function newCircularProgressBar () {
|
||||
function finalize () {
|
||||
let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id
|
||||
if (eventSubscriptionIdHeartbeat !== undefined) {
|
||||
systemEventHandler.stopListening(key, eventSubscriptionIdHeartbeat)
|
||||
eventsServerClient.stopListening(key, eventSubscriptionIdHeartbeat)
|
||||
}
|
||||
|
||||
thisObject.container = undefined
|
||||
@@ -48,7 +48,7 @@ function newCircularProgressBar () {
|
||||
}
|
||||
|
||||
let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id
|
||||
systemEventHandler.listenToEvent(key, 'Heartbeat', undefined, key, onResponse, onHeartBeat)
|
||||
eventsServerClient.listenToEvent(key, 'Heartbeat', undefined, key, onResponse, onHeartBeat)
|
||||
|
||||
function onResponse (message) {
|
||||
eventSubscriptionIdHeartbeat = message.eventSubscriptionId
|
||||
|
||||
@@ -286,6 +286,7 @@ function newFloatingObject () {
|
||||
|
||||
function positionContraintsPhysics () {
|
||||
const MAX_DISTANCE_TO_PARENT = 3000
|
||||
const MIN_DISTANCE_TO_PARENT = 100
|
||||
|
||||
if (thisObject.angleToParent !== ANGLE_TO_PARENT.NOT_FIXED && thisObject.isOnFocus !== true) {
|
||||
let parent = thisObject.payload.chainParent
|
||||
@@ -324,6 +325,10 @@ function newFloatingObject () {
|
||||
distanceToParent = MAX_DISTANCE_TO_PARENT
|
||||
}
|
||||
|
||||
if (distanceToParent < MIN_DISTANCE_TO_PARENT) {
|
||||
distanceToParent = MIN_DISTANCE_TO_PARENT
|
||||
}
|
||||
|
||||
switch (thisObject.angleToParent) {
|
||||
case ANGLE_TO_PARENT.RANGE_360:
|
||||
angleToParentAngle = 360
|
||||
@@ -560,20 +565,32 @@ function newFloatingObject () {
|
||||
}
|
||||
|
||||
function drawBackground () {
|
||||
if (canvas.floatingSpace.isItFar(thisObject.payload)) { return }
|
||||
if ((thisObject.isCollapsed === true && thisObject.collapsedManually === false) || thisObject.isParentCollapsed === true) { return }
|
||||
if (canvas.floatingSpace.isItFar(thisObject.payload) && thisObject.payload.uiObject.isShowing === false) { return }
|
||||
if ((thisObject.isCollapsed === true && thisObject.collapsedManually === false) || thisObject.isParentCollapsed === true) {
|
||||
if (thisObject.payload.uiObject.isShowing !== true) {
|
||||
return
|
||||
}
|
||||
}
|
||||
thisObject.payload.uiObject.drawBackground()
|
||||
}
|
||||
|
||||
function drawMiddleground () {
|
||||
if (canvas.floatingSpace.isItFar(thisObject.payload)) { return }
|
||||
if ((thisObject.isCollapsed === true && thisObject.collapsedManually === false) || thisObject.isParentCollapsed === true) { return }
|
||||
if (canvas.floatingSpace.isItFar(thisObject.payload) && thisObject.payload.uiObject.isShowing === false) { return }
|
||||
if ((thisObject.isCollapsed === true && thisObject.collapsedManually === false) || thisObject.isParentCollapsed === true) {
|
||||
if (thisObject.payload.uiObject.isShowing !== true) {
|
||||
return
|
||||
}
|
||||
}
|
||||
thisObject.payload.uiObject.drawMiddleground()
|
||||
}
|
||||
|
||||
function drawForeground () {
|
||||
if (canvas.floatingSpace.isItFar(thisObject.payload)) { return }
|
||||
if ((thisObject.isCollapsed === true && thisObject.collapsedManually === false) || thisObject.isParentCollapsed === true) { return }
|
||||
if (canvas.floatingSpace.isItFar(thisObject.payload) && thisObject.payload.uiObject.isShowing === false) { return }
|
||||
if ((thisObject.isCollapsed === true && thisObject.collapsedManually === false) || thisObject.isParentCollapsed === true) {
|
||||
if (thisObject.payload.uiObject.isShowing !== true) {
|
||||
return
|
||||
}
|
||||
}
|
||||
thisObject.payload.uiObject.drawForeground()
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ function newUiObject () {
|
||||
isExecuting: undefined,
|
||||
isRunning: undefined,
|
||||
shortcutKey: undefined,
|
||||
isShowing: undefined,
|
||||
run: run,
|
||||
stop: stop,
|
||||
heartBeat: heartBeat,
|
||||
@@ -122,10 +123,10 @@ function newUiObject () {
|
||||
let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id
|
||||
|
||||
if (eventSubscriptionIdOnRunning !== undefined) {
|
||||
systemEventHandler.stopListening(key, eventSubscriptionIdOnRunning, 'UiObject')
|
||||
eventsServerClient.stopListening(key, eventSubscriptionIdOnRunning, 'UiObject')
|
||||
}
|
||||
if (eventSubscriptionIdOnStopped !== undefined) {
|
||||
systemEventHandler.stopListening(key, eventSubscriptionIdOnStopped, 'UiObject')
|
||||
eventsServerClient.stopListening(key, eventSubscriptionIdOnStopped, 'UiObject')
|
||||
}
|
||||
|
||||
thisObject.container.eventHandler.stopListening(selfFocusEventSubscriptionId)
|
||||
@@ -186,6 +187,7 @@ function newUiObject () {
|
||||
thisObject.uiObjectTitle = newUiObjectTitle()
|
||||
thisObject.uiObjectTitle.isVisibleFunction = thisObject.isVisibleFunction
|
||||
thisObject.uiObjectTitle.container.connectToParent(thisObject.container, false, false, true, true, false, false, true, true)
|
||||
thisObject.uiObjectTitle.fitFunction = thisObject.fitFunction
|
||||
thisObject.uiObjectTitle.initialize(thisObject.payload)
|
||||
|
||||
/* Load UI Object Image */
|
||||
@@ -364,8 +366,10 @@ function newUiObject () {
|
||||
let totalRunning = 0
|
||||
for (let j = 0; j < children.length; j++) {
|
||||
let child = children[j]
|
||||
if (child.payload.uiObject.isRunning === true) {
|
||||
totalRunning++
|
||||
if (child.payload !== undefined) {
|
||||
if (child.payload.uiObject.isRunning === true) {
|
||||
totalRunning++
|
||||
}
|
||||
}
|
||||
}
|
||||
if (totalRunning > 0) {
|
||||
@@ -759,7 +763,7 @@ function newUiObject () {
|
||||
|
||||
/* We will wait to hear the Running event 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, 'UiObject', onResponse, onRunning)
|
||||
eventsServerClient.listenToEvent(key, 'Running', undefined, 'UiObject', onResponse, onRunning)
|
||||
|
||||
onRunningCallBackFunction = callBackFunction
|
||||
|
||||
@@ -771,7 +775,7 @@ function newUiObject () {
|
||||
if (thisObject.payload === undefined) { return }
|
||||
|
||||
let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id
|
||||
systemEventHandler.stopListening(key, eventSubscriptionIdOnRunning, 'UiObject')
|
||||
eventsServerClient.stopListening(key, eventSubscriptionIdOnRunning, 'UiObject')
|
||||
|
||||
thisObject.isRunning = true
|
||||
|
||||
@@ -801,7 +805,7 @@ 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, 'UiObject', onResponse, onStopped)
|
||||
eventsServerClient.listenToEvent(key, 'Stopped', undefined, 'UiObject', onResponse, onStopped)
|
||||
|
||||
function onResponse (message) {
|
||||
eventSubscriptionIdOnStopped = message.eventSubscriptionId
|
||||
@@ -870,6 +874,10 @@ function newUiObject () {
|
||||
|
||||
function onFocus () {
|
||||
thisObject.isOnFocus = true
|
||||
|
||||
if (thisObject.payload !== undefined && thisObject.isOnFocus === true && thisObject.payload.referenceParent !== undefined) {
|
||||
thisObject.payload.referenceParent.payload.uiObject.isShowing = true
|
||||
}
|
||||
}
|
||||
|
||||
function onNotFocus () {
|
||||
@@ -886,6 +894,10 @@ function newUiObject () {
|
||||
if (thisObject.formulaEditor !== undefined) {
|
||||
thisObject.formulaEditor.deactivate()
|
||||
}
|
||||
|
||||
if (thisObject.payload !== undefined && thisObject.isOnFocus === false && thisObject.payload.referenceParent !== undefined) {
|
||||
thisObject.payload.referenceParent.payload.uiObject.isShowing = false
|
||||
}
|
||||
}
|
||||
|
||||
function onDisplace (event) {
|
||||
@@ -1113,11 +1125,11 @@ function newUiObject () {
|
||||
}
|
||||
|
||||
function drawReferenceLine () {
|
||||
if (canvas.floatingSpace.drawReferenceLines === false) { return }
|
||||
if (canvas.floatingSpace.drawReferenceLines === false && thisObject.isOnFocus === false) { return }
|
||||
if (thisObject.payload.referenceParent === undefined) { return }
|
||||
if (thisObject.payload.referenceParent.payload === undefined) { return }
|
||||
if (thisObject.payload.referenceParent.payload.floatingObject === undefined) { return }
|
||||
if (thisObject.payload.referenceParent.payload.floatingObject.isParentCollapsed === true) { return }
|
||||
if (thisObject.payload.referenceParent.payload.floatingObject.isParentCollapsed === true && thisObject.isOnFocus === false) { return }
|
||||
|
||||
let targetPoint = {
|
||||
x: thisObject.payload.referenceParent.payload.position.x,
|
||||
@@ -1132,6 +1144,10 @@ function newUiObject () {
|
||||
targetPoint = canvas.floatingSpace.container.frame.frameThisPoint(targetPoint)
|
||||
position = thisObject.container.frame.frameThisPoint(position)
|
||||
|
||||
if (thisObject.isOnFocus === true) {
|
||||
targetPoint = thisObject.fitFunction(targetPoint)
|
||||
}
|
||||
|
||||
if (canvas.floatingSpace.inMapMode === true) {
|
||||
position = canvas.floatingSpace.transformPointToMap(position)
|
||||
targetPoint = canvas.floatingSpace.transformPointToMap(targetPoint)
|
||||
@@ -1268,6 +1284,9 @@ function newUiObject () {
|
||||
function drawValue () {
|
||||
if (hasValue === false) { return }
|
||||
if (canvas.floatingSpace.inMapMode === true) { return }
|
||||
if (thisObject.payload === undefined) { return }
|
||||
if ((thisObject.payload.floatingObject.isCollapsed === true && thisObject.payload.floatingObject.collapsedManually === false) || thisObject.payload.floatingObject.isParentCollapsed === true) { return }
|
||||
|
||||
// if (currentValue === undefined || currentValue === '') { return }
|
||||
|
||||
/* Text Follows */
|
||||
@@ -1322,6 +1341,8 @@ function newUiObject () {
|
||||
function drawPercentage () {
|
||||
if (hasPercentage === false) { return }
|
||||
if (canvas.floatingSpace.inMapMode === true) { return }
|
||||
if (thisObject.payload === undefined) { return }
|
||||
if ((thisObject.payload.floatingObject.isCollapsed === true && thisObject.payload.floatingObject.collapsedManually === false) || thisObject.payload.floatingObject.isParentCollapsed === true) { return }
|
||||
|
||||
let position = {
|
||||
x: 0,
|
||||
@@ -1475,6 +1496,10 @@ function newUiObject () {
|
||||
|
||||
position = thisObject.container.frame.frameThisPoint(position)
|
||||
|
||||
if (thisObject.isShowing === true) {
|
||||
position = thisObject.fitFunction(position)
|
||||
}
|
||||
|
||||
if (canvas.floatingSpace.inMapMode === true) {
|
||||
position = canvas.floatingSpace.transformPointToMap(position)
|
||||
}
|
||||
@@ -1704,6 +1729,11 @@ function newUiObject () {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (thisObject.isShowing === true) {
|
||||
totalImageSize = 50
|
||||
}
|
||||
|
||||
browserCanvasContext.drawImage(
|
||||
icon, position.x - totalImageSize / 2,
|
||||
position.y - totalImageSize / 2,
|
||||
|
||||
@@ -7,6 +7,7 @@ function newUiObjectTitle () {
|
||||
logger.fileName = MODULE_NAME
|
||||
|
||||
let thisObject = {
|
||||
fitFunction: undefined,
|
||||
isVisibleFunction: undefined,
|
||||
allwaysVisible: undefined,
|
||||
editMode: undefined,
|
||||
@@ -43,6 +44,7 @@ function newUiObjectTitle () {
|
||||
thisObject.container = undefined
|
||||
thisObject.payload = undefined
|
||||
thisObject.isVisibleFunction = undefined
|
||||
thisObject.fitFunction = undefined
|
||||
}
|
||||
|
||||
function initialize (payload) {
|
||||
|
||||
@@ -147,7 +147,7 @@ function newPlotterPanel () {
|
||||
value = eval(panelData.dataFormula.code)
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] plotCurrentRecordData -> err = ' + err.stack) }
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] plotCurrentRecordData -> dataFormula.code = ' + panelNode.dataFormula.code) }
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] plotCurrentRecordData -> dataFormula.code = ' + panelData.dataFormula.code) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
let canvas
|
||||
let markets
|
||||
let systemEventHandler
|
||||
let eventsServerClient
|
||||
|
||||
let APP_SCHEMA_MAP = new Map()
|
||||
let APP_SCHEMA_ARRAY = []
|
||||
@@ -24,8 +24,8 @@ function newDashboard () {
|
||||
try {
|
||||
setBrowserEvents()
|
||||
|
||||
systemEventHandler = newSystemEventHandler()
|
||||
systemEventHandler.initialize(setUpAppSchema)
|
||||
eventsServerClient = newEventsServerClient()
|
||||
eventsServerClient.initialize(setUpAppSchema)
|
||||
|
||||
function setUpAppSchema () {
|
||||
APP_SCHEMA_ARRAY = getAppSchema()
|
||||
|
||||
+75
-15
@@ -43,18 +43,30 @@ function newRateScale () {
|
||||
let onMouseOverEventSubscriptionId
|
||||
let onMouseNotOverEventSubscriptionId
|
||||
let onScaleChangedEventSubscriptionId
|
||||
let onDragStartedEventSubscriptionId
|
||||
|
||||
let coordinateSystem
|
||||
let coordinateSystemWhenDragStarted
|
||||
|
||||
let limitingContainer
|
||||
let rateCalculationsContainer
|
||||
|
||||
let mouse = {
|
||||
mouseWhenDragStarted = {
|
||||
position: {
|
||||
x: 0,
|
||||
y: 0
|
||||
}
|
||||
}
|
||||
|
||||
parentFrameWhenDragStarted = {
|
||||
position: {
|
||||
x: 0,
|
||||
y: 0
|
||||
},
|
||||
width: 0,
|
||||
height: 0
|
||||
}
|
||||
|
||||
let scaleDisplayTimer = 0
|
||||
let autoScaleButton
|
||||
|
||||
@@ -68,16 +80,25 @@ function newRateScale () {
|
||||
thisObject.container.eventHandler.stopListening(onMouseOverEventSubscriptionId)
|
||||
thisObject.container.eventHandler.stopListening(onMouseNotOverEventSubscriptionId)
|
||||
coordinateSystem.eventHandler.stopListening(onScaleChangedEventSubscriptionId)
|
||||
thisObject.container.eventHandler.stopListening(onDragStartedEventSubscriptionId)
|
||||
|
||||
thisObject.container.finalize()
|
||||
thisObject.container = undefined
|
||||
thisObject.fitFunction = undefined
|
||||
thisObject.payload = undefined
|
||||
|
||||
if (coordinateSystemWhenDragStarted !== undefined) {
|
||||
coordinateSystemWhenDragStarted.finalize()
|
||||
}
|
||||
|
||||
coordinateSystemWhenDragStarted = undefined
|
||||
|
||||
coordinateSystem = undefined
|
||||
limitingContainer = undefined
|
||||
rateCalculationsContainer = undefined
|
||||
mouse = undefined
|
||||
|
||||
mouseWhenDragStarted = undefined
|
||||
parentFrameWhenDragStarted = undefined
|
||||
|
||||
autoScaleButton.finalize()
|
||||
autoScaleButton = undefined
|
||||
@@ -95,6 +116,7 @@ function newRateScale () {
|
||||
onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver)
|
||||
onMouseNotOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver)
|
||||
onScaleChangedEventSubscriptionId = coordinateSystem.eventHandler.listenToEvent('Scale Changed', onScaleChanged)
|
||||
onDragStartedEventSubscriptionId = draggeableContainer.eventHandler.listenToEvent('onDragStarted', onDragStarted)
|
||||
|
||||
autoScaleButton = newAutoScaleButton()
|
||||
autoScaleButton.container.connectToParent(thisObject.container)
|
||||
@@ -115,12 +137,6 @@ function newRateScale () {
|
||||
turnOnCounter = 0
|
||||
}
|
||||
}
|
||||
mouse = {
|
||||
position: {
|
||||
x: event.x,
|
||||
y: event.y
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onScaleChanged () {
|
||||
@@ -195,6 +211,38 @@ function newRateScale () {
|
||||
scaleDisplayTimer = 100
|
||||
}
|
||||
|
||||
function onDragStarted (event) {
|
||||
mouseWhenDragStarted = {
|
||||
position: {
|
||||
x: event.x,
|
||||
y: event.y
|
||||
}
|
||||
}
|
||||
|
||||
parentFrameWhenDragStarted = {
|
||||
position: {
|
||||
x: limitingContainer.frame.position.x,
|
||||
y: limitingContainer.frame.position.y
|
||||
},
|
||||
width: limitingContainer.frame.width,
|
||||
height: limitingContainer.frame.height
|
||||
}
|
||||
|
||||
coordinateSystemWhenDragStarted = newCoordinateSystem()
|
||||
|
||||
let minValue = {
|
||||
x: coordinateSystem.min.x,
|
||||
y: coordinateSystem.min.y
|
||||
}
|
||||
|
||||
let maxValue = {
|
||||
x: coordinateSystem.max.x,
|
||||
y: coordinateSystem.max.y
|
||||
}
|
||||
|
||||
coordinateSystemWhenDragStarted.initialize(minValue, maxValue, coordinateSystem.maxWidth, coordinateSystem.maxHeight)
|
||||
}
|
||||
|
||||
function getContainer (point, purpose) {
|
||||
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
||||
if (purpose === GET_CONTAINER_PURPOSE.DRAGGING) {
|
||||
@@ -262,26 +310,38 @@ function newRateScale () {
|
||||
}
|
||||
|
||||
function draggingPhysics () {
|
||||
if (coordinateSystemWhenDragStarted === undefined) { return }
|
||||
if (draggeableContainer.frame.position.y === 0) { return }
|
||||
|
||||
let mouseNoZoom = canvas.chartingSpace.viewport.unTransformThisPoint(canvas.mouse.position)
|
||||
let mouseWhenDragStartedNoZoom = canvas.chartingSpace.viewport.unTransformThisPoint(mouseWhenDragStarted.position)
|
||||
|
||||
let dragVectorWhenDragStarted = {
|
||||
x: 0,
|
||||
y: mouseNoZoom.y - mouseWhenDragStartedNoZoom.y
|
||||
}
|
||||
|
||||
let dragVector = {
|
||||
x: draggeableContainer.frame.position.x,
|
||||
x: 0,
|
||||
y: draggeableContainer.frame.position.y
|
||||
}
|
||||
|
||||
draggeableContainer.frame.position.x = 0
|
||||
draggeableContainer.frame.position.y = 0
|
||||
|
||||
let point = {
|
||||
x: 0,
|
||||
y: -dragVector.y
|
||||
y: (-dragVectorWhenDragStarted.y)
|
||||
}
|
||||
|
||||
let newMaxRate = getRateFromPointAtContainer(point, limitingContainer, coordinateSystem)
|
||||
let yDifferenceMaxMin = coordinateSystem.max.y - coordinateSystem.min.y
|
||||
let newMaxRate = getRateFromPointAtContainer(point, limitingContainer, coordinateSystemWhenDragStarted)
|
||||
let yDifferenceMaxMin = coordinateSystemWhenDragStarted.max.y - coordinateSystemWhenDragStarted.min.y
|
||||
|
||||
coordinateSystem.min.y = newMaxRate - yDifferenceMaxMin
|
||||
coordinateSystem.max.y = newMaxRate
|
||||
let event = {
|
||||
type: 'center dragged',
|
||||
dragVector: dragVector
|
||||
}
|
||||
coordinateSystem.recalculateScale()
|
||||
}
|
||||
|
||||
@@ -375,7 +435,7 @@ function newRateScale () {
|
||||
/* Mouse Position Rate Calculation */
|
||||
let ratePoint = {
|
||||
x: 0,
|
||||
y: mouse.position.y
|
||||
y: canvas.mouse.position.y
|
||||
}
|
||||
|
||||
thisObject.rate = getRateFromPointAtBrowserCanvas(ratePoint, rateCalculationsContainer, coordinateSystem)
|
||||
@@ -387,7 +447,7 @@ function newRateScale () {
|
||||
}
|
||||
|
||||
ratePoint = transformThisPoint(ratePoint, limitingContainer.frame.container)
|
||||
ratePoint.y = mouse.position.y - thisObject.container.frame.height / 2 + thisObject.container.frame.height
|
||||
ratePoint.y = canvas.mouse.position.y - thisObject.container.frame.height / 2 + thisObject.container.frame.height
|
||||
|
||||
/* Checking against the container limits. */
|
||||
if (ratePoint.x < upCorner.x) { ratePoint.x = upCorner.x }
|
||||
|
||||
@@ -38,12 +38,6 @@ function newTimeFrameScale () {
|
||||
|
||||
let limitingContainer
|
||||
|
||||
let mouse = {
|
||||
position: {
|
||||
x: 0,
|
||||
y: 0
|
||||
}
|
||||
}
|
||||
setupContainer()
|
||||
|
||||
let wheelDeltaDirection
|
||||
@@ -76,7 +70,6 @@ function newTimeFrameScale () {
|
||||
thisObject.payload = undefined
|
||||
|
||||
limitingContainer = undefined
|
||||
mouse = undefined
|
||||
}
|
||||
|
||||
function initialize (pLimitingContainer) {
|
||||
@@ -103,12 +96,6 @@ function newTimeFrameScale () {
|
||||
turnOnCounter = 0
|
||||
}
|
||||
}
|
||||
mouse = {
|
||||
position: {
|
||||
x: event.x,
|
||||
y: event.y
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onMouseOver (event) {
|
||||
@@ -201,7 +188,7 @@ function newTimeFrameScale () {
|
||||
}
|
||||
|
||||
timePoint = transformThisPoint(timePoint, limitingContainer.frame.container)
|
||||
timePoint.x = mouse.position.x - thisObject.container.frame.width / 2
|
||||
timePoint.x = canvas.mouse.position.x - thisObject.container.frame.width / 2
|
||||
|
||||
/* Checking against the container limits. */
|
||||
if (timePoint.x < upCorner.x) { timePoint.x = upCorner.x }
|
||||
|
||||
+2
-16
@@ -42,13 +42,6 @@ function newTimeScale () {
|
||||
let coordinateSystem
|
||||
let limitingContainer
|
||||
|
||||
let mouse = {
|
||||
position: {
|
||||
x: 0,
|
||||
y: 0
|
||||
}
|
||||
}
|
||||
|
||||
let wheelDeltaDirection
|
||||
let wheelDeltaCounter = 0
|
||||
|
||||
@@ -67,7 +60,6 @@ function newTimeScale () {
|
||||
|
||||
coordinateSystem = undefined
|
||||
limitingContainer = undefined
|
||||
mouse = undefined
|
||||
|
||||
autoScaleButton.finalize()
|
||||
autoScaleButton = undefined
|
||||
@@ -101,12 +93,6 @@ function newTimeScale () {
|
||||
turnOnCounter = 0
|
||||
}
|
||||
}
|
||||
mouse = {
|
||||
position: {
|
||||
x: event.x,
|
||||
y: event.y
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onMouseOver (event) {
|
||||
@@ -253,7 +239,7 @@ function newTimeScale () {
|
||||
|
||||
/* Mouse Position Date Calculation */
|
||||
let timePoint = {
|
||||
x: mouse.position.x,
|
||||
x: canvas.mouse.position.x,
|
||||
y: 0
|
||||
}
|
||||
|
||||
@@ -268,7 +254,7 @@ function newTimeScale () {
|
||||
}
|
||||
|
||||
timePoint = transformThisPoint(timePoint, limitingContainer.frame.container)
|
||||
timePoint.x = mouse.position.x - thisObject.container.frame.width / 2
|
||||
timePoint.x = canvas.mouse.position.x - thisObject.container.frame.width / 2
|
||||
|
||||
/* Checking against the container limits. */
|
||||
if (timePoint.x < upCorner.x) { timePoint.x = upCorner.x }
|
||||
|
||||
Reference in new issue
Block a user