Restarting Chart Spaace when new workspace is loaded

This commit is contained in:
Luis Fernando Molina committed 2019-12-05 12:51:01 +01:00
1 parent be8b12a19c
commit fafe5b8d02
7 files changed
+118 -79

No files matched your search

+4 -11
View File
@@ -81,7 +81,7 @@ function newCanvas () {
}
}
async function initialize () {
function initialize () {
try {
initializeBrowserCanvas()
@@ -93,10 +93,10 @@ function newCanvas () {
thisObject.floatingSpace.initialize()
thisObject.topSpace = newTopSpace()
await thisObject.topSpace.initialize()
thisObject.topSpace.initialize()
thisObject.designerSpace = newDesignerSpace()
await thisObject.designerSpace.initialize()
thisObject.designerSpace.initialize()
thisObject.cockpitSpace = newCockpitSpace()
thisObject.cockpitSpace.initialize()
@@ -105,17 +105,10 @@ function newCanvas () {
thisObject.panelsSpace.initialize()
thisObject.chartSpace = newChartSpace()
thisObject.chartSpace.initialize(onCharSpaceInitialized)
thisObject.chartSpace.initialize()
thisObject.bottomSpace = thisObject.cockpitSpace
function onCharSpaceInitialized (err) {
try {
viewPort.raiseEvents() // These events will impacts on objects just initialized.
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> onCharSpaceInitialized -> err = ' + err.stack) }
}
}
splashScreen = newSplashScreen()
splashScreen.initialize()
+32 -24
View File
@@ -21,40 +21,48 @@ function newPlottersManager () {
finalize: finalize
}
thisObject.container = newContainer()
thisObject.container.initialize(MODULE_NAME)
let initializationReady = false
let productsPanel
let exchange
let market
setupContainer()
return thisObject
function finalize (callBackFunction) {
try {
for (let i = 0; i < productPlotters.length; i++) {
if (productPlotters[i].profile !== undefined) {
canvas.floatingSpace.profileBalls.destroyProfileBall(productPlotters[i].profile)
}
/* Destroyd the Note Set */
canvas.floatingSpace.noteSets.destroyNoteSet(productPlotters[i].noteSet)
/* Then the panels. */
for (let j = 0; j < productPlotters[i].panels.length; j++) {
canvas.panelsSpace.destroyPanel(productPlotters[i].panels[j])
}
/* Finally the Storage Objects */
productPlotters[i].storage.finalize()
if (productPlotters[i].plotter.finalize !== undefined) {
productPlotters[i].plotter.finalize()
}
productPlotters.splice(i, 1) // Delete item from array.
function setupContainer () {
thisObject.container = newContainer()
thisObject.container.initialize(MODULE_NAME)
}
function finalize () {
for (let i = 0; i < productPlotters.length; 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
}
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] finalize -> err = ' + err.stack) }
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
productPlotters[i].panels = undefined
/* Finalize the plotters */
if (productPlotters[i].plotter.finalize !== undefined) {
productPlotters[i].plotter.finalize()
}
productPlotters[i].plotter = undefined
/* Finally the Storage Objects */
productPlotters[i].storage.finalize()
productPlotters[i].storage = undefined
productPlotters[i] = undefined
}
productPlotters = []
productsPanel = undefined
thisObject.container.finalize()
thisObject.container = undefined
setupContainer()
}
function initialize (pProductsPanel, pExchange, pMarket, callBackFunction) {
+22 -13
View File
@@ -28,17 +28,6 @@ function newTimeMachine () {
finalize: finalize
}
thisObject.container = newContainer()
thisObject.container.initialize(MODULE_NAME)
thisObject.container.isDraggeable = false
thisObject.container.detectMouseOver = true
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
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
@@ -52,21 +41,38 @@ function newTimeMachine () {
}
}
setupContainer()
return thisObject
function setupContainer () {
thisObject.container = newContainer()
thisObject.container.initialize(MODULE_NAME)
thisObject.container.isDraggeable = false
thisObject.container.detectMouseOver = true
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 () {
for (let i = 0; i < thisObject.charts.length; i++) {
let chart = thisObject.charts[i]
chart.finalize()
}
thisObject.container.finalize()
thisObject.container = undefined
thisObject.charts = []
thisObject.timeScale.finalize()
thisObject.timeScale = undefined
thisObject.rateScale.finalize()
thisObject.rateScale = undefined
thisObject.fitFunction = undefined
thisObject.container.finalize()
thisObject.container = undefined
setupContainer()
}
function initialize (callBackFunction) {
@@ -261,6 +267,9 @@ function newTimeMachine () {
}
function childrenPhysics () {
if (thisObject.timeScale === undefined) { return }
if (thisObject.rateScale === undefined) { return }
thisObject.timeScale.physics()
thisObject.rateScale.physics()
+16 -11
View File
@@ -23,10 +23,6 @@ function newTimelineChart () {
finalize: finalize
}
thisObject.container = newContainer()
thisObject.container.initialize(MODULE_NAME)
thisObject.container.detectMouseOver = true
thisObject.fitFunction = canvas.chartSpace.fitIntoVisibleArea
let initializationReady = false
@@ -50,16 +46,25 @@ function newTimelineChart () {
let productsPanelHandle
let timePeriodScale
setupContainer()
return thisObject
function finalize () {
try {
if (INFO_LOG === true) { logger.write('[INFO] finalize -> Entering function.') }
function setupContainer () {
thisObject.container = newContainer()
thisObject.container.initialize(MODULE_NAME)
thisObject.container.detectMouseOver = true
}
plotterManager.finalize()
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] finalize -> err = ' + err.stack) }
}
function finalize () {
plotterManager.finalize()
plotterManager = undefined
timePeriodScale.finalize()
timePeriodScale = undefined
canvas.panelsSpace.destroyPanel(productsPanelHandle)
thisObject.container.finalize()
thisObject.container = undefined
setupContainer()
}
function initialize (pExchange, pMarket, pTimeLineCoordinateSystem, callBackFunction) {
+2
View File
@@ -208,6 +208,8 @@ function newWorkspace () {
canvas.floatingSpace.warmUp()
thisObject.workspaceNode = droppedNode
functionLibraryUiObjectsFromNodes.recreateWorkspace(thisObject.workspaceNode)
canvas.chartSpace.finalize()
canvas.chartSpace.initialize()
return
} else {
if (
+28 -11
View File
@@ -14,13 +14,6 @@ function newTimePeriodScale () {
const TIME_PERIOD_DEFAULT_VALUE = 0
const MIN_HEIGHT = 50
thisObject.container = newContainer()
thisObject.container.initialize(MODULE_NAME)
thisObject.container.isDraggeable = false
thisObject.container.isClickeable = false
thisObject.container.isWheelable = true
let mouse = {
position: {
x: 0,
@@ -36,33 +29,57 @@ function newTimePeriodScale () {
let timePeriodsMasterArray = [marketFilesPeriods, dailyFilePeriods]
let timePeriodLabel = ''
let onMouseWheelEventSubscriptionId
let onMouseOverEventSubscriptionId
let onMouseNotOverEventSubscriptionId
let onZoomChangedEventSubscriptionId
setupContainer()
return thisObject
function setupContainer () {
thisObject.container = newContainer()
thisObject.container.initialize(MODULE_NAME)
thisObject.container.isDraggeable = false
thisObject.container.isClickeable = false
thisObject.container.isWheelable = true
}
function finalize () {
thisObject.container.eventHandler.stopListening(onMouseWheelEventSubscriptionId)
thisObject.container.eventHandler.stopListening(onMouseOverEventSubscriptionId)
thisObject.container.eventHandler.stopListening(onMouseNotOverEventSubscriptionId)
thisObject.container.eventHandler.stopListening(onZoomChangedEventSubscriptionId)
timeLineCoordinateSystem = undefined
objectStorage = undefined
thisObject.container.finalize()
thisObject.container = undefined
setupContainer()
}
function initialize (pTimeLineCoordinateSystem) {
timeLineCoordinateSystem = pTimeLineCoordinateSystem
thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel)
onMouseWheelEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel)
readObjectState()
newTimePeriod()
thisObject.container.eventHandler.listenToEvent('onMouseOver', function (event) {
onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', function (event) {
mouse.position.x = event.x
mouse.position.y = event.y
visible = true
})
thisObject.container.eventHandler.listenToEvent('onMouseNotOver', function (event) {
onMouseWheelEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', function (event) {
visible = false
})
viewPort.eventHandler.listenToEvent('Zoom Changed', onZoomChanged)
onZoomChangedEventSubscriptionId = viewPort.eventHandler.listenToEvent('Zoom Changed', onZoomChanged)
}
function onZoomChanged (event) {
+14 -9
View File
@@ -30,17 +30,21 @@ function newChartSpace () {
finalize: finalize
}
thisObject.container = newContainer()
thisObject.container.initialize(MODULE_NAME)
thisObject.container.isDraggeable = false
thisObject.container.isWheelable = false
let canvasBrowserResizedEventSubscriptionId
const PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT = 25
setupContainer()
return thisObject
function setupContainer () {
thisObject.container = newContainer()
thisObject.container.initialize(MODULE_NAME)
thisObject.container.isDraggeable = false
thisObject.container.isWheelable = false
}
function finalize () {
for (let i = 0; i < thisObject.timeMachines.length; i++) {
let timeMachine = thisObject.timeMachines[i]
@@ -51,9 +55,10 @@ function newChartSpace () {
thisObject.container.finalize()
thisObject.container = undefined
setupContainer()
}
function initialize (callBackFunction) {
function initialize () {
let initializedCounter = 0
let toInitialize = 1
@@ -75,14 +80,14 @@ function newChartSpace () {
initializedCounter++
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
callBackFunction(err)
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> Initialization Failed. -> Err ' + err.message) }
return
}
thisObject.timeMachines.push(timeMachine)
if (initializedCounter === toInitialize) {
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE)
viewPort.raiseEvents() // These events will impacts on objects just initialized.
}
}
}