37 files changed
+813
-146
No files matched your search
@@ -111,6 +111,10 @@ function newAnimation () {
|
||||
}
|
||||
}
|
||||
|
||||
/* Frame per Seconds */
|
||||
|
||||
ANIMATION_FRAME_PER_SECONDS = Math.trunc(1000 / totalTimeConsumed)
|
||||
|
||||
/* Performance Check */
|
||||
if (SHOW_ANIMATION_PERFORMACE === true) {
|
||||
row = 0
|
||||
@@ -132,6 +136,8 @@ function newAnimation () {
|
||||
printLabel(DEBUG.variable3, 300, 100 + row * 30, 1, 20, UI_COLOR.RED)
|
||||
row++
|
||||
printLabel(DEBUG.variable4, 300, 100 + row * 30, 1, 20, UI_COLOR.RED)
|
||||
row++
|
||||
printLabel('Animation Frame Per Seconds: ' + ANIMATION_FRAME_PER_SECONDS, 300, 100 + row * 30, 1, 20, UI_COLOR.TITANIUM_YELLOW)
|
||||
}
|
||||
} else {
|
||||
browserCanvas.width = 1
|
||||
|
||||
@@ -40,6 +40,7 @@ function newCanvas () {
|
||||
designSpace: undefined,
|
||||
animation: undefined,
|
||||
mouse: undefined,
|
||||
shorcutNumbers: new Map(),
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
}
|
||||
@@ -57,12 +58,14 @@ function newCanvas () {
|
||||
},
|
||||
action: ''
|
||||
}
|
||||
|
||||
return thisObject
|
||||
|
||||
function finalize () {
|
||||
try {
|
||||
thisObject.chartingSpace.finalize()
|
||||
thisObject.floatingSpace.finalize()
|
||||
thisObject.shorcutNumbers = undefined
|
||||
|
||||
browserCanvas.removeEventListener('mousedown', onMouseDown, false)
|
||||
browserCanvas.removeEventListener('mouseup', onMouseUp, false)
|
||||
@@ -246,12 +249,31 @@ function newCanvas () {
|
||||
}
|
||||
|
||||
function onKeyDown (event) {
|
||||
if (EDITOR_ON_FOCUS === true) { return }
|
||||
thisObject.mouse.event = event
|
||||
thisObject.mouse.action = 'key down'
|
||||
|
||||
checkMediaRecording(event)
|
||||
canvas.chartingSpace.onKeyPressed(event)
|
||||
|
||||
/* Shourcuts to Menu Items */
|
||||
if ((event.keyCode >= 48 && event.keyCode <= 57)) {
|
||||
let number = event.key
|
||||
if (MENU_ITEM_ON_FOCUS !== undefined) {
|
||||
let menuItem = thisObject.shorcutNumbers.get(number)
|
||||
if (menuItem !== undefined) {
|
||||
menuItem.shorcutNumber = undefined
|
||||
}
|
||||
thisObject.shorcutNumbers.set(number, MENU_ITEM_ON_FOCUS)
|
||||
MENU_ITEM_ON_FOCUS.shorcutNumber = number
|
||||
} else {
|
||||
let menuItem = thisObject.shorcutNumbers.get(number)
|
||||
if (menuItem !== undefined) {
|
||||
menuItem.internalClick()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (event.key === 'Escape' && canvas.floatingSpace.inMapMode === true) {
|
||||
canvas.floatingSpace.exitMapMode()
|
||||
}
|
||||
@@ -274,6 +296,16 @@ function newCanvas () {
|
||||
return
|
||||
}
|
||||
|
||||
if (event.shiftKey === true && (event.ctrlKey === true || event.metaKey === true) && (event.key === 'S' || event.key === 's')) {
|
||||
let saved = canvas.designSpace.workspace.save()
|
||||
if (saved === true) {
|
||||
canvas.cockpitSpace.setStatus('Workspace Saved.', 50, canvas.cockpitSpace.statusTypes.ALL_GOOD)
|
||||
}
|
||||
|
||||
event.preventDefault()
|
||||
return
|
||||
}
|
||||
|
||||
let nodeOnFocus = canvas.designSpace.workspace.getNodeThatIsOnFocus()
|
||||
if (nodeOnFocus !== undefined) {
|
||||
if (nodeOnFocus.payload.uiObject.codeEditor !== undefined) {
|
||||
@@ -399,6 +431,7 @@ function newCanvas () {
|
||||
}
|
||||
|
||||
if ((event.ctrlKey === true || event.metaKey === true) && event.altKey === true) {
|
||||
/* Shortcuts to nodes */
|
||||
if ((event.keyCode >= 48 && event.keyCode <= 57) || (event.keyCode >= 65 && event.keyCode <= 90)) {
|
||||
/* From here we prevent the default behaviour. Putting it earlier prevents imput box and text area to receive keystrokes */
|
||||
event.preventDefault()
|
||||
|
||||
@@ -19,6 +19,10 @@ function newCoordinateSystem () {
|
||||
autoMaxXScale: true,
|
||||
autoMinYScale: true,
|
||||
autoMaxYScale: true,
|
||||
HORIZONTAL_MARGIN_FACTOR: 0.80,
|
||||
VERTICAL_MARGIN_FACTOR: 0.90,
|
||||
HORIZONTAL_MARGIN_INVERSE_FACTOR: 0.20,
|
||||
VERTICAL_MARGIN_INVERSE_FACTOR: 0.10,
|
||||
physics: physics,
|
||||
reportXValue: reportXValue,
|
||||
reportYValue: reportYValue,
|
||||
@@ -105,6 +109,10 @@ function newCoordinateSystem () {
|
||||
|
||||
/* Reseting this to start over at each cycle. */
|
||||
noXValueReported = true
|
||||
|
||||
if (mustRecalculate === true) {
|
||||
thisObject.eventHandler.raiseEvent('X-Range Changed')
|
||||
}
|
||||
}
|
||||
|
||||
if ((thisObject.autoMinYScale === true || thisObject.autoMaxYScale === true) && noYValueReported === false) {
|
||||
@@ -189,8 +197,8 @@ function newCoordinateSystem () {
|
||||
}
|
||||
|
||||
function recalculateScale (event) {
|
||||
thisObject.scale.x = thisObject.maxWidth / (thisObject.max.x - thisObject.min.x)
|
||||
thisObject.scale.y = thisObject.maxHeight / (thisObject.max.y - thisObject.min.y)
|
||||
thisObject.scale.x = thisObject.maxWidth * thisObject.HORIZONTAL_MARGIN_FACTOR / (thisObject.max.x - thisObject.min.x)
|
||||
thisObject.scale.y = thisObject.maxHeight * thisObject.VERTICAL_MARGIN_FACTOR / (thisObject.max.y - thisObject.min.y)
|
||||
|
||||
thisObject.eventHandler.raiseEvent('Scale Changed', event)
|
||||
}
|
||||
@@ -226,8 +234,8 @@ function newCoordinateSystem () {
|
||||
*/
|
||||
|
||||
point = {
|
||||
x: (point.x - thisObject.min.x) * thisObject.scale.x,
|
||||
y: thisObject.maxHeight - (point.y - thisObject.min.y) * thisObject.scale.y
|
||||
x: (point.x - thisObject.min.x) * thisObject.scale.x + thisObject.maxWidth * thisObject.HORIZONTAL_MARGIN_INVERSE_FACTOR / 2,
|
||||
y: thisObject.maxHeight - (point.y - thisObject.min.y) * thisObject.scale.y - thisObject.maxHeight * thisObject.VERTICAL_MARGIN_INVERSE_FACTOR / 2
|
||||
}
|
||||
|
||||
return point
|
||||
@@ -235,8 +243,8 @@ function newCoordinateSystem () {
|
||||
|
||||
function transformThisPoint2 (point) {
|
||||
point = {
|
||||
x: (point.x - thisObject.min.x) * thisObject.scale.x,
|
||||
y: (thisObject.maxHeight - point.y - thisObject.min.y) * thisObject.scale.y
|
||||
x: (point.x - thisObject.min.x) * thisObject.scale.x + thisObject.maxWidth * thisObject.HORIZONTAL_MARGIN_INVERSE_FACTOR / 2,
|
||||
y: (thisObject.maxHeight - point.y - thisObject.min.y) * thisObject.scale.y - thisObject.maxHeight * thisObject.VERTICAL_MARGIN_INVERSE_FACTOR / 2
|
||||
}
|
||||
|
||||
return point
|
||||
@@ -244,8 +252,8 @@ function newCoordinateSystem () {
|
||||
|
||||
function unInverseTransform (point, inverseY) {
|
||||
point = {
|
||||
x: (point.x / thisObject.scale.x) + thisObject.min.x,
|
||||
y: (inverseY - point.y) / thisObject.scale.y + thisObject.min.y
|
||||
x: ((point.x - thisObject.maxWidth * thisObject.HORIZONTAL_MARGIN_INVERSE_FACTOR / 2) / thisObject.scale.x) + thisObject.min.x,
|
||||
y: (inverseY * thisObject.VERTICAL_MARGIN_FACTOR - point.y + thisObject.maxHeight * thisObject.VERTICAL_MARGIN_INVERSE_FACTOR / 2) / thisObject.scale.y + thisObject.min.y
|
||||
}
|
||||
|
||||
return point
|
||||
@@ -253,8 +261,8 @@ function newCoordinateSystem () {
|
||||
|
||||
function inverseTransformUncappedY (point, inverseY) {
|
||||
point = {
|
||||
x: (point.x - thisObject.min.x) * thisObject.scale.x,
|
||||
y: (inverseY - point.y) * thisObject.scale.y
|
||||
x: (point.x - thisObject.min.x) * thisObject.scale.x + thisObject.maxWidth * thisObject.HORIZONTAL_MARGIN_INVERSE_FACTOR / 2,
|
||||
y: (inverseY * thisObject.VERTICAL_MARGIN_FACTOR - point.y) * thisObject.scale.y - thisObject.maxHeight * thisObject.VERTICAL_MARGIN_INVERSE_FACTOR / 2
|
||||
}
|
||||
|
||||
return point
|
||||
|
||||
@@ -109,7 +109,7 @@ function newEdgeEditor () {
|
||||
/* Resize the Time Machine to match the current screen aspect ration */
|
||||
|
||||
thisObject.container.parentContainer.frame.width = browserCanvas.width / TIME_MACHINE_WIDTH
|
||||
thisObject.container.parentContainer.frame.height = (browserCanvas.height - TOP_SPACE_HEIGHT - COCKPIT_SPACE_HEIGHT) / TIME_MACHINE_HEIGHT
|
||||
thisObject.container.parentContainer.frame.height = (COCKPIT_SPACE_POSITION - TOP_SPACE_HEIGHT) / TIME_MACHINE_HEIGHT
|
||||
coordinateSystem.maxHeight = thisObject.container.parentContainer.frame.height
|
||||
coordinateSystem.maxWidth = thisObject.container.parentContainer.frame.width
|
||||
coordinateSystem.recalculateScale()
|
||||
@@ -185,25 +185,29 @@ function newEdgeEditor () {
|
||||
function onKeyPressed (event) {
|
||||
const STEP = 10
|
||||
|
||||
if (event.shiftKey === false && event.code === 'ArrowLeft') {
|
||||
if (event.shiftKey === false && event.ctrlKey === false && event.code === 'ArrowLeft') {
|
||||
onDragStarted(event)
|
||||
thisObject.container.frame.position.x = thisObject.container.frame.position.x + STEP
|
||||
whatHappened = 'left or right arrow key pressed'
|
||||
return
|
||||
}
|
||||
|
||||
if (event.shiftKey === false && event.code === 'ArrowRight') {
|
||||
if (event.shiftKey === false && event.ctrlKey === false && event.code === 'ArrowRight') {
|
||||
onDragStarted(event)
|
||||
thisObject.container.frame.position.x = thisObject.container.frame.position.x - STEP
|
||||
whatHappened = 'left or right arrow key pressed'
|
||||
return
|
||||
}
|
||||
|
||||
if (event.shiftKey === false && event.code === 'ArrowUp') {
|
||||
if (event.shiftKey === false && event.ctrlKey === false && event.code === 'ArrowUp') {
|
||||
onDragStarted(event)
|
||||
thisObject.container.frame.position.y = thisObject.container.frame.position.y + STEP
|
||||
whatHappened = 'up or down arrow key pressed'
|
||||
return
|
||||
}
|
||||
|
||||
if (event.shiftKey === false && event.code === 'ArrowDown') {
|
||||
if (event.shiftKey === false && event.ctrlKey === false && event.code === 'ArrowDown') {
|
||||
onDragStarted(event)
|
||||
thisObject.container.frame.position.y = thisObject.container.frame.position.y - STEP
|
||||
whatHappened = 'up or down arrow key pressed'
|
||||
return
|
||||
@@ -268,6 +272,7 @@ function newEdgeEditor () {
|
||||
}
|
||||
|
||||
function draggingPhysics () {
|
||||
if (coordinateSystemWhenDragStarted === undefined) { return }
|
||||
if (thisObject.container.frame.position.x === 0 && thisObject.container.frame.position.y === 0) { return }
|
||||
|
||||
let mouseNoZoom = canvas.chartingSpace.viewport.unTransformThisPoint(mouse.position)
|
||||
@@ -324,7 +329,7 @@ function newEdgeEditor () {
|
||||
break
|
||||
case 'left or right arrow key pressed': {
|
||||
let point = {
|
||||
x: -dragVector.x,
|
||||
x: -dragVector.x + thisObject.container.frame.width * coordinateSystem.HORIZONTAL_MARGIN_INVERSE_FACTOR / 2,
|
||||
y: 0
|
||||
}
|
||||
|
||||
@@ -342,7 +347,7 @@ function newEdgeEditor () {
|
||||
case 'up or down arrow key pressed': {
|
||||
let point = {
|
||||
x: 0,
|
||||
y: -dragVector.y
|
||||
y: -dragVector.y + thisObject.container.frame.height * coordinateSystem.VERTICAL_MARGIN_INVERSE_FACTOR / 2
|
||||
}
|
||||
|
||||
let newMaxRate = getRateFromPointAtContainer(point, thisObject.container.parentContainer, coordinateSystem)
|
||||
|
||||
@@ -43,6 +43,7 @@ function newTimelineChart () {
|
||||
let timeFrameScaleEventSuscriptionId
|
||||
let timeFrameScaleMouseOverEventSuscriptionId
|
||||
let scaleChangedEventSubscriptionId
|
||||
let xRangeChangedEventSubscriptionId
|
||||
|
||||
let drawScales = false
|
||||
let mouse = {
|
||||
@@ -63,6 +64,7 @@ function newTimelineChart () {
|
||||
|
||||
function finalize () {
|
||||
coordinateSystem.eventHandler.stopListening(scaleChangedEventSubscriptionId)
|
||||
timelineChartCoordinateSystem.eventHandler.stopListening(xRangeChangedEventSubscriptionId)
|
||||
|
||||
if (thisObject.layersManager !== undefined) {
|
||||
finalizeLayersManager()
|
||||
@@ -145,6 +147,7 @@ function newTimelineChart () {
|
||||
onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver)
|
||||
onMouseNotOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver)
|
||||
scaleChangedEventSubscriptionId = timeMachineCoordinateSystem.eventHandler.listenToEvent('Scale Changed', onScaleChanged)
|
||||
xRangeChangedEventSubscriptionId = timelineChartCoordinateSystem.eventHandler.listenToEvent('X-Range Changed', xRangeChanged)
|
||||
}
|
||||
|
||||
function initializeCoordinateSystem () {
|
||||
@@ -231,6 +234,15 @@ function newTimelineChart () {
|
||||
}
|
||||
}
|
||||
|
||||
function xRangeChanged (event) {
|
||||
if (thisObject.rateScale !== undefined) {
|
||||
/* We need to re trasmit the changes on the x Range of the timelinechart coordinate system to the time machine coordinate system so that its scale is syncronized. */
|
||||
timeMachineCoordinateSystem.min.x = timelineChartCoordinateSystem.min.x
|
||||
timeMachineCoordinateSystem.max.x = timelineChartCoordinateSystem.max.x
|
||||
timeMachineCoordinateSystem.recalculateScale()
|
||||
}
|
||||
}
|
||||
|
||||
function onScaleChanged (event) {
|
||||
if (thisObject.rateScale !== undefined) {
|
||||
thisObject.rateScale.onUpstreamScaleChanged(event)
|
||||
|
||||
@@ -61,7 +61,7 @@ function newViewport () {
|
||||
|
||||
/* Initial default value */
|
||||
thisObject.zoomLevel = MIN_ZOOM_LEVEL
|
||||
thisObject.zoomTargetLevel = MIN_ZOOM_LEVEL
|
||||
thisObject.zoomTargetLevel = Math.round(MIN_ZOOM_LEVEL)
|
||||
INITIAL_TIME_PERIOD = recalculatePeriod(thisObject.zoomLevel)
|
||||
|
||||
let overrideMousePositionCounter = 0
|
||||
@@ -140,11 +140,11 @@ function newViewport () {
|
||||
y: -container.frame.position.y - container.frame.height / 2
|
||||
}
|
||||
position.x = targetPoint.x + browserCanvas.width / 2
|
||||
position.y = targetPoint.y + (browserCanvas.height - COCKPIT_SPACE_HEIGHT - TOP_SPACE_HEIGHT) / 2 + TOP_SPACE_HEIGHT
|
||||
position.y = targetPoint.y + (COCKPIT_SPACE_POSITION - TOP_SPACE_HEIGHT) / 2 + TOP_SPACE_HEIGHT
|
||||
}
|
||||
|
||||
function zoomAtCenter (level) {
|
||||
thisObject.zoomTargetLevel = level
|
||||
thisObject.zoomTargetLevel = Math.round(level)
|
||||
overrideMousePositionCounter = 50
|
||||
ANIMATION_INCREMENT = 0.5
|
||||
}
|
||||
@@ -152,7 +152,7 @@ function newViewport () {
|
||||
function mousePositionPhysics () {
|
||||
if (overrideMousePositionCounter > 0) {
|
||||
thisObject.mousePosition.x = browserCanvas.width / 2
|
||||
thisObject.mousePosition.y = (browserCanvas.height - TOP_SPACE_HEIGHT - COCKPIT_SPACE_HEIGHT) / 2 + TOP_SPACE_HEIGHT
|
||||
thisObject.mousePosition.y = (COCKPIT_SPACE_POSITION - TOP_SPACE_HEIGHT) / 2 + TOP_SPACE_HEIGHT
|
||||
|
||||
overrideMousePositionCounter--
|
||||
if (overrideMousePositionCounter < 0) {
|
||||
@@ -200,7 +200,13 @@ function newViewport () {
|
||||
if (thisObject.visible === false) { return }
|
||||
if ((event.ctrlKey === true || event.metaKey === true)) { return }
|
||||
let morePower = 1
|
||||
|
||||
if (IS_MAC) {
|
||||
event.delta = event.delta * MAC_AMOUNT_FACTOR
|
||||
}
|
||||
|
||||
let amount = event.delta
|
||||
|
||||
if (event.buttons === 4) { morePower = 2 } // Mouse wheel pressed.
|
||||
/* We adjust the sensitivity for Mac Users */
|
||||
|
||||
@@ -220,7 +226,7 @@ function newViewport () {
|
||||
if (thisObject.zoomTargetLevel + amount * morePower < MIN_ZOOM_LEVEL) {
|
||||
return false
|
||||
}
|
||||
thisObject.zoomTargetLevel = Math.round((thisObject.zoomTargetLevel + amount * morePower) * MAC_AMOUNT_FACTOR) / MAC_AMOUNT_FACTOR
|
||||
thisObject.zoomTargetLevel = Math.round(thisObject.zoomTargetLevel + amount * morePower)
|
||||
|
||||
ANIMATION_INCREMENT = Math.round(Math.abs(thisObject.zoomTargetLevel - thisObject.zoomLevel) / ANIMATION_STEPS * 100) / 100
|
||||
|
||||
@@ -398,7 +404,7 @@ function newViewport () {
|
||||
|
||||
function newZoomLevel (level) {
|
||||
thisObject.zoomLevel = Math.round(level)
|
||||
thisObject.zoomTargetLevel = level
|
||||
thisObject.zoomTargetLevel = Math.round(level)
|
||||
INITIAL_TIME_PERIOD = recalculatePeriod(level)
|
||||
saveObjectState()
|
||||
ANIMATION_INCREMENT = 0
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
|
||||
function newContainer () {
|
||||
let thisObject = {
|
||||
id: Math.trunc(Math.random() * 10000000),
|
||||
id: newUniqueId(),
|
||||
type: 'Rectangle',
|
||||
frame: undefined,
|
||||
eventHandler: undefined,
|
||||
|
||||
@@ -52,6 +52,9 @@ function newCCXTFunctions () {
|
||||
newExchange.exchangeAssets.payload.floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_050X
|
||||
newExchange.exchangeMarkets.payload.floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_100X
|
||||
newExchange.exchangeAccounts.payload.floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_025X
|
||||
newExchange.exchangeAssets.payload.floatingObject.arrangementStyle = ARRANGEMENT_STYLE.CONCAVE
|
||||
newExchange.exchangeMarkets.payload.floatingObject.arrangementStyle = ARRANGEMENT_STYLE.CONCAVE
|
||||
newExchange.exchangeAccounts.payload.floatingObject.arrangementStyle = ARRANGEMENT_STYLE.CONCAVE
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -114,6 +117,7 @@ function newCCXTFunctions () {
|
||||
newAsseet.code = '{ \n\"codeName\": \"' + name + '\"\n}'
|
||||
newAsseet.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_360
|
||||
newAsseet.payload.floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_200X
|
||||
newAsseet.payload.floatingObject.arrangementStyle = ARRANGEMENT_STYLE.CONCAVE
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -184,13 +188,18 @@ function newCCXTFunctions () {
|
||||
newMarket.code = '{ \n\"codeName\": \"' + name + '\"\n}'
|
||||
newMarket.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
|
||||
newMarket.payload.floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_050X
|
||||
newMarket.payload.floatingObject.arrangementStyle = ARRANGEMENT_STYLE.CONCAVE
|
||||
newMarket.baseAsset.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_45
|
||||
newMarket.quotedAsset.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_45
|
||||
newMarket.baseAsset.payload.floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_100X
|
||||
newMarket.quotedAsset.payload.floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_150X
|
||||
newMarket.baseAsset.payload.floatingObject.arrangementStyle = ARRANGEMENT_STYLE.CONCAVE
|
||||
newMarket.quotedAsset.payload.floatingObject.arrangementStyle = ARRANGEMENT_STYLE.CONCAVE
|
||||
newMarket.baseAsset.payload.referenceParent = baseAsset
|
||||
newMarket.quotedAsset.payload.referenceParent = quotedAsset
|
||||
|
||||
currentMarkets.set(name, newMarket)
|
||||
|
||||
let superActions = node.payload.parentNode.payload.parentNode.payload.parentNode.superActions
|
||||
|
||||
for (let j = 0; j < superActions.superActions.length; j++) {
|
||||
|
||||
@@ -146,7 +146,8 @@ function newNodeCloning () {
|
||||
isFrozen: (node.payload.floatingObject.isFrozen && node.payload.floatingObject.frozenManually),
|
||||
isCollapsed: (node.payload.floatingObject.isCollapsed && node.payload.floatingObject.collapsedManually),
|
||||
angleToParent: (node.payload.floatingObject.angleToParent),
|
||||
distanceToParent: (node.payload.floatingObject.distanceToParent)
|
||||
distanceToParent: (node.payload.floatingObject.distanceToParent),
|
||||
arrangementStyle: (node.payload.floatingObject.arrangementStyle)
|
||||
},
|
||||
uiObject: {
|
||||
isRunning: node.payload.uiObject.isRunning,
|
||||
|
||||
@@ -149,7 +149,8 @@ function newProtocolNode () {
|
||||
isFrozen: (node.payload.floatingObject.isFrozen && node.payload.floatingObject.frozenManually),
|
||||
isCollapsed: (node.payload.floatingObject.isCollapsed && node.payload.floatingObject.collapsedManually),
|
||||
angleToParent: (node.payload.floatingObject.angleToParent),
|
||||
distanceToParent: (node.payload.floatingObject.distanceToParent)
|
||||
distanceToParent: (node.payload.floatingObject.distanceToParent),
|
||||
arrangementStyle: (node.payload.floatingObject.arrangementStyle)
|
||||
},
|
||||
uiObject: {
|
||||
isRunning: node.payload.uiObject.isRunning,
|
||||
|
||||
@@ -37,7 +37,7 @@ function newSessionFunctions () {
|
||||
'Exchange Account Asset->Asset->' +
|
||||
'Strategy->' +
|
||||
'Trigger Stage->Trigger On Event->Trigger Off Event->Take Position Event->' +
|
||||
'Announcement->Telegram Bot->' +
|
||||
'Announcement->Formula->' +
|
||||
'Open Stage->Initial Definition->Open Execution->' +
|
||||
'Position Size->Position Rate->Formula->' +
|
||||
'Initial Stop->Initial Take Profit->' +
|
||||
@@ -45,8 +45,8 @@ function newSessionFunctions () {
|
||||
'Stop->Take Profit->' +
|
||||
'Phase->Formula->Next Phase Event->' +
|
||||
'Situation->Condition->Javascript Code->' +
|
||||
'Announcement->Telegram Bot->' +
|
||||
'Close Stage->Close Execution->'
|
||||
'Close Stage->Close Execution->' +
|
||||
'Announcement->Formula->'
|
||||
|
||||
let tradingSystem = functionLibraryProtocolNode.getProtocolNode(node.payload.referenceParent, false, true, true, false, false, lightingPath)
|
||||
|
||||
@@ -54,7 +54,8 @@ function newSessionFunctions () {
|
||||
'Backtesting Session->Paper Trading Session->Fordward Testing Session->Live Trading Session->' +
|
||||
'Parameters->' +
|
||||
'Base Asset->Quoted Asset->Time Range->Time Frame->Slippage->Fee Structure->' +
|
||||
'Exchange Account Asset->Asset->'
|
||||
'Exchange Account Asset->Asset->' +
|
||||
'Social Bots->Telegram Bot->'
|
||||
|
||||
let session = functionLibraryProtocolNode.getProtocolNode(node, false, true, true, false, false, lightingPath)
|
||||
|
||||
|
||||
@@ -19,26 +19,132 @@ function newUiObjectsFromNodes () {
|
||||
tasksToRun = []
|
||||
sessionsToRun = []
|
||||
|
||||
/* Create the workspace UI OBject and then continue with the root nodes. */
|
||||
createUiObject(false, 'Workspace', node.name, node, undefined, undefined, 'Workspace')
|
||||
if (node.rootNodes !== undefined) {
|
||||
for (let i = 0; i < node.rootNodes.length; i++) {
|
||||
let rootNode = node.rootNodes[i]
|
||||
createUiObjectFromNode(rootNode, undefined, undefined)
|
||||
addIncludedNodes()
|
||||
|
||||
function addIncludedNodes () {
|
||||
blobService = newFileStorage()
|
||||
|
||||
// if (node.code === undefined) {
|
||||
node.code = '{ \n"includeDataMines": ["Masters", "Sparta", "TradingEngines"],\n"includeTradingSystems": ["Sparta-WHB-BTC-USDT", "Masters-WHB-ETH-USDT", "Sparta-BRR-BTC-USDT"],\n"includeSuperScripts": ["Masters"]\n }'
|
||||
// }
|
||||
|
||||
let code = JSON.parse(node.code)
|
||||
let includeDataMines = code.includeDataMines
|
||||
let includeTradingSystems = code.includeTradingSystems
|
||||
let includeSuperScripts = code.includeSuperScripts
|
||||
|
||||
let totalIncluded = 0
|
||||
|
||||
for (let i = 0; i < includeDataMines.length; i++) {
|
||||
let name = includeDataMines[i]
|
||||
blobService.getBlobToText('DataMines' + '/' + name, undefined, onFileReceived, true)
|
||||
function onFileReceived (err, text, response) {
|
||||
if (err && err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
console.log('Cannot load included Data Mine ' + name + '. The workspace can not be loaded.')
|
||||
return
|
||||
}
|
||||
let receivedNode = JSON.parse(text)
|
||||
for (let i = 0; i < node.rootNodes.length; i++) {
|
||||
let rootNode = node.rootNodes[i]
|
||||
if (rootNode.type === 'Data Mine') {
|
||||
if (rootNode.code !== undefined) {
|
||||
let code = JSON.parse(rootNode.code)
|
||||
if (code.name === name) {
|
||||
rootNodes.splice(i, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
receivedNode.isIncluded = true
|
||||
node.rootNodes.push(receivedNode)
|
||||
totalIncluded++
|
||||
if (totalIncluded === includeDataMines.length + includeTradingSystems.length + includeSuperScripts.length) {
|
||||
addUserDefinedNodes()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < includeTradingSystems.length; i++) {
|
||||
let name = includeTradingSystems[i]
|
||||
blobService.getBlobToText('TradingSystems' + '/' + name, undefined, onFileReceived, true)
|
||||
function onFileReceived (err, text, response) {
|
||||
if (err && err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
console.log('Cannot load included Data Mine ' + name + '. The workspace can not be loaded.')
|
||||
return
|
||||
}
|
||||
let receivedNode = JSON.parse(text)
|
||||
for (let i = 0; i < node.rootNodes.length; i++) {
|
||||
let rootNode = node.rootNodes[i]
|
||||
if (rootNode.type === 'Trading System') {
|
||||
if (rootNode.code !== undefined) {
|
||||
let code = JSON.parse(rootNode.code)
|
||||
if (code.name === name) {
|
||||
rootNodes.splice(i, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
receivedNode.isIncluded = true
|
||||
node.rootNodes.push(receivedNode)
|
||||
totalIncluded++
|
||||
if (totalIncluded === includeDataMines.length + includeTradingSystems.length + includeSuperScripts.length) {
|
||||
addUserDefinedNodes()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < includeSuperScripts.length; i++) {
|
||||
let name = includeSuperScripts[i]
|
||||
blobService.getBlobToText('SuperScripts' + '/' + name, undefined, onFileReceived, true)
|
||||
function onFileReceived (err, text, response) {
|
||||
if (err && err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
console.log('Cannot load included Data Mine ' + name + '. The workspace can not be loaded.')
|
||||
return
|
||||
}
|
||||
let receivedNode = JSON.parse(text)
|
||||
for (let i = 0; i < node.rootNodes.length; i++) {
|
||||
let rootNode = node.rootNodes[i]
|
||||
if (rootNode.type === 'Super Scripts') {
|
||||
if (rootNode.code !== undefined) {
|
||||
let code = JSON.parse(rootNode.code)
|
||||
if (code.name === name) {
|
||||
rootNodes.splice(i, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
receivedNode.isIncluded = true
|
||||
node.rootNodes.push(receivedNode)
|
||||
totalIncluded++
|
||||
if (totalIncluded === includeDataMines.length + includeTradingSystems.length + includeSuperScripts.length) {
|
||||
addUserDefinedNodes()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tryToConnectChildrenWithReferenceParents()
|
||||
function addUserDefinedNodes () {
|
||||
/* Create the workspace UI OBject and then continue with the root nodes. */
|
||||
createUiObject(false, 'Workspace', node.name, node, undefined, undefined, 'Workspace')
|
||||
if (node.rootNodes !== undefined) {
|
||||
for (let i = 0; i < node.rootNodes.length; i++) {
|
||||
let rootNode = node.rootNodes[i]
|
||||
createUiObjectFromNode(rootNode, undefined, undefined)
|
||||
}
|
||||
}
|
||||
|
||||
if (replacingCurrentWorkspace === true) {
|
||||
// We need to wait all tasks that were potentially running to stop
|
||||
setTimeout(runTasks, 70000)
|
||||
// We give a few seconds for the tasks to start
|
||||
setTimeout(runSessions, 80000)
|
||||
} else {
|
||||
runTasks()
|
||||
// We give a few seconds for the tasks to start
|
||||
setTimeout(runSessions, 10000)
|
||||
tryToConnectChildrenWithReferenceParents()
|
||||
|
||||
if (replacingCurrentWorkspace === true) {
|
||||
// We need to wait all tasks that were potentially running to stop
|
||||
setTimeout(runTasks, 70000)
|
||||
// We give a few seconds for the tasks to start
|
||||
setTimeout(runSessions, 80000)
|
||||
} else {
|
||||
runTasks()
|
||||
// We give a few seconds for the tasks to start
|
||||
setTimeout(runSessions, 10000)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,10 +7,10 @@ function newWorkspace () {
|
||||
|
||||
let thisObject = {
|
||||
workspaceNode: undefined,
|
||||
tradingSystem: undefined,
|
||||
container: undefined,
|
||||
enabled: false,
|
||||
nodeChildren: undefined,
|
||||
save: saveWorkspace,
|
||||
getHierarchyHeads: getHierarchyHeads,
|
||||
getNodeThatIsOnFocus: getNodeThatIsOnFocus,
|
||||
getNodeByShortcutKey: getNodeByShortcutKey,
|
||||
@@ -66,6 +66,8 @@ function newWorkspace () {
|
||||
let circularProgressBar = newBusyProgressBar()
|
||||
circularProgressBar.fitFunction = canvas.floatingSpace.fitIntoVisibleArea
|
||||
let droppedNode
|
||||
let sessionTimestamp = (new Date()).valueOf()
|
||||
window.localStorage.setItem('Session Timestamp', sessionTimestamp)
|
||||
|
||||
return thisObject
|
||||
|
||||
@@ -90,7 +92,7 @@ function newWorkspace () {
|
||||
functionLibraryUiObjectsFromNodes.recreateWorkspace(thisObject.workspaceNode)
|
||||
thisObject.enabled = true
|
||||
|
||||
setInterval(saveWorkspace, 10000)
|
||||
setInterval(saveWorkspace, 60000)
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err.stack) }
|
||||
}
|
||||
@@ -113,8 +115,15 @@ function newWorkspace () {
|
||||
}
|
||||
|
||||
function saveWorkspace () {
|
||||
let textToSave = stringifyWorkspace()
|
||||
window.localStorage.setItem(CANVAS_APP_NAME + '.' + 'Workspace', textToSave)
|
||||
let savedSessionTimestamp = window.localStorage.getItem('Session Timestamp')
|
||||
if (Number(savedSessionTimestamp) !== sessionTimestamp) {
|
||||
canvas.cockpitSpace.setStatus('Could not save the Workspace. You have more that one instance of the Superlagos User Interface open at the same time. Plese close this instance as it is older than the others.', 150, canvas.cockpitSpace.statusTypes.WARNING)
|
||||
} else {
|
||||
let textToSave = stringifyWorkspace()
|
||||
window.localStorage.setItem(CANVAS_APP_NAME + '.' + 'Workspace', textToSave)
|
||||
window.localStorage.setItem('Session Timestamp', sessionTimestamp)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
function physics () {
|
||||
@@ -163,8 +172,9 @@ function newWorkspace () {
|
||||
let stringifyReadyNodes = []
|
||||
for (let i = 0; i < thisObject.workspaceNode.rootNodes.length; i++) {
|
||||
let rootNode = thisObject.workspaceNode.rootNodes[i]
|
||||
let node = functionLibraryProtocolNode.getProtocolNode(rootNode, removePersonalData, false, true, true, true)
|
||||
if (node) {
|
||||
|
||||
if (rootNode.isIncluded !== true) {
|
||||
let node = functionLibraryProtocolNode.getProtocolNode(rootNode, removePersonalData, false, true, true, true)
|
||||
stringifyReadyNodes.push(node)
|
||||
}
|
||||
}
|
||||
@@ -184,15 +194,15 @@ function newWorkspace () {
|
||||
if (rootNode.networkNodes !== undefined) {
|
||||
for (let j = 0; j < rootNode.networkNodes.length; j++) {
|
||||
let networkNode = rootNode.networkNodes[j]
|
||||
if (networkNode.dataMining !== undefined) {
|
||||
if (networkNode.dataMining !== undefined && networkNode.dataMining.payload !== undefined) {
|
||||
networkNode.dataMining.payload.uiObject.menu.internalClick('Stop All Exchange Tasks')
|
||||
networkNode.dataMining.payload.uiObject.menu.internalClick('Stop All Exchange Tasks')
|
||||
}
|
||||
if (networkNode.testingEnvironment !== undefined) {
|
||||
if (networkNode.testingEnvironment !== undefined && networkNode.testingEnvironment.payload !== undefined) {
|
||||
networkNode.testingEnvironment.payload.uiObject.menu.internalClick('Stop All Exchange Tasks')
|
||||
networkNode.testingEnvironment.payload.uiObject.menu.internalClick('Stop All Exchange Tasks')
|
||||
}
|
||||
if (networkNode.productionEnvironment !== undefined) {
|
||||
if (networkNode.productionEnvironment !== undefined && networkNode.productionEnvironment.payload !== undefined) {
|
||||
networkNode.productionEnvironment.payload.uiObject.menu.internalClick('Stop All Exchange Tasks')
|
||||
networkNode.productionEnvironment.payload.uiObject.menu.internalClick('Stop All Exchange Tasks')
|
||||
}
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ function newEventHandler () {
|
||||
}
|
||||
|
||||
function listenToEvent (eventType, handler, extraData) {
|
||||
let eventSubscriptionId = Math.trunc(Math.random() * 1000000)
|
||||
let eventSubscriptionId = newUniqueId()
|
||||
eventHandlers.push([eventType, handler, extraData, eventSubscriptionId])
|
||||
return eventSubscriptionId
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ function newCircularMenu () {
|
||||
isDeployed: undefined,
|
||||
internalClick: internalClick,
|
||||
physics: physics,
|
||||
invisiblePhysics: invisiblePhysics,
|
||||
drawBackground: drawBackground,
|
||||
drawForeground: drawForeground,
|
||||
getContainer: getContainer,
|
||||
@@ -171,6 +172,13 @@ function newCircularMenu () {
|
||||
}
|
||||
}
|
||||
|
||||
function invisiblePhysics () {
|
||||
for (let i = 0; i < menuItems.length; i++) {
|
||||
let menuItem = menuItems[i]
|
||||
menuItem.invisiblePhysics()
|
||||
}
|
||||
}
|
||||
|
||||
function physics () {
|
||||
for (let i = 0; i < menuItems.length; i++) {
|
||||
let menuItem = menuItems[i]
|
||||
@@ -190,7 +198,7 @@ function newCircularMenu () {
|
||||
function onNotFocus () {
|
||||
for (let i = 0; i < menuItems.length; i++) {
|
||||
let menuItem = menuItems[i]
|
||||
menuItem.targetRadius = menuItem.rawRadius * 0 - i * 4
|
||||
menuItem.targetRadius = menuItem.rawRadius * 0 - i * 1.5
|
||||
menuItem.isDeployed = false
|
||||
}
|
||||
thisObject.isDeployed = false
|
||||
|
||||
@@ -39,8 +39,10 @@ function newCircularMenuItem () {
|
||||
relatedUiObject: undefined,
|
||||
dontShowAtFullscreen: undefined,
|
||||
isEnabled: true,
|
||||
shorcutNumber: undefined,
|
||||
internalClick: internalClick,
|
||||
physics: physics,
|
||||
invisiblePhysics: invisiblePhysics,
|
||||
drawBackground: drawBackground,
|
||||
drawForeground: drawForeground,
|
||||
getContainer: getContainer,
|
||||
@@ -133,10 +135,29 @@ function newCircularMenuItem () {
|
||||
}
|
||||
}
|
||||
|
||||
function invisiblePhysics () {
|
||||
temporaryStatusPhysics()
|
||||
}
|
||||
|
||||
function temporaryStatusPhysics () {
|
||||
/* Temporary Status impacts on the label to use and the background of that label */
|
||||
if (temporaryStatusCounter > 0) {
|
||||
temporaryStatusCounter--
|
||||
}
|
||||
|
||||
if (temporaryStatusCounter === 0) {
|
||||
temporaryStatus = STATUS_NO_ACTION_TAKEN_YET
|
||||
labelToPrint = thisObject.label
|
||||
backgroundColorToUse = defaultBackgroudColor
|
||||
thisObject.nextAction = thisObject.action
|
||||
}
|
||||
}
|
||||
|
||||
function physics () {
|
||||
if (thisObject.dontShowAtFullscreen === true && AT_FULL_SCREEN_MODE === true) { return }
|
||||
|
||||
const INCREASE_STEP = 2
|
||||
let INCREASE_STEP = 2 // (thisObject.targetRadius - thisObject.rawRadius) / 4
|
||||
// if (INCREASE_STEP === 0) { INCREASE_STEP = 2 }
|
||||
|
||||
if (Math.abs(thisObject.currentRadius - thisObject.targetRadius) >= INCREASE_STEP) {
|
||||
if (thisObject.currentRadius < thisObject.targetRadius) {
|
||||
@@ -150,19 +171,19 @@ function newCircularMenuItem () {
|
||||
if (thisObject.type === 'Icon Only') {
|
||||
switch (thisObject.ring) {
|
||||
case 1: {
|
||||
radiusGrowthFactor = 6.5
|
||||
radiusGrowthFactor = 5.5
|
||||
break
|
||||
}
|
||||
case 2: {
|
||||
radiusGrowthFactor = 5.0
|
||||
radiusGrowthFactor = 4.0
|
||||
break
|
||||
}
|
||||
case 3: {
|
||||
radiusGrowthFactor = 3.5
|
||||
radiusGrowthFactor = 3.0
|
||||
break
|
||||
}
|
||||
case 4: {
|
||||
radiusGrowthFactor = 2.5
|
||||
radiusGrowthFactor = 2.0
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -170,20 +191,10 @@ function newCircularMenuItem () {
|
||||
radiusGrowthFactor = 4
|
||||
}
|
||||
|
||||
thisObject.container.frame.position.x = thisObject.container.frame.radius * radiusGrowthFactor / 7 * Math.cos(toRadians(thisObject.angle)) - thisObject.currentRadius * 1.5
|
||||
thisObject.container.frame.position.y = thisObject.container.frame.radius * radiusGrowthFactor / 7 * Math.sin(toRadians(thisObject.angle)) - thisObject.container.frame.height / 2
|
||||
thisObject.container.frame.position.x = thisObject.payload.floatingObject.targetRadius * radiusGrowthFactor / 7 * Math.cos(toRadians(thisObject.angle)) - thisObject.currentRadius * 1.5
|
||||
thisObject.container.frame.position.y = thisObject.payload.floatingObject.targetRadius * radiusGrowthFactor / 7 * Math.sin(toRadians(thisObject.angle)) - thisObject.container.frame.height / 2
|
||||
|
||||
/* Temporary Status impacts on the label to use and the background of that label */
|
||||
if (temporaryStatusCounter > 0) {
|
||||
temporaryStatusCounter--
|
||||
}
|
||||
|
||||
if (temporaryStatusCounter === 0) {
|
||||
temporaryStatus = STATUS_NO_ACTION_TAKEN_YET
|
||||
labelToPrint = thisObject.label
|
||||
backgroundColorToUse = defaultBackgroudColor
|
||||
thisObject.nextAction = thisObject.action
|
||||
}
|
||||
temporaryStatusPhysics()
|
||||
|
||||
/* Here we will check if we need to monitor a property that influences the status of the Menu Item. */
|
||||
if (thisObject.disableIfPropertyIsDefined === true) {
|
||||
@@ -245,13 +256,20 @@ function newCircularMenuItem () {
|
||||
} else {
|
||||
isMouseOver = false
|
||||
}
|
||||
MENU_ITEM_ON_FOCUS = thisObject
|
||||
}
|
||||
|
||||
function onMouseNotOver (point) {
|
||||
isMouseOver = false
|
||||
MENU_ITEM_ON_FOCUS = undefined
|
||||
}
|
||||
|
||||
function internalClick () {
|
||||
if (thisObject.shorcutNumber !== undefined) {
|
||||
let label = thisObject.payload.node.name + ' ' + labelToPrint
|
||||
canvas.cockpitSpace.setStatus(label, 50, canvas.cockpitSpace.statusTypes.ALL_GOOD)
|
||||
}
|
||||
|
||||
onMouseClick()
|
||||
}
|
||||
|
||||
@@ -279,7 +297,11 @@ function newCircularMenuItem () {
|
||||
/* A Click during confirmation executes the pre-defined action. */
|
||||
if (temporaryStatus === STATUS_WAITING_CONFIRMATION || temporaryStatus === STATUS_PRIMARY_WORK_DONE) {
|
||||
executeAction()
|
||||
setStatus(thisObject.workDoneLabel, UI_COLOR.PATINATED_TURQUOISE, 100, STATUS_SECONDARY_WORK_DONE)
|
||||
if (thisObject.workDoneLabel !== undefined) {
|
||||
setStatus(thisObject.workDoneLabel, UI_COLOR.PATINATED_TURQUOISE, 100, STATUS_SECONDARY_WORK_DONE)
|
||||
} else {
|
||||
setStatus('Done', UI_COLOR.PATINATED_TURQUOISE, 100, STATUS_SECONDARY_WORK_DONE)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -421,6 +443,11 @@ function newCircularMenuItem () {
|
||||
/* Menu Label */
|
||||
|
||||
if (thisObject.type === 'Icon & Text') {
|
||||
label = labelToPrint
|
||||
if (thisObject.shorcutNumber !== undefined) {
|
||||
label = '' + thisObject.shorcutNumber + '- ' + labelToPrint
|
||||
}
|
||||
|
||||
let labelPoint
|
||||
let fontSize = 15
|
||||
|
||||
@@ -434,7 +461,7 @@ function newCircularMenuItem () {
|
||||
|
||||
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY
|
||||
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)'
|
||||
browserCanvasContext.fillText(labelToPrint, labelPoint.x, labelPoint.y)
|
||||
browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,11 +25,15 @@ function newCircularProgressBar () {
|
||||
|
||||
let eventSubscriptionIdHeartbeat
|
||||
|
||||
let needToDrawRing = true
|
||||
|
||||
return thisObject
|
||||
|
||||
function finalize () {
|
||||
let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id
|
||||
systemEventHandler.stopListening(key, eventSubscriptionIdHeartbeat)
|
||||
if (eventSubscriptionIdHeartbeat !== undefined) {
|
||||
systemEventHandler.stopListening(key, eventSubscriptionIdHeartbeat)
|
||||
}
|
||||
|
||||
thisObject.container = undefined
|
||||
thisObject.payload = undefined
|
||||
@@ -62,6 +66,7 @@ function newCircularProgressBar () {
|
||||
thisObject.payload.uiObject.setPercentage(message.event.percentage, 2000)
|
||||
}
|
||||
if (message.event.status !== undefined) {
|
||||
needToDrawRing = false
|
||||
thisObject.payload.uiObject.setStatus(message.event.status, 200000)
|
||||
}
|
||||
|
||||
@@ -95,6 +100,8 @@ function newCircularProgressBar () {
|
||||
|
||||
function drawBackground (pFloatingObject) {
|
||||
if (canvas.floatingSpace.inMapMode === true) { return }
|
||||
if (needToDrawRing !== true) { return }
|
||||
|
||||
const VISIBLE_RADIUS = thisObject.container.frame.radius * 2
|
||||
|
||||
let visiblePosition = {
|
||||
|
||||
@@ -34,6 +34,7 @@ function newCodeEditor () {
|
||||
thisObject.container.frame.position.y = 0
|
||||
|
||||
let isMouseOver = false
|
||||
let SIZE_FACTOR = 1.4
|
||||
|
||||
return thisObject
|
||||
|
||||
@@ -72,6 +73,7 @@ function newCodeEditor () {
|
||||
textArea.style.display = 'none'
|
||||
thisObject.payload.node.code = textArea.value
|
||||
}
|
||||
EDITOR_ON_FOCUS = false
|
||||
}
|
||||
|
||||
function activate (payload) {
|
||||
@@ -97,6 +99,7 @@ function newCodeEditor () {
|
||||
'height: ' + thisObject.container.frame.height + 'px'
|
||||
textArea.style.display = 'block'
|
||||
textArea.focus()
|
||||
EDITOR_ON_FOCUS = true
|
||||
}
|
||||
|
||||
function getContainer (point) {
|
||||
@@ -129,8 +132,8 @@ function newCodeEditor () {
|
||||
thisObject.container.frame.position.x = 0
|
||||
thisObject.container.frame.position.y = 0
|
||||
|
||||
thisObject.container.frame.width = thisObject.container.frame.radius * 1.8 * 1.5
|
||||
thisObject.container.frame.height = thisObject.container.frame.radius * 1 * 1.4
|
||||
thisObject.container.frame.width = thisObject.container.frame.radius * 1.8 * SIZE_FACTOR
|
||||
thisObject.container.frame.height = thisObject.container.frame.radius * 1 * SIZE_FACTOR
|
||||
|
||||
let textAreaPosition = {
|
||||
x: 0 - thisObject.container.frame.width / 2,
|
||||
@@ -162,7 +165,7 @@ function newCodeEditor () {
|
||||
|
||||
position = thisObject.container.frame.frameThisPoint(position)
|
||||
|
||||
let radius = thisObject.container.frame.radius * 1.5
|
||||
let radius = thisObject.container.frame.radius * SIZE_FACTOR
|
||||
|
||||
if (radius > 0.5) {
|
||||
browserCanvasContext.beginPath()
|
||||
|
||||
@@ -72,6 +72,7 @@ function newConditionEditor () {
|
||||
textArea.style.display = 'none'
|
||||
thisObject.payload.node.code = textArea.value
|
||||
}
|
||||
EDITOR_ON_FOCUS = false
|
||||
}
|
||||
|
||||
function activate (payload) {
|
||||
@@ -97,6 +98,7 @@ function newConditionEditor () {
|
||||
'height: ' + thisObject.container.frame.height + 'px'
|
||||
textArea.style.display = 'block'
|
||||
textArea.focus()
|
||||
EDITOR_ON_FOCUS = true
|
||||
}
|
||||
|
||||
function getContainer (point) {
|
||||
|
||||
@@ -34,7 +34,7 @@ function newConfigEditor () {
|
||||
thisObject.container.frame.position.y = 0
|
||||
|
||||
let isMouseOver = false
|
||||
let SIZE_FACTOR = 0.8
|
||||
let SIZE_FACTOR = 1
|
||||
|
||||
return thisObject
|
||||
|
||||
@@ -79,6 +79,7 @@ function newConfigEditor () {
|
||||
thisObject.payload.uiObject.setErrorMessage(err.message, 10)
|
||||
}
|
||||
}
|
||||
EDITOR_ON_FOCUS = false
|
||||
}
|
||||
|
||||
function activate (payload) {
|
||||
@@ -104,6 +105,7 @@ function newConfigEditor () {
|
||||
'height: ' + thisObject.container.frame.height + 'px'
|
||||
textArea.style.display = 'block'
|
||||
textArea.focus()
|
||||
EDITOR_ON_FOCUS = true
|
||||
}
|
||||
|
||||
function getContainer (point) {
|
||||
|
||||
@@ -217,7 +217,7 @@ function newFloatingLayer () {
|
||||
|
||||
collapsePhysics(floatingObject)
|
||||
|
||||
if (floatingObject.isFrozen === false && floatingObject.isParentCollapsed === false) {
|
||||
if (floatingObject.isParentCollapsed === false) {
|
||||
visibleFloatingObjects.push(floatingObject)
|
||||
invisibleFloatingObjects.splice(i, 1) // Delete item from array.
|
||||
makeVisible()
|
||||
@@ -232,7 +232,7 @@ function newFloatingLayer () {
|
||||
|
||||
collapsePhysics(floatingObject)
|
||||
|
||||
if (floatingObject.isFrozen === true || floatingObject.isParentCollapsed === true) {
|
||||
if (floatingObject.isParentCollapsed === true) {
|
||||
invisibleFloatingObjects.push(floatingObject)
|
||||
visibleFloatingObjects.splice(i, 1) // Delete item from array.
|
||||
makeInvisible()
|
||||
@@ -265,8 +265,24 @@ function newFloatingLayer () {
|
||||
try {
|
||||
makeVisible()
|
||||
makeInvisible()
|
||||
invisiblePhysics()
|
||||
visiblePhysics()
|
||||
applyPhysics()
|
||||
|
||||
function invisiblePhysics () {
|
||||
for (let i = 0; i < invisibleFloatingObjects.length; i++) {
|
||||
let floatingObject = invisibleFloatingObjects[i]
|
||||
floatingObject.invisiblePhysics()
|
||||
}
|
||||
}
|
||||
|
||||
function visiblePhysics () {
|
||||
for (let i = 0; i < visibleFloatingObjects.length; i++) {
|
||||
let floatingObject = visibleFloatingObjects[i]
|
||||
floatingObject.physics()
|
||||
}
|
||||
}
|
||||
|
||||
function applyPhysics () {
|
||||
/* This function makes all the calculations to apply phisycs on all visible floatingObjects in this layer. */
|
||||
|
||||
@@ -276,7 +292,7 @@ function newFloatingLayer () {
|
||||
|
||||
for (let i = 0; i < visibleFloatingObjects.length; i++) {
|
||||
let floatingObject = visibleFloatingObjects[i]
|
||||
floatingObject.physics()
|
||||
if (floatingObject.isFrozen === true) { continue }
|
||||
|
||||
/* From here on, only if they are not too far. */
|
||||
if (canvas.floatingSpace.isItFar(floatingObject.payload)) { continue }
|
||||
|
||||
+143
-23
@@ -22,8 +22,9 @@ function newFloatingObject () {
|
||||
targetRadius: 0, // This is the target radius of the floating object with zoom applied. It should be animated until reaching this value.
|
||||
isPinned: false,
|
||||
isFrozen: false,
|
||||
angleToParent: ANGLE_TO_PARENT.RANGE_90,
|
||||
distanceToParent: DISTANCE_TO_PARENT.PARENT_100X,
|
||||
angleToParent: undefined,
|
||||
distanceToParent: undefined,
|
||||
arrangementStyle: ARRANGEMENT_STYLE.CONCAVE,
|
||||
isCollapsed: false,
|
||||
isParentCollapsed: false,
|
||||
frozenManually: false,
|
||||
@@ -33,6 +34,7 @@ function newFloatingObject () {
|
||||
getCollapseStatus: getCollapseStatus,
|
||||
getAngleToParent: getAngleToParent,
|
||||
getDistanceToParent: getDistanceToParent,
|
||||
getArrangementStyle: getArrangementStyle,
|
||||
nearbyFloatingObjects: [],
|
||||
setPosition: setPosition,
|
||||
pinToggle: pinToggle,
|
||||
@@ -40,7 +42,9 @@ function newFloatingObject () {
|
||||
collapseToggle: collapseToggle,
|
||||
angleToParentToggle: angleToParentToggle,
|
||||
distanceToParentToggle: distanceToParentToggle,
|
||||
arrangementStyleToggle: arrangementStyleToggle,
|
||||
physics: physics,
|
||||
invisiblePhysics: invisiblePhysics,
|
||||
initializeMass: initializeMass,
|
||||
initializeRadius: initializeRadius,
|
||||
initializeImageSize: initializeImageSize,
|
||||
@@ -107,6 +111,7 @@ function newFloatingObject () {
|
||||
}
|
||||
|
||||
function getContainer (point) {
|
||||
if (thisObject.payload === undefined) { return }
|
||||
if ((thisObject.isCollapsed === true && thisObject.collapsedManually === false) || thisObject.isParentCollapsed === true) { return }
|
||||
if (canvas.floatingSpace.inMapMode === true) { return }
|
||||
let container
|
||||
@@ -151,6 +156,10 @@ function newFloatingObject () {
|
||||
return thisObject.distanceToParent
|
||||
}
|
||||
|
||||
function getArrangementStyle () {
|
||||
return thisObject.arrangementStyle
|
||||
}
|
||||
|
||||
function freezeToggle () {
|
||||
if (thisObject.isFrozen !== true) {
|
||||
thisObject.isFrozen = true
|
||||
@@ -220,6 +229,37 @@ function newFloatingObject () {
|
||||
return thisObject.distanceToParent
|
||||
}
|
||||
|
||||
function arrangementStyleToggle () {
|
||||
switch (thisObject.arrangementStyle) {
|
||||
case ARRANGEMENT_STYLE.CONCAVE:
|
||||
thisObject.arrangementStyle = ARRANGEMENT_STYLE.CONVEX
|
||||
break
|
||||
case ARRANGEMENT_STYLE.CONVEX:
|
||||
thisObject.arrangementStyle = ARRANGEMENT_STYLE.VERTICAL_RIGHT
|
||||
break
|
||||
case ARRANGEMENT_STYLE.VERTICAL_RIGHT:
|
||||
thisObject.arrangementStyle = ARRANGEMENT_STYLE.VERTICAL_LEFT
|
||||
break
|
||||
case ARRANGEMENT_STYLE.VERTICAL_LEFT:
|
||||
thisObject.arrangementStyle = ARRANGEMENT_STYLE.HORIZONTAL_BOTTOM
|
||||
break
|
||||
case ARRANGEMENT_STYLE.HORIZONTAL_BOTTOM:
|
||||
thisObject.arrangementStyle = ARRANGEMENT_STYLE.HORIZONTAL_TOP
|
||||
break
|
||||
case ARRANGEMENT_STYLE.HORIZONTAL_TOP:
|
||||
thisObject.arrangementStyle = ARRANGEMENT_STYLE.CONCAVE
|
||||
break
|
||||
}
|
||||
|
||||
return thisObject.arrangementStyle
|
||||
}
|
||||
|
||||
function invisiblePhysics () {
|
||||
if (thisObject.payload.uiObject !== undefined) {
|
||||
thisObject.payload.uiObject.invisiblePhysics()
|
||||
}
|
||||
}
|
||||
|
||||
function physics () {
|
||||
frozenPhysics()
|
||||
/* From here on, only if they are not too far. */
|
||||
@@ -245,6 +285,8 @@ function newFloatingObject () {
|
||||
}
|
||||
|
||||
function positionContraintsPhysics () {
|
||||
const MAX_DISTANCE_TO_PARENT = 3000
|
||||
|
||||
if (thisObject.angleToParent !== ANGLE_TO_PARENT.NOT_FIXED && thisObject.isOnFocus !== true) {
|
||||
let parent = thisObject.payload.chainParent
|
||||
if (parent === undefined) { return }
|
||||
@@ -278,6 +320,10 @@ function newFloatingObject () {
|
||||
}
|
||||
}
|
||||
|
||||
if (distanceToParent > MAX_DISTANCE_TO_PARENT) {
|
||||
distanceToParent = MAX_DISTANCE_TO_PARENT
|
||||
}
|
||||
|
||||
switch (thisObject.angleToParent) {
|
||||
case ANGLE_TO_PARENT.RANGE_360:
|
||||
angleToParentAngle = 360
|
||||
@@ -321,12 +367,82 @@ function newFloatingObject () {
|
||||
|
||||
thisObject.payload.distance = distanceToParent
|
||||
|
||||
if (distanceToParent > 3000 || thisObject.isPinned === true) { return } // this is introduced to avoid edges cases when importing workspaces.
|
||||
if (thisObject.isPinned === true) {
|
||||
/* When an object is pinned, its angle to its parent needs to be calculated since it depends on where the user places the node. */
|
||||
/*
|
||||
if (thisObject.payload.chainParent !== undefined) {
|
||||
let x = thisObject.container.frame.position.x - thisObject.payload.chainParent.payload.floatingObject.container.frame.position.x
|
||||
let y = thisObject.container.frame.position.y - thisObject.payload.chainParent.payload.floatingObject.container.frame.position.y
|
||||
|
||||
newPosition = {
|
||||
x: parent.payload.position.x + distanceToParent * Math.cos(toRadians(thisObject.payload.angle)),
|
||||
y: parent.payload.position.y + distanceToParent * Math.sin(toRadians(thisObject.payload.angle))
|
||||
thisObject.payload.angle = Math.atan(y / x)
|
||||
}
|
||||
*/
|
||||
return
|
||||
}
|
||||
|
||||
let newPosition = {
|
||||
x: parent.payload.position.x,
|
||||
y: parent.payload.position.y
|
||||
}
|
||||
|
||||
let displacement
|
||||
|
||||
switch (thisObject.arrangementStyle) {
|
||||
case ARRANGEMENT_STYLE.CONCAVE: {
|
||||
displacement = {
|
||||
x: distanceToParent * Math.cos(toRadians(thisObject.payload.angle)),
|
||||
y: distanceToParent * Math.sin(toRadians(thisObject.payload.angle))
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
case ARRANGEMENT_STYLE.CONVEX: {
|
||||
displacement = {
|
||||
x: 2 * distanceToParent * Math.cos(toRadians(lastParentAngle)) + distanceToParent * Math.cos(toRadians(thisObject.payload.angle + 180)),
|
||||
y: 2 * distanceToParent * Math.sin(toRadians(lastParentAngle)) + distanceToParent * Math.sin(toRadians(thisObject.payload.angle + 180))
|
||||
}
|
||||
break
|
||||
}
|
||||
case ARRANGEMENT_STYLE.HORIZONTAL_BOTTOM: {
|
||||
displacement = {
|
||||
x: distanceToParent * Math.tan(toRadians(thisObject.payload.angle)),
|
||||
y: distanceToParent
|
||||
}
|
||||
break
|
||||
}
|
||||
case ARRANGEMENT_STYLE.HORIZONTAL_TOP: {
|
||||
displacement = {
|
||||
x: -distanceToParent * Math.tan(toRadians(thisObject.payload.angle)),
|
||||
y: -distanceToParent
|
||||
}
|
||||
break
|
||||
}
|
||||
case ARRANGEMENT_STYLE.VERTICAL_RIGHT: {
|
||||
displacement = {
|
||||
x: distanceToParent,
|
||||
y: distanceToParent * Math.tan(toRadians(thisObject.payload.angle))
|
||||
}
|
||||
break
|
||||
}
|
||||
case ARRANGEMENT_STYLE.VERTICAL_LEFT: {
|
||||
displacement = {
|
||||
x: -distanceToParent,
|
||||
y: -distanceToParent * Math.tan(toRadians(thisObject.payload.angle))
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (displacement.x > MAX_DISTANCE_TO_PARENT) {
|
||||
displacement.x = MAX_DISTANCE_TO_PARENT
|
||||
}
|
||||
if (displacement.y > MAX_DISTANCE_TO_PARENT) {
|
||||
displacement.y = MAX_DISTANCE_TO_PARENT
|
||||
}
|
||||
|
||||
newPosition.x = newPosition.x + displacement.x
|
||||
newPosition.y = newPosition.y + displacement.y
|
||||
|
||||
if (isNaN(newPosition.x) === false) {
|
||||
thisObject.container.frame.position.x = newPosition.x
|
||||
}
|
||||
@@ -338,41 +454,45 @@ function newFloatingObject () {
|
||||
|
||||
function thisObjectPhysics () {
|
||||
// The radius also have a target.
|
||||
let ANIMATION_STEP = Math.abs(thisObject.targetRadius - thisObject.rawRadius) / 5
|
||||
|
||||
if (Math.abs(thisObject.container.frame.radius - thisObject.targetRadius) >= 10) {
|
||||
if (ANIMATION_STEP === 0) { ANIMATION_STEP = 10 }
|
||||
|
||||
if (Math.abs(thisObject.container.frame.radius - thisObject.targetRadius) >= ANIMATION_STEP) {
|
||||
if (thisObject.container.frame.radius < thisObject.targetRadius) {
|
||||
thisObject.container.frame.radius = thisObject.container.frame.radius + 10
|
||||
thisObject.container.frame.radius = thisObject.container.frame.radius + ANIMATION_STEP
|
||||
} else {
|
||||
thisObject.container.frame.radius = thisObject.container.frame.radius - 10
|
||||
thisObject.container.frame.radius = thisObject.container.frame.radius - ANIMATION_STEP
|
||||
}
|
||||
|
||||
thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event)
|
||||
}
|
||||
|
||||
// The imageSize also have a target.
|
||||
|
||||
if (Math.abs(thisObject.currentImageSize - thisObject.targetImageSize) >= 10) {
|
||||
if (Math.abs(thisObject.currentImageSize - thisObject.targetImageSize) >= ANIMATION_STEP) {
|
||||
if (thisObject.currentImageSize < thisObject.targetImageSize) {
|
||||
thisObject.currentImageSize = thisObject.currentImageSize + 10
|
||||
thisObject.currentImageSize = thisObject.currentImageSize + ANIMATION_STEP
|
||||
} else {
|
||||
thisObject.currentImageSize = thisObject.currentImageSize - 10
|
||||
thisObject.currentImageSize = thisObject.currentImageSize - ANIMATION_STEP
|
||||
}
|
||||
}
|
||||
|
||||
// The fontSize also have a target.
|
||||
|
||||
if (Math.abs(thisObject.currentFontSize - thisObject.targetFontSize) >= 1) {
|
||||
if (Math.abs(thisObject.currentFontSize - thisObject.targetFontSize) >= ANIMATION_STEP / 10) {
|
||||
if (thisObject.currentFontSize < thisObject.targetFontSize) {
|
||||
thisObject.currentFontSize = thisObject.currentFontSize + 1
|
||||
thisObject.currentFontSize = thisObject.currentFontSize + ANIMATION_STEP / 10
|
||||
} else {
|
||||
thisObject.currentFontSize = thisObject.currentFontSize - 1
|
||||
thisObject.currentFontSize = thisObject.currentFontSize - ANIMATION_STEP / 10
|
||||
}
|
||||
}
|
||||
|
||||
if (Math.abs(thisObject.currentHierarchyRing - thisObject.targetHierarchyRing) >= 10) {
|
||||
if (Math.abs(thisObject.currentHierarchyRing - thisObject.targetHierarchyRing) >= ANIMATION_STEP) {
|
||||
if (thisObject.currentHierarchyRing < thisObject.targetHierarchyRing) {
|
||||
thisObject.currentHierarchyRing = thisObject.currentHierarchyRing + 10
|
||||
thisObject.currentHierarchyRing = thisObject.currentHierarchyRing + ANIMATION_STEP
|
||||
} else {
|
||||
thisObject.currentHierarchyRing = thisObject.currentHierarchyRing - 10
|
||||
thisObject.currentHierarchyRing = thisObject.currentHierarchyRing - ANIMATION_STEP
|
||||
}
|
||||
}
|
||||
|
||||
@@ -393,7 +513,7 @@ function newFloatingObject () {
|
||||
|
||||
thisObject.positionLocked = true
|
||||
|
||||
canvas.floatingSpace.container.eventHandler.raiseEvent('onFocusAquired', thisObject.container)
|
||||
canvas.floatingSpace.container.eventHandler.raiseEvent('onFocusAquired', thisObject)
|
||||
thisObject.isOnFocus = true
|
||||
}
|
||||
}
|
||||
@@ -402,14 +522,14 @@ function newFloatingObject () {
|
||||
removeFocus()
|
||||
}
|
||||
|
||||
function someoneAquiredFocus (container) {
|
||||
if (container === undefined) {
|
||||
function someoneAquiredFocus (floatingObject) {
|
||||
if (floatingObject === undefined || floatingObject.container === undefined) {
|
||||
return
|
||||
}
|
||||
if (thisObject.container === undefined) {
|
||||
return
|
||||
}
|
||||
if (container.id !== thisObject.container.id) {
|
||||
if (floatingObject.container.id !== thisObject.container.id) {
|
||||
removeFocus()
|
||||
}
|
||||
}
|
||||
@@ -422,7 +542,7 @@ function newFloatingObject () {
|
||||
thisObject.targetFontSize = thisObject.rawFontSize * 1
|
||||
thisObject.targetHierarchyRing = thisObject.rawHierarchyRing * 1
|
||||
|
||||
thisObject.payload.uiObject.container.eventHandler.raiseEvent('onNotFocus')
|
||||
thisObject.payload.uiObject.container.eventHandler.raiseEvent('onNotFocus', thisObject.container)
|
||||
|
||||
if (thisObject.isPinned !== true) {
|
||||
thisObject.positionLocked = false
|
||||
|
||||
@@ -34,6 +34,7 @@ function newFormulaEditor () {
|
||||
thisObject.container.frame.position.y = 0
|
||||
|
||||
let isMouseOver = false
|
||||
let SIZE_FACTOR = 1.2
|
||||
|
||||
return thisObject
|
||||
|
||||
@@ -72,6 +73,7 @@ function newFormulaEditor () {
|
||||
textArea.style.display = 'none'
|
||||
thisObject.payload.node.code = textArea.value
|
||||
}
|
||||
EDITOR_ON_FOCUS = false
|
||||
}
|
||||
|
||||
function activate (payload) {
|
||||
@@ -97,6 +99,7 @@ function newFormulaEditor () {
|
||||
'height: ' + thisObject.container.frame.height + 'px'
|
||||
textArea.style.display = 'block'
|
||||
textArea.focus()
|
||||
EDITOR_ON_FOCUS = true
|
||||
}
|
||||
|
||||
function getContainer (point) {
|
||||
@@ -129,8 +132,8 @@ function newFormulaEditor () {
|
||||
thisObject.container.frame.position.x = 0
|
||||
thisObject.container.frame.position.y = 0
|
||||
|
||||
thisObject.container.frame.width = thisObject.container.frame.radius * 1.8 * 2
|
||||
thisObject.container.frame.height = thisObject.container.frame.radius * 1 * 2
|
||||
thisObject.container.frame.width = thisObject.container.frame.radius * 1.8 * SIZE_FACTOR
|
||||
thisObject.container.frame.height = thisObject.container.frame.radius * 1 * SIZE_FACTOR
|
||||
|
||||
let textAreaPosition = {
|
||||
x: 0 - thisObject.container.frame.width / 2,
|
||||
@@ -162,7 +165,7 @@ function newFormulaEditor () {
|
||||
|
||||
position = thisObject.container.frame.frameThisPoint(position)
|
||||
|
||||
let radius = thisObject.container.frame.radius * 2
|
||||
let radius = thisObject.container.frame.radius * SIZE_FACTOR
|
||||
|
||||
if (radius > 0.5) {
|
||||
browserCanvasContext.beginPath()
|
||||
|
||||
@@ -36,6 +36,7 @@ function newUiObject () {
|
||||
setPercentage: setPercentage,
|
||||
setStatus: setStatus,
|
||||
physics: physics,
|
||||
invisiblePhysics: invisiblePhysics,
|
||||
drawBackground: drawBackground,
|
||||
drawMiddleground: drawMiddleground,
|
||||
drawForeground: drawForeground,
|
||||
@@ -119,8 +120,13 @@ function newUiObject () {
|
||||
|
||||
function finalize () {
|
||||
let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id
|
||||
systemEventHandler.stopListening(key, eventSubscriptionIdOnRunning, 'UiObject')
|
||||
systemEventHandler.stopListening(key, eventSubscriptionIdOnStopped, 'UiObject')
|
||||
|
||||
if (eventSubscriptionIdOnRunning !== undefined) {
|
||||
systemEventHandler.stopListening(key, eventSubscriptionIdOnRunning, 'UiObject')
|
||||
}
|
||||
if (eventSubscriptionIdOnStopped !== undefined) {
|
||||
systemEventHandler.stopListening(key, eventSubscriptionIdOnStopped, 'UiObject')
|
||||
}
|
||||
|
||||
thisObject.container.eventHandler.stopListening(selfFocusEventSubscriptionId)
|
||||
thisObject.container.eventHandler.stopListening(selfNotFocusEventSubscriptionId)
|
||||
@@ -256,6 +262,11 @@ function newUiObject () {
|
||||
}
|
||||
}
|
||||
|
||||
function invisiblePhysics () {
|
||||
thisObject.menu.invisiblePhysics()
|
||||
childrenRunningPhysics()
|
||||
}
|
||||
|
||||
function physics () {
|
||||
thisObject.menu.physics()
|
||||
thisObject.uiObjectTitle.physics()
|
||||
@@ -746,7 +757,7 @@ function newUiObject () {
|
||||
thisObject.circularProgressBar.fitFunction = thisObject.fitFunction
|
||||
thisObject.circularProgressBar.container = thisObject.container
|
||||
|
||||
/* We will wait to hear the first onHeartBeat in order to confirm the execution was really started */
|
||||
/* We will wait to hear the Running event in order to confirm the execution was really started */
|
||||
let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id
|
||||
systemEventHandler.listenToEvent(key, 'Running', undefined, 'UiObject', onResponse, onRunning)
|
||||
|
||||
@@ -1366,7 +1377,7 @@ function newUiObject () {
|
||||
position = canvas.floatingSpace.transformPointToMap(position)
|
||||
}
|
||||
|
||||
let radius = thisObject.container.frame.radius * 1.4
|
||||
let radius = thisObject.container.frame.radius * 0.9
|
||||
/* Label Text */
|
||||
let labelPoint
|
||||
let fontSize = thisObject.payload.floatingObject.currentFontSize * 6 / 4 / 2
|
||||
@@ -1384,7 +1395,7 @@ function newUiObject () {
|
||||
|
||||
labelPoint = {
|
||||
x: position.x - label.length / 2 * fontSize * FONT_ASPECT_RATIO - 10,
|
||||
y: position.y - radius * 7 / 5 + fontSize * FONT_ASPECT_RATIO + 15
|
||||
y: position.y + radius * 7 / 5 + fontSize * FONT_ASPECT_RATIO + 15
|
||||
}
|
||||
|
||||
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY
|
||||
@@ -1526,7 +1537,11 @@ function newUiObject () {
|
||||
browserCanvasContext.closePath()
|
||||
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.LIGHT_GREY + ', ' + OPACITY + ')'
|
||||
browserCanvasContext.lineWidth = 1
|
||||
browserCanvasContext.setLineDash([20, 20])
|
||||
if (thisObject.payload.node.isIncluded === true) {
|
||||
browserCanvasContext.setLineDash([0, 0])
|
||||
} else {
|
||||
browserCanvasContext.setLineDash([20, 20])
|
||||
}
|
||||
browserCanvasContext.stroke()
|
||||
}
|
||||
}
|
||||
@@ -1713,4 +1728,3 @@ function newUiObject () {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,12 +63,98 @@ function newUiObjectConstructor () {
|
||||
if (payload.node.savedPayload.floatingObject.distanceToParent !== undefined) {
|
||||
floatingObject.distanceToParent = payload.node.savedPayload.floatingObject.distanceToParent
|
||||
}
|
||||
if (payload.node.savedPayload.floatingObject.arrangementStyle !== undefined) {
|
||||
floatingObject.arrangementStyle = payload.node.savedPayload.floatingObject.arrangementStyle
|
||||
}
|
||||
}
|
||||
|
||||
/* For brand new objects being created directly by the user, we will make them inherit some properties from their parents. */
|
||||
/*
|
||||
For brand new objects being created directly by the user, we will make them inherit some properties
|
||||
from their closest siblings, and if they don't have, from their parents.
|
||||
*/
|
||||
|
||||
if (userAddingNew === true) {
|
||||
floatingObject.angleToParent = payload.parentNode.payload.floatingObject.angleToParent
|
||||
floatingObject.distanceToParent = payload.parentNode.payload.floatingObject.distanceToParent
|
||||
let definition = APP_SCHEMA_MAP.get(payload.parentNode.type)
|
||||
if (definition.properties !== undefined) {
|
||||
for (let i = 0; i < definition.properties.length; i++) {
|
||||
let property = definition.properties[i]
|
||||
if (property.childType === payload.node.type) {
|
||||
if (property.type === 'array') {
|
||||
let parentNode = payload.parentNode
|
||||
let parentNodeArray = parentNode[property.name]
|
||||
if (parentNodeArray.length > 1) { // the new node was already added
|
||||
let closestSibling = parentNodeArray[parentNodeArray.length - 2]
|
||||
if (closestSibling !== undefined) {
|
||||
floatingObject.angleToParent = closestSibling.payload.floatingObject.angleToParent
|
||||
floatingObject.distanceToParent = closestSibling.payload.floatingObject.distanceToParent
|
||||
floatingObject.arrangementStyle = closestSibling.payload.floatingObject.arrangementStyle
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if (floatingObject.angleToParent === undefined) {
|
||||
for (let j = i - 1; j >= 0; j--) {
|
||||
let siblingProperty = definition.properties[j]
|
||||
let parentNode = payload.parentNode
|
||||
let parentNodeProperty = parentNode[siblingProperty.name]
|
||||
if (parentNodeProperty !== undefined) {
|
||||
if (siblingProperty.type === 'array') {
|
||||
if (parentNodeProperty.length > 0) {
|
||||
let closestSibling = parentNodeProperty[parentNodeProperty.length - 1]
|
||||
if (closestSibling !== undefined) {
|
||||
floatingObject.angleToParent = closestSibling.payload.floatingObject.angleToParent
|
||||
floatingObject.distanceToParent = closestSibling.payload.floatingObject.distanceToParent
|
||||
floatingObject.arrangementStyle = closestSibling.payload.floatingObject.arrangementStyle
|
||||
break
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let closestSibling = parentNodeProperty
|
||||
if (closestSibling !== undefined) {
|
||||
floatingObject.angleToParent = closestSibling.payload.floatingObject.angleToParent
|
||||
floatingObject.distanceToParent = closestSibling.payload.floatingObject.distanceToParent
|
||||
floatingObject.arrangementStyle = closestSibling.payload.floatingObject.arrangementStyle
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (let j = i + 1; j < definition.properties.length; j++) {
|
||||
let siblingProperty = definition.properties[j]
|
||||
let parentNode = payload.parentNode
|
||||
let parentNodeProperty = parentNode[siblingProperty.name]
|
||||
if (parentNodeProperty !== undefined) {
|
||||
if (siblingProperty.type === 'array') {
|
||||
if (parentNodeProperty.length > 0) {
|
||||
let closestSibling = parentNodeProperty[parentNodeProperty.length - 1]
|
||||
if (closestSibling !== undefined) {
|
||||
floatingObject.angleToParent = closestSibling.payload.floatingObject.angleToParent
|
||||
floatingObject.distanceToParent = closestSibling.payload.floatingObject.distanceToParent
|
||||
floatingObject.arrangementStyle = closestSibling.payload.floatingObject.arrangementStyle
|
||||
break
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let closestSibling = parentNodeProperty
|
||||
if (closestSibling !== undefined) {
|
||||
floatingObject.angleToParent = closestSibling.payload.floatingObject.angleToParent
|
||||
floatingObject.distanceToParent = closestSibling.payload.floatingObject.distanceToParent
|
||||
floatingObject.arrangementStyle = closestSibling.payload.floatingObject.arrangementStyle
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (floatingObject.angleToParent === undefined) {
|
||||
floatingObject.angleToParent = payload.parentNode.payload.floatingObject.angleToParent
|
||||
floatingObject.distanceToParent = payload.parentNode.payload.floatingObject.distanceToParent
|
||||
floatingObject.arrangementStyle = payload.parentNode.payload.floatingObject.arrangementStyle
|
||||
}
|
||||
}
|
||||
|
||||
let uiObject = newUiObject()
|
||||
@@ -170,6 +256,21 @@ function newUiObjectConstructor () {
|
||||
ring: 1
|
||||
}
|
||||
)
|
||||
menuItemsInitialValues.push(
|
||||
{
|
||||
action: 'change Arrangement Style',
|
||||
actionFunction: floatingObject.arrangementStyleToggle,
|
||||
actionStatus: floatingObject.getArrangementStyle,
|
||||
currentStatus: true,
|
||||
label: undefined,
|
||||
visible: true,
|
||||
icons: ['arrangement-concave', 'arrangement-convex', 'arrangement-vertical-right', 'arrangement-vertical-left', 'arrangement-horizontal-bottom', 'arrangement-horizontal-top'],
|
||||
rawRadius: 12,
|
||||
targetRadius: 0,
|
||||
currentRadius: 0,
|
||||
ring: 1
|
||||
}
|
||||
)
|
||||
menuItemsInitialValues.push(
|
||||
{
|
||||
action: 'Freeze / Unfreeze',
|
||||
|
||||
@@ -12,6 +12,7 @@ function newUiObjectTitle () {
|
||||
editMode: undefined,
|
||||
container: undefined,
|
||||
payload: undefined,
|
||||
isDefault: undefined,
|
||||
enterEditMode: enterEditMode,
|
||||
exitEditMode: exitEditMode,
|
||||
physics: physics,
|
||||
@@ -81,6 +82,19 @@ function newUiObjectTitle () {
|
||||
}
|
||||
|
||||
function physics () {
|
||||
inheritancePhysics()
|
||||
defaultPhysics()
|
||||
}
|
||||
|
||||
function defaultPhysics () {
|
||||
if (thisObject.payload.title !== 'New ' + thisObject.payload.node.type && thisObject.payload.title !== 'My ' + thisObject.payload.node.type) {
|
||||
thisObject.isDefault = false
|
||||
} else {
|
||||
thisObject.isDefault = true
|
||||
}
|
||||
}
|
||||
|
||||
function inheritancePhysics () {
|
||||
if (thisObject.payload.title === undefined) { return }
|
||||
|
||||
/* It is possible to override the default title by setting the APP SCHEMA property 'title' */
|
||||
@@ -255,7 +269,7 @@ function newUiObjectTitle () {
|
||||
}
|
||||
|
||||
function draw () {
|
||||
if (thisObject.isOnFocus === true || thisObject.allwaysVisible === true) {
|
||||
if (thisObject.isOnFocus === true || thisObject.allwaysVisible === true || thisObject.isDefault === false) {
|
||||
if (thisObject.payload.uiObject.codeEditor !== undefined) {
|
||||
if (thisObject.payload.uiObject.codeEditor.visible !== true) {
|
||||
drawTitleBackground()
|
||||
@@ -291,7 +305,7 @@ function newUiObjectTitle () {
|
||||
let fontSize = thisObject.payload.floatingObject.currentFontSize
|
||||
let label
|
||||
|
||||
if (radius > 6 && (thisObject.isOnFocus === true || thisObject.allwaysVisible === true)) {
|
||||
if (radius > 6 && (thisObject.isOnFocus === true || thisObject.allwaysVisible === true || thisObject.isDefault === false)) {
|
||||
browserCanvasContext.strokeStyle = thisObject.payload.floatingObject.labelStrokeStyle
|
||||
|
||||
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY
|
||||
|
||||
+14
-2
@@ -37,7 +37,8 @@ const DOUBLE_CLICK_ZOOM_IN_IN_LEVEL = 7
|
||||
|
||||
const DEBUG = {}
|
||||
const ZOOM_OUT_THRESHOLD_FOR_NOT_HIDDING_PANELS = 12
|
||||
const ZOOM_OUT_THRESHOLD_FOR_HIDDING_PANELS = 7
|
||||
const ZOOM_OUT_THRESHOLD_FOR_HIDDING_PANELS = 7
|
||||
const ZOOM_OUT_THRESHOLD_FOR_HIDDING_CHARTS_LABELS = 7
|
||||
const ZOOM_OUT_THRESHOLD_FOR_CHANGING_TIME_FRAME = 3 // This help regulate when to change the Time Frame base on the level of zoom out.
|
||||
const ZOOM_OUT_THRESHOLD_FOR_PACKING_OBJECTS_AT_THE_BOTTOM_OR_TOP_OF_VIEWPORT = 2
|
||||
const ZOOM_OUT_THRESHOLD_FOR_PLOTTING_IN_LOW_RESOLUTION = 3
|
||||
@@ -45,7 +46,7 @@ const ZOOM_OUT_THRESHOLD_FOR_DISPLAYING_TIME_MACHINES_ICONIZED = 5
|
||||
const ZOOM_OUT_THRESHOLD_FOR_DISPLAYING_SCALES = 3
|
||||
|
||||
let FONT_ASPECT_RATIO = 0.32;
|
||||
|
||||
let ANIMATION_FRAME_PER_SECONDS
|
||||
|
||||
const GET_CONTAINER_PURPOSE = {
|
||||
MOUSE_OVER: 1,
|
||||
@@ -71,6 +72,15 @@ const DISTANCE_TO_PARENT = {
|
||||
PARENT_200X: 5
|
||||
}
|
||||
|
||||
const ARRANGEMENT_STYLE = {
|
||||
CONCAVE: 0,
|
||||
CONVEX: 1,
|
||||
VERTICAL_RIGHT: 2,
|
||||
VERTICAL_LEFT: 3,
|
||||
HORIZONTAL_BOTTOM: 4,
|
||||
HORIZONTAL_TOP: 5
|
||||
}
|
||||
|
||||
/* User Interface Panels */
|
||||
|
||||
const UI_PANEL = {
|
||||
@@ -120,6 +130,8 @@ let dailyFilePeriods =
|
||||
dailyFilePeriods = JSON.parse(dailyFilePeriods);
|
||||
|
||||
let SHOW_ANIMATION_PERFORMACE = false;
|
||||
let MENU_ITEM_ON_FOCUS
|
||||
let EDITOR_ON_FOCUS
|
||||
|
||||
let testUser = window.localStorage.getItem("test_user")
|
||||
let LOGGED_IN_USER_LOCAL_STORAGE_KEY
|
||||
|
||||
@@ -227,7 +227,7 @@ function newLayersPanel () {
|
||||
}
|
||||
|
||||
function panelSizePhysics () {
|
||||
if (isInitialized === false || thisObject.visible === false || thisObject.isHidden === true) { return }
|
||||
if (isInitialized === false || thisObject.isHidden === true) { return }
|
||||
|
||||
let viewPortHeight = canvas.chartingSpace.viewport.visibleArea.bottomLeft.y - canvas.chartingSpace.viewport.visibleArea.topLeft.y
|
||||
|
||||
@@ -237,6 +237,8 @@ function newLayersPanel () {
|
||||
thisObject.visible = true
|
||||
}
|
||||
|
||||
if (thisObject.visible === false) { return }
|
||||
|
||||
if (desiredPanelHeight > viewPortHeight) {
|
||||
posibleVisibleLayers = Math.trunc((viewPortHeight - headerHeight - footerHeight) / (layerHeight + LAYER_SEPARATION))
|
||||
} else {
|
||||
|
||||
+26
-8
@@ -96,7 +96,8 @@ function newPlotterPanel () {
|
||||
|
||||
const X_AXIS = thisObject.container.frame.width / 2
|
||||
const Y_AXIS = frameTitleHeight + frameBodyHeight / 2
|
||||
const PANEL_HEIGHT = frameTitleHeight + frameBodyHeight
|
||||
|
||||
const PANEL_HEIGHT = UI_PANEL.HEIGHT.NORMAL
|
||||
|
||||
if (currentRecord === undefined) { return }
|
||||
if (currentRecord.data === undefined) { return }
|
||||
@@ -113,19 +114,32 @@ function newPlotterPanel () {
|
||||
}
|
||||
}
|
||||
|
||||
printLabel('Indicator Properties', X_AXIS, UI_PANEL.HEIGHT.NORMAL * 17 / 100, '1.00', 14, undefined, true, thisObject.container, thisObject.fitFunction)
|
||||
|
||||
/* Second we go through the panel data. */
|
||||
if (panelNode.panelData === undefined) { return }
|
||||
for (let i = 0; i < panelNode.panelData.length; i++) {
|
||||
let panelData = panelNode.panelData[i]
|
||||
|
||||
let labelText = panelData.name
|
||||
let labelPosition = i * 10 + 10
|
||||
let valuePosition = i * 10 + 15
|
||||
let labelPosition = i * 10 + 25
|
||||
let valuePosition = i * 10 + 30
|
||||
let value = 'No value defined.'
|
||||
|
||||
if (valuePosition > 100) {
|
||||
heightFactor = 2
|
||||
thisObject.container.frame.height = UI_PANEL.HEIGHT.NORMAL * heightFactor
|
||||
thisObject.container.frame.height = UI_PANEL.HEIGHT.NORMAL * 1.25
|
||||
}
|
||||
|
||||
if (valuePosition > 125) {
|
||||
thisObject.container.frame.height = UI_PANEL.HEIGHT.NORMAL * 1.50
|
||||
}
|
||||
|
||||
if (valuePosition > 150) {
|
||||
thisObject.container.frame.height = UI_PANEL.HEIGHT.NORMAL * 1.75
|
||||
}
|
||||
|
||||
if (valuePosition > 175) {
|
||||
thisObject.container.frame.height = UI_PANEL.HEIGHT.NORMAL * 2.00
|
||||
}
|
||||
|
||||
if (panelData.dataFormula !== undefined) {
|
||||
@@ -138,7 +152,11 @@ function newPlotterPanel () {
|
||||
}
|
||||
|
||||
if (panelData.code.valueDecimals !== undefined) {
|
||||
value = value.toFixed(panelData.code.valueDecimals)
|
||||
if (value !== undefined) {
|
||||
if (isNaN(value) === false) {
|
||||
value = value.toFixed(panelData.code.valueDecimals)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (panelData.code.labelText !== undefined) {
|
||||
@@ -153,8 +171,8 @@ function newPlotterPanel () {
|
||||
valuePosition = panelData.code.valuePosition
|
||||
}
|
||||
|
||||
printLabel(labelText, X_AXIS, PANEL_HEIGHT * labelPosition / 100 / heightFactor, '0.60', undefined, undefined, true, thisObject.container, thisObject.fitFunction)
|
||||
printLabel(value, X_AXIS, PANEL_HEIGHT * valuePosition / 100 / heightFactor, '1.00', 15, undefined, true, thisObject.container, thisObject.fitFunction)
|
||||
printLabel(labelText, X_AXIS, UI_PANEL.HEIGHT.NORMAL * labelPosition / 100 / heightFactor, '0.60', undefined, undefined, true, thisObject.container, thisObject.fitFunction)
|
||||
printLabel(value, X_AXIS, UI_PANEL.HEIGHT.NORMAL * valuePosition / 100 / heightFactor, '1.00', 14, undefined, true, thisObject.container, thisObject.fitFunction)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,10 +85,10 @@ function newAutoScaleButton () {
|
||||
currentStatus = 2
|
||||
}
|
||||
if (thisObject.autoMinScale === false && thisObject.autoMaxScale === true) {
|
||||
currentStatus = 3
|
||||
currentStatus = 4
|
||||
}
|
||||
if (thisObject.autoMinScale === true && thisObject.autoMaxScale === true) {
|
||||
currentStatus = 4
|
||||
currentStatus = 6
|
||||
}
|
||||
}
|
||||
function onMouseWheel (event) {
|
||||
@@ -100,8 +100,8 @@ function newAutoScaleButton () {
|
||||
delta = 1
|
||||
}
|
||||
currentStatus = currentStatus + delta
|
||||
if (currentStatus === 5) { currentStatus = 1 }
|
||||
if (currentStatus === 0) { currentStatus = 4 }
|
||||
if (currentStatus === 7) { currentStatus = 1 }
|
||||
if (currentStatus === 0) { currentStatus = 6 }
|
||||
|
||||
switch (currentStatus) {
|
||||
case 1: {
|
||||
@@ -118,11 +118,23 @@ function newAutoScaleButton () {
|
||||
}
|
||||
case 3: {
|
||||
thisObject.autoMinScale = false
|
||||
thisObject.autoMaxScale = true
|
||||
thisObject.autoMaxScale = false
|
||||
update()
|
||||
return
|
||||
}
|
||||
case 4: {
|
||||
thisObject.autoMinScale = false
|
||||
thisObject.autoMaxScale = true
|
||||
update()
|
||||
return
|
||||
}
|
||||
case 5: {
|
||||
thisObject.autoMinScale = false
|
||||
thisObject.autoMaxScale = false
|
||||
update()
|
||||
return
|
||||
}
|
||||
case 6: {
|
||||
thisObject.autoMinScale = true
|
||||
thisObject.autoMaxScale = true
|
||||
update()
|
||||
|
||||
+10
-1
@@ -41,11 +41,15 @@ function newChartingSpace () {
|
||||
const PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT = 25
|
||||
|
||||
initialSetup()
|
||||
|
||||
let isInitialized = false
|
||||
|
||||
return thisObject
|
||||
|
||||
function reset () {
|
||||
finalize()
|
||||
initialSetup()
|
||||
isInitialized = false
|
||||
initialize()
|
||||
}
|
||||
|
||||
@@ -87,6 +91,8 @@ function newChartingSpace () {
|
||||
}
|
||||
|
||||
function initialize () {
|
||||
if (isInitialized === true) { return }
|
||||
|
||||
let rootNodes = canvas.designSpace.workspace.workspaceNode.rootNodes
|
||||
for (let i = 0; i < rootNodes.length; i++) {
|
||||
let rootNode = rootNodes[i]
|
||||
@@ -96,7 +102,7 @@ function newChartingSpace () {
|
||||
}
|
||||
|
||||
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. ') }
|
||||
// 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
|
||||
}
|
||||
|
||||
@@ -111,6 +117,8 @@ function newChartingSpace () {
|
||||
thisObject.viewport.initialize()
|
||||
|
||||
canvasBrowserResizedEventSubscriptionId = canvas.eventHandler.listenToEvent('Browser Resized', resize)
|
||||
|
||||
isInitialized = true
|
||||
}
|
||||
|
||||
function getContainer (point, purpose) {
|
||||
@@ -263,6 +271,7 @@ function newChartingSpace () {
|
||||
}
|
||||
|
||||
function physics () {
|
||||
initialize()
|
||||
thisObjectPhysics()
|
||||
if (thisObject.visible !== true) { return }
|
||||
if (thisObject.viewport !== undefined) {
|
||||
|
||||
+56
-3
@@ -1,11 +1,16 @@
|
||||
|
||||
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,
|
||||
@@ -31,6 +36,10 @@
|
||||
let selfMouseClickEventSubscriptionId
|
||||
let canvasBrowserResizedEventSubscriptionId
|
||||
|
||||
let statusCounter = 0
|
||||
let statusText
|
||||
let statusType
|
||||
|
||||
return thisObject
|
||||
|
||||
function finalize () {
|
||||
@@ -72,6 +81,12 @@
|
||||
|
||||
}
|
||||
|
||||
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
|
||||
@@ -114,9 +129,19 @@
|
||||
}
|
||||
}
|
||||
|
||||
function statusPhysics () {
|
||||
statusCounter--
|
||||
if (statusCounter < 0) {
|
||||
statusCounter = 0
|
||||
statusText = undefined,
|
||||
statusType = undefined
|
||||
}
|
||||
}
|
||||
|
||||
function physics () {
|
||||
thisObjectPhysics()
|
||||
childrenPhysics()
|
||||
statusPhysics()
|
||||
}
|
||||
|
||||
function childrenPhysics () {
|
||||
@@ -195,9 +220,29 @@
|
||||
|
||||
zeroPoint = thisObject.container.frame.frameThisPoint(zeroPoint)
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
browserCanvasContext.beginPath()
|
||||
browserCanvasContext.rect(zeroPoint.x, zeroPoint.y, thisObject.container.frame.width, thisObject.container.frame.height)
|
||||
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.DARK_TURQUOISE + ', ' + opacity + ')'
|
||||
browserCanvasContext.fillStyle = 'rgba(' + barColor + ', ' + opacity + ')'
|
||||
browserCanvasContext.closePath()
|
||||
browserCanvasContext.fill()
|
||||
|
||||
@@ -213,7 +258,15 @@
|
||||
browserCanvasContext.closePath()
|
||||
browserCanvasContext.fill()
|
||||
|
||||
if (canvas.designSpace.workspace.enabled === true) {
|
||||
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.workspace.enabled === true && statusText === undefined) {
|
||||
arrow()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,7 +278,13 @@ function newDesignSpace () {
|
||||
'help',
|
||||
'key-a',
|
||||
'key-m',
|
||||
'key-r'
|
||||
'key-r',
|
||||
'arrangement-horizontal-top',
|
||||
'arrangement-convex',
|
||||
'arrangement-horizontal-bottom',
|
||||
'arrangement-vertical-right',
|
||||
'arrangement-vertical-left',
|
||||
'arrangement-concave'
|
||||
]
|
||||
|
||||
for (let i = 0; i < iconsNames.length; i++) {
|
||||
|
||||
@@ -57,14 +57,17 @@ function newFloatingSpace () {
|
||||
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()
|
||||
@@ -73,6 +76,8 @@ function newFloatingSpace () {
|
||||
thisObject.floatingLayer = undefined
|
||||
thisObject.uiObjectConstructor = undefined
|
||||
thisObject.container = undefined
|
||||
|
||||
floatingObjetOnFocus = undefined
|
||||
}
|
||||
|
||||
function initialize (callBackFunction) {
|
||||
@@ -83,6 +88,14 @@ function newFloatingSpace () {
|
||||
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
|
||||
}
|
||||
floatingObjetOnFocus = floatingObject
|
||||
}
|
||||
|
||||
function toggleDrawReferenceLines () {
|
||||
@@ -347,8 +360,17 @@ function newFloatingSpace () {
|
||||
|
||||
function getContainer (point) {
|
||||
if (visible === false) { return }
|
||||
|
||||
let container
|
||||
|
||||
if (floatingObjetOnFocus !== undefined) {
|
||||
container = floatingObjetOnFocus.getContainer(point)
|
||||
if (container !== undefined) {
|
||||
container.space = 'Floating Space'
|
||||
return container
|
||||
}
|
||||
}
|
||||
|
||||
container = thisObject.floatingLayer.getContainer(point)
|
||||
if (container !== undefined) {
|
||||
container.space = 'Floating Space'
|
||||
|
||||
@@ -71,7 +71,7 @@ function newPanelsSpace () {
|
||||
panel.owner = pOwner
|
||||
thisObject.panels.push(panel)
|
||||
|
||||
panel.handle = Math.floor((Math.random() * 10000000) + 1)
|
||||
panel.handle = newUniqueId()
|
||||
|
||||
return panel.handle
|
||||
}
|
||||
|
||||
+18
-1
@@ -12,6 +12,7 @@ function newSystemEventHandler () {
|
||||
let WEB_SOCKETS_CONNECTION
|
||||
|
||||
let thisObject = {
|
||||
isConnected: isConnected,
|
||||
initialize: initialize,
|
||||
physics: physics,
|
||||
createEventHandler: createEventHandler,
|
||||
@@ -30,6 +31,14 @@ function newSystemEventHandler () {
|
||||
setuptWebSockets(callBackFunction)
|
||||
}
|
||||
|
||||
function isConnected () {
|
||||
if (WEB_SOCKETS_CONNECTION.readyState === 1) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
function sendCommand (command, responseCallBack, eventsCallBack) {
|
||||
if (command.action === 'listenToEvent') {
|
||||
let key
|
||||
@@ -44,7 +53,11 @@ function newSystemEventHandler () {
|
||||
responseWaiters.set(command.callerId, responseCallBack)
|
||||
}
|
||||
|
||||
WEB_SOCKETS_CONNECTION.send(JSON.stringify(command))
|
||||
if (WEB_SOCKETS_CONNECTION.readyState === 1) { // 1 means connected and ready.
|
||||
WEB_SOCKETS_CONNECTION.send(JSON.stringify(command))
|
||||
} else {
|
||||
console.log('WebSocket message could not be sent because the connection was not ready. Message = ' + JSON.stringify(command))
|
||||
}
|
||||
}
|
||||
|
||||
function createEventHandler (eventHandlerName, callerId, responseCallBack) {
|
||||
@@ -106,6 +119,10 @@ function newSystemEventHandler () {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (thisObject.isConnected() !== true) {
|
||||
canvas.cockpitSpace.setStatus('Connection with the local backend lost. Please check that all localhost servers are running.', 100, canvas.cockpitSpace.statusTypes.WARNING)
|
||||
}
|
||||
}
|
||||
|
||||
function setuptWebSockets (callBackFunction) {
|
||||
|
||||
@@ -245,6 +245,7 @@ function removeTime (datetime) {
|
||||
}
|
||||
|
||||
function printLabel (labelToPrint, x, y, opacity, fontSize, color, center, container, fitFunction, noDecimals) {
|
||||
if (labelToPrint === undefined) { return }
|
||||
let labelPoint
|
||||
if (color === undefined) { color = UI_COLOR.DARK }
|
||||
if (fontSize === undefined) { fontSize = 10 };
|
||||
|
||||
Reference in new issue
Block a user