Removing Old Code

This commit is contained in:
Luis Fernando Molina committed 2020-01-07 09:15:47 +01:00
1 parent bca250eed4
commit d9076ee6af
4 files changed
-183

No files matched your search

-14
View File
@@ -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) {
-2
View File
@@ -218,8 +218,6 @@ function newTimelineChart () {
datetime = newDate
plotterManager.setDatetime(datetime)
thisObject.container.eventHandler.raiseEvent('Datetime Changed', datetime)
}
function getContainer (point) {
-160
View File
@@ -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)
}
}
-7
View File
@@ -40,13 +40,6 @@ function newPanelsSpace () {
switch (pType) {
case 'Time Control Panel':
{
panel = newTimeControlPanel()
panel.initialize()
break
}
case 'Products Panel':
{
panel = newProductsPanel()