Change in Code Indentation

This commit is contained in:
Luis Fernando Molina committed 2020-07-29 11:09:04 +02:00
1 parent 1a52e5494e
commit 199a71a4e5
89 files changed
+22093 -22093

No files matched your search

+389 -389
View File
@@ -6,441 +6,441 @@ changes, then all charts in it are replotted with the corresponging data.
*/
function newChartingSpace () {
const MODULE_NAME = 'Charting Space'
const ERROR_LOG = true
const logger = newWebDebugLog()
logger.fileName = MODULE_NAME
function newChartingSpace() {
const MODULE_NAME = 'Charting Space'
const ERROR_LOG = true
const logger = newWebDebugLog()
logger.fileName = MODULE_NAME
let thisObject = {
visible: false,
container: undefined,
inViewport: undefined,
timeMachines: undefined,
viewport: undefined,
payload: undefined,
onKeyPressed: onKeyPressed,
reset: reset,
oneScreenUp: oneScreenUp,
oneScreenDown: oneScreenDown,
oneScreenLeft: oneScreenLeft,
oneScreenRight: oneScreenRight,
fitFunction: fitFunction,
isThisPointVisible: isThisPointVisible,
physics: physics,
draw: draw,
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
initialize: initialize,
finalize: finalize
}
let thisObject = {
visible: false,
container: undefined,
inViewport: undefined,
timeMachines: undefined,
viewport: undefined,
payload: undefined,
onKeyPressed: onKeyPressed,
reset: reset,
oneScreenUp: oneScreenUp,
oneScreenDown: oneScreenDown,
oneScreenLeft: oneScreenLeft,
oneScreenRight: oneScreenRight,
fitFunction: fitFunction,
isThisPointVisible: isThisPointVisible,
physics: physics,
draw: draw,
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
initialize: initialize,
finalize: finalize
}
let canvasBrowserResizedEventSubscriptionId
let timeMachinesMap
let syncWithDesignerLoop
let canvasBrowserResizedEventSubscriptionId
let timeMachinesMap
let syncWithDesignerLoop
const PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT = 25
const PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT = 25
initialSetup()
let isInitialized = false
return thisObject
function reset () {
finalize()
initialSetup()
isInitialized = false
initialize()
}
function initialSetup () {
thisObject.timeMachines = []
thisObject.visible = true
timeMachinesMap = new Map()
syncWithDesignerLoop = 0
thisObject.inViewport = new Map()
let isInitialized = false
thisObject.container = newContainer()
thisObject.container.initialize(MODULE_NAME)
return thisObject
thisObject.container.isDraggeable = false
thisObject.container.isWheelable = false
}
function finalize () {
for (let i = 0; i < thisObject.timeMachines.length; i++) {
let timeMachine = thisObject.timeMachines[i]
timeMachine.finalize()
function reset() {
finalize()
initialSetup()
isInitialized = false
initialize()
}
thisObject.inViewport = undefined
thisObject.timeMachines = undefined
timeMachinesMap = undefined
function initialSetup() {
thisObject.timeMachines = []
thisObject.visible = true
timeMachinesMap = new Map()
syncWithDesignerLoop = 0
thisObject.inViewport = new Map()
thisObject.container.eventHandler.stopListening(canvasBrowserResizedEventSubscriptionId)
thisObject.container = newContainer()
thisObject.container.initialize(MODULE_NAME)
thisObject.container.finalize()
thisObject.container = undefined
if (thisObject.viewport !== undefined) {
thisObject.viewport.finalize()
thisObject.viewport = undefined
thisObject.container.isDraggeable = false
thisObject.container.isWheelable = false
}
thisObject.payload = undefined
}
function initialize () {
if (isInitialized === true) { return }
if (canvas.designSpace === undefined) { return }
if (canvas.designSpace.workspace === undefined) { return }
let rootNodes = canvas.designSpace.workspace.workspaceNode.rootNodes
for (let i = 0; i < rootNodes.length; i++) {
let rootNode = rootNodes[i]
if (rootNode !== null) {
if (rootNode.type === 'Charting Space') {
thisObject.payload = rootNode.payload
function finalize() {
for (let i = 0; i < thisObject.timeMachines.length; i++) {
let timeMachine = thisObject.timeMachines[i]
timeMachine.finalize()
}
}
thisObject.inViewport = undefined
thisObject.timeMachines = undefined
timeMachinesMap = undefined
thisObject.container.eventHandler.stopListening(canvasBrowserResizedEventSubscriptionId)
thisObject.container.finalize()
thisObject.container = undefined
if (thisObject.viewport !== undefined) {
thisObject.viewport.finalize()
thisObject.viewport = undefined
}
thisObject.payload = undefined
}
if (thisObject.payload === undefined) {
// if (ERROR_LOG === true) { logger.write('[WARN] initialize -> There must exist a Charting Space at the Design Space in order to enable Charts. PLease create one and refreash your browser. ') }
return
}
function initialize() {
if (isInitialized === true) { return }
if (canvas.designSpace === undefined) { return }
if (canvas.designSpace.workspace === undefined) { 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
}
let rootNodes = canvas.designSpace.workspace.workspaceNode.rootNodes
for (let i = 0; i < rootNodes.length; i++) {
let rootNode = rootNodes[i]
if (rootNode !== null) {
if (rootNode.type === 'Charting Space') {
thisObject.payload = rootNode.payload
}
}
}
thisObject.viewport.initialize()
if (thisObject.payload === undefined) {
// if (ERROR_LOG === true) { logger.write('[WARN] initialize -> There must exist a Charting Space at the Design Space in order to enable Charts. PLease create one and refreash your browser. ') }
return
}
canvasBrowserResizedEventSubscriptionId = canvas.eventHandler.listenToEvent('Browser Resized', resize)
isInitialized = true
}
function getContainer (point, purpose) {
if (thisObject.visible !== true) { return }
if (thisObject.viewport === undefined) { return }
if (thisObject.viewport.isThisPointInViewport(point) === false) { return }
let container
/* 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.
In this case we will ask all the time machines even if one of them already returned a matching container.
This will help the others know they are not on ofcus
*/
let containerFound
for (let i = 0; i < thisObject.timeMachines.length; i++) {
container = thisObject.timeMachines[i].getContainer(point, purpose)
if (container !== undefined) {
if (purpose !== undefined) {
if (containerFound === undefined) {
containerFound = container
}
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 {
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
if (containerFound === undefined) {
containerFound = container
}
}
thisObject.viewport.payload = thisObject.payload.node.viewport.payload
}
}
}
if (containerFound !== undefined) {
containerFound.space = 'Charting Space'
return containerFound
thisObject.viewport.initialize()
canvasBrowserResizedEventSubscriptionId = canvas.eventHandler.listenToEvent('Browser Resized', resize)
isInitialized = true
}
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
thisObject.container.space = 'Charting Space'
return thisObject.container
} else {
return undefined
}
}
function getContainer(point, purpose) {
if (thisObject.visible !== true) { return }
if (thisObject.viewport === undefined) { return }
if (thisObject.viewport.isThisPointInViewport(point) === false) { return }
function resize () {
thisObject.viewport.resize()
thisObject.container.frame.width = browserCanvas.width
thisObject.container.frame.height = COCKPIT_SPACE_POSITION
}
let container
function oneScreenUp () {
if (thisObject.visible === false) { return }
let displaceVector = {
x: 0,
y: browserCanvas.height * PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT / 100
}
canvas.chartingSpace.viewport.displace(displaceVector)
}
function oneScreenDown () {
if (thisObject.visible === false) { return }
let displaceVector = {
x: 0,
y: -browserCanvas.height * PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT / 100
}
canvas.chartingSpace.viewport.displace(displaceVector)
}
function oneScreenLeft () {
if (thisObject.visible === false) { return }
let displaceVector = {
x: browserCanvas.width * PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT / 100,
y: 0
}
canvas.chartingSpace.viewport.displace(displaceVector, true)
}
function oneScreenRight () {
if (thisObject.visible === false) { return }
let displaceVector = {
x: -browserCanvas.width * PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT / 100,
y: 0
}
canvas.chartingSpace.viewport.displace(displaceVector, true)
}
function fitFunction (point, fullVisible) {
/* Here we check the boundaries of the resulting points, so they dont go out of the visible area. */
let returnPoint = {
x: point.x,
y: point.y
}
if (point.x > browserCanvas.width) {
returnPoint.x = browserCanvas.width
}
if (point.x < 0) {
returnPoint.x = 0
}
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 < TOP_SPACE_HEIGHT) {
returnPoint.y = TOP_SPACE_HEIGHT
}
return returnPoint
}
function isThisPointVisible (point) {
if (point.x > browserCanvas.width) {
return false
}
if (point.x < 0) {
return false
}
if (point.y > COCKPIT_SPACE_POSITION + COCKPIT_SPACE_HEIGHT / 2) {
return false
}
if (point.y < 0) {
return false
}
return true
}
function physics () {
initialize()
thisObjectPhysics()
if (thisObject.visible !== true) { return }
if (thisObject.viewport !== undefined) {
thisObject.viewport.physics()
}
childrenPhysics()
syncWithDesigner()
}
function onKeyPressed (event) {
if (thisObject.visible !== true) { return }
for (let j = 0; j < thisObject.timeMachines.length; j++) {
let timeMachine = thisObject.timeMachines[j]
if (timeMachine.onFocus === true) {
timeMachine.onKeyPressed(event)
}
}
}
function syncWithDesigner () {
if (thisObject.payload === undefined) { return }
if (thisObject.payload.node === undefined) { return }
syncWithDesignerLoop = syncWithDesignerLoop + 0.00000000001
if (thisObject.payload.node.dashboards !== undefined) {
for (let i = 0; i < thisObject.payload.node.dashboards.length; i++) {
let dashboard = thisObject.payload.node.dashboards[i]
if (dashboard.timeMachines !== undefined) {
for (let j = 0; j < dashboard.timeMachines.length; j++) {
let node = dashboard.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
/* 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.
In this case we will ask all the time machines even if one of them already returned a matching container.
This will help the others know they are not on ofcus
*/
let containerFound
for (let i = 0; i < thisObject.timeMachines.length; i++) {
container = thisObject.timeMachines[i].getContainer(point, purpose)
if (container !== undefined) {
if (purpose !== undefined) {
if (containerFound === undefined) {
containerFound = container
}
} else {
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
if (containerFound === undefined) {
containerFound = container
}
}
}
}
}
if (containerFound !== undefined) {
containerFound.space = 'Charting Space'
return containerFound
}
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
thisObject.container.space = 'Charting Space'
return thisObject.container
} else {
return undefined
}
}
/* 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.nodeId)
thisObject.timeMachines.splice(i, 1)
/* We remove one at the time */
return
}
function resize() {
thisObject.viewport.resize()
thisObject.container.frame.width = browserCanvas.width
thisObject.container.frame.height = COCKPIT_SPACE_POSITION
}
function initializeTimeMachine (node, syncWithDesignerLoop) {
if (node.payload === undefined) { return } // not ready to consider this Time Machine
if (node.payload.uiObject === undefined) { return }
function oneScreenUp() {
if (thisObject.visible === false) { return }
let displaceVector = {
x: 0,
y: browserCanvas.height * PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT / 100
}
let timeMachine = newTimeMachine()
timeMachine.syncWithDesignerLoop = syncWithDesignerLoop
timeMachine.payload = node.payload
timeMachine.nodeId = node.id
canvas.chartingSpace.viewport.displace(displaceVector)
}
timeMachinesMap.set(node.id, timeMachine)
timeMachine.payload.uiObject.setValue('Loading...')
function oneScreenDown() {
if (thisObject.visible === false) { return }
let displaceVector = {
x: 0,
y: -browserCanvas.height * PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT / 100
}
/* Setting up the new time machine. */
timeMachine.container.frame.position.x = browserCanvas.width / 2 - browserCanvas.width / TIME_MACHINE_WIDTH / 2
timeMachine.container.frame.position.y = browserCanvas.height / 2 - (browserCanvas.height - TOP_SPACE_HEIGHT - COCKPIT_SPACE_HEIGHT) / TIME_MACHINE_HEIGHT / 2
timeMachine.initialize(onTimeMachineInitialized)
canvas.chartingSpace.viewport.displace(displaceVector)
}
function oneScreenLeft() {
if (thisObject.visible === false) { return }
let displaceVector = {
x: browserCanvas.width * PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT / 100,
y: 0
}
canvas.chartingSpace.viewport.displace(displaceVector, true)
}
function oneScreenRight() {
if (thisObject.visible === false) { return }
let displaceVector = {
x: -browserCanvas.width * PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT / 100,
y: 0
}
canvas.chartingSpace.viewport.displace(displaceVector, true)
}
function fitFunction(point, fullVisible) {
/* Here we check the boundaries of the resulting points, so they dont go out of the visible area. */
let returnPoint = {
x: point.x,
y: point.y
}
if (point.x > browserCanvas.width) {
returnPoint.x = browserCanvas.width
}
if (point.x < 0) {
returnPoint.x = 0
}
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 < TOP_SPACE_HEIGHT) {
returnPoint.y = TOP_SPACE_HEIGHT
}
return returnPoint
}
function isThisPointVisible(point) {
if (point.x > browserCanvas.width) {
return false
}
if (point.x < 0) {
return false
}
if (point.y > COCKPIT_SPACE_POSITION + COCKPIT_SPACE_HEIGHT / 2) {
return false
}
if (point.y < 0) {
return false
}
return true
}
function physics() {
initialize()
thisObjectPhysics()
if (thisObject.visible !== true) { return }
if (thisObject.viewport !== undefined) {
thisObject.viewport.physics()
}
childrenPhysics()
syncWithDesigner()
}
function onKeyPressed(event) {
if (thisObject.visible !== true) { return }
for (let j = 0; j < thisObject.timeMachines.length; j++) {
let timeMachine = thisObject.timeMachines[j]
if (timeMachine.onFocus === true) {
timeMachine.onKeyPressed(event)
}
}
}
function syncWithDesigner() {
if (thisObject.payload === undefined) { return }
if (thisObject.payload.node === undefined) { return }
syncWithDesignerLoop = syncWithDesignerLoop + 0.00000000001
if (thisObject.payload.node.dashboards !== undefined) {
for (let i = 0; i < thisObject.payload.node.dashboards.length; i++) {
let dashboard = thisObject.payload.node.dashboards[i]
if (dashboard.timeMachines !== undefined) {
for (let j = 0; j < dashboard.timeMachines.length; j++) {
let node = dashboard.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.nodeId)
thisObject.timeMachines.splice(i, 1)
/* We remove one at the time */
return
}
}
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...')
/* Setting up the new time machine. */
timeMachine.container.frame.position.x = browserCanvas.width / 2 - browserCanvas.width / TIME_MACHINE_WIDTH / 2
timeMachine.container.frame.position.y = browserCanvas.height / 2 - (browserCanvas.height - TOP_SPACE_HEIGHT - COCKPIT_SPACE_HEIGHT) / TIME_MACHINE_HEIGHT / 2
timeMachine.initialize(onTimeMachineInitialized)
function onTimeMachineInitialized() {
thisObject.timeMachines.push(timeMachine)
timeMachine.payload.uiObject.setValue('')
if (canvas.chartingSpace.viewport !== undefined) {
canvas.chartingSpace.viewport.raiseEvents() // These events will impacts on objects just initialized.
}
}
}
}
function thisObjectPhysics() {
thisObject.container.frame.height = COCKPIT_SPACE_POSITION
if (thisObject.container.frame.height <= TOP_SPACE_HEIGHT) {
thisObject.visible = false
if (thisObject.viewport !== undefined) {
thisObject.viewport.visible = false
}
} else {
thisObject.visible = true
if (thisObject.viewport !== undefined) {
thisObject.viewport.visible = true
}
}
function onTimeMachineInitialized () {
thisObject.timeMachines.push(timeMachine)
timeMachine.payload.uiObject.setValue('')
if (canvas.chartingSpace.viewport !== undefined) {
canvas.chartingSpace.viewport.raiseEvents() // These events will impacts on objects just initialized.
canvas.chartingSpace.viewport.resize()
}
}
}
}
function thisObjectPhysics () {
thisObject.container.frame.height = COCKPIT_SPACE_POSITION
if (thisObject.container.frame.height <= TOP_SPACE_HEIGHT) {
thisObject.visible = false
if (thisObject.viewport !== undefined) {
thisObject.viewport.visible = false
}
} else {
thisObject.visible = true
if (thisObject.viewport !== undefined) {
thisObject.viewport.visible = true
}
}
if (canvas.chartingSpace.viewport !== undefined) {
canvas.chartingSpace.viewport.resize()
}
}
function childrenPhysics() {
for (let i = 0; i < thisObject.timeMachines.length; i++) {
let timeMachine = thisObject.timeMachines[i]
if (timeMachine.payload.node === undefined) {
continue
}
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()) {
thisObject.inViewport.set(timeMachine.payload.node.id, timeMachine)
} else {
thisObject.inViewport.delete(timeMachine.payload.node.id)
}
timeMachine.physics()
}
}
function drawBackground () {
if (thisObject.visible === false) { return }
drawSpaceBackground()
for (let i = 0; i < thisObject.timeMachines.length; i++) {
let timeMachine = thisObject.timeMachines[thisObject.timeMachines.length - i - 1]
timeMachine.drawBackground()
}
}
function draw () {
if (canWeDraw === false) { return }
if (thisObject.visible === false) { return }
drawBackground()
for (let i = 0; i < thisObject.timeMachines.length; i++) {
let timeMachine = thisObject.timeMachines[thisObject.timeMachines.length - i - 1]
timeMachine.draw()
if (timeMachine.container.frame.isInViewPort()) {
thisObject.inViewport.set(timeMachine.payload.node.id, timeMachine)
} else {
thisObject.inViewport.delete(timeMachine.payload.node.id)
}
timeMachine.physics()
}
}
drawForeground()
}
function drawBackground() {
if (thisObject.visible === false) { return }
drawSpaceBackground()
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 = {
x: 0,
y: 0
for (let i = 0; i < thisObject.timeMachines.length; i++) {
let timeMachine = thisObject.timeMachines[thisObject.timeMachines.length - i - 1]
timeMachine.drawBackground()
}
}
let toPoint = {
x: browserCanvas.width,
y: COCKPIT_SPACE_POSITION
function draw() {
if (canWeDraw === false) { return }
if (thisObject.visible === false) { return }
drawBackground()
for (let i = 0; i < thisObject.timeMachines.length; i++) {
let timeMachine = thisObject.timeMachines[thisObject.timeMachines.length - i - 1]
timeMachine.draw()
}
drawForeground()
}
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()
}
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 = {
x: 0,
y: 0
}
let toPoint = {
x: browserCanvas.width,
y: COCKPIT_SPACE_POSITION
}
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()
}
}
+307 -307
View File
@@ -1,370 +1,370 @@
function newCockpitSpace () {
const MODULE_NAME = 'CockpitSpace'
const STATUS_TYPES = {
ALL_GOOD: 1,
WARNING: 2
}
let thisObject = {
container: undefined,
status: 'BOTTOM',
fullscreen: undefined,
statusTypes: STATUS_TYPES,
setStatus: setStatus,
toTop: toTop,
toBottom: toBottom,
toMiddle: toMiddle,
moveUp: moveUp,
moveDown: moveDown,
draw: draw,
physics: physics,
getContainer: getContainer,
finalize: finalize,
initialize: initialize,
initializePosition: initializePosition
}
function newCockpitSpace() {
const MODULE_NAME = 'CockpitSpace'
const STATUS_TYPES = {
ALL_GOOD: 1,
WARNING: 2
}
let thisObject = {
container: undefined,
status: 'BOTTOM',
fullscreen: undefined,
statusTypes: STATUS_TYPES,
setStatus: setStatus,
toTop: toTop,
toBottom: toBottom,
toMiddle: toMiddle,
moveUp: moveUp,
moveDown: moveDown,
draw: draw,
physics: physics,
getContainer: getContainer,
finalize: finalize,
initialize: initialize,
initializePosition: initializePosition
}
thisObject.container = newContainer()
thisObject.container.initialize(MODULE_NAME)
thisObject.container.isClickeable = false
thisObject.container.detectMouseOver = true
thisObject.container.isDraggeable = true
thisObject.container.notDraggingOnX = true
thisObject.container = newContainer()
thisObject.container.initialize(MODULE_NAME)
thisObject.container.isClickeable = false
thisObject.container.detectMouseOver = true
thisObject.container.isDraggeable = true
thisObject.container.notDraggingOnX = true
controlsMap = new Map()
resize()
controlsMap = new Map()
resize()
let selfMouseClickEventSubscriptionId
let canvasBrowserResizedEventSubscriptionId
let selfMouseClickEventSubscriptionId
let canvasBrowserResizedEventSubscriptionId
let statusCounter = 0
let statusText
let statusType
let isInitilized = false
let statusCounter = 0
let statusText
let statusType
let isInitilized = false
return thisObject
return thisObject
function finalize () {
thisObject.container.eventHandler.stopListening(selfMouseClickEventSubscriptionId)
thisObject.container.eventHandler.stopListening(canvasBrowserResizedEventSubscriptionId)
function finalize() {
thisObject.container.eventHandler.stopListening(selfMouseClickEventSubscriptionId)
thisObject.container.eventHandler.stopListening(canvasBrowserResizedEventSubscriptionId)
thisObject.container.finalize()
thisObject.container = undefined
thisObject.fullscreen = undefined
}
thisObject.container.finalize()
thisObject.container = undefined
thisObject.fullscreen = undefined
}
function initialize () {
canvasBrowserResizedEventSubscriptionId = canvas.eventHandler.listenToEvent('Browser Resized', resize)
selfMouseClickEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick)
function initialize() {
canvasBrowserResizedEventSubscriptionId = canvas.eventHandler.listenToEvent('Browser Resized', resize)
selfMouseClickEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick)
thisObject.fullscreen = newFullScreen()
thisObject.fullscreen.container.connectToParent(thisObject.container)
thisObject.fullscreen.initialize()
}
thisObject.fullscreen = newFullScreen()
thisObject.fullscreen.container.connectToParent(thisObject.container)
thisObject.fullscreen.initialize()
}
function initializePosition () {
thisObject.container.frame.position.x = 0
function initializePosition() {
thisObject.container.frame.position.x = 0
let INITIAL_POSITION
if (canvas.designSpace.workspace.enabled === true) {
let localStorage = window.localStorage.getItem(MODULE_NAME)
if (localStorage !== null) {
storage = JSON.parse(localStorage)
thisObject.container.frame.position.y = storage.spacePosition
} else {
INITIAL_POSITION = 55
thisObject.container.frame.position.y = browserCanvas.height * INITIAL_POSITION / 100 - COCKPIT_SPACE_HEIGHT
}
} else {
INITIAL_POSITION = 100
thisObject.container.frame.position.y = browserCanvas.height * INITIAL_POSITION / 100 - COCKPIT_SPACE_HEIGHT
}
isInitilized = true
}
let INITIAL_POSITION
if (canvas.designSpace.workspace.enabled === true) {
let localStorage = window.localStorage.getItem(MODULE_NAME)
if (localStorage !== null) {
storage = JSON.parse(localStorage)
thisObject.container.frame.position.y = storage.spacePosition
} else {
INITIAL_POSITION = 55
thisObject.container.frame.position.y = browserCanvas.height * INITIAL_POSITION / 100 - COCKPIT_SPACE_HEIGHT
}
} else {
INITIAL_POSITION = 100
thisObject.container.frame.position.y = browserCanvas.height * INITIAL_POSITION / 100 - COCKPIT_SPACE_HEIGHT
}
isInitilized = true
}
function onMouseClick (event) {
function onMouseClick(event) {
}
}
function setStatus (text, counter, type) {
statusCounter = counter
statusText = text
statusType = type
}
function setStatus(text, counter, type) {
statusCounter = counter
statusText = text
statusType = type
}
function resize () {
thisObject.container.frame.width = browserCanvas.width
thisObject.container.frame.height = COCKPIT_SPACE_HEIGHT
function resize() {
thisObject.container.frame.width = browserCanvas.width
thisObject.container.frame.height = COCKPIT_SPACE_HEIGHT
switch (thisObject.status) {
case 'BOTTOM': {
thisObject.container.frame.position.y = browserCanvas.height - COCKPIT_SPACE_HEIGHT
break
}
case 'TOP': {
thisObject.container.frame.position.y = TOP_SPACE_HEIGHT
break
}
}
}
switch (thisObject.status) {
case 'BOTTOM': {
thisObject.container.frame.position.y = browserCanvas.height - COCKPIT_SPACE_HEIGHT
break
}
case 'TOP': {
thisObject.container.frame.position.y = TOP_SPACE_HEIGHT
break
}
}
}
function toTop () {
thisObject.container.frame.position.y = COCKPIT_SPACE_HEIGHT
}
function toTop() {
thisObject.container.frame.position.y = COCKPIT_SPACE_HEIGHT
}
function toBottom () {
thisObject.container.frame.position.y = browserCanvas.height - COCKPIT_SPACE_HEIGHT
}
function toBottom() {
thisObject.container.frame.position.y = browserCanvas.height - COCKPIT_SPACE_HEIGHT
}
function toMiddle () {
thisObject.container.frame.position.y = browserCanvas.height / 2 - COCKPIT_SPACE_HEIGHT
}
function toMiddle() {
thisObject.container.frame.position.y = browserCanvas.height / 2 - COCKPIT_SPACE_HEIGHT
}
function moveUp () {
thisObject.container.frame.position.y = thisObject.container.frame.position.y - COCKPIT_SPACE_HEIGHT * 2
if (thisObject.container.frame.position.y < 0) {
thisObject.container.frame.position.y = 0
}
}
function moveUp() {
thisObject.container.frame.position.y = thisObject.container.frame.position.y - COCKPIT_SPACE_HEIGHT * 2
if (thisObject.container.frame.position.y < 0) {
thisObject.container.frame.position.y = 0
}
}
function moveDown () {
thisObject.container.frame.position.y = thisObject.container.frame.position.y + COCKPIT_SPACE_HEIGHT * 2
if (thisObject.container.frame.position.y > browserCanvas.height - COCKPIT_SPACE_HEIGHT) {
thisObject.container.frame.position.y = browserCanvas.height - COCKPIT_SPACE_HEIGHT
}
}
function moveDown() {
thisObject.container.frame.position.y = thisObject.container.frame.position.y + COCKPIT_SPACE_HEIGHT * 2
if (thisObject.container.frame.position.y > browserCanvas.height - COCKPIT_SPACE_HEIGHT) {
thisObject.container.frame.position.y = browserCanvas.height - COCKPIT_SPACE_HEIGHT
}
}
function statusPhysics () {
statusCounter--
if (statusCounter < 0) {
statusCounter = 0
statusText = undefined,
statusType = undefined
}
}
function statusPhysics() {
statusCounter--
if (statusCounter < 0) {
statusCounter = 0
statusText = undefined,
statusType = undefined
}
}
function physics () {
thisObjectPhysics()
childrenPhysics()
statusPhysics()
}
function physics() {
thisObjectPhysics()
childrenPhysics()
statusPhysics()
}
function childrenPhysics () {
thisObject.fullscreen.physics()
}
function thisObjectPhysics () {
if (isInitilized === false) { return }
/* Check the limits */
function childrenPhysics() {
thisObject.fullscreen.physics()
}
function thisObjectPhysics() {
if (isInitilized === false) { return }
/* Check the limits */
thisObject.status = 'MIDDLE'
thisObject.status = 'MIDDLE'
if (canvas.designSpace.workspace.enabled === true) {
thisObject.container.isDraggeable = true
} else {
thisObject.container.isDraggeable = false
}
if (canvas.designSpace.workspace.enabled === true) {
thisObject.container.isDraggeable = true
} else {
thisObject.container.isDraggeable = false
}
if (thisObject.container.frame.position.y > browserCanvas.height * 99.5 / 100 - COCKPIT_SPACE_HEIGHT) {
thisObject.container.frame.position.y = browserCanvas.height - COCKPIT_SPACE_HEIGHT
thisObject.status = 'BOTTOM'
canvas.designSpace.makeInvisible()
canvas.floatingSpace.makeInvisible()
} else {
canvas.designSpace.makeVisible()
canvas.floatingSpace.makeVisible()
}
if (thisObject.container.frame.position.y > browserCanvas.height * 99.5 / 100 - COCKPIT_SPACE_HEIGHT) {
thisObject.container.frame.position.y = browserCanvas.height - COCKPIT_SPACE_HEIGHT
thisObject.status = 'BOTTOM'
canvas.designSpace.makeInvisible()
canvas.floatingSpace.makeInvisible()
} else {
canvas.designSpace.makeVisible()
canvas.floatingSpace.makeVisible()
}
if (thisObject.container.frame.position.y < browserCanvas.height * 0.5 / 100 + TOP_SPACE_HEIGHT) {
thisObject.container.frame.position.y = TOP_SPACE_HEIGHT
thisObject.status = 'TOP'
canvas.panelsSpace.visible = false
} else {
canvas.panelsSpace.visible = true
}
if (thisObject.container.frame.position.y < browserCanvas.height * 0.5 / 100 + TOP_SPACE_HEIGHT) {
thisObject.container.frame.position.y = TOP_SPACE_HEIGHT
thisObject.status = 'TOP'
canvas.panelsSpace.visible = false
} else {
canvas.panelsSpace.visible = true
}
COCKPIT_SPACE_POSITION = thisObject.container.frame.position.y
let storage = {
spacePosition: COCKPIT_SPACE_POSITION
}
window.localStorage.setItem(MODULE_NAME, JSON.stringify(storage))
if (canvas.chartingSpace.viewport !== undefined) {
canvas.chartingSpace.viewport.resize()
}
}
COCKPIT_SPACE_POSITION = thisObject.container.frame.position.y
let storage = {
spacePosition: COCKPIT_SPACE_POSITION
}
window.localStorage.setItem(MODULE_NAME, JSON.stringify(storage))
if (canvas.chartingSpace.viewport !== undefined) {
canvas.chartingSpace.viewport.resize()
}
}
function getContainer (point) {
let container
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) {
thisObject.container.space = 'Cockpit Space'
return thisObject.container
} else {
return undefined
}
}
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
thisObject.container.space = 'Cockpit Space'
return thisObject.container
} else {
return undefined
}
}
function draw () {
if (canWeDraw === false) { return }
thisObject.container.frame.draw(false, false)
function draw() {
if (canWeDraw === false) { return }
thisObject.container.frame.draw(false, false)
drawBackground()
drawBackground()
// thisObject.fullscreen.draw()
}
// thisObject.fullscreen.draw()
}
function drawBackground () {
let opacity = 1
function drawBackground() {
let opacity = 1
let zeroPoint = {
x: 0,
y: 0
}
let zeroPoint = {
x: 0,
y: 0
}
const RED_LINE_HIGHT = 2
const RED_LINE_HIGHT = 2
zeroPoint = thisObject.container.frame.frameThisPoint(zeroPoint)
zeroPoint = thisObject.container.frame.frameThisPoint(zeroPoint)
let barColor = UI_COLOR.DARK_TURQUOISE // default
let textColor
let barColor = UI_COLOR.DARK_TURQUOISE // default
let textColor
if (statusType !== undefined) {
switch (statusType) {
case STATUS_TYPES.ALL_GOOD:
{
barColor = UI_COLOR.PATINATED_TURQUOISE
textColor = UI_COLOR.WHITE
break
}
case STATUS_TYPES.WARNING:
{
barColor = UI_COLOR.RED
textColor = UI_COLOR.TITANIUM_YELLOW
break
}
}
}
if (statusType !== undefined) {
switch (statusType) {
case STATUS_TYPES.ALL_GOOD:
{
barColor = UI_COLOR.PATINATED_TURQUOISE
textColor = UI_COLOR.WHITE
break
}
case STATUS_TYPES.WARNING:
{
barColor = UI_COLOR.RED
textColor = UI_COLOR.TITANIUM_YELLOW
break
}
}
}
browserCanvasContext.beginPath()
browserCanvasContext.rect(zeroPoint.x, zeroPoint.y, thisObject.container.frame.width, thisObject.container.frame.height)
browserCanvasContext.fillStyle = 'rgba(' + barColor + ', ' + opacity + ')'
browserCanvasContext.closePath()
browserCanvasContext.fill()
browserCanvasContext.beginPath()
browserCanvasContext.rect(zeroPoint.x, zeroPoint.y, thisObject.container.frame.width, thisObject.container.frame.height)
browserCanvasContext.fillStyle = 'rgba(' + barColor + ', ' + opacity + ')'
browserCanvasContext.closePath()
browserCanvasContext.fill()
browserCanvasContext.beginPath()
browserCanvasContext.rect(zeroPoint.x, zeroPoint.y, thisObject.container.frame.width, RED_LINE_HIGHT)
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.RUSTED_RED + ', ' + opacity + ')'
browserCanvasContext.closePath()
browserCanvasContext.fill()
browserCanvasContext.beginPath()
browserCanvasContext.rect(zeroPoint.x, zeroPoint.y, thisObject.container.frame.width, RED_LINE_HIGHT)
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.RUSTED_RED + ', ' + opacity + ')'
browserCanvasContext.closePath()
browserCanvasContext.fill()
browserCanvasContext.beginPath()
browserCanvasContext.rect(zeroPoint.x, zeroPoint.y - RED_LINE_HIGHT + thisObject.container.frame.height, thisObject.container.frame.width, RED_LINE_HIGHT)
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.RUSTED_RED + ', ' + opacity + ')'
browserCanvasContext.closePath()
browserCanvasContext.fill()
browserCanvasContext.beginPath()
browserCanvasContext.rect(zeroPoint.x, zeroPoint.y - RED_LINE_HIGHT + thisObject.container.frame.height, thisObject.container.frame.width, RED_LINE_HIGHT)
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.RUSTED_RED + ', ' + opacity + ')'
browserCanvasContext.closePath()
browserCanvasContext.fill()
if (statusText !== undefined) {
let position = {
x: thisObject.container.frame.width / 2,
y: thisObject.container.frame.height / 2 + 5
}
printLabel(statusText, position.x, position.y, 1, 15, textColor, true, thisObject.container)
}
if (statusText !== undefined) {
let position = {
x: thisObject.container.frame.width / 2,
y: thisObject.container.frame.height / 2 + 5
}
printLabel(statusText, position.x, position.y, 1, 15, textColor, true, thisObject.container)
}
if (canvas.designSpace !== undefined) {
if (canvas.designSpace.workspace.enabled === true && statusText === undefined) {
arrow()
}
}
}
if (canvas.designSpace !== undefined) {
if (canvas.designSpace.workspace.enabled === true && statusText === undefined) {
arrow()
}
}
}
function arrow () {
const X_OFFSET = thisObject.container.frame.width / 2
const Y_OFFSET = thisObject.container.frame.height / 2
const HEIGHT = 6
const WIDTH = 18
const LINE_WIDTH = 3
const OPACITY = 1
let DISTANCE_BETWEEN_ARROWS = 0
let ARROW_1_DIRECTION = 0
let ARROW_2_DIRECTION = 0
function arrow() {
const X_OFFSET = thisObject.container.frame.width / 2
const Y_OFFSET = thisObject.container.frame.height / 2
const HEIGHT = 6
const WIDTH = 18
const LINE_WIDTH = 3
const OPACITY = 1
let DISTANCE_BETWEEN_ARROWS = 0
let ARROW_1_DIRECTION = 0
let ARROW_2_DIRECTION = 0
switch (thisObject.status) {
switch (thisObject.status) {
case ('TOP'): {
ARROW_1_DIRECTION = -1
ARROW_2_DIRECTION = -1
DISTANCE_BETWEEN_ARROWS = 6
break
}
case ('MIDDLE'): {
ARROW_1_DIRECTION = 1
ARROW_2_DIRECTION = -1
DISTANCE_BETWEEN_ARROWS = 9
break
}
case ('BOTTOM'): {
ARROW_1_DIRECTION = 1
ARROW_2_DIRECTION = 1
DISTANCE_BETWEEN_ARROWS = 6
break
}
}
case ('TOP'): {
ARROW_1_DIRECTION = -1
ARROW_2_DIRECTION = -1
DISTANCE_BETWEEN_ARROWS = 6
break
}
case ('MIDDLE'): {
ARROW_1_DIRECTION = 1
ARROW_2_DIRECTION = -1
DISTANCE_BETWEEN_ARROWS = 9
break
}
case ('BOTTOM'): {
ARROW_1_DIRECTION = 1
ARROW_2_DIRECTION = 1
DISTANCE_BETWEEN_ARROWS = 6
break
}
}
point1 = {
x: X_OFFSET - WIDTH / 2,
y: Y_OFFSET + HEIGHT / 2 * ARROW_1_DIRECTION - DISTANCE_BETWEEN_ARROWS / 2
}
point1 = {
x: X_OFFSET - WIDTH / 2,
y: Y_OFFSET + HEIGHT / 2 * ARROW_1_DIRECTION - DISTANCE_BETWEEN_ARROWS / 2
}
point2 = {
x: X_OFFSET,
y: Y_OFFSET - HEIGHT / 2 * ARROW_1_DIRECTION - DISTANCE_BETWEEN_ARROWS / 2
}
point2 = {
x: X_OFFSET,
y: Y_OFFSET - HEIGHT / 2 * ARROW_1_DIRECTION - DISTANCE_BETWEEN_ARROWS / 2
}
point3 = {
x: X_OFFSET + WIDTH / 2,
y: Y_OFFSET + HEIGHT / 2 * ARROW_1_DIRECTION - DISTANCE_BETWEEN_ARROWS / 2
}
point3 = {
x: X_OFFSET + WIDTH / 2,
y: Y_OFFSET + HEIGHT / 2 * ARROW_1_DIRECTION - DISTANCE_BETWEEN_ARROWS / 2
}
point1 = thisObject.container.frame.frameThisPoint(point1)
point2 = thisObject.container.frame.frameThisPoint(point2)
point3 = thisObject.container.frame.frameThisPoint(point3)
point1 = thisObject.container.frame.frameThisPoint(point1)
point2 = thisObject.container.frame.frameThisPoint(point2)
point3 = thisObject.container.frame.frameThisPoint(point3)
point4 = {
x: X_OFFSET - WIDTH / 2,
y: Y_OFFSET + HEIGHT / 2 * ARROW_2_DIRECTION + DISTANCE_BETWEEN_ARROWS / 2
}
point4 = {
x: X_OFFSET - WIDTH / 2,
y: Y_OFFSET + HEIGHT / 2 * ARROW_2_DIRECTION + DISTANCE_BETWEEN_ARROWS / 2
}
point5 = {
x: X_OFFSET,
y: Y_OFFSET - HEIGHT / 2 * ARROW_2_DIRECTION + DISTANCE_BETWEEN_ARROWS / 2
}
point5 = {
x: X_OFFSET,
y: Y_OFFSET - HEIGHT / 2 * ARROW_2_DIRECTION + DISTANCE_BETWEEN_ARROWS / 2
}
point6 = {
x: X_OFFSET + WIDTH / 2,
y: Y_OFFSET + HEIGHT / 2 * ARROW_2_DIRECTION + DISTANCE_BETWEEN_ARROWS / 2
}
point6 = {
x: X_OFFSET + WIDTH / 2,
y: Y_OFFSET + HEIGHT / 2 * ARROW_2_DIRECTION + DISTANCE_BETWEEN_ARROWS / 2
}
point4 = thisObject.container.frame.frameThisPoint(point4)
point5 = thisObject.container.frame.frameThisPoint(point5)
point6 = thisObject.container.frame.frameThisPoint(point6)
point4 = thisObject.container.frame.frameThisPoint(point4)
point5 = thisObject.container.frame.frameThisPoint(point5)
point6 = thisObject.container.frame.frameThisPoint(point6)
browserCanvasContext.setLineDash([0, 0])
browserCanvasContext.setLineDash([0, 0])
browserCanvasContext.beginPath()
browserCanvasContext.beginPath()
browserCanvasContext.moveTo(point1.x, point1.y)
browserCanvasContext.lineTo(point2.x, point2.y)
browserCanvasContext.lineTo(point3.x, point3.y)
browserCanvasContext.moveTo(point1.x, point1.y)
browserCanvasContext.lineTo(point2.x, point2.y)
browserCanvasContext.lineTo(point3.x, point3.y)
browserCanvasContext.moveTo(point4.x, point4.y)
browserCanvasContext.lineTo(point5.x, point5.y)
browserCanvasContext.lineTo(point6.x, point6.y)
browserCanvasContext.moveTo(point4.x, point4.y)
browserCanvasContext.lineTo(point5.x, point5.y)
browserCanvasContext.lineTo(point6.x, point6.y)
browserCanvasContext.lineWidth = LINE_WIDTH
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.WHITE + ', ' + OPACITY + ')'
browserCanvasContext.stroke()
}
}
browserCanvasContext.lineWidth = LINE_WIDTH
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.WHITE + ', ' + OPACITY + ')'
browserCanvasContext.stroke()
}
}
+337 -337
View File
@@ -1,351 +1,351 @@
function newDesignSpace () {
const MODULE_NAME = 'Designe Space'
let thisObject = {
sidePanel: undefined,
container: undefined,
iconCollection: undefined,
iconByUiObjectType: undefined,
workspace: undefined,
physics: physics,
draw: draw,
getContainer: getContainer,
makeVisible: makeVisible,
makeInvisible: makeInvisible,
initialize: initialize
}
let container = newContainer()
container.initialize()
thisObject.container = container
container.isDraggeable = false
thisObject.iconCollection = new Map()
thisObject.iconByUiObjectType = new Map()
return thisObject
function initialize () {
loadIconCollection()
buildIconByUiObjectTypeMap()
thisObject.workspace = newWorkspace()
thisObject.workspace.initialize()
}
function buildIconByUiObjectTypeMap () {
/* Take types-icons relationships defined at the schema */
for (let i = 0; i < APP_SCHEMA_ARRAY.length; i++) {
let nodeDefinition = APP_SCHEMA_ARRAY[i]
let iconName = nodeDefinition.icon
if (iconName !== undefined) {
let icon = thisObject.iconCollection.get(iconName)
thisObject.iconByUiObjectType.set(nodeDefinition.type, icon)
}
}
}
function loadIconCollection () {
const iconsNames = [
'analysis',
'analysis-1',
'approve',
'attach',
'attractive',
'pyramid',
'brainstorming',
'broken-link',
'chat',
'chronometer',
'compass',
'competition',
'content',
'design-tool',
'grid',
'headphones',
'html',
'image',
'layout',
'loading',
'login',
'pantone',
'paper-plane',
'photo-camera',
'piggy-bank',
'pipette',
'pixel',
'placeholder',
'planning',
'promotion',
'pyramid',
'quality',
'responsive',
'schedule',
'search',
'security',
'settings',
'sitemap',
'startup',
'support',
'tap',
'menu-fix-pinned',
'menu-fix-unpinned',
'targeting',
'task',
'testing',
'text',
'timeline',
'tools',
'delete',
'upload',
'vector',
'video-player',
'menu-mobility-freeze',
'menu-mobility-unfreeze',
'menu-tree-minus',
'menu-tree-plus',
'menu-backup',
'menu-share',
'stop',
'stage-open',
'stage-close',
'stage-trigger',
'stage-trigger-trigger-on',
'stage-trigger-trigger-off',
'stage-trigger-take-position',
'menu-tensor-fixed-angles',
'menu-tensor-free-angles',
'stage-open-position-size',
'stage-open-take-profit',
'stage-open-postion-rate',
'session-live-trading',
'session-paper-trading',
'session-backtesting',
'session-forward-testing',
'network',
'network-node',
'bot-trading',
'layer-manager',
'process',
'bot-indicator',
'bot-sensor',
'time-period',
'data-mine',
'procedure-loop',
'calculations-procedure',
'data-building-procedure',
'procedure-initialization',
'process-definition',
'output-dataset',
'data-dependency',
'product-definition',
'plotter-module',
'status-dependency',
'record-property',
'record-definition',
'plotter',
'plotter-panel',
'dataset-definition',
'status-report',
'execution-finished-event',
'process-dependencies',
'process-output',
'social-bot',
'execution-started-event',
'shapes',
'chart-point',
'style',
'chart-points',
'shapes-polygon-vertex',
'shapes-polygon-border',
'shapes-polygon-body',
'chart-point-formula',
'style-condition',
'shapes-polygon',
'data-entry',
'data-formula',
'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-space',
'time-line-chart',
'time-frame-scale',
'time-scale',
'rate-scale',
'time-machine',
'data-product',
'single-market-data',
'data-storage',
'dataset',
'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',
'trend',
'oscillator',
'moving-average',
'histogram',
'band',
'volume',
'candles',
'bitmex',
'liquid',
'hitbtc',
'us-dollar',
'distance-to-parent-200',
'distance-to-parent-150',
'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',
'angle-to-parent-045',
'angle-to-parent-000',
'data-mining',
'initial-definition',
'next-phase-event',
'testing-environment',
'production-environment',
'task-manager',
'session-based-data',
'session-independent-data',
'session-reference',
'dashboard',
'toggle-auto-scale-manual',
'toggle-auto-scale-auto-min-max',
'toggle-auto-scale-auto-max',
'toggle-auto-scale-auto-min',
'toggle-panel-off',
'toggle-auto-time-scale-auto-min',
'toggle-auto-time-scale-auto-max',
'toggle-auto-time-scale-auto-min-max',
'toggle-auto-time-scale-manual',
'mouse-pointer',
'mouse-left-click',
'mouse-right-click',
'mouse-wheel-up',
'mouse-wheel-down',
'mouse-wheel-click',
'key-alt',
'key-shift',
'key-ctrl',
'hand-drag',
'key-down',
'key-left',
'key-right',
'key-up',
'master-script',
'scripts-library',
'super-action',
'super-scripts',
'template-script',
'template-structure',
'template-target',
'delink',
'detach',
'help',
'key-a',
'key-m',
'key-r',
'arrangement-horizontal-top',
'arrangement-convex',
'arrangement-horizontal-bottom',
'arrangement-vertical-right',
'arrangement-vertical-left',
'arrangement-concave',
'move-to-phase-event',
'open-execution',
'move-order',
'market-order',
'limit-order',
'execution-algorithm',
'cancel-order'
]
for (let i = 0; i < iconsNames.length; i++) {
let name = iconsNames[i]
loadImage(name)
function newDesignSpace() {
const MODULE_NAME = 'Designe Space'
let thisObject = {
sidePanel: undefined,
container: undefined,
iconCollection: undefined,
iconByUiObjectType: undefined,
workspace: undefined,
physics: physics,
draw: draw,
getContainer: getContainer,
makeVisible: makeVisible,
makeInvisible: makeInvisible,
initialize: initialize
}
function loadImage (name) {
const PATH = 'Images/Icons/style-01/'
let image = new Image()
image.onload = onImageLoad
image.fileName = name
let container = newContainer()
container.initialize()
thisObject.container = container
function onImageLoad () {
image.canDrawIcon = true
}
image.src = window.canvasApp.urlPrefix + PATH + name + '.png'
thisObject.iconCollection.set(name, image)
}
}
container.isDraggeable = false
function physics () {
thisObject.workspace.physics()
}
thisObject.iconCollection = new Map()
thisObject.iconByUiObjectType = new Map()
function makeVisible () {
visible = true
}
return thisObject
function makeInvisible () {
visible = false
}
function initialize() {
loadIconCollection()
buildIconByUiObjectTypeMap()
function getContainer (point) {
let container
if (thisObject.sidePanel !== undefined) {
container = thisObject.sidePanel.getContainer(point)
if (container !== undefined) {
container.space = 'Design Space'
return container
}
thisObject.workspace = newWorkspace()
thisObject.workspace.initialize()
}
return
}
function buildIconByUiObjectTypeMap() {
/* Take types-icons relationships defined at the schema */
for (let i = 0; i < APP_SCHEMA_ARRAY.length; i++) {
let nodeDefinition = APP_SCHEMA_ARRAY[i]
let iconName = nodeDefinition.icon
if (iconName !== undefined) {
let icon = thisObject.iconCollection.get(iconName)
thisObject.iconByUiObjectType.set(nodeDefinition.type, icon)
}
}
}
function draw () {
if (canWeDraw === false) { return }
if (thisObject.sidePanel !== undefined) {
thisObject.sidePanel.draw()
function loadIconCollection() {
const iconsNames = [
'analysis',
'analysis-1',
'approve',
'attach',
'attractive',
'pyramid',
'brainstorming',
'broken-link',
'chat',
'chronometer',
'compass',
'competition',
'content',
'design-tool',
'grid',
'headphones',
'html',
'image',
'layout',
'loading',
'login',
'pantone',
'paper-plane',
'photo-camera',
'piggy-bank',
'pipette',
'pixel',
'placeholder',
'planning',
'promotion',
'pyramid',
'quality',
'responsive',
'schedule',
'search',
'security',
'settings',
'sitemap',
'startup',
'support',
'tap',
'menu-fix-pinned',
'menu-fix-unpinned',
'targeting',
'task',
'testing',
'text',
'timeline',
'tools',
'delete',
'upload',
'vector',
'video-player',
'menu-mobility-freeze',
'menu-mobility-unfreeze',
'menu-tree-minus',
'menu-tree-plus',
'menu-backup',
'menu-share',
'stop',
'stage-open',
'stage-close',
'stage-trigger',
'stage-trigger-trigger-on',
'stage-trigger-trigger-off',
'stage-trigger-take-position',
'menu-tensor-fixed-angles',
'menu-tensor-free-angles',
'stage-open-position-size',
'stage-open-take-profit',
'stage-open-postion-rate',
'session-live-trading',
'session-paper-trading',
'session-backtesting',
'session-forward-testing',
'network',
'network-node',
'bot-trading',
'layer-manager',
'process',
'bot-indicator',
'bot-sensor',
'time-period',
'data-mine',
'procedure-loop',
'calculations-procedure',
'data-building-procedure',
'procedure-initialization',
'process-definition',
'output-dataset',
'data-dependency',
'product-definition',
'plotter-module',
'status-dependency',
'record-property',
'record-definition',
'plotter',
'plotter-panel',
'dataset-definition',
'status-report',
'execution-finished-event',
'process-dependencies',
'process-output',
'social-bot',
'execution-started-event',
'shapes',
'chart-point',
'style',
'chart-points',
'shapes-polygon-vertex',
'shapes-polygon-border',
'shapes-polygon-body',
'chart-point-formula',
'style-condition',
'shapes-polygon',
'data-entry',
'data-formula',
'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-space',
'time-line-chart',
'time-frame-scale',
'time-scale',
'rate-scale',
'time-machine',
'data-product',
'single-market-data',
'data-storage',
'dataset',
'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',
'trend',
'oscillator',
'moving-average',
'histogram',
'band',
'volume',
'candles',
'bitmex',
'liquid',
'hitbtc',
'us-dollar',
'distance-to-parent-200',
'distance-to-parent-150',
'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',
'angle-to-parent-045',
'angle-to-parent-000',
'data-mining',
'initial-definition',
'next-phase-event',
'testing-environment',
'production-environment',
'task-manager',
'session-based-data',
'session-independent-data',
'session-reference',
'dashboard',
'toggle-auto-scale-manual',
'toggle-auto-scale-auto-min-max',
'toggle-auto-scale-auto-max',
'toggle-auto-scale-auto-min',
'toggle-panel-off',
'toggle-auto-time-scale-auto-min',
'toggle-auto-time-scale-auto-max',
'toggle-auto-time-scale-auto-min-max',
'toggle-auto-time-scale-manual',
'mouse-pointer',
'mouse-left-click',
'mouse-right-click',
'mouse-wheel-up',
'mouse-wheel-down',
'mouse-wheel-click',
'key-alt',
'key-shift',
'key-ctrl',
'hand-drag',
'key-down',
'key-left',
'key-right',
'key-up',
'master-script',
'scripts-library',
'super-action',
'super-scripts',
'template-script',
'template-structure',
'template-target',
'delink',
'detach',
'help',
'key-a',
'key-m',
'key-r',
'arrangement-horizontal-top',
'arrangement-convex',
'arrangement-horizontal-bottom',
'arrangement-vertical-right',
'arrangement-vertical-left',
'arrangement-concave',
'move-to-phase-event',
'open-execution',
'move-order',
'market-order',
'limit-order',
'execution-algorithm',
'cancel-order'
]
for (let i = 0; i < iconsNames.length; i++) {
let name = iconsNames[i]
loadImage(name)
}
function loadImage(name) {
const PATH = 'Images/Icons/style-01/'
let image = new Image()
image.onload = onImageLoad
image.fileName = name
function onImageLoad() {
image.canDrawIcon = true
}
image.src = window.canvasApp.urlPrefix + PATH + name + '.png'
thisObject.iconCollection.set(name, image)
}
}
if (thisObject.workspace !== undefined) {
thisObject.workspace.draw()
function physics() {
thisObject.workspace.physics()
}
function makeVisible() {
visible = true
}
function makeInvisible() {
visible = false
}
function getContainer(point) {
let container
if (thisObject.sidePanel !== undefined) {
container = thisObject.sidePanel.getContainer(point)
if (container !== undefined) {
container.space = 'Design Space'
return container
}
}
return
}
function draw() {
if (canWeDraw === false) { return }
if (thisObject.sidePanel !== undefined) {
thisObject.sidePanel.draw()
}
if (thisObject.workspace !== undefined) {
thisObject.workspace.draw()
}
}
}
}
+363 -363
View File
@@ -1,433 +1,433 @@
function newFloatingSpace () {
const MODULE_NAME = 'Floating Space'
const ERROR_LOG = true
/*
The Floating Space is the place where floating elements like floatingObjects, live and are rendered.
This space has its own physics which helps with the animation of these objects and also preventing them to overlap.
*/
function newFloatingSpace() {
const MODULE_NAME = 'Floating Space'
const ERROR_LOG = true
/*
The Floating Space is the place where floating elements like floatingObjects, live and are rendered.
This space has its own physics which helps with the animation of these objects and also preventing them to overlap.
*/
let thisObject = {
floatingLayer: undefined, // This is the array of floatingObjects being displayed
uiObjectConstructor: undefined,
container: undefined,
inMapMode: false,
drawReferenceLines: false,
drawChainLines: true,
toggleDrawChainLines: toggleDrawChainLines,
toggleDrawReferenceLines: toggleDrawReferenceLines,
toggleMapMode: toggleMapMode,
enterMapMode: enterMapMode,
exitMapMode: exitMapMode,
transformPointToMap: transformPointToMap,
transformRadiusToMap: transformRadiusToMap,
transformImagesizeToMap: transformImagesizeToMap,
oneScreenUp: oneScreenUp,
oneScreenDown: oneScreenDown,
oneScreenLeft: oneScreenLeft,
oneScreenRight: oneScreenRight,
positionAtNode: positionAtNode,
fitIntoVisibleArea: fitIntoVisibleArea,
isThisPointVisible: isThisPointVisible,
isItFar: isItFar,
makeVisible: makeVisible,
makeInvisible: makeInvisible,
draw: draw,
physics: physics,
getContainer: getContainer,
initialize: initialize,
finalize: finalize
}
thisObject.container = newContainer()
thisObject.container.initialize(MODULE_NAME)
thisObject.container.isClickeable = false
thisObject.container.isDraggeable = true
thisObject.container.isWheelable = true
thisObject.container.detectMouseOver = true
thisObject.container.isClickeable = false
thisObject.container.frame.radius = 0
let devicePixelRatio = window.devicePixelRatio
const SPACE_SIZE = 50000
thisObject.container.frame.width = SPACE_SIZE
thisObject.container.frame.height = SPACE_SIZE
thisObject.container.frame.position.x = browserCanvas.width / 2 - thisObject.container.frame.width / 2
thisObject.container.frame.position.y = browserCanvas.height / 2 - thisObject.container.frame.height / 2
let visible = false
let floatingObjetOnFocus
const PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT = 25
let onDragStartedEventSubscriptionId
let spaceFocusAquiredEventSubscriptionId
return thisObject
function finalize () {
thisObject.container.eventHandler.stopListening(onDragStartedEventSubscriptionId)
canvas.floatingSpace.container.eventHandler.stopListening(spaceFocusAquiredEventSubscriptionId)
thisObject.floatingLayer.finalize()
thisObject.uiObjectConstructor.finalize()
thisObject.container.finalize()
thisObject.floatingLayer = undefined
thisObject.uiObjectConstructor = undefined
thisObject.container = undefined
floatingObjetOnFocus = undefined
}
function initialize (callBackFunction) {
thisObject.floatingLayer = newFloatingLayer()
thisObject.floatingLayer.initialize()
thisObject.uiObjectConstructor = newUiObjectConstructor()
thisObject.uiObjectConstructor.initialize(thisObject.floatingLayer)
onDragStartedEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onDragStarted', onDragStarted)
spaceFocusAquiredEventSubscriptionId = canvas.floatingSpace.container.eventHandler.listenToEvent('onFocusAquired', someoneAquiredFocus)
}
function someoneAquiredFocus (floatingObject) {
if (floatingObject === undefined || floatingObject.container === undefined) {
return
let thisObject = {
floatingLayer: undefined, // This is the array of floatingObjects being displayed
uiObjectConstructor: undefined,
container: undefined,
inMapMode: false,
drawReferenceLines: false,
drawChainLines: true,
toggleDrawChainLines: toggleDrawChainLines,
toggleDrawReferenceLines: toggleDrawReferenceLines,
toggleMapMode: toggleMapMode,
enterMapMode: enterMapMode,
exitMapMode: exitMapMode,
transformPointToMap: transformPointToMap,
transformRadiusToMap: transformRadiusToMap,
transformImagesizeToMap: transformImagesizeToMap,
oneScreenUp: oneScreenUp,
oneScreenDown: oneScreenDown,
oneScreenLeft: oneScreenLeft,
oneScreenRight: oneScreenRight,
positionAtNode: positionAtNode,
fitIntoVisibleArea: fitIntoVisibleArea,
isThisPointVisible: isThisPointVisible,
isItFar: isItFar,
makeVisible: makeVisible,
makeInvisible: makeInvisible,
draw: draw,
physics: physics,
getContainer: getContainer,
initialize: initialize,
finalize: finalize
}
floatingObjetOnFocus = floatingObject
}
function toggleDrawReferenceLines () {
if (thisObject.drawReferenceLines === true) {
thisObject.drawReferenceLines = false
} else {
thisObject.drawReferenceLines = true
thisObject.container = newContainer()
thisObject.container.initialize(MODULE_NAME)
thisObject.container.isClickeable = false
thisObject.container.isDraggeable = true
thisObject.container.isWheelable = true
thisObject.container.detectMouseOver = true
thisObject.container.isClickeable = false
thisObject.container.frame.radius = 0
let devicePixelRatio = window.devicePixelRatio
const SPACE_SIZE = 50000
thisObject.container.frame.width = SPACE_SIZE
thisObject.container.frame.height = SPACE_SIZE
thisObject.container.frame.position.x = browserCanvas.width / 2 - thisObject.container.frame.width / 2
thisObject.container.frame.position.y = browserCanvas.height / 2 - thisObject.container.frame.height / 2
let visible = false
let floatingObjetOnFocus
const PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT = 25
let onDragStartedEventSubscriptionId
let spaceFocusAquiredEventSubscriptionId
return thisObject
function finalize() {
thisObject.container.eventHandler.stopListening(onDragStartedEventSubscriptionId)
canvas.floatingSpace.container.eventHandler.stopListening(spaceFocusAquiredEventSubscriptionId)
thisObject.floatingLayer.finalize()
thisObject.uiObjectConstructor.finalize()
thisObject.container.finalize()
thisObject.floatingLayer = undefined
thisObject.uiObjectConstructor = undefined
thisObject.container = undefined
floatingObjetOnFocus = undefined
}
}
function toggleDrawChainLines () {
if (thisObject.drawChainLines === true) {
thisObject.drawChainLines = false
} else {
thisObject.drawChainLines = true
function initialize(callBackFunction) {
thisObject.floatingLayer = newFloatingLayer()
thisObject.floatingLayer.initialize()
thisObject.uiObjectConstructor = newUiObjectConstructor()
thisObject.uiObjectConstructor.initialize(thisObject.floatingLayer)
onDragStartedEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onDragStarted', onDragStarted)
spaceFocusAquiredEventSubscriptionId = canvas.floatingSpace.container.eventHandler.listenToEvent('onFocusAquired', someoneAquiredFocus)
}
}
function transformPointToMap (point) {
let returnPoint = {
x: point.x - thisObject.container.frame.position.x,
y: point.y - thisObject.container.frame.position.y
}
returnPoint.x = returnPoint.x / SPACE_SIZE * browserCanvas.width
returnPoint.y = returnPoint.y / SPACE_SIZE * browserCanvas.height
return returnPoint
}
function transformRadiusToMap (radius) {
const RADIUS_REDUCTION_FACTOR = 2
return radius / RADIUS_REDUCTION_FACTOR
}
function transformImagesizeToMap (imageSize) {
const IMAGE_REDUCTION_FACTOR = 3
return imageSize / IMAGE_REDUCTION_FACTOR
}
function enterMapMode () {
thisObject.inMapMode = true
}
function exitMapMode () {
thisObject.inMapMode = false
}
function toggleMapMode () {
if (thisObject.inMapMode === false) {
enterMapMode()
} else {
exitMapMode()
}
}
function onDragStarted (event) {
if (thisObject.inMapMode === false) {
if (event.buttons !== 2) { return }
event.candelDragging = true
enterMapMode()
} else {
if (event.buttons !== 1) {
event.candelDragging = true
return
}
let mousePosition = {
x: event.x,
y: event.y
}
let mouseAtSpace = {
x: mousePosition.x / browserCanvas.width * SPACE_SIZE,
y: mousePosition.y / browserCanvas.height * SPACE_SIZE
}
/* Let's see if we can snap to some of the root nodes that are isHierarchyHead */
let snapCandidateNodes = canvas.designSpace.workspace.getHierarchyHeads()
for (let i = 0; i < snapCandidateNodes.length; i++) {
let node = snapCandidateNodes[i]
let nodePosition = {
x: node.payload.floatingObject.container.frame.position.x,
y: node.payload.floatingObject.container.frame.position.y
function someoneAquiredFocus(floatingObject) {
if (floatingObject === undefined || floatingObject.container === undefined) {
return
}
// nodePosition = node.payload.floatingObject.container.frame.frameThisPoint(nodePosition)
floatingObjetOnFocus = floatingObject
}
let distance = Math.sqrt(Math.pow(mouseAtSpace.x - nodePosition.x, 2) + Math.pow(mouseAtSpace.y - nodePosition.y, 2))
const SNAP_THREASHOLD = 1000
if (distance < SNAP_THREASHOLD) {
mousePosition.x = nodePosition.x / SPACE_SIZE * browserCanvas.width
mousePosition.y = nodePosition.y / SPACE_SIZE * browserCanvas.height
function toggleDrawReferenceLines() {
if (thisObject.drawReferenceLines === true) {
thisObject.drawReferenceLines = false
} else {
thisObject.drawReferenceLines = true
}
}
/* Movign the Floating Space to where the mouse is. */
thisObject.container.frame.position.x = -mousePosition.x / browserCanvas.width * SPACE_SIZE + browserCanvas.width / 2
thisObject.container.frame.position.y = -mousePosition.y / browserCanvas.height * SPACE_SIZE + browserCanvas.height / 2
exitMapMode()
}
}
function isItFar (payload, dontCheckParent) {
/* If for any reason the paylaod is undefined we return false */
if (payload === undefined) { return false }
if (thisObject.inMapMode === true) { return false }
let radarFactor = 2 // How big is the margin
/* If the chain parent is not far, they we dont consither this far. */
if (dontCheckParent !== true) {
if (payload.chainParent !== undefined) {
if (isItFar(payload.chainParent.payload, true) === false) { return false }
}
}
/* Exceptions that are never considered far. */
if (
payload.node.type === 'Trading System' ||
payload.node.type === 'Network' ||
payload.node.type === 'Crypto Ecosystem' ||
payload.node.type === 'Charting Space' ||
payload.node.type === 'Data Mine' ||
payload.node.type === 'Super Scripts'
) {
return false
function toggleDrawChainLines() {
if (thisObject.drawChainLines === true) {
thisObject.drawChainLines = false
} else {
thisObject.drawChainLines = true
}
}
/* Another exception are the ones who have reference parents */
if (payload.referenceParent !== undefined) { return false }
/* Here we will check the position of a floatingobject to see if it is outside the screen, with a margin of one screen around. */
let point = thisObject.container.frame.frameThisPoint(payload.position)
if (point.x > browserCanvas.width + browserCanvas.width * radarFactor) {
return true
function transformPointToMap(point) {
let returnPoint = {
x: point.x - thisObject.container.frame.position.x,
y: point.y - thisObject.container.frame.position.y
}
returnPoint.x = returnPoint.x / SPACE_SIZE * browserCanvas.width
returnPoint.y = returnPoint.y / SPACE_SIZE * browserCanvas.height
return returnPoint
}
if (point.x < 0 - browserCanvas.width * radarFactor) {
return true
function transformRadiusToMap(radius) {
const RADIUS_REDUCTION_FACTOR = 2
return radius / RADIUS_REDUCTION_FACTOR
}
let bottom = COCKPIT_SPACE_POSITION + COCKPIT_SPACE_HEIGHT
let heightDiff = browserCanvas.height - bottom
if (point.y < bottom - heightDiff * radarFactor) {
return true
function transformImagesizeToMap(imageSize) {
const IMAGE_REDUCTION_FACTOR = 3
return imageSize / IMAGE_REDUCTION_FACTOR
}
if (point.y > browserCanvas.height + heightDiff * radarFactor) {
return true
}
return false
}
function fitIntoVisibleArea (point) {
/* Here we check the boundaries of the resulting points, so they dont go out of the visible area. */
let returnPoint = {
x: point.x,
y: point.y
function enterMapMode() {
thisObject.inMapMode = true
}
if (point.x > browserCanvas.width) {
returnPoint.x = browserCanvas.width
function exitMapMode() {
thisObject.inMapMode = false
}
if (point.x < 0) {
returnPoint.x = 0
function toggleMapMode() {
if (thisObject.inMapMode === false) {
enterMapMode()
} else {
exitMapMode()
}
}
if (point.y < COCKPIT_SPACE_POSITION + COCKPIT_SPACE_HEIGHT) {
returnPoint.y = COCKPIT_SPACE_POSITION + COCKPIT_SPACE_HEIGHT
function onDragStarted(event) {
if (thisObject.inMapMode === false) {
if (event.buttons !== 2) { return }
event.candelDragging = true
enterMapMode()
} else {
if (event.buttons !== 1) {
event.candelDragging = true
return
}
let mousePosition = {
x: event.x,
y: event.y
}
let mouseAtSpace = {
x: mousePosition.x / browserCanvas.width * SPACE_SIZE,
y: mousePosition.y / browserCanvas.height * SPACE_SIZE
}
/* Let's see if we can snap to some of the root nodes that are isHierarchyHead */
let snapCandidateNodes = canvas.designSpace.workspace.getHierarchyHeads()
for (let i = 0; i < snapCandidateNodes.length; i++) {
let node = snapCandidateNodes[i]
let nodePosition = {
x: node.payload.floatingObject.container.frame.position.x,
y: node.payload.floatingObject.container.frame.position.y
}
// nodePosition = node.payload.floatingObject.container.frame.frameThisPoint(nodePosition)
let distance = Math.sqrt(Math.pow(mouseAtSpace.x - nodePosition.x, 2) + Math.pow(mouseAtSpace.y - nodePosition.y, 2))
const SNAP_THREASHOLD = 1000
if (distance < SNAP_THREASHOLD) {
mousePosition.x = nodePosition.x / SPACE_SIZE * browserCanvas.width
mousePosition.y = nodePosition.y / SPACE_SIZE * browserCanvas.height
}
}
/* Movign the Floating Space to where the mouse is. */
thisObject.container.frame.position.x = -mousePosition.x / browserCanvas.width * SPACE_SIZE + browserCanvas.width / 2
thisObject.container.frame.position.y = -mousePosition.y / browserCanvas.height * SPACE_SIZE + browserCanvas.height / 2
exitMapMode()
}
}
if (point.y > browserCanvas.height) {
returnPoint.y = browserCanvas.height
function isItFar(payload, dontCheckParent) {
/* If for any reason the paylaod is undefined we return false */
if (payload === undefined) { return false }
if (thisObject.inMapMode === true) { return false }
let radarFactor = 2 // How big is the margin
/* If the chain parent is not far, they we dont consither this far. */
if (dontCheckParent !== true) {
if (payload.chainParent !== undefined) {
if (isItFar(payload.chainParent.payload, true) === false) { return false }
}
}
/* Exceptions that are never considered far. */
if (
payload.node.type === 'Trading System' ||
payload.node.type === 'Network' ||
payload.node.type === 'Crypto Ecosystem' ||
payload.node.type === 'Charting Space' ||
payload.node.type === 'Data Mine' ||
payload.node.type === 'Super Scripts'
) {
return false
}
/* Another exception are the ones who have reference parents */
if (payload.referenceParent !== undefined) { return false }
/* Here we will check the position of a floatingobject to see if it is outside the screen, with a margin of one screen around. */
let point = thisObject.container.frame.frameThisPoint(payload.position)
if (point.x > browserCanvas.width + browserCanvas.width * radarFactor) {
return true
}
if (point.x < 0 - browserCanvas.width * radarFactor) {
return true
}
let bottom = COCKPIT_SPACE_POSITION + COCKPIT_SPACE_HEIGHT
let heightDiff = browserCanvas.height - bottom
if (point.y < bottom - heightDiff * radarFactor) {
return true
}
if (point.y > browserCanvas.height + heightDiff * radarFactor) {
return true
}
return false
}
return returnPoint
}
function fitIntoVisibleArea(point) {
/* Here we check the boundaries of the resulting points, so they dont go out of the visible area. */
function oneScreenUp () {
if (visible === false) { return }
let displaceVector = {
x: 0,
y: browserCanvas.height * PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT / 100
let returnPoint = {
x: point.x,
y: point.y
}
if (point.x > browserCanvas.width) {
returnPoint.x = browserCanvas.width
}
if (point.x < 0) {
returnPoint.x = 0
}
if (point.y < COCKPIT_SPACE_POSITION + COCKPIT_SPACE_HEIGHT) {
returnPoint.y = COCKPIT_SPACE_POSITION + COCKPIT_SPACE_HEIGHT
}
if (point.y > browserCanvas.height) {
returnPoint.y = browserCanvas.height
}
return returnPoint
}
thisObject.container.displace(displaceVector)
return displaceVector
}
function oneScreenUp() {
if (visible === false) { return }
let displaceVector = {
x: 0,
y: browserCanvas.height * PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT / 100
}
function oneScreenDown () {
if (visible === false) { return }
let displaceVector = {
x: 0,
y: -browserCanvas.height * PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT / 100
thisObject.container.displace(displaceVector)
return displaceVector
}
thisObject.container.displace(displaceVector)
return displaceVector
}
function oneScreenDown() {
if (visible === false) { return }
let displaceVector = {
x: 0,
y: -browserCanvas.height * PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT / 100
}
function oneScreenLeft () {
if (visible === false) { return }
let displaceVector = {
x: browserCanvas.width * PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT / 100,
y: 0
thisObject.container.displace(displaceVector)
return displaceVector
}
thisObject.container.displace(displaceVector)
return displaceVector
}
function oneScreenLeft() {
if (visible === false) { return }
let displaceVector = {
x: browserCanvas.width * PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT / 100,
y: 0
}
function oneScreenRight () {
if (visible === false) { return }
let displaceVector = {
x: -browserCanvas.width * PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT / 100,
y: 0
thisObject.container.displace(displaceVector)
return displaceVector
}
thisObject.container.displace(displaceVector)
return displaceVector
}
function oneScreenRight() {
if (visible === false) { return }
let displaceVector = {
x: -browserCanvas.width * PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT / 100,
y: 0
}
function positionAtNode (node) {
let position = thisObject.container.frame.frameThisPoint(node.payload.position)
let displaceVector = {
x: browserCanvas.width / 2 - position.x,
y: (COCKPIT_SPACE_POSITION + COCKPIT_SPACE_HEIGHT) + (browserCanvas.height - (COCKPIT_SPACE_POSITION + COCKPIT_SPACE_HEIGHT)) / 2 - position.y
thisObject.container.displace(displaceVector)
return displaceVector
}
thisObject.container.displace(displaceVector)
}
function positionAtNode(node) {
let position = thisObject.container.frame.frameThisPoint(node.payload.position)
function isThisPointVisible (point) {
if (point.x > browserCanvas.width) {
return false
let displaceVector = {
x: browserCanvas.width / 2 - position.x,
y: (COCKPIT_SPACE_POSITION + COCKPIT_SPACE_HEIGHT) + (browserCanvas.height - (COCKPIT_SPACE_POSITION + COCKPIT_SPACE_HEIGHT)) / 2 - position.y
}
thisObject.container.displace(displaceVector)
}
if (point.x < 0) {
return false
function isThisPointVisible(point) {
if (point.x > browserCanvas.width) {
return false
}
if (point.x < 0) {
return false
}
if (point.y < COCKPIT_SPACE_POSITION + COCKPIT_SPACE_HEIGHT) {
return false
}
if (point.y > browserCanvas.height) {
return false
}
return true
}
if (point.y < COCKPIT_SPACE_POSITION + COCKPIT_SPACE_HEIGHT) {
return false
function makeVisible() {
visible = true
}
if (point.y > browserCanvas.height) {
return false
function makeInvisible() {
visible = false
}
return true
}
function getContainer(point) {
if (visible === false) { return }
function makeVisible () {
visible = true
}
let container
function makeInvisible () {
visible = false
}
if (floatingObjetOnFocus !== undefined) {
container = floatingObjetOnFocus.getContainer(point)
if (container !== undefined) {
container.space = 'Floating Space'
return container
}
}
function getContainer (point) {
if (visible === false) { return }
container = thisObject.floatingLayer.getContainer(point)
if (container !== undefined) {
container.space = 'Floating Space'
return container
}
let container
if (floatingObjetOnFocus !== undefined) {
container = floatingObjetOnFocus.getContainer(point)
if (container !== undefined) {
container.space = 'Floating Space'
return container
}
if (visible === true) {
thisObject.container.space = 'Floating Space'
return thisObject.container
}
}
container = thisObject.floatingLayer.getContainer(point)
if (container !== undefined) {
container.space = 'Floating Space'
return container
function physics() {
if (visible === false) { return }
browserZoomPhysics()
positionContraintsPhysics()
thisObject.floatingLayer.physics()
}
if (visible === true) {
thisObject.container.space = 'Floating Space'
return thisObject.container
function positionContraintsPhysics() {
if (thisObject.container.frame.position.x > 0) {
thisObject.container.frame.position.x = 0
}
if (thisObject.container.frame.position.y > 0) {
thisObject.container.frame.position.y = 0
}
if (thisObject.container.frame.position.x + thisObject.container.frame.width < browserCanvas.width) {
thisObject.container.frame.position.x = browserCanvas.width - thisObject.container.frame.width
}
if (thisObject.container.frame.position.y + thisObject.container.frame.height < browserCanvas.height) {
thisObject.container.frame.position.y = browserCanvas.height - thisObject.container.frame.height
}
}
}
function physics () {
if (visible === false) { return }
browserZoomPhysics()
positionContraintsPhysics()
thisObject.floatingLayer.physics()
}
function browserZoomPhysics() {
if (devicePixelRatio !== window.devicePixelRatio) {
devicePixelRatio = window.devicePixelRatio
function positionContraintsPhysics () {
if (thisObject.container.frame.position.x > 0) {
thisObject.container.frame.position.x = 0
thisObject.container.frame.position.x = browserCanvas.width / 2 - thisObject.container.frame.width / 2
thisObject.container.frame.position.y = browserCanvas.height / 2 - thisObject.container.frame.height / 2
}
}
if (thisObject.container.frame.position.y > 0) {
thisObject.container.frame.position.y = 0
function draw() {
if (canWeDraw === false) { return }
if (visible === false) { return }
drawBackground()
thisObject.floatingLayer.draw()
}
if (thisObject.container.frame.position.x + thisObject.container.frame.width < browserCanvas.width) {
thisObject.container.frame.position.x = browserCanvas.width - thisObject.container.frame.width
function drawBackground() {
browserCanvasContext.beginPath()
browserCanvasContext.rect(thisObject.container.frame.position.x, thisObject.container.frame.position.y, thisObject.container.frame.width, thisObject.container.frame.height)
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.BLACK + ', 1)'
browserCanvasContext.closePath()
browserCanvasContext.fill()
}
if (thisObject.container.frame.position.y + thisObject.container.frame.height < browserCanvas.height) {
thisObject.container.frame.position.y = browserCanvas.height - thisObject.container.frame.height
}
}
function browserZoomPhysics () {
if (devicePixelRatio !== window.devicePixelRatio) {
devicePixelRatio = window.devicePixelRatio
thisObject.container.frame.position.x = browserCanvas.width / 2 - thisObject.container.frame.width / 2
thisObject.container.frame.position.y = browserCanvas.height / 2 - thisObject.container.frame.height / 2
}
}
function draw () {
if (canWeDraw === false) { return }
if (visible === false) { return }
drawBackground()
thisObject.floatingLayer.draw()
}
function drawBackground () {
browserCanvasContext.beginPath()
browserCanvasContext.rect(thisObject.container.frame.position.x, thisObject.container.frame.position.y, thisObject.container.frame.width, thisObject.container.frame.height)
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.BLACK + ', 1)'
browserCanvasContext.closePath()
browserCanvasContext.fill()
}
}
+343 -343
View File
@@ -1,379 +1,379 @@
/*
/*
The Panel Space y the place wehre all panels live, no matter who create them.
*/
function newPanelsSpace () {
let thisObject = {
visible: true,
container: undefined,
unHide: unHide,
hide: hide,
createNewPanel: createNewPanel,
destroyPanel: destroyPanel,
getPanel: getPanel,
physics: physics,
draw: draw,
panels: [],
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
initialize: initialize
}
function newPanelsSpace() {
let thisObject = {
visible: true,
container: undefined,
unHide: unHide,
hide: hide,
createNewPanel: createNewPanel,
destroyPanel: destroyPanel,
getPanel: getPanel,
physics: physics,
draw: draw,
panels: [],
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
initialize: initialize
}
let container = newContainer()
container.initialize()
thisObject.container = container
thisObject.container.isDraggeable = false
let container = newContainer()
container.initialize()
thisObject.container = container
thisObject.container.isDraggeable = false
container.frame.containerName = 'Panels Space'
container.frame.containerName = 'Panels Space'
return thisObject
return thisObject
function initialize () {
function initialize() {
/* The space does not create any Panels for itself, it just sits and waits others need panels. */
}
function createNewPanel (pType, pParameters, pOwner, pSession) {
let panel
switch (pType) {
case 'Layers Panel':
{
panel = newLayersPanel()
panel.fitFunction = canvas.chartingSpace.fitFunction
panel.container.isVisibleFunction = canvas.chartingSpace.isThisPointVisible
panel.type = 'Layers Panel'
break
}
case 'Plotter Panel':
{
if (pParameters.panelNode.config.isLegacy !== true) {
panel = newPlotterPanel()
panel.fitFunction = canvas.chartingSpace.fitFunction
panel.container.isVisibleFunction = canvas.chartingSpace.isThisPointVisible
panel.session = pSession
panel.initialize(pParameters.panelNode)
} else {
panel = getNewPlotterPanel(pParameters.dataMine, pParameters.plotterCodeName, pParameters.moduleCodeName, pParameters.panelNode.config.codeName)
panel.fitFunction = canvas.chartingSpace.fitFunction
panel.container.isVisibleFunction = canvas.chartingSpace.isThisPointVisible
panel.session = pSession
panel.initialize()
}
panel.type = 'Plotter Panel'
break
}
}
panel.owner = pOwner
thisObject.panels.push(panel)
function createNewPanel(pType, pParameters, pOwner, pSession) {
let panel
panel.handle = newUniqueId()
switch (pType) {
return panel.handle
}
function unHide (owner, type) {
for (let i = 0; i < thisObject.panels.length; i++) {
let panel = thisObject.panels[i]
if (panel.owner === owner && panel.type === type) {
panel.isHidden = false
}
}
}
function hide (owner, type) {
for (let i = 0; i < thisObject.panels.length; i++) {
let panel = thisObject.panels[i]
if (panel.owner === owner && panel.type === type) {
panel.isHidden = true
}
}
}
function destroyPanel (pPanelHandle) {
for (let i = 0; i < thisObject.panels.length; i++) {
let panel = thisObject.panels[i]
if (panel.handle === pPanelHandle) {
if (panel.finalize !== undefined) {
panel.finalize()
case 'Layers Panel':
{
panel = newLayersPanel()
panel.fitFunction = canvas.chartingSpace.fitFunction
panel.container.isVisibleFunction = canvas.chartingSpace.isThisPointVisible
panel.type = 'Layers Panel'
break
}
case 'Plotter Panel':
{
if (pParameters.panelNode.config.isLegacy !== true) {
panel = newPlotterPanel()
panel.fitFunction = canvas.chartingSpace.fitFunction
panel.container.isVisibleFunction = canvas.chartingSpace.isThisPointVisible
panel.session = pSession
panel.initialize(pParameters.panelNode)
} else {
panel = getNewPlotterPanel(pParameters.dataMine, pParameters.plotterCodeName, pParameters.moduleCodeName, pParameters.panelNode.config.codeName)
panel.fitFunction = canvas.chartingSpace.fitFunction
panel.container.isVisibleFunction = canvas.chartingSpace.isThisPointVisible
panel.session = pSession
panel.initialize()
}
panel.type = 'Plotter Panel'
break
}
}
thisObject.panels.splice(i, 1) // Delete item from array.
return
}
panel.owner = pOwner
thisObject.panels.push(panel)
panel.handle = newUniqueId()
return panel.handle
}
}
function getPanel (pPanelHandle) {
for (let i = 0; i < thisObject.panels.length; i++) {
let panel = thisObject.panels[i]
if (panel.handle === pPanelHandle) {
return panel
}
}
}
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]
let owner = canvas.chartingSpace.inViewport.get(panel.owner)
if (owner !== undefined) {
if (panel.physics !== undefined) {
panel.physics()
}
}
}
}
}
function positioningPhysics () {
if (thisObject.panels !== undefined) {
for (let i = 0; i < thisObject.panels.length; i++) {
let panel = thisObject.panels[i]
if (panel.isVisible === false || panel.isHidden === true) { continue }
/* setting the speed of the panel */
if (panel.container.speed === undefined) {
panel.container.speed = {
x: 2,
y: 2
}
}
/* 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
}
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 verticalLine = (canvas.chartingSpace.viewport.visibleArea.topRight.x - canvas.chartingSpace.viewport.visibleArea.topLeft.x) / 2 + canvas.chartingSpace.viewport.visibleArea.topLeft.x
let horizontalLine = (canvas.chartingSpace.viewport.visibleArea.bottomRight.y - canvas.chartingSpace.viewport.visibleArea.topRight.y) / 2 + canvas.chartingSpace.viewport.visibleArea.topRight.y
if (panel.upDownButton !== undefined) {
if (panel.upDownButton.status === 'up') {
if (panel.leftRightButton !== undefined) {
if (panel.leftRightButton.status === 'left') {
panel.gravitatesTowards = 'topLeft'
} else {
panel.gravitatesTowards = 'topRight'
}
} else {
if (centerPoint.x < verticalLine) {
panel.gravitatesTowards = 'topLeft'
} else {
panel.gravitatesTowards = 'topRight'
}
function unHide(owner, type) {
for (let i = 0; i < thisObject.panels.length; i++) {
let panel = thisObject.panels[i]
if (panel.owner === owner && panel.type === type) {
panel.isHidden = false
}
} else {
if (panel.leftRightButton !== undefined) {
if (panel.leftRightButton.status === 'left') {
panel.gravitatesTowards = 'bottomLeft'
} else {
panel.gravitatesTowards = 'bottomRight'
}
} 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 (panel.gravitatesTowards === 'topLeft' || panel.gravitatesTowards === 'bottomLeft') {
panel.container.frame.position.x = panel.container.frame.position.x - panel.container.speed.x
if (panel.leftRightButton !== undefined) {
if (panel.leftRightButton.status === 'left' || panel.leftRightButton.status === 'right') { // we avoid pushing other panels while in transition
}
}
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
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
}
}
if (panel.container.frame.height <= canvas.chartingSpace.viewport.visibleArea.bottomRight.y - canvas.chartingSpace.viewport.visibleArea.topRight.y) {
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.chartingSpace.viewport.visibleArea.topLeft.y) {
panel.container.frame.position.y = canvas.chartingSpace.viewport.visibleArea.topLeft.y
}
} else {
panel.container.frame.position.y = panel.container.frame.position.y + panel.container.speed.y
isOverlapping(i, panel.container)
if (panel.container.frame.position.y + panel.container.frame.height > canvas.chartingSpace.viewport.visibleArea.bottomRight.y) {
panel.container.frame.position.y = canvas.chartingSpace.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 (panel.leftRightButton !== undefined) {
if (panel.leftRightButton.status !== 'left' && panel.leftRightButton.status !== 'right') { // we avoid pushing other panels while in transition
continue
}
function hide(owner, type) {
for (let i = 0; i < thisObject.panels.length; i++) {
let panel = thisObject.panels[i]
if (panel.owner === owner && panel.type === type) {
panel.isHidden = true
}
}
if (panel.isVisible === true && panel.isHidden === false) {
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
}
}
}
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 (canWeDraw === false) { return }
if (thisObject.visible !== true) { return }
function destroyPanel(pPanelHandle) {
for (let i = 0; i < thisObject.panels.length; i++) {
let panel = thisObject.panels[i]
thisObject.container.frame.draw(false, false)
if (panel.handle === pPanelHandle) {
if (panel.finalize !== undefined) {
panel.finalize()
}
for (let i = 0; i < thisObject.panels.length; i++) {
let panel = thisObject.panels[i]
let owner = canvas.chartingSpace.inViewport.get(panel.owner)
if (owner !== undefined) {
if (panel.isVisible === true && panel.isHidden === false) {
panel.draw()
thisObject.panels.splice(i, 1) // Delete item from array.
return
}
}
}
}
}
function getContainer (point, purpose) {
if (thisObject.visible !== true) { return }
function getPanel(pPanelHandle) {
for (let i = 0; i < thisObject.panels.length; i++) {
let panel = thisObject.panels[i]
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.
*/
for (let i = thisObject.panels.length - 1; i >= 0; i--) {
let panel = thisObject.panels[i]
let owner = canvas.chartingSpace.inViewport.get(panel.owner)
if (owner !== undefined) {
if (panel.isVisible === true && panel.isHidden === false) {
container = panel.getContainer(point, purpose)
if (panel.handle === pPanelHandle) {
return panel
}
}
}
if (container !== undefined) {
container.space = 'Panels Space'
return container
}
}
// thisObject.container.space = 'Panels Space'
// return thisObject.container
}
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]
let owner = canvas.chartingSpace.inViewport.get(panel.owner)
if (owner !== undefined) {
if (panel.physics !== undefined) {
panel.physics()
}
}
}
}
}
function positioningPhysics() {
if (thisObject.panels !== undefined) {
for (let i = 0; i < thisObject.panels.length; i++) {
let panel = thisObject.panels[i]
if (panel.isVisible === false || panel.isHidden === true) { continue }
/* setting the speed of the panel */
if (panel.container.speed === undefined) {
panel.container.speed = {
x: 2,
y: 2
}
}
/* 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
}
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 verticalLine = (canvas.chartingSpace.viewport.visibleArea.topRight.x - canvas.chartingSpace.viewport.visibleArea.topLeft.x) / 2 + canvas.chartingSpace.viewport.visibleArea.topLeft.x
let horizontalLine = (canvas.chartingSpace.viewport.visibleArea.bottomRight.y - canvas.chartingSpace.viewport.visibleArea.topRight.y) / 2 + canvas.chartingSpace.viewport.visibleArea.topRight.y
if (panel.upDownButton !== undefined) {
if (panel.upDownButton.status === 'up') {
if (panel.leftRightButton !== undefined) {
if (panel.leftRightButton.status === 'left') {
panel.gravitatesTowards = 'topLeft'
} else {
panel.gravitatesTowards = 'topRight'
}
} else {
if (centerPoint.x < verticalLine) {
panel.gravitatesTowards = 'topLeft'
} else {
panel.gravitatesTowards = 'topRight'
}
}
} else {
if (panel.leftRightButton !== undefined) {
if (panel.leftRightButton.status === 'left') {
panel.gravitatesTowards = 'bottomLeft'
} else {
panel.gravitatesTowards = 'bottomRight'
}
} 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 (panel.gravitatesTowards === 'topLeft' || panel.gravitatesTowards === 'bottomLeft') {
panel.container.frame.position.x = panel.container.frame.position.x - panel.container.speed.x
if (panel.leftRightButton !== undefined) {
if (panel.leftRightButton.status === 'left' || panel.leftRightButton.status === 'right') { // we avoid pushing other panels while in transition
}
}
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
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
}
}
if (panel.container.frame.height <= canvas.chartingSpace.viewport.visibleArea.bottomRight.y - canvas.chartingSpace.viewport.visibleArea.topRight.y) {
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.chartingSpace.viewport.visibleArea.topLeft.y) {
panel.container.frame.position.y = canvas.chartingSpace.viewport.visibleArea.topLeft.y
}
} else {
panel.container.frame.position.y = panel.container.frame.position.y + panel.container.speed.y
isOverlapping(i, panel.container)
if (panel.container.frame.position.y + panel.container.frame.height > canvas.chartingSpace.viewport.visibleArea.bottomRight.y) {
panel.container.frame.position.y = canvas.chartingSpace.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 (panel.leftRightButton !== undefined) {
if (panel.leftRightButton.status !== 'left' && panel.leftRightButton.status !== 'right') { // we avoid pushing other panels while in transition
continue
}
}
if (panel.isVisible === true && panel.isHidden === false) {
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
}
}
}
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 (canWeDraw === false) { return }
if (thisObject.visible !== true) { return }
thisObject.container.frame.draw(false, false)
for (let i = 0; i < thisObject.panels.length; i++) {
let panel = thisObject.panels[i]
let owner = canvas.chartingSpace.inViewport.get(panel.owner)
if (owner !== undefined) {
if (panel.isVisible === true && panel.isHidden === false) {
panel.draw()
}
}
}
}
function getContainer(point, purpose) {
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.
*/
for (let i = thisObject.panels.length - 1; i >= 0; i--) {
let panel = thisObject.panels[i]
let owner = canvas.chartingSpace.inViewport.get(panel.owner)
if (owner !== undefined) {
if (panel.isVisible === true && panel.isHidden === false) {
container = panel.getContainer(point, purpose)
}
}
if (container !== undefined) {
container.space = 'Panels Space'
return container
}
}
// thisObject.container.space = 'Panels Space'
// return thisObject.container
}
}
+137 -137
View File
@@ -1,168 +1,168 @@
function newSideSpace () {
const MODULE_NAME = 'Side Space'
let thisObject = {
sidePanelTab: undefined,
container: undefined,
physics: physics,
draw: draw,
getContainer: getContainer,
initialize: initialize,
finalize: finalize
}
let isInitialized = false
thisObject.container = newContainer()
thisObject.container.name = MODULE_NAME
thisObject.container.initialize()
thisObject.container.isClickeable = true
thisObject.container.isDraggeable = false
thisObject.container.detectMouseOver = true
thisObject.container.status = 'hidden'
let listView
resize()
let openingEventSubscriptionId
let closedEventSubscriptionId
let browserResizedEventSubscriptionId
return thisObject
function initialize () {
thisObject.sidePanelTab = newSidePanelTab()
thisObject.sidePanelTab.container.connectToParent(thisObject.container, false, false)
thisObject.sidePanelTab.initialize()
browserResizedEventSubscriptionId = canvas.eventHandler.listenToEvent('Browser Resized', resize)
initializeListView()
isInitialized = true
}
function finalize () {
canvas.eventHandler.stopListening(browserResizedEventSubscriptionId)
thisObject.sidePanelTab.container.eventHandler.stopListening(openingEventSubscriptionId)
thisObject.sidePanelTab.container.eventHandler.stopListening(closedEventSubscriptionId)
}
function initializeListView () {
listView = newListView()
listView.initialize()
listView.container.connectToParent(thisObject.container, false, false)
openingEventSubscriptionId = thisObject.sidePanelTab.container.eventHandler.listenToEvent('opening', listView.turnOn)
closedEventSubscriptionId = thisObject.sidePanelTab.container.eventHandler.listenToEvent('closed', listView.turnOff)
}
function resize () {
thisObject.container.frame.width = SIDE_PANEL_WIDTH
thisObject.container.frame.height = browserCanvas.height // - TOP_SPACE_HEIGHT
thisObject.container.frame.position.x = -SIDE_PANEL_WIDTH
thisObject.container.frame.position.y = 0 // TOP_SPACE_HEIGHT
if (listView !== undefined) {
listView.resize()
function newSideSpace() {
const MODULE_NAME = 'Side Space'
let thisObject = {
sidePanelTab: undefined,
container: undefined,
physics: physics,
draw: draw,
getContainer: getContainer,
initialize: initialize,
finalize: finalize
}
if (thisObject.sidePanelTab !== undefined) {
thisObject.sidePanelTab.resize()
}
}
let isInitialized = false
function getContainer (point, purpose) {
let container
thisObject.container = newContainer()
thisObject.container.name = MODULE_NAME
thisObject.container.initialize()
thisObject.container.isClickeable = true
thisObject.container.isDraggeable = false
thisObject.container.detectMouseOver = true
thisObject.container.status = 'hidden'
container = thisObject.sidePanelTab.getContainer(point, purpose)
if (container !== undefined) { return container }
let listView
container = listView.getContainer(point, purpose)
if (container !== undefined) { return container }
resize()
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
return thisObject.container
} else {
return undefined
}
}
let openingEventSubscriptionId
let closedEventSubscriptionId
let browserResizedEventSubscriptionId
return thisObject
function physics () {
thisObject.sidePanelTab.physics()
listView.physics()
}
function initialize() {
thisObject.sidePanelTab = newSidePanelTab()
thisObject.sidePanelTab.container.connectToParent(thisObject.container, false, false)
thisObject.sidePanelTab.initialize()
function draw () {
if (canWeDraw === false) { return }
if (isInitialized === false) { return }
borders()
thisObject.sidePanelTab.draw()
listView.draw()
}
browserResizedEventSubscriptionId = canvas.eventHandler.listenToEvent('Browser Resized', resize)
function borders () {
let point1
let point2
let point3
let point4
point1 = {
x: 0,
y: 0
initializeListView()
isInitialized = true
}
point2 = {
x: thisObject.container.frame.width,
y: 0
function finalize() {
canvas.eventHandler.stopListening(browserResizedEventSubscriptionId)
thisObject.sidePanelTab.container.eventHandler.stopListening(openingEventSubscriptionId)
thisObject.sidePanelTab.container.eventHandler.stopListening(closedEventSubscriptionId)
}
point3 = {
x: thisObject.container.frame.width,
y: thisObject.container.frame.height
function initializeListView() {
listView = newListView()
listView.initialize()
listView.container.connectToParent(thisObject.container, false, false)
openingEventSubscriptionId = thisObject.sidePanelTab.container.eventHandler.listenToEvent('opening', listView.turnOn)
closedEventSubscriptionId = thisObject.sidePanelTab.container.eventHandler.listenToEvent('closed', listView.turnOff)
}
point4 = {
x: 0,
y: thisObject.container.frame.height
function resize() {
thisObject.container.frame.width = SIDE_PANEL_WIDTH
thisObject.container.frame.height = browserCanvas.height // - TOP_SPACE_HEIGHT
thisObject.container.frame.position.x = -SIDE_PANEL_WIDTH
thisObject.container.frame.position.y = 0 // TOP_SPACE_HEIGHT
if (listView !== undefined) {
listView.resize()
}
if (thisObject.sidePanelTab !== undefined) {
thisObject.sidePanelTab.resize()
}
}
point1 = thisObject.container.frame.frameThisPoint(point1)
point2 = thisObject.container.frame.frameThisPoint(point2)
point3 = thisObject.container.frame.frameThisPoint(point3)
point4 = thisObject.container.frame.frameThisPoint(point4)
function getContainer(point, purpose) {
let container
browserCanvasContext.setLineDash([0, 0])
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.lineTo(point1.x, point1.y)
browserCanvasContext.closePath()
container = thisObject.sidePanelTab.getContainer(point, purpose)
if (container !== undefined) { return container }
let opacity = 1
container = listView.getContainer(point, purpose)
if (container !== undefined) { return container }
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.LIGHT_GREY + ', ' + opacity + ''
browserCanvasContext.fill()
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
return thisObject.container
} else {
return undefined
}
}
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.GREY + ', ' + opacity + ''
browserCanvasContext.lineWidth = 0.3
browserCanvasContext.stroke()
function physics() {
thisObject.sidePanelTab.physics()
listView.physics()
}
/* Shadow */
function draw() {
if (canWeDraw === false) { return }
if (isInitialized === false) { return }
borders()
thisObject.sidePanelTab.draw()
listView.draw()
}
if (thisObject.container.status !== 'hidden') {
for (let i = 0; i <= 30; i++) {
opacity = 1 - (i / 300) - 0.95
function borders() {
let point1
let point2
let point3
let point4
point1 = {
x: 0,
y: 0
}
point2 = {
x: thisObject.container.frame.width,
y: 0
}
point3 = {
x: thisObject.container.frame.width,
y: thisObject.container.frame.height
}
point4 = {
x: 0,
y: thisObject.container.frame.height
}
point1 = thisObject.container.frame.frameThisPoint(point1)
point2 = thisObject.container.frame.frameThisPoint(point2)
point3 = thisObject.container.frame.frameThisPoint(point3)
point4 = thisObject.container.frame.frameThisPoint(point4)
browserCanvasContext.setLineDash([0, 0])
browserCanvasContext.beginPath()
browserCanvasContext.moveTo(point2.x + i, point2.y)
browserCanvasContext.lineTo(point3.x + i, point3.y)
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.lineTo(point1.x, point1.y)
browserCanvasContext.closePath()
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.BLACK + ', ' + opacity + ''
browserCanvasContext.lineWidth = 1
let opacity = 1
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.LIGHT_GREY + ', ' + opacity + ''
browserCanvasContext.fill()
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.GREY + ', ' + opacity + ''
browserCanvasContext.lineWidth = 0.3
browserCanvasContext.stroke()
}
/* Shadow */
if (thisObject.container.status !== 'hidden') {
for (let i = 0; i <= 30; i++) {
opacity = 1 - (i / 300) - 0.95
browserCanvasContext.setLineDash([0, 0])
browserCanvasContext.beginPath()
browserCanvasContext.moveTo(point2.x + i, point2.y)
browserCanvasContext.lineTo(point3.x + i, point3.y)
browserCanvasContext.closePath()
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.BLACK + ', ' + opacity + ''
browserCanvasContext.lineWidth = 1
browserCanvasContext.stroke()
}
}
}
}
}
+92 -92
View File
@@ -1,109 +1,109 @@
function newTopSpace () {
let thisObject = {
container: undefined,
draw: draw,
getContainer: getContainer,
initialize: initialize
}
thisObject.container = newContainer()
thisObject.container.initialize()
resize()
thisObject.container.isDraggeable = false
let backgroundImage
let logoImage
return thisObject
function initialize () {
canvas.eventHandler.listenToEvent('Browser Resized', resize)
backgroundImage = new Image()
logoImage = new Image()
loadImage('superalgos-header-background', backgroundImage)
loadImage('superalgos-logo-for-color-background', logoImage)
function loadImage (name, image) {
const PATH = 'Images/'
image.onload = onImageLoad
image.fileName = name
function onImageLoad () {
image.canDraw = true
}
image.src = window.canvasApp.urlPrefix + PATH + name + '.png'
function newTopSpace() {
let thisObject = {
container: undefined,
draw: draw,
getContainer: getContainer,
initialize: initialize
}
}
function resize () {
thisObject.container.frame.width = browserCanvas.width
thisObject.container.frame.height = TOP_SPACE_HEIGHT
thisObject.container = newContainer()
thisObject.container.initialize()
thisObject.container.frame.position.x = 0
try {
thisObject.container.frame.position.y = canvas.chartingSpace.viewport.visibleArea.bottomLeft.y
} catch (e) { }
}
resize()
function getContainer (point) {
thisObject.container.isDraggeable = false
let backgroundImage
let logoImage
return thisObject
}
function initialize() {
canvas.eventHandler.listenToEvent('Browser Resized', resize)
function draw () {
if (canWeDraw === false) { return }
thisObject.container.frame.draw(false, false)
backgroundImage = new Image()
logoImage = new Image()
drawBackground()
return
}
loadImage('superalgos-header-background', backgroundImage)
loadImage('superalgos-logo-for-color-background', logoImage)
function drawBackground () {
/* Solid Color */
let opacity = 1
browserCanvasContext.beginPath()
browserCanvasContext.rect(0, 0, thisObject.container.frame.width, thisObject.container.frame.height)
if (ARE_WE_RECORDING_A_VIDEO === true) {
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.PATINATED_TURQUOISE + ', ' + opacity + ')'
} else {
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.RUSTED_RED + ', ' + opacity + ')'
function loadImage(name, image) {
const PATH = 'Images/'
image.onload = onImageLoad
image.fileName = name
function onImageLoad() {
image.canDraw = true
}
image.src = window.canvasApp.urlPrefix + PATH + name + '.png'
}
}
browserCanvasContext.closePath()
browserCanvasContext.fill()
/* Background Image */
if (backgroundImage !== undefined) {
if (backgroundImage.canDraw === true) {
let imagePosition = {
x: 0,
y: 0
function resize() {
thisObject.container.frame.width = browserCanvas.width
thisObject.container.frame.height = TOP_SPACE_HEIGHT
thisObject.container.frame.position.x = 0
try {
thisObject.container.frame.position.y = canvas.chartingSpace.viewport.visibleArea.bottomLeft.y
} catch (e) { }
}
function getContainer(point) {
}
function draw() {
if (canWeDraw === false) { return }
thisObject.container.frame.draw(false, false)
drawBackground()
return
}
function drawBackground() {
/* Solid Color */
let opacity = 1
browserCanvasContext.beginPath()
browserCanvasContext.rect(0, 0, thisObject.container.frame.width, thisObject.container.frame.height)
if (ARE_WE_RECORDING_A_VIDEO === true) {
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.PATINATED_TURQUOISE + ', ' + opacity + ')'
} else {
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.RUSTED_RED + ', ' + opacity + ')'
}
browserCanvasContext.closePath()
browserCanvasContext.fill()
/* Background Image */
if (backgroundImage !== undefined) {
if (backgroundImage.canDraw === true) {
let imagePosition = {
x: 0,
y: 0
}
browserCanvasContext.drawImage(
backgroundImage, imagePosition.x,
imagePosition.y,
browserCanvas.width,
TOP_SPACE_HEIGHT - 2)
}
}
browserCanvasContext.drawImage(
backgroundImage, imagePosition.x,
imagePosition.y,
browserCanvas.width,
TOP_SPACE_HEIGHT - 2)
}
}
/* Logo Image */
if (logoImage !== undefined) {
if (logoImage.canDraw === true) {
let imagePosition = {
x: 10,
y: 0
}
/* Logo Image */
if (logoImage !== undefined) {
if (logoImage.canDraw === true) {
let imagePosition = {
x: 10,
y: 0
browserCanvasContext.drawImage(
logoImage, imagePosition.x,
imagePosition.y,
150,
TOP_SPACE_HEIGHT - 2)
}
}
browserCanvasContext.drawImage(
logoImage, imagePosition.x,
imagePosition.y,
150,
TOP_SPACE_HEIGHT - 2)
}
}
}
}