Working Again
This commit is contained in:
1 parent
24e2876815
commit
fd91ce3dcb
12 files changed
+158
-181
No files matched your search
+1
-1
@@ -62,7 +62,7 @@ function newAnimation () {
|
||||
browserCanvas.height = window.innerHeight - CURRENT_TOP_MARGIN
|
||||
|
||||
/* First thing is to clear the actual canvas */
|
||||
clearBrowserCanvas()
|
||||
// clearBrowserCanvas()
|
||||
|
||||
/* We loop through the callback functions collections and execute them all. */
|
||||
let performanceMap = new Map()
|
||||
|
||||
@@ -804,7 +804,7 @@ function newCanvas () {
|
||||
}
|
||||
|
||||
if (container !== undefined) {
|
||||
canvas.chartSpace.viewport.applyZoom(delta)
|
||||
canvas.chartSpace.viewport.onMouseWheel(delta)
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -872,7 +872,7 @@ function newCanvas () {
|
||||
}
|
||||
|
||||
let downNoZoom
|
||||
downNoZoom = canvas.chartSpace.viewport.unzoomThisPoint(downCopy)
|
||||
downNoZoom = canvas.chartSpace.viewport.unTransformThisPoint(downCopy)
|
||||
|
||||
let upCopy = {
|
||||
x: dragVector.upX,
|
||||
@@ -880,7 +880,7 @@ function newCanvas () {
|
||||
}
|
||||
|
||||
let upNoZoom
|
||||
upNoZoom = canvas.chartSpace.viewport.unzoomThisPoint(upCopy)
|
||||
upNoZoom = canvas.chartSpace.viewport.unTransformThisPoint(upCopy)
|
||||
|
||||
displaceVector = {
|
||||
x: upNoZoom.x - downNoZoom.x,
|
||||
|
||||
@@ -64,11 +64,11 @@ function getTransparenceFactor (timeFrame) {
|
||||
function recalculatePeriod (zoomLevel) {
|
||||
// console.log(" recalculatePeriod > " + zoomLevel);
|
||||
|
||||
if (zoomLevel > 200) {
|
||||
if (zoomLevel > 90) {
|
||||
return _1_MINUTE_IN_MILISECONDS
|
||||
}
|
||||
|
||||
if (zoomLevel > 120) {
|
||||
if (zoomLevel > 85) {
|
||||
return _2_MINUTES_IN_MILISECONDS
|
||||
}
|
||||
|
||||
@@ -76,68 +76,65 @@ function recalculatePeriod (zoomLevel) {
|
||||
return _3_MINUTES_IN_MILISECONDS
|
||||
}
|
||||
|
||||
if (zoomLevel > 60) {
|
||||
if (zoomLevel > 75) {
|
||||
return _4_MINUTES_IN_MILISECONDS
|
||||
}
|
||||
|
||||
if (zoomLevel > 15) {
|
||||
if (zoomLevel > 70) {
|
||||
return _5_MINUTES_IN_MILISECONDS
|
||||
}
|
||||
|
||||
if (zoomLevel > -7) {
|
||||
if (zoomLevel > 65) {
|
||||
return _10_MINUTES_IN_MILISECONDS
|
||||
}
|
||||
|
||||
if (zoomLevel > -10) {
|
||||
if (zoomLevel > 60) {
|
||||
return _15_MINUTES_IN_MILISECONDS
|
||||
}
|
||||
|
||||
if (zoomLevel > -13) {
|
||||
if (zoomLevel > 55) {
|
||||
return _20_MINUTES_IN_MILISECONDS
|
||||
}
|
||||
|
||||
if (zoomLevel > -15) {
|
||||
if (zoomLevel > 50) {
|
||||
return _30_MINUTES_IN_MILISECONDS
|
||||
}
|
||||
|
||||
if (zoomLevel > -16) {
|
||||
if (zoomLevel > 45) {
|
||||
return _40_MINUTES_IN_MILISECONDS
|
||||
}
|
||||
|
||||
if (zoomLevel > -17) {
|
||||
if (zoomLevel > 50) {
|
||||
return _45_MINUTES_IN_MILISECONDS
|
||||
}
|
||||
|
||||
if (zoomLevel > -18) {
|
||||
if (zoomLevel > 35) {
|
||||
return _1_HOUR_IN_MILISECONDS
|
||||
}
|
||||
|
||||
if (zoomLevel > -24) {
|
||||
if (zoomLevel > 30) {
|
||||
return _2_HOURS_IN_MILISECONDS
|
||||
}
|
||||
|
||||
if (zoomLevel > -25) {
|
||||
if (zoomLevel > 25) {
|
||||
return _3_HOURS_IN_MILISECONDS
|
||||
}
|
||||
|
||||
if (zoomLevel > -27) {
|
||||
if (zoomLevel > 20) {
|
||||
return _4_HOURS_IN_MILISECONDS
|
||||
}
|
||||
|
||||
if (zoomLevel > -27.5) {
|
||||
if (zoomLevel > 15) {
|
||||
return _6_HOURS_IN_MILISECONDS
|
||||
}
|
||||
|
||||
if (zoomLevel > -27.75) {
|
||||
if (zoomLevel > 10) {
|
||||
return _8_HOURS_IN_MILISECONDS
|
||||
}
|
||||
|
||||
if (zoomLevel > -28) {
|
||||
if (zoomLevel > 5) {
|
||||
return _12_HOURS_IN_MILISECONDS
|
||||
}
|
||||
|
||||
if (zoomLevel <= -28) {
|
||||
return ONE_DAY_IN_MILISECONDS
|
||||
}
|
||||
return ONE_DAY_IN_MILISECONDS
|
||||
}
|
||||
@@ -132,7 +132,7 @@ function newTimeMachine () {
|
||||
|
||||
function initialize (callBackFunction) {
|
||||
timeFrame = INITIAL_TIME_PERIOD
|
||||
loadFrame(thisObject.payload, thisObject.container.frame)
|
||||
// loadFrame(thisObject.payload, thisObject.container.frame)
|
||||
|
||||
recalculateCoordinateSystem()
|
||||
|
||||
@@ -180,10 +180,10 @@ function newTimeMachine () {
|
||||
thisObject.timeScale.payload = thisObject.payload.node.timeScale.payload
|
||||
|
||||
timeScaleEventSuscriptionId = thisObject.timeScale.container.eventHandler.listenToEvent('Lenght Percentage Changed', function (event) {
|
||||
thisObject.container.frame.width = TIME_MACHINE_WIDTH * event.value / 100
|
||||
thisObject.container.frame.width = TIME_MACHINE_WIDTH * event.value
|
||||
recalculateCoordinateSystem()
|
||||
if (event.isUserAction === true) {
|
||||
moveToUserPosition(thisObject.container, timeMachineCoordinateSystem, false, true, event.mousePosition, false, true)
|
||||
moveToUserPosition(thisObject.container, timeMachineCoordinateSystem, false, true, event.mousePosition, true)
|
||||
}
|
||||
thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event)
|
||||
})
|
||||
@@ -203,10 +203,10 @@ function newTimeMachine () {
|
||||
thisObject.rateScale.payload = thisObject.payload.node.rateScale.payload
|
||||
|
||||
rateScaleEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('Height Percentage Changed', function (event) {
|
||||
thisObject.container.frame.height = TIME_MACHINE_HEIGHT * event.value / 100
|
||||
thisObject.container.frame.height = TIME_MACHINE_HEIGHT * event.value
|
||||
recalculateCoordinateSystem()
|
||||
if (event.isUserAction === true) {
|
||||
moveToUserPosition(thisObject.container, timeMachineCoordinateSystem, true, false, event.mousePosition, false, true)
|
||||
moveToUserPosition(thisObject.container, timeMachineCoordinateSystem, true, false, event.mousePosition, true)
|
||||
}
|
||||
thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event)
|
||||
})
|
||||
@@ -411,7 +411,7 @@ function newTimeMachine () {
|
||||
timelineChart.container.fitFunction = thisObject.container.fitFunction
|
||||
timelineChart.fitFunction = thisObject.fitFunction
|
||||
timelineChart.container.frame.height = thisObject.container.frame.height
|
||||
timelineChart.container.frame.position.x = thisObject.container.frame.width / 2 - timelineChart.container.frame.width / 2
|
||||
timelineChart.container.frame.position.x = 0
|
||||
timelineChart.container.frame.position.y = 0
|
||||
timelineChart.initialize(timeMachineCoordinateSystem)
|
||||
|
||||
|
||||
@@ -57,6 +57,9 @@ function newTimelineChart () {
|
||||
thisObject.container = newContainer()
|
||||
thisObject.container.initialize(MODULE_NAME)
|
||||
thisObject.container.detectMouseOver = true
|
||||
|
||||
thisObject.container.frame.width = TIME_MACHINE_WIDTH
|
||||
thisObject.container.frame.height = TIME_MACHINE_HEIGHT
|
||||
}
|
||||
|
||||
function finalize () {
|
||||
@@ -119,8 +122,10 @@ function newTimelineChart () {
|
||||
thisObject.rateScale = undefined
|
||||
|
||||
/* Resets the local container with the dimessions of its parent, the Time Machine */
|
||||
thisObject.container.frame.position.position.x = 0
|
||||
thisObject.container.frame.position.position.y = 0
|
||||
thisObject.container.frame.position.height = thisObject.container.parentContainer.frame.height
|
||||
thisObject.container.frame.height = TIME_MACHINE_HEIGHT
|
||||
thisObject.container.frame.width = TIME_MACHINE_WIDTH
|
||||
}
|
||||
|
||||
function initialize (pTimeMachineCoordinateSystem) {
|
||||
@@ -166,10 +171,10 @@ function newTimelineChart () {
|
||||
thisObject.rateScale.payload = thisObject.payload.node.rateScale.payload
|
||||
|
||||
rateScaleEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('Height Percentage Changed', function (event) {
|
||||
thisObject.container.frame.height = TIME_MACHINE_HEIGHT * event.value / 100
|
||||
thisObject.container.frame.height = TIME_MACHINE_HEIGHT * event.value
|
||||
recalculateCoordinateSystem()
|
||||
if (event.isUserAction === true) {
|
||||
moveToUserPosition(thisObject.container, timelineChartCoordinateSystem, true, false, event.mousePosition, false, true)
|
||||
moveToUserPosition(thisObject.container, timelineChartCoordinateSystem, true, false, event.mousePosition, true)
|
||||
}
|
||||
thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event)
|
||||
})
|
||||
@@ -279,7 +284,7 @@ function newTimelineChart () {
|
||||
}
|
||||
|
||||
let newDate = new Date(0)
|
||||
newDate.setUTCSeconds(center.x / 1000)
|
||||
newDate.setUTCSeconds(center.x)
|
||||
|
||||
datetime = newDate
|
||||
|
||||
@@ -366,22 +371,6 @@ function newTimelineChart () {
|
||||
}
|
||||
}
|
||||
|
||||
function tooTiny () {
|
||||
if (canvas.chartSpace.viewport.zoomLevel < Math.trunc(-28.25 * 100) / 100) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
function tooSmall () {
|
||||
if (canvas.chartSpace.viewport.zoomLevel < Math.trunc(-27.25 * 100) / 100) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
function drawBackground () {
|
||||
if (thisObject.container.frame.isInViewPort()) {
|
||||
drawChartsBackground()
|
||||
|
||||
+100
-109
@@ -1,17 +1,12 @@
|
||||
|
||||
function newViewport () {
|
||||
const MODULE_NAME = 'Viewport'
|
||||
const INFO_LOG = false
|
||||
const INTENSIVE_LOG = false
|
||||
const ERROR_LOG = true
|
||||
const logger = newWebDebugLog()
|
||||
logger.fileName = MODULE_NAME
|
||||
|
||||
const CONSOLE_LOG = true
|
||||
const MIN_ZOOM_LEVEL = -28.25
|
||||
const MAX_ZOOM_LEVEL = 1000
|
||||
const MIN_ZOOM_LEVEL = 1
|
||||
const MAX_ZOOM_LEVEL = 100
|
||||
|
||||
let ANIMATION_INCREMENT = 0.25
|
||||
let ANIMATION_STEPS = 5
|
||||
|
||||
let TOP_MARGIN = 40 + TOP_SPACE_HEIGHT
|
||||
let BOTTOM_MARGIN = 42 + COCKPIT_SPACE_HEIGHT
|
||||
@@ -34,10 +29,10 @@ function newViewport () {
|
||||
mousePosition: undefined,
|
||||
margins: MARGINS,
|
||||
payload: undefined,
|
||||
newZoomLevel: newZoomLevel,
|
||||
applyZoom: applyZoom,
|
||||
zoomThisPoint: zoomThisPoint,
|
||||
unzoomThisPoint: unzoomThisPoint,
|
||||
changeZoom: changeZoom,
|
||||
onMouseWheel: onMouseWheel,
|
||||
transformThisPoint: transformThisPoint,
|
||||
unTransformThisPoint: unTransformThisPoint,
|
||||
isThisPointVisible: isThisPointVisible,
|
||||
fitIntoVisibleArea: fitIntoVisibleArea,
|
||||
displace: displace,
|
||||
@@ -74,7 +69,6 @@ function newViewport () {
|
||||
return thisObject
|
||||
|
||||
function finalize () {
|
||||
logger = undefined
|
||||
thisObject.eventHandler.finalize()
|
||||
thisObject.payload = undefined
|
||||
thisObject = undefined
|
||||
@@ -83,6 +77,7 @@ function newViewport () {
|
||||
function initialize () {
|
||||
if (thisObject.payload !== undefined) {
|
||||
/* Read the position from the frame structure */
|
||||
|
||||
let frame = {
|
||||
position: {
|
||||
x: 0,
|
||||
@@ -91,15 +86,15 @@ function newViewport () {
|
||||
}
|
||||
loadFrame(thisObject.payload, frame)
|
||||
if (!isNaN(frame.position.x)) {
|
||||
position.x = frame.position.x
|
||||
// position.x = frame.position.x
|
||||
}
|
||||
if (!isNaN(frame.position.y)) {
|
||||
position.y = frame.position.y
|
||||
// position.y = frame.position.y
|
||||
}
|
||||
}
|
||||
|
||||
resize()
|
||||
readObjectState()
|
||||
// readObjectState()
|
||||
}
|
||||
|
||||
function resize () {
|
||||
@@ -123,6 +118,11 @@ function newViewport () {
|
||||
|
||||
thisObject.width = thisObject.visibleArea.topRight.x - thisObject.visibleArea.topLeft.x
|
||||
thisObject.height = thisObject.visibleArea.bottomRight.y - thisObject.visibleArea.topLeft.y
|
||||
|
||||
thisObject.center = {
|
||||
x: LEFT_MARGIN + thisObject.width / 2,
|
||||
y: TOP_MARGIN + thisObject.height / 2
|
||||
}
|
||||
}
|
||||
|
||||
function raiseEvents () {
|
||||
@@ -136,7 +136,7 @@ function newViewport () {
|
||||
function physics () {
|
||||
animationPhysics()
|
||||
positioningphysics()
|
||||
readObjectState()
|
||||
// readObjectState()
|
||||
}
|
||||
|
||||
function positioningphysics () {
|
||||
@@ -175,57 +175,19 @@ function newViewport () {
|
||||
}
|
||||
}
|
||||
|
||||
function displace (displaceVector, recalculate) {
|
||||
position.x = position.x + displaceVector.x
|
||||
position.y = position.y + displaceVector.y
|
||||
|
||||
saveObjectState()
|
||||
|
||||
let event = {
|
||||
newPosition: position,
|
||||
recalculate: recalculate
|
||||
}
|
||||
|
||||
thisObject.eventHandler.raiseEvent('Position Changed', event)
|
||||
|
||||
// console.log("displace produced new Position x = " + position.x + " y = " + position.y);
|
||||
}
|
||||
|
||||
function newZoomLevel (level) {
|
||||
thisObject.zoomTargetLevel = level
|
||||
thisObject.zoomLevel = level
|
||||
|
||||
saveObjectState()
|
||||
|
||||
ANIMATION_INCREMENT = Math.abs(thisObject.zoomTargetLevel - thisObject.zoomLevel) / 3
|
||||
|
||||
let event = {
|
||||
newLevel: thisObject.zoomTargetLevel,
|
||||
newPosition: position,
|
||||
type: undefined
|
||||
}
|
||||
|
||||
thisObject.eventHandler.raiseEvent('Zoom Changed', event)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
function applyZoom (amount) {
|
||||
// console.log("applyZoom amount: " + amount);
|
||||
|
||||
function onMouseWheel (amount) {
|
||||
/* We adjust the sensitivity for Mac Users */
|
||||
let isMac = navigator.platform.toUpperCase().indexOf('MAC') >= 0
|
||||
if (isMac) { amount = amount / 5 }
|
||||
|
||||
/*
|
||||
if (amount > 0) {
|
||||
if (thisObject.zoomTargetLevel > -5) {
|
||||
amount = amount * 2
|
||||
}
|
||||
|
||||
if (thisObject.zoomTargetLevel > 10) {
|
||||
amount = amount * 3
|
||||
}
|
||||
|
||||
if (thisObject.zoomTargetLevel > 15) {
|
||||
amount = amount * 4
|
||||
}
|
||||
@@ -235,35 +197,31 @@ function newViewport () {
|
||||
if (thisObject.zoomTargetLevel > -4) {
|
||||
amount = amount * 2
|
||||
}
|
||||
|
||||
if (thisObject.zoomTargetLevel > 13) {
|
||||
amount = amount * 3
|
||||
}
|
||||
|
||||
if (thisObject.zoomTargetLevel > 19) {
|
||||
amount = amount * 4
|
||||
}
|
||||
}
|
||||
|
||||
if (thisObject.zoomTargetLevel + amount > MAX_ZOOM_LEVEL) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (thisObject.zoomTargetLevel <= -27 && amount < 0) {
|
||||
amount = amount / 4
|
||||
}
|
||||
|
||||
if (thisObject.zoomTargetLevel < -27 && amount > 0) {
|
||||
amount = amount / 4
|
||||
}
|
||||
|
||||
*/
|
||||
if (thisObject.zoomTargetLevel + amount > MAX_ZOOM_LEVEL) {
|
||||
return false
|
||||
}
|
||||
if (thisObject.zoomTargetLevel + amount < MIN_ZOOM_LEVEL) {
|
||||
return false
|
||||
}
|
||||
|
||||
thisObject.zoomTargetLevel = thisObject.zoomTargetLevel + amount
|
||||
|
||||
ANIMATION_INCREMENT = Math.abs(thisObject.zoomTargetLevel - thisObject.zoomLevel) / 3
|
||||
ANIMATION_INCREMENT = Math.abs(thisObject.zoomTargetLevel - thisObject.zoomLevel) / ANIMATION_STEPS
|
||||
|
||||
let event = {
|
||||
newLevel: thisObject.zoomTargetLevel,
|
||||
@@ -278,30 +236,9 @@ function newViewport () {
|
||||
}
|
||||
|
||||
thisObject.eventHandler.raiseEvent('Zoom Changed', event)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
function changeZoom (oldLevel, newLevel) {
|
||||
let mouseNoZoom = unzoomThisPoint(thisObject.mousePosition, oldLevel)
|
||||
let newMouse = zoomThisPoint(mouseNoZoom, newLevel)
|
||||
|
||||
position.x = position.x - newMouse.x + thisObject.mousePosition.x
|
||||
position.y = position.y - newMouse.y + thisObject.mousePosition.y
|
||||
|
||||
saveObjectState()
|
||||
|
||||
targetPosition.x = position.x
|
||||
targetPosition.y = position.y
|
||||
|
||||
positionIncrement = {
|
||||
x: 0,
|
||||
y: 0
|
||||
}
|
||||
|
||||
thisObject.eventHandler.raiseEvent('Zoom Changed')
|
||||
}
|
||||
|
||||
function fitIntoVisibleArea (point) {
|
||||
/* Here we check the boundaries of the resulting points, so they dont go out of the visible area. */
|
||||
|
||||
@@ -324,35 +261,74 @@ function newViewport () {
|
||||
return point
|
||||
}
|
||||
|
||||
function zoomThisPoint (point, level) {
|
||||
let zoomFactor = increment // + increment * thisObject.zoomLevel / 100;
|
||||
function displace (displaceVector, recalculate) {
|
||||
position.x = position.x + displaceVector.x
|
||||
position.y = position.y + displaceVector.y
|
||||
|
||||
if (level === undefined) {
|
||||
point.x = point.x * (1 + zoomFactor * thisObject.zoomLevel) + position.x
|
||||
point.y = point.y * (1 + zoomFactor * thisObject.zoomLevel) + position.y
|
||||
} else {
|
||||
point.x = point.x * (1 + zoomFactor * level) + position.x
|
||||
point.y = point.y * (1 + zoomFactor * level) + position.y
|
||||
saveObjectState()
|
||||
|
||||
let event = {
|
||||
newPosition: position,
|
||||
recalculate: recalculate
|
||||
}
|
||||
|
||||
return point
|
||||
thisObject.eventHandler.raiseEvent('Position Changed', event)
|
||||
|
||||
// console.log("displace produced new Position x = " + position.x + " y = " + position.y);
|
||||
}
|
||||
|
||||
function unzoomThisPoint (pointWithZoom, level) {
|
||||
let pointWithoutZoom
|
||||
let zoomFactor = increment // + increment * thisObject.zoomLevel / 100;
|
||||
function changeZoom (oldLevel, newLevel) {
|
||||
let oldMouse = unTransformThisPoint(thisObject.mousePosition, oldLevel)
|
||||
let newMouse = transformThisPoint(oldMouse, newLevel)
|
||||
|
||||
position.x = position.x - newMouse.x + thisObject.mousePosition.x
|
||||
position.y = position.y - newMouse.y + thisObject.mousePosition.y
|
||||
|
||||
let testPoint = unTransformThisPoint(thisObject.mousePosition, newLevel)
|
||||
|
||||
saveObjectState()
|
||||
|
||||
targetPosition.x = position.x
|
||||
targetPosition.y = position.y
|
||||
|
||||
positionIncrement = {
|
||||
x: 0,
|
||||
y: 0
|
||||
}
|
||||
|
||||
thisObject.eventHandler.raiseEvent('Zoom Changed')
|
||||
}
|
||||
|
||||
function transformThisPoint (point, level) {
|
||||
let transformedPoint = {
|
||||
x: 0,
|
||||
y: 0
|
||||
}
|
||||
|
||||
if (level === undefined) {
|
||||
pointWithoutZoom = {
|
||||
x: (pointWithZoom.x - position.x) / (1 + zoomFactor * thisObject.zoomLevel),
|
||||
y: (pointWithZoom.y - position.y) / (1 + zoomFactor * thisObject.zoomLevel)
|
||||
}
|
||||
transformedPoint.x = point.x * (1 + thisObject.zoomLevel) + position.x
|
||||
transformedPoint.y = point.y * (1 + thisObject.zoomLevel) + position.y
|
||||
} else {
|
||||
pointWithoutZoom = {
|
||||
x: (pointWithZoom.x - position.x) / (1 + zoomFactor * level),
|
||||
y: (pointWithZoom.y - position.y) / (1 + zoomFactor * level)
|
||||
}
|
||||
transformedPoint.x = point.x * (1 + level) + position.x
|
||||
transformedPoint.y = point.y * (1 + level) + position.y
|
||||
}
|
||||
|
||||
return transformedPoint
|
||||
}
|
||||
|
||||
function unTransformThisPoint (point, level) {
|
||||
let pointWithoutZoom = {
|
||||
x: 0,
|
||||
y: 0
|
||||
}
|
||||
if (level === undefined) {
|
||||
pointWithoutZoom.x = (point.x - position.x) / (1 + thisObject.zoomLevel)
|
||||
pointWithoutZoom.y = (point.y - position.y) / (1 + thisObject.zoomLevel)
|
||||
} else {
|
||||
pointWithoutZoom.x = (point.x - position.x) / (1 + level)
|
||||
pointWithoutZoom.y = (point.y - position.y) / (1 + level)
|
||||
}
|
||||
|
||||
return pointWithoutZoom
|
||||
}
|
||||
|
||||
@@ -374,7 +350,7 @@ function newViewport () {
|
||||
/* Save the zoom at the node config, so that the user can change it if he wishes to. */
|
||||
try {
|
||||
let code = JSON.parse(thisObject.payload.node.code)
|
||||
code.zoom = (thisObject.zoomLevel - MIN_ZOOM_LEVEL) / (MAX_ZOOM_LEVEL - MIN_ZOOM_LEVEL) * 100
|
||||
code.zoom = (thisObject.zoomTargetLevel - MIN_ZOOM_LEVEL) / (MAX_ZOOM_LEVEL - MIN_ZOOM_LEVEL) * 100
|
||||
code.zoom = code.zoom.toFixed(2)
|
||||
thisObject.payload.node.code = JSON.stringify(code)
|
||||
} catch (err) {
|
||||
@@ -397,7 +373,7 @@ function newViewport () {
|
||||
if (code.zoom < MIN_ZOOM_LEVEL) { code.zoom = MIN_ZOOM_LEVEL }
|
||||
if (code.zoom > MAX_ZOOM_LEVEL) { code.zoom = MAX_ZOOM_LEVEL }
|
||||
|
||||
if (code.zoom !== thisObject.zoomLevel) {
|
||||
if (code.zoom !== thisObject.zoomTargetLevel) {
|
||||
newZoomLevel(code.zoom)
|
||||
} else {
|
||||
saveObjectState()
|
||||
@@ -405,5 +381,20 @@ function newViewport () {
|
||||
} catch (err) {
|
||||
// we ignore errors here since most likely they will be parsing errors.
|
||||
}
|
||||
|
||||
function newZoomLevel (level) {
|
||||
thisObject.level = level
|
||||
thisObject.zoomTargetLevel = level
|
||||
saveObjectState()
|
||||
ANIMATION_INCREMENT = 0
|
||||
|
||||
let event = {
|
||||
newLevel: thisObject.zoomTargetLevel,
|
||||
newPosition: position,
|
||||
type: undefined
|
||||
}
|
||||
thisObject.eventHandler.raiseEvent('Zoom Changed', event)
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -188,8 +188,8 @@ const PERIOD_01_MIN = "01-min";
|
||||
We define here the size of the chartSpace. It has to bee enough big in order to accomodate all the charts we expect to display in this space.
|
||||
*/
|
||||
|
||||
const TIME_MACHINE_WIDTH = browserCanvas.width * 1000;
|
||||
const TIME_MACHINE_HEIGHT = browserCanvas.height * 100;
|
||||
const TIME_MACHINE_WIDTH = 500;
|
||||
const TIME_MACHINE_HEIGHT = 100;
|
||||
|
||||
function toRadians(angle) {
|
||||
return angle * (Math.PI / 180);
|
||||
|
||||
+4
-3
@@ -16,10 +16,10 @@ function newRateScale () {
|
||||
finalize: finalize
|
||||
}
|
||||
|
||||
const DEFAULT_VALUE = 50
|
||||
const STEP_SIZE = 2
|
||||
const DEFAULT_VALUE = 1
|
||||
const STEP_SIZE = 1
|
||||
const MIN_WIDTH = 50
|
||||
const MAX_VALUE = 150
|
||||
const MAX_VALUE = 100
|
||||
|
||||
thisObject.container = newContainer()
|
||||
thisObject.container.initialize(MODULE_NAME)
|
||||
@@ -148,6 +148,7 @@ function newRateScale () {
|
||||
}
|
||||
|
||||
function readObjectState () {
|
||||
return
|
||||
try {
|
||||
let code = JSON.parse(thisObject.payload.node.code)
|
||||
|
||||
|
||||
@@ -180,7 +180,7 @@ function newTimeFrameScale () {
|
||||
function onViewportZoomChanged (event) {
|
||||
if (event !== undefined) { // it is undefined when the level is just being animated.
|
||||
let currentTimeFrame = thisObject.timeFrame
|
||||
let timeFrame = recalculatePeriod(event.newLevel)
|
||||
let timeFrame = currentTimeFrame // recalculatePeriod(event.newLevel)
|
||||
if (timeFrame !== currentTimeFrame) {
|
||||
for (let i = 0; i < timeFramesMasterArray.length; i++) {
|
||||
let timeFrameArray = timeFramesMasterArray[i]
|
||||
@@ -245,6 +245,7 @@ function newTimeFrameScale () {
|
||||
}
|
||||
|
||||
function readObjectState () {
|
||||
return
|
||||
try {
|
||||
let code = JSON.parse(thisObject.payload.node.code)
|
||||
if (code.value !== timeFrameLabel) {
|
||||
|
||||
+6
-4
@@ -16,8 +16,9 @@ function newTimeScale () {
|
||||
finalize: finalize
|
||||
}
|
||||
|
||||
const DEFAULT_VALUE = 5
|
||||
const STEP_SIZE = 2.5
|
||||
const DEFAULT_VALUE = 1
|
||||
const STEP_SIZE = 1
|
||||
const MIN_VALUE = 1
|
||||
const MAX_VALUE = 400
|
||||
|
||||
thisObject.container = newContainer()
|
||||
@@ -117,7 +118,7 @@ function newTimeScale () {
|
||||
delta = event.wheelDelta
|
||||
if (delta < 0) {
|
||||
thisObject.value = thisObject.value - STEP_SIZE * morePower
|
||||
if (thisObject.value < STEP_SIZE) { thisObject.value = STEP_SIZE }
|
||||
if (thisObject.value < MIN_VALUE) { thisObject.value = STEP_SIZE }
|
||||
} else {
|
||||
thisObject.value = thisObject.value + STEP_SIZE * morePower
|
||||
if (thisObject.value > MAX_VALUE) { thisObject.value = MAX_VALUE }
|
||||
@@ -148,6 +149,7 @@ function newTimeScale () {
|
||||
}
|
||||
|
||||
function readObjectState () {
|
||||
return
|
||||
try {
|
||||
let code = JSON.parse(thisObject.payload.node.code)
|
||||
|
||||
@@ -156,7 +158,7 @@ function newTimeScale () {
|
||||
return
|
||||
}
|
||||
code.value = code.value / 100 * MAX_VALUE
|
||||
if (code.value < STEP_SIZE) { code.value = STEP_SIZE }
|
||||
if (code.value < MIN_VALUE) { code.value = STEP_SIZE }
|
||||
if (code.value > MAX_VALUE) { code.value = MAX_VALUE }
|
||||
|
||||
if (code.value !== thisObject.value) {
|
||||
|
||||
@@ -151,7 +151,7 @@ function newChartSpace () {
|
||||
function oneScreenUp () {
|
||||
let displaceVector = {
|
||||
x: 0,
|
||||
y: +browserCanvas.height * PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT / 100
|
||||
y: browserCanvas.height * PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT / 100
|
||||
}
|
||||
|
||||
canvas.chartSpace.viewport.displace(displaceVector)
|
||||
@@ -290,8 +290,8 @@ function newChartSpace () {
|
||||
timeMachine.payload.uiObject.setValue('Loading...')
|
||||
|
||||
/* Setting up the new time machine. */
|
||||
timeMachine.container.frame.position.x = thisObject.container.frame.width / 2 - timeMachine.container.frame.width / 2
|
||||
timeMachine.container.frame.position.y = thisObject.container.frame.height / 2 - timeMachine.container.frame.height / 2
|
||||
timeMachine.container.frame.position.x = browserCanvas.width / 2 - TIME_MACHINE_WIDTH / 2
|
||||
timeMachine.container.frame.position.y = browserCanvas.height / 2 - TIME_MACHINE_HEIGHT / 2
|
||||
timeMachine.initialize(onTimeMachineInitialized)
|
||||
|
||||
function onTimeMachineInitialized (err) {
|
||||
|
||||
+5
-9
@@ -57,13 +57,13 @@ function transformThisPoint (point, container) {
|
||||
|
||||
/* We pass this point through the canvas.chartSpace.viewport lends, meaning we apply the canvas.chartSpace.viewport zoom and displacement. */
|
||||
|
||||
point = canvas.chartSpace.viewport.zoomThisPoint(point)
|
||||
point = canvas.chartSpace.viewport.transformThisPoint(point)
|
||||
|
||||
return point
|
||||
}
|
||||
|
||||
function unTransformThisPoint (point, container) {
|
||||
point = canvas.chartSpace.viewport.unzoomThisPoint(point)
|
||||
point = canvas.chartSpace.viewport.unTransformThisPoint(point)
|
||||
point = container.frame.unframeThisPoint(point)
|
||||
|
||||
return point
|
||||
@@ -146,13 +146,9 @@ function getUserPosition (timeLineCoordinateSystem) {
|
||||
return userPosition
|
||||
}
|
||||
|
||||
function moveToUserPosition (container, timeLineCoordinateSystem, ignoreX, ignoreY, center, considerZoom, moveContainer) {
|
||||
function moveToUserPosition (container, timeLineCoordinateSystem, ignoreX, ignoreY, center, moveContainer) {
|
||||
let userPosition = getUserPosition(timeLineCoordinateSystem)
|
||||
|
||||
if (considerZoom === true) {
|
||||
canvas.chartSpace.viewport.newZoomLevel(userPosition.zoom)
|
||||
}
|
||||
|
||||
INITIAL_TIME_PERIOD = recalculatePeriod(userPosition.zoom)
|
||||
NEW_SESSION_INITIAL_DATE = new Date(userPosition.date)
|
||||
|
||||
@@ -190,7 +186,7 @@ function moveToUserPosition (container, timeLineCoordinateSystem, ignoreX, ignor
|
||||
}
|
||||
|
||||
let targetNoZoom
|
||||
targetNoZoom = canvas.chartSpace.viewport.unzoomThisPoint(targetCopy)
|
||||
targetNoZoom = canvas.chartSpace.viewport.unTransformThisPoint(targetCopy)
|
||||
|
||||
let centerCopy = {
|
||||
x: centerPoint.x,
|
||||
@@ -198,7 +194,7 @@ function moveToUserPosition (container, timeLineCoordinateSystem, ignoreX, ignor
|
||||
}
|
||||
|
||||
let centerNoZoom
|
||||
centerNoZoom = canvas.chartSpace.viewport.unzoomThisPoint(centerCopy)
|
||||
centerNoZoom = canvas.chartSpace.viewport.unTransformThisPoint(centerCopy)
|
||||
|
||||
displaceVector = {
|
||||
x: centerNoZoom.x - targetNoZoom.x,
|
||||
|
||||
Reference in new issue
Block a user