Change in Code Indentation
This commit is contained in:
1 parent
1a52e5494e
commit
199a71a4e5
89 files changed
+22093
-22093
No files matched your search
+607
-607
File diff suppressed because it is too large.
Load diff
+478
-478
@@ -1,519 +1,519 @@
|
||||
function newLayersPanel () {
|
||||
let thisObject = {
|
||||
name: 'Layers Panel',
|
||||
fitFunction: undefined,
|
||||
container: undefined,
|
||||
layers: [],
|
||||
payload: undefined,
|
||||
isVisible: true,
|
||||
upDownButton: undefined,
|
||||
leftRightButton: undefined,
|
||||
physics: physics,
|
||||
draw: draw,
|
||||
getContainer: getContainer,
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
}
|
||||
|
||||
thisObject.container = newContainer()
|
||||
thisObject.container.initialize()
|
||||
thisObject.container.isDraggeable = true
|
||||
thisObject.container.isWheelable = true
|
||||
thisObject.container.detectMouseOver = true
|
||||
|
||||
let isInitialized = false
|
||||
let mouseOverCounter = 0
|
||||
|
||||
let layersMap = new Map()
|
||||
let visibleLayers = []
|
||||
let firstVisibleLayer = 1
|
||||
|
||||
const LAYER_SEPARATION = 0
|
||||
|
||||
let headerHeight = 40
|
||||
let footerHeight = 10
|
||||
let layerHeight = 70
|
||||
let desiredVisibleLayers = 5
|
||||
let posibleVisibleLayers = 5
|
||||
let desiredPanelHeight = (layerHeight + LAYER_SEPARATION) * desiredVisibleLayers + headerHeight + footerHeight
|
||||
let posiblePanelHeight = (layerHeight + LAYER_SEPARATION) * posibleVisibleLayers + headerHeight + footerHeight
|
||||
|
||||
let onMouseWheelEventSuscriptionId
|
||||
let onMouseOverEventSubscriptionId
|
||||
let onMouseNotOverEventSubscriptionId
|
||||
|
||||
let isMouseOver
|
||||
return thisObject
|
||||
|
||||
function finalize () {
|
||||
thisObject.container.eventHandler.stopListening(onMouseWheelEventSuscriptionId)
|
||||
thisObject.container.eventHandler.stopListening(onMouseOverEventSubscriptionId)
|
||||
thisObject.container.eventHandler.stopListening(onMouseNotOverEventSubscriptionId)
|
||||
|
||||
thisObject.upDownButton.finalize()
|
||||
thisObject.upDownButton = undefined
|
||||
|
||||
thisObject.leftRightButton.finalize()
|
||||
thisObject.leftRightButton = undefined
|
||||
|
||||
layersMap = undefined
|
||||
visibleLayers = undefined
|
||||
|
||||
thisObject.container.finalize()
|
||||
thisObject.container = undefined
|
||||
|
||||
thisObject.payload = undefined
|
||||
thisObject = undefined
|
||||
}
|
||||
|
||||
function initialize () {
|
||||
thisObject.container.name = thisObject.payload.node.name
|
||||
thisObject.container.frame.containerName = thisObject.container.name
|
||||
thisObject.container.frame.width = UI_PANEL.WIDTH.NORMAL
|
||||
thisObject.container.frame.height = headerHeight
|
||||
|
||||
let position = { // Default position
|
||||
x: canvas.chartingSpace.viewport.visibleArea.topLeft.x,
|
||||
y: canvas.chartingSpace.viewport.visibleArea.topLeft.y
|
||||
function newLayersPanel() {
|
||||
let thisObject = {
|
||||
name: 'Layers Panel',
|
||||
fitFunction: undefined,
|
||||
container: undefined,
|
||||
layers: [],
|
||||
payload: undefined,
|
||||
isVisible: true,
|
||||
upDownButton: undefined,
|
||||
leftRightButton: undefined,
|
||||
physics: physics,
|
||||
draw: draw,
|
||||
getContainer: getContainer,
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
}
|
||||
|
||||
thisObject.container.frame.position = position
|
||||
loadFrame(thisObject.payload, thisObject.container.frame)
|
||||
thisObject.container = newContainer()
|
||||
thisObject.container.initialize()
|
||||
thisObject.container.isDraggeable = true
|
||||
thisObject.container.isWheelable = true
|
||||
thisObject.container.detectMouseOver = true
|
||||
|
||||
thisObject.upDownButton = newUpDownButton()
|
||||
thisObject.upDownButton.parentContainer = thisObject.container
|
||||
thisObject.upDownButton.container.frame.parentFrame = thisObject.container.frame
|
||||
thisObject.upDownButton.fitFunction = thisObject.fitFunction
|
||||
thisObject.upDownButton.initialize()
|
||||
let isInitialized = false
|
||||
let mouseOverCounter = 0
|
||||
|
||||
thisObject.leftRightButton = newLeftRightButton()
|
||||
thisObject.leftRightButton.parentContainer = thisObject.container
|
||||
thisObject.leftRightButton.container.frame.parentFrame = thisObject.container.frame
|
||||
thisObject.leftRightButton.fitFunction = thisObject.fitFunction
|
||||
thisObject.leftRightButton.initialize()
|
||||
let layersMap = new Map()
|
||||
let visibleLayers = []
|
||||
let firstVisibleLayer = 1
|
||||
|
||||
onMouseWheelEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel)
|
||||
onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver)
|
||||
onMouseNotOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver)
|
||||
const LAYER_SEPARATION = 0
|
||||
|
||||
readObjectState()
|
||||
let headerHeight = 40
|
||||
let footerHeight = 10
|
||||
let layerHeight = 70
|
||||
let desiredVisibleLayers = 5
|
||||
let posibleVisibleLayers = 5
|
||||
let desiredPanelHeight = (layerHeight + LAYER_SEPARATION) * desiredVisibleLayers + headerHeight + footerHeight
|
||||
let posiblePanelHeight = (layerHeight + LAYER_SEPARATION) * posibleVisibleLayers + headerHeight + footerHeight
|
||||
|
||||
isInitialized = true
|
||||
}
|
||||
let onMouseWheelEventSuscriptionId
|
||||
let onMouseOverEventSubscriptionId
|
||||
let onMouseNotOverEventSubscriptionId
|
||||
|
||||
function onMouseOver (event) {
|
||||
isMouseOver = true
|
||||
}
|
||||
let isMouseOver
|
||||
return thisObject
|
||||
|
||||
function onMouseNotOver () {
|
||||
isMouseOver = false
|
||||
}
|
||||
function finalize() {
|
||||
thisObject.container.eventHandler.stopListening(onMouseWheelEventSuscriptionId)
|
||||
thisObject.container.eventHandler.stopListening(onMouseOverEventSubscriptionId)
|
||||
thisObject.container.eventHandler.stopListening(onMouseNotOverEventSubscriptionId)
|
||||
|
||||
function saveObjectStateVisibleLayers () {
|
||||
savePropertyAtNodeConfig(thisObject.payload, 'visibleLayers', desiredVisibleLayers)
|
||||
}
|
||||
thisObject.upDownButton.finalize()
|
||||
thisObject.upDownButton = undefined
|
||||
|
||||
function saveObjectStatePanelLocation () {
|
||||
let panelLocation = {
|
||||
upOrDown: thisObject.upDownButton.status,
|
||||
leftOrRight: thisObject.leftRightButton.status
|
||||
thisObject.leftRightButton.finalize()
|
||||
thisObject.leftRightButton = undefined
|
||||
|
||||
layersMap = undefined
|
||||
visibleLayers = undefined
|
||||
|
||||
thisObject.container.finalize()
|
||||
thisObject.container = undefined
|
||||
|
||||
thisObject.payload = undefined
|
||||
thisObject = undefined
|
||||
}
|
||||
savePropertyAtNodeConfig(thisObject.payload, 'panelLocation', panelLocation)
|
||||
}
|
||||
|
||||
function readObjectState () {
|
||||
let storedValue
|
||||
function initialize() {
|
||||
thisObject.container.name = thisObject.payload.node.name
|
||||
thisObject.container.frame.containerName = thisObject.container.name
|
||||
thisObject.container.frame.width = UI_PANEL.WIDTH.NORMAL
|
||||
thisObject.container.frame.height = headerHeight
|
||||
|
||||
storedValue = loadPropertyFromNodeConfig(thisObject.payload, 'visibleLayers')
|
||||
let position = { // Default position
|
||||
x: canvas.chartingSpace.viewport.visibleArea.topLeft.x,
|
||||
y: canvas.chartingSpace.viewport.visibleArea.topLeft.y
|
||||
}
|
||||
|
||||
if (isNaN(storedValue) || storedValue === null || storedValue === undefined) {
|
||||
// not using this value
|
||||
saveObjectStateVisibleLayers() // this overrides any invalid value at the config.
|
||||
return
|
||||
} else {
|
||||
if (storedValue < 0) { storedValue = 0 }
|
||||
if (storedValue > thisObject.layers.length) {
|
||||
storedValue = thisObject.layers.length
|
||||
}
|
||||
thisObject.container.frame.position = position
|
||||
loadFrame(thisObject.payload, thisObject.container.frame)
|
||||
|
||||
if (storedValue !== desiredVisibleLayers) {
|
||||
desiredVisibleLayers = storedValue
|
||||
thisObject.upDownButton = newUpDownButton()
|
||||
thisObject.upDownButton.parentContainer = thisObject.container
|
||||
thisObject.upDownButton.container.frame.parentFrame = thisObject.container.frame
|
||||
thisObject.upDownButton.fitFunction = thisObject.fitFunction
|
||||
thisObject.upDownButton.initialize()
|
||||
|
||||
thisObject.leftRightButton = newLeftRightButton()
|
||||
thisObject.leftRightButton.parentContainer = thisObject.container
|
||||
thisObject.leftRightButton.container.frame.parentFrame = thisObject.container.frame
|
||||
thisObject.leftRightButton.fitFunction = thisObject.fitFunction
|
||||
thisObject.leftRightButton.initialize()
|
||||
|
||||
onMouseWheelEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel)
|
||||
onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver)
|
||||
onMouseNotOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver)
|
||||
|
||||
readObjectState()
|
||||
|
||||
isInitialized = true
|
||||
}
|
||||
|
||||
function onMouseOver(event) {
|
||||
isMouseOver = true
|
||||
}
|
||||
|
||||
function onMouseNotOver() {
|
||||
isMouseOver = false
|
||||
}
|
||||
|
||||
function saveObjectStateVisibleLayers() {
|
||||
savePropertyAtNodeConfig(thisObject.payload, 'visibleLayers', desiredVisibleLayers)
|
||||
}
|
||||
|
||||
function saveObjectStatePanelLocation() {
|
||||
let panelLocation = {
|
||||
upOrDown: thisObject.upDownButton.status,
|
||||
leftOrRight: thisObject.leftRightButton.status
|
||||
}
|
||||
savePropertyAtNodeConfig(thisObject.payload, 'panelLocation', panelLocation)
|
||||
}
|
||||
|
||||
function readObjectState() {
|
||||
let storedValue
|
||||
|
||||
storedValue = loadPropertyFromNodeConfig(thisObject.payload, 'visibleLayers')
|
||||
|
||||
if (isNaN(storedValue) || storedValue === null || storedValue === undefined) {
|
||||
// not using this value
|
||||
saveObjectStateVisibleLayers() // this overrides any invalid value at the config.
|
||||
return
|
||||
} else {
|
||||
if (storedValue < 0) { storedValue = 0 }
|
||||
if (storedValue > thisObject.layers.length) {
|
||||
storedValue = thisObject.layers.length
|
||||
}
|
||||
|
||||
if (storedValue !== desiredVisibleLayers) {
|
||||
desiredVisibleLayers = storedValue
|
||||
desiredPanelHeight = (layerHeight + LAYER_SEPARATION) * desiredVisibleLayers + headerHeight + footerHeight
|
||||
calculateVisbleLayers()
|
||||
}
|
||||
}
|
||||
|
||||
storedValue = loadPropertyFromNodeConfig(thisObject.payload, 'panelLocation')
|
||||
|
||||
if (storedValue === null || storedValue === undefined) {
|
||||
// not using this value
|
||||
saveObjectStatePanelLocation() // this overrides any invalid value at the config.
|
||||
return
|
||||
} else {
|
||||
if (storedValue.upOrDown !== 'up' && storedValue.upOrDown !== 'down') {
|
||||
saveObjectStatePanelLocation() // this overrides any invalid value at the config.
|
||||
return
|
||||
}
|
||||
if (storedValue.leftOrRight !== 'left' && storedValue.leftOrRight !== 'right') {
|
||||
saveObjectStatePanelLocation() // this overrides any invalid value at the config.
|
||||
return
|
||||
}
|
||||
thisObject.upDownButton.setStatus(storedValue.upOrDown)
|
||||
thisObject.leftRightButton.setStatus(storedValue.leftOrRight)
|
||||
saveObjectStatePanelLocation()
|
||||
}
|
||||
}
|
||||
|
||||
function removeLayer(id) {
|
||||
let layer = layersMap.get(id)
|
||||
layersMap.delete(id)
|
||||
layer.turnOff()
|
||||
layer.container.eventHandler.stopListening(layer.onLayerStatusChangedEventSuscriptionId)
|
||||
layer.container.eventHandler.stopListening(layer.onMouseWheelEventSuscriptionId)
|
||||
layer.finalize()
|
||||
}
|
||||
|
||||
function addLayer(layerNode) {
|
||||
/* Now we create Product objects */
|
||||
let layer = newLayer()
|
||||
layer.payload = layerNode.payload
|
||||
layer.nodeId = layerNode.payload.node.id
|
||||
layer.fitFunction = thisObject.fitFunction
|
||||
|
||||
/* Initialize it */
|
||||
layer.initialize(onInitialized)
|
||||
|
||||
function onInitialized(err) {
|
||||
if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
layersMap.set(layerNode.id, layer)
|
||||
|
||||
/* Container Stuff */
|
||||
layer.container.frame.parentFrame = thisObject.container.frame
|
||||
layer.container.parentContainer = thisObject.container
|
||||
layer.container.isWheelable = true
|
||||
|
||||
/* Add to the Product Array */
|
||||
thisObject.layers.push(layer)
|
||||
|
||||
/* Listen to Status Changes Events */
|
||||
layer.onLayerStatusChangedEventSuscriptionId = layer.container.eventHandler.listenToEvent('Status Changed', onLayerStatusChanged)
|
||||
layer.onMouseWheelEventSuscriptionId = layer.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel)
|
||||
|
||||
layer.checkStatusAtShutDown()
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onMouseWheel(event) {
|
||||
delta = event.wheelDelta
|
||||
if (delta > 0) {
|
||||
delta = -1
|
||||
} else {
|
||||
delta = 1
|
||||
}
|
||||
|
||||
if (event.y - thisObject.container.frame.position.y - CURRENT_TOP_MARGIN < headerHeight) { // Mouse wheel over the header, not a layer
|
||||
desiredVisibleLayers = desiredVisibleLayers + delta
|
||||
if (desiredVisibleLayers < 0) { desiredVisibleLayers = 0 }
|
||||
if (desiredVisibleLayers > thisObject.layers.length) { desiredVisibleLayers = thisObject.layers.length }
|
||||
} else {
|
||||
firstVisibleLayer = firstVisibleLayer + delta
|
||||
}
|
||||
desiredPanelHeight = (layerHeight + LAYER_SEPARATION) * desiredVisibleLayers + headerHeight + footerHeight
|
||||
calculateVisbleLayers()
|
||||
}
|
||||
saveObjectStateVisibleLayers()
|
||||
}
|
||||
|
||||
storedValue = loadPropertyFromNodeConfig(thisObject.payload, 'panelLocation')
|
||||
function panelSizePhysics() {
|
||||
if (isInitialized === false || thisObject.isHidden === true) { return }
|
||||
|
||||
if (storedValue === null || storedValue === undefined) {
|
||||
// not using this value
|
||||
saveObjectStatePanelLocation() // this overrides any invalid value at the config.
|
||||
return
|
||||
} else {
|
||||
if (storedValue.upOrDown !== 'up' && storedValue.upOrDown !== 'down') {
|
||||
saveObjectStatePanelLocation() // this overrides any invalid value at the config.
|
||||
return
|
||||
}
|
||||
if (storedValue.leftOrRight !== 'left' && storedValue.leftOrRight !== 'right') {
|
||||
saveObjectStatePanelLocation() // this overrides any invalid value at the config.
|
||||
return
|
||||
}
|
||||
thisObject.upDownButton.setStatus(storedValue.upOrDown)
|
||||
thisObject.leftRightButton.setStatus(storedValue.leftOrRight)
|
||||
saveObjectStatePanelLocation()
|
||||
}
|
||||
}
|
||||
let viewPortHeight = canvas.chartingSpace.viewport.visibleArea.bottomLeft.y - canvas.chartingSpace.viewport.visibleArea.topLeft.y
|
||||
|
||||
function removeLayer (id) {
|
||||
let layer = layersMap.get(id)
|
||||
layersMap.delete(id)
|
||||
layer.turnOff()
|
||||
layer.container.eventHandler.stopListening(layer.onLayerStatusChangedEventSuscriptionId)
|
||||
layer.container.eventHandler.stopListening(layer.onMouseWheelEventSuscriptionId)
|
||||
layer.finalize()
|
||||
}
|
||||
|
||||
function addLayer (layerNode) {
|
||||
/* Now we create Product objects */
|
||||
let layer = newLayer()
|
||||
layer.payload = layerNode.payload
|
||||
layer.nodeId = layerNode.payload.node.id
|
||||
layer.fitFunction = thisObject.fitFunction
|
||||
|
||||
/* Initialize it */
|
||||
layer.initialize(onInitialized)
|
||||
|
||||
function onInitialized (err) {
|
||||
if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
layersMap.set(layerNode.id, layer)
|
||||
|
||||
/* Container Stuff */
|
||||
layer.container.frame.parentFrame = thisObject.container.frame
|
||||
layer.container.parentContainer = thisObject.container
|
||||
layer.container.isWheelable = true
|
||||
|
||||
/* Add to the Product Array */
|
||||
thisObject.layers.push(layer)
|
||||
|
||||
/* Listen to Status Changes Events */
|
||||
layer.onLayerStatusChangedEventSuscriptionId = layer.container.eventHandler.listenToEvent('Status Changed', onLayerStatusChanged)
|
||||
layer.onMouseWheelEventSuscriptionId = layer.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel)
|
||||
|
||||
layer.checkStatusAtShutDown()
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onMouseWheel (event) {
|
||||
delta = event.wheelDelta
|
||||
if (delta > 0) {
|
||||
delta = -1
|
||||
} else {
|
||||
delta = 1
|
||||
}
|
||||
|
||||
if (event.y - thisObject.container.frame.position.y - CURRENT_TOP_MARGIN < headerHeight) { // Mouse wheel over the header, not a layer
|
||||
desiredVisibleLayers = desiredVisibleLayers + delta
|
||||
if (desiredVisibleLayers < 0) { desiredVisibleLayers = 0 }
|
||||
if (desiredVisibleLayers > thisObject.layers.length) { desiredVisibleLayers = thisObject.layers.length }
|
||||
} else {
|
||||
firstVisibleLayer = firstVisibleLayer + delta
|
||||
}
|
||||
desiredPanelHeight = (layerHeight + LAYER_SEPARATION) * desiredVisibleLayers + headerHeight + footerHeight
|
||||
calculateVisbleLayers()
|
||||
saveObjectStateVisibleLayers()
|
||||
}
|
||||
|
||||
function panelSizePhysics () {
|
||||
if (isInitialized === false || thisObject.isHidden === true) { return }
|
||||
|
||||
let viewPortHeight = canvas.chartingSpace.viewport.visibleArea.bottomLeft.y - canvas.chartingSpace.viewport.visibleArea.topLeft.y
|
||||
|
||||
if (viewPortHeight < headerHeight) {
|
||||
thisObject.visible = false
|
||||
} else {
|
||||
thisObject.visible = true
|
||||
}
|
||||
|
||||
if (thisObject.visible === false) { return }
|
||||
|
||||
if (desiredPanelHeight > viewPortHeight) {
|
||||
posibleVisibleLayers = Math.trunc((viewPortHeight - headerHeight - footerHeight) / (layerHeight + LAYER_SEPARATION))
|
||||
} else {
|
||||
posibleVisibleLayers = desiredVisibleLayers
|
||||
}
|
||||
if (thisObject.layers.length < posibleVisibleLayers) { posibleVisibleLayers = thisObject.layers.length }
|
||||
|
||||
if (posibleVisibleLayers === 0) {
|
||||
posiblePanelHeight = (layerHeight + LAYER_SEPARATION) * posibleVisibleLayers + headerHeight
|
||||
} else {
|
||||
posiblePanelHeight = (layerHeight + LAYER_SEPARATION) * posibleVisibleLayers + headerHeight + footerHeight
|
||||
}
|
||||
|
||||
thisObject.container.frame.height = posiblePanelHeight
|
||||
}
|
||||
|
||||
function calculateVisbleLayers () {
|
||||
panelSizePhysics()
|
||||
let availableSlots = posibleVisibleLayers
|
||||
|
||||
if (firstVisibleLayer < 1) { firstVisibleLayer = 1 }
|
||||
if (firstVisibleLayer > (thisObject.layers.length - availableSlots + 1)) { firstVisibleLayer = thisObject.layers.length - availableSlots + 1 }
|
||||
|
||||
visibleLayers = []
|
||||
|
||||
for (let i = 0; i < thisObject.layers.length; i++) {
|
||||
if (i + 1 >= firstVisibleLayer && i + 1 < firstVisibleLayer + availableSlots) {
|
||||
let layer = thisObject.layers[i]
|
||||
|
||||
layer.container.frame.position.x = 0
|
||||
layer.container.frame.position.y = (layerHeight + LAYER_SEPARATION) * visibleLayers.length + headerHeight
|
||||
|
||||
/* Add to Visible Product Array */
|
||||
visibleLayers.push(layer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onLayerStatusChanged (layer) {
|
||||
thisObject.container.eventHandler.raiseEvent('Layer Status Changed', layer)
|
||||
}
|
||||
|
||||
function getContainer (point, purpose) {
|
||||
if (isInitialized === false || thisObject.visible === false || thisObject.isHidden === true) { return }
|
||||
let container
|
||||
|
||||
if (isMouseOver === true && purpose !== GET_CONTAINER_PURPOSE.MOUSE_OVER) {
|
||||
container = thisObject.upDownButton.getContainer(point)
|
||||
if (container !== undefined) { return container }
|
||||
|
||||
container = thisObject.leftRightButton.getContainer(point)
|
||||
if (container !== undefined) { return container }
|
||||
}
|
||||
|
||||
/* First we check if thisObject point is inside thisObject space. */
|
||||
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
||||
/* Now we see which is the inner most container that has it */
|
||||
for (let i = 0; i < visibleLayers.length; i++) {
|
||||
container = visibleLayers[i].getContainer(point)
|
||||
|
||||
if (container !== undefined) {
|
||||
let checkPoint = {
|
||||
x: point.x,
|
||||
y: point.y
|
||||
}
|
||||
|
||||
checkPoint = thisObject.fitFunction(checkPoint)
|
||||
|
||||
if (point.x === checkPoint.x && point.y === checkPoint.y) {
|
||||
if (purpose !== GET_CONTAINER_PURPOSE.MOUSE_OVER) {
|
||||
return container
|
||||
}
|
||||
}
|
||||
if (viewPortHeight < headerHeight) {
|
||||
thisObject.visible = false
|
||||
} else {
|
||||
thisObject.visible = true
|
||||
}
|
||||
}
|
||||
|
||||
/* The point does not belong to any inner container, so we return the current container. */
|
||||
let checkPoint = {
|
||||
x: point.x,
|
||||
y: point.y
|
||||
}
|
||||
if (thisObject.visible === false) { return }
|
||||
|
||||
checkPoint = thisObject.fitFunction(checkPoint)
|
||||
|
||||
if (point.x === checkPoint.x && point.y === checkPoint.y) {
|
||||
return thisObject.container
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function childrenPhysics () {
|
||||
for (let i = 0; i < thisObject.layers.length; i++) {
|
||||
let layer = thisObject.layers[i]
|
||||
layer.physics()
|
||||
}
|
||||
}
|
||||
|
||||
function syncWithConfigPhysics () {
|
||||
readObjectState()
|
||||
}
|
||||
|
||||
function physics () {
|
||||
if (isInitialized === false) { return }
|
||||
if (thisObject.payload.node === undefined) { return }
|
||||
|
||||
thisObject.upDownButton.physics()
|
||||
thisObject.leftRightButton.physics()
|
||||
saveFrame(thisObject.payload, thisObject.container.frame)
|
||||
syncWithConfigPhysics()
|
||||
|
||||
/*
|
||||
The overall idea here is that we need to keep syncronized the panel with the layers that are
|
||||
defined at the Designer. Users can connect or disconnect any objext resulting in changes in which
|
||||
are valid layers and which not at any point in time. So what we do here is trying to keep the panel
|
||||
only with the layers that are connected to the Charting Space hiriarcy.
|
||||
|
||||
To achieve this, first we are going to move all session related cards to a local array. Then we are
|
||||
going to check for layers at the designer, and will move back the cards which still have layers well
|
||||
defined to where they were.
|
||||
|
||||
If we find new layers we will add them at that point. Finally, the cards that still remain at the
|
||||
local array after all the layers at the designer have been processed, are turned off and discarded.
|
||||
*/
|
||||
childrenPhysics()
|
||||
|
||||
let localLayers = []
|
||||
moveToLocalLayers()
|
||||
syncWithDesignerLayers()
|
||||
|
||||
/* At this poins all the cards still at the local array need to be removed from the panel. */
|
||||
turnOffUnusedLayers()
|
||||
calculateVisbleLayers()
|
||||
|
||||
function syncWithDesignerLayers () {
|
||||
if (thisObject.payload.node === undefined) { return }
|
||||
let layerManager = thisObject.payload.node
|
||||
for (let p = 0; p < layerManager.layers.length; p++) {
|
||||
let layerNode = layerManager.layers[p]
|
||||
|
||||
let found = removeFromLocalLayers(layerNode.id)
|
||||
if (found !== true) {
|
||||
layer = addLayer(layerNode)
|
||||
if (layer !== undefined) {
|
||||
onLayerStatusChanged(layer)
|
||||
}
|
||||
if (desiredPanelHeight > viewPortHeight) {
|
||||
posibleVisibleLayers = Math.trunc((viewPortHeight - headerHeight - footerHeight) / (layerHeight + LAYER_SEPARATION))
|
||||
} else {
|
||||
posibleVisibleLayers = desiredVisibleLayers
|
||||
}
|
||||
}
|
||||
if (thisObject.layers.length < posibleVisibleLayers) { posibleVisibleLayers = thisObject.layers.length }
|
||||
|
||||
if (posibleVisibleLayers === 0) {
|
||||
posiblePanelHeight = (layerHeight + LAYER_SEPARATION) * posibleVisibleLayers + headerHeight
|
||||
} else {
|
||||
posiblePanelHeight = (layerHeight + LAYER_SEPARATION) * posibleVisibleLayers + headerHeight + footerHeight
|
||||
}
|
||||
|
||||
thisObject.container.frame.height = posiblePanelHeight
|
||||
}
|
||||
|
||||
function moveToLocalLayers () {
|
||||
removeNext()
|
||||
function calculateVisbleLayers() {
|
||||
panelSizePhysics()
|
||||
let availableSlots = posibleVisibleLayers
|
||||
|
||||
if (firstVisibleLayer < 1) { firstVisibleLayer = 1 }
|
||||
if (firstVisibleLayer > (thisObject.layers.length - availableSlots + 1)) { firstVisibleLayer = thisObject.layers.length - availableSlots + 1 }
|
||||
|
||||
visibleLayers = []
|
||||
|
||||
function removeNext () {
|
||||
for (let i = 0; i < thisObject.layers.length; i++) {
|
||||
let layer = thisObject.layers[i]
|
||||
if (i + 1 >= firstVisibleLayer && i + 1 < firstVisibleLayer + availableSlots) {
|
||||
let layer = thisObject.layers[i]
|
||||
|
||||
thisObject.layers.splice(i, 1)
|
||||
localLayers.push(layer)
|
||||
removeNext()
|
||||
layer.container.frame.position.x = 0
|
||||
layer.container.frame.position.y = (layerHeight + LAYER_SEPARATION) * visibleLayers.length + headerHeight
|
||||
|
||||
/* Add to Visible Product Array */
|
||||
visibleLayers.push(layer)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function removeFromLocalLayers (id) {
|
||||
for (let i = 0; i < localLayers.length; i++) {
|
||||
let layer = localLayers[i]
|
||||
if (layer.payload.node.id === id) {
|
||||
thisObject.layers.push(layer)
|
||||
localLayers.splice(i, 1)
|
||||
return true
|
||||
function onLayerStatusChanged(layer) {
|
||||
thisObject.container.eventHandler.raiseEvent('Layer Status Changed', layer)
|
||||
}
|
||||
|
||||
function getContainer(point, purpose) {
|
||||
if (isInitialized === false || thisObject.visible === false || thisObject.isHidden === true) { return }
|
||||
let container
|
||||
|
||||
if (isMouseOver === true && purpose !== GET_CONTAINER_PURPOSE.MOUSE_OVER) {
|
||||
container = thisObject.upDownButton.getContainer(point)
|
||||
if (container !== undefined) { return container }
|
||||
|
||||
container = thisObject.leftRightButton.getContainer(point)
|
||||
if (container !== undefined) { return container }
|
||||
}
|
||||
|
||||
/* First we check if thisObject point is inside thisObject space. */
|
||||
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
||||
/* Now we see which is the inner most container that has it */
|
||||
for (let i = 0; i < visibleLayers.length; i++) {
|
||||
container = visibleLayers[i].getContainer(point)
|
||||
|
||||
if (container !== undefined) {
|
||||
let checkPoint = {
|
||||
x: point.x,
|
||||
y: point.y
|
||||
}
|
||||
|
||||
checkPoint = thisObject.fitFunction(checkPoint)
|
||||
|
||||
if (point.x === checkPoint.x && point.y === checkPoint.y) {
|
||||
if (purpose !== GET_CONTAINER_PURPOSE.MOUSE_OVER) {
|
||||
return container
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* The point does not belong to any inner container, so we return the current container. */
|
||||
let checkPoint = {
|
||||
x: point.x,
|
||||
y: point.y
|
||||
}
|
||||
|
||||
checkPoint = thisObject.fitFunction(checkPoint)
|
||||
|
||||
if (point.x === checkPoint.x && point.y === checkPoint.y) {
|
||||
return thisObject.container
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function turnOffUnusedLayers () {
|
||||
for (let i = 0; i < localLayers.length; i++) {
|
||||
let layer = localLayers[i]
|
||||
removeLayer(layer.nodeId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function draw () {
|
||||
if (isInitialized === false || thisObject.visible === false || thisObject.isHidden === true) { return }
|
||||
|
||||
// thisObject.container.frame.draw(false, false, false, thisObject.fitFunction)
|
||||
|
||||
drawHeader()
|
||||
for (let i = 0; i < visibleLayers.length; i++) {
|
||||
visibleLayers[i].draw()
|
||||
}
|
||||
drawScrollBar()
|
||||
if (isMouseOver === true) {
|
||||
thisObject.upDownButton.draw()
|
||||
thisObject.leftRightButton.draw()
|
||||
}
|
||||
}
|
||||
|
||||
function drawHeader () {
|
||||
if (thisObject.payload === undefined) { return }
|
||||
if (thisObject.payload.node === undefined) { return }
|
||||
if (thisObject.payload.node.payload.parentNode === undefined) { return }
|
||||
if (thisObject.payload.node.payload.parentNode.payload.parentNode === undefined) { return }
|
||||
|
||||
let label1 = thisObject.payload.node.payload.parentNode.payload.parentNode.name.substring(0, 18)
|
||||
let label2 = thisObject.payload.node.payload.parentNode.name.substring(0, 18)
|
||||
let label3 = ''
|
||||
|
||||
let icon1 = canvas.designSpace.iconByUiObjectType.get(thisObject.payload.node.payload.parentNode.payload.parentNode.type)
|
||||
let icon2 = canvas.designSpace.iconByUiObjectType.get(thisObject.payload.node.payload.parentNode.type)
|
||||
|
||||
let backgroundColor = UI_COLOR.BLACK
|
||||
|
||||
let params = {
|
||||
cornerRadius: 5,
|
||||
lineWidth: 1,
|
||||
container: thisObject.container,
|
||||
borderColor: UI_COLOR.RUSTED_RED,
|
||||
castShadow: false,
|
||||
backgroundColor: backgroundColor,
|
||||
opacity: 1
|
||||
function childrenPhysics() {
|
||||
for (let i = 0; i < thisObject.layers.length; i++) {
|
||||
let layer = thisObject.layers[i]
|
||||
layer.physics()
|
||||
}
|
||||
}
|
||||
|
||||
roundedCornersBackground(params)
|
||||
|
||||
drawLabel(label1, 1 / 2, 0, 0, 15, 9, thisObject.container)
|
||||
drawLabel(label2, 1 / 2, 0, 0, 30, 9, thisObject.container)
|
||||
|
||||
drawIcon(icon1, 1 / 8, 0, 0, 20, 28, thisObject.container)
|
||||
drawIcon(icon2, 7 / 8, 0, 0, 20, 28, thisObject.container)
|
||||
}
|
||||
|
||||
function drawScrollBar () {
|
||||
if (thisObject.layers.length > posibleVisibleLayers && posibleVisibleLayers > 0) {
|
||||
let xOffset = 4
|
||||
let barTopPoint = {
|
||||
x: thisObject.container.frame.width - xOffset,
|
||||
y: headerHeight
|
||||
}
|
||||
let barBottomPoint = {
|
||||
x: thisObject.container.frame.width - xOffset,
|
||||
y: thisObject.container.frame.height - footerHeight
|
||||
}
|
||||
let ratio = posibleVisibleLayers / thisObject.layers.length
|
||||
let handleHeight = (posibleVisibleLayers * (layerHeight + LAYER_SEPARATION)) * ratio
|
||||
let handleTopPoint = {
|
||||
x: thisObject.container.frame.width - xOffset,
|
||||
y: headerHeight + (layerHeight + LAYER_SEPARATION) * ratio * (firstVisibleLayer - 1)
|
||||
}
|
||||
let handleBottomPoint = {
|
||||
x: thisObject.container.frame.width - xOffset,
|
||||
y: handleTopPoint.y + handleHeight
|
||||
}
|
||||
barTopPoint = thisObject.container.frame.frameThisPoint(barTopPoint)
|
||||
barBottomPoint = thisObject.container.frame.frameThisPoint(barBottomPoint)
|
||||
handleTopPoint = thisObject.container.frame.frameThisPoint(handleTopPoint)
|
||||
handleBottomPoint = thisObject.container.frame.frameThisPoint(handleBottomPoint)
|
||||
|
||||
browserCanvasContext.beginPath()
|
||||
browserCanvasContext.moveTo(barTopPoint.x, barTopPoint.y)
|
||||
browserCanvasContext.lineTo(barBottomPoint.x, barBottomPoint.y)
|
||||
browserCanvasContext.closePath()
|
||||
browserCanvasContext.setLineDash([0, 0])
|
||||
browserCanvasContext.lineWidth = 1
|
||||
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.GREY + ', ' + 1 + ')'
|
||||
browserCanvasContext.stroke()
|
||||
|
||||
browserCanvasContext.beginPath()
|
||||
browserCanvasContext.moveTo(handleTopPoint.x, handleTopPoint.y)
|
||||
browserCanvasContext.lineTo(handleBottomPoint.x, handleBottomPoint.y)
|
||||
browserCanvasContext.closePath()
|
||||
browserCanvasContext.setLineDash([0, 0])
|
||||
browserCanvasContext.lineWidth = 4
|
||||
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.PATINATED_TURQUOISE + ', ' + 1 + ')'
|
||||
browserCanvasContext.stroke()
|
||||
function syncWithConfigPhysics() {
|
||||
readObjectState()
|
||||
}
|
||||
|
||||
function physics() {
|
||||
if (isInitialized === false) { return }
|
||||
if (thisObject.payload.node === undefined) { return }
|
||||
|
||||
thisObject.upDownButton.physics()
|
||||
thisObject.leftRightButton.physics()
|
||||
saveFrame(thisObject.payload, thisObject.container.frame)
|
||||
syncWithConfigPhysics()
|
||||
|
||||
/*
|
||||
The overall idea here is that we need to keep syncronized the panel with the layers that are
|
||||
defined at the Designer. Users can connect or disconnect any objext resulting in changes in which
|
||||
are valid layers and which not at any point in time. So what we do here is trying to keep the panel
|
||||
only with the layers that are connected to the Charting Space hiriarcy.
|
||||
|
||||
To achieve this, first we are going to move all session related cards to a local array. Then we are
|
||||
going to check for layers at the designer, and will move back the cards which still have layers well
|
||||
defined to where they were.
|
||||
|
||||
If we find new layers we will add them at that point. Finally, the cards that still remain at the
|
||||
local array after all the layers at the designer have been processed, are turned off and discarded.
|
||||
*/
|
||||
childrenPhysics()
|
||||
|
||||
let localLayers = []
|
||||
moveToLocalLayers()
|
||||
syncWithDesignerLayers()
|
||||
|
||||
/* At this poins all the cards still at the local array need to be removed from the panel. */
|
||||
turnOffUnusedLayers()
|
||||
calculateVisbleLayers()
|
||||
|
||||
function syncWithDesignerLayers() {
|
||||
if (thisObject.payload.node === undefined) { return }
|
||||
let layerManager = thisObject.payload.node
|
||||
for (let p = 0; p < layerManager.layers.length; p++) {
|
||||
let layerNode = layerManager.layers[p]
|
||||
|
||||
let found = removeFromLocalLayers(layerNode.id)
|
||||
if (found !== true) {
|
||||
layer = addLayer(layerNode)
|
||||
if (layer !== undefined) {
|
||||
onLayerStatusChanged(layer)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function moveToLocalLayers() {
|
||||
removeNext()
|
||||
|
||||
function removeNext() {
|
||||
for (let i = 0; i < thisObject.layers.length; i++) {
|
||||
let layer = thisObject.layers[i]
|
||||
|
||||
thisObject.layers.splice(i, 1)
|
||||
localLayers.push(layer)
|
||||
removeNext()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function removeFromLocalLayers(id) {
|
||||
for (let i = 0; i < localLayers.length; i++) {
|
||||
let layer = localLayers[i]
|
||||
if (layer.payload.node.id === id) {
|
||||
thisObject.layers.push(layer)
|
||||
localLayers.splice(i, 1)
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function turnOffUnusedLayers() {
|
||||
for (let i = 0; i < localLayers.length; i++) {
|
||||
let layer = localLayers[i]
|
||||
removeLayer(layer.nodeId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function draw() {
|
||||
if (isInitialized === false || thisObject.visible === false || thisObject.isHidden === true) { return }
|
||||
|
||||
// thisObject.container.frame.draw(false, false, false, thisObject.fitFunction)
|
||||
|
||||
drawHeader()
|
||||
for (let i = 0; i < visibleLayers.length; i++) {
|
||||
visibleLayers[i].draw()
|
||||
}
|
||||
drawScrollBar()
|
||||
if (isMouseOver === true) {
|
||||
thisObject.upDownButton.draw()
|
||||
thisObject.leftRightButton.draw()
|
||||
}
|
||||
}
|
||||
|
||||
function drawHeader() {
|
||||
if (thisObject.payload === undefined) { return }
|
||||
if (thisObject.payload.node === undefined) { return }
|
||||
if (thisObject.payload.node.payload.parentNode === undefined) { return }
|
||||
if (thisObject.payload.node.payload.parentNode.payload.parentNode === undefined) { return }
|
||||
|
||||
let label1 = thisObject.payload.node.payload.parentNode.payload.parentNode.name.substring(0, 18)
|
||||
let label2 = thisObject.payload.node.payload.parentNode.name.substring(0, 18)
|
||||
let label3 = ''
|
||||
|
||||
let icon1 = canvas.designSpace.iconByUiObjectType.get(thisObject.payload.node.payload.parentNode.payload.parentNode.type)
|
||||
let icon2 = canvas.designSpace.iconByUiObjectType.get(thisObject.payload.node.payload.parentNode.type)
|
||||
|
||||
let backgroundColor = UI_COLOR.BLACK
|
||||
|
||||
let params = {
|
||||
cornerRadius: 5,
|
||||
lineWidth: 1,
|
||||
container: thisObject.container,
|
||||
borderColor: UI_COLOR.RUSTED_RED,
|
||||
castShadow: false,
|
||||
backgroundColor: backgroundColor,
|
||||
opacity: 1
|
||||
}
|
||||
|
||||
roundedCornersBackground(params)
|
||||
|
||||
drawLabel(label1, 1 / 2, 0, 0, 15, 9, thisObject.container)
|
||||
drawLabel(label2, 1 / 2, 0, 0, 30, 9, thisObject.container)
|
||||
|
||||
drawIcon(icon1, 1 / 8, 0, 0, 20, 28, thisObject.container)
|
||||
drawIcon(icon2, 7 / 8, 0, 0, 20, 28, thisObject.container)
|
||||
}
|
||||
|
||||
function drawScrollBar() {
|
||||
if (thisObject.layers.length > posibleVisibleLayers && posibleVisibleLayers > 0) {
|
||||
let xOffset = 4
|
||||
let barTopPoint = {
|
||||
x: thisObject.container.frame.width - xOffset,
|
||||
y: headerHeight
|
||||
}
|
||||
let barBottomPoint = {
|
||||
x: thisObject.container.frame.width - xOffset,
|
||||
y: thisObject.container.frame.height - footerHeight
|
||||
}
|
||||
let ratio = posibleVisibleLayers / thisObject.layers.length
|
||||
let handleHeight = (posibleVisibleLayers * (layerHeight + LAYER_SEPARATION)) * ratio
|
||||
let handleTopPoint = {
|
||||
x: thisObject.container.frame.width - xOffset,
|
||||
y: headerHeight + (layerHeight + LAYER_SEPARATION) * ratio * (firstVisibleLayer - 1)
|
||||
}
|
||||
let handleBottomPoint = {
|
||||
x: thisObject.container.frame.width - xOffset,
|
||||
y: handleTopPoint.y + handleHeight
|
||||
}
|
||||
barTopPoint = thisObject.container.frame.frameThisPoint(barTopPoint)
|
||||
barBottomPoint = thisObject.container.frame.frameThisPoint(barBottomPoint)
|
||||
handleTopPoint = thisObject.container.frame.frameThisPoint(handleTopPoint)
|
||||
handleBottomPoint = thisObject.container.frame.frameThisPoint(handleBottomPoint)
|
||||
|
||||
browserCanvasContext.beginPath()
|
||||
browserCanvasContext.moveTo(barTopPoint.x, barTopPoint.y)
|
||||
browserCanvasContext.lineTo(barBottomPoint.x, barBottomPoint.y)
|
||||
browserCanvasContext.closePath()
|
||||
browserCanvasContext.setLineDash([0, 0])
|
||||
browserCanvasContext.lineWidth = 1
|
||||
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.GREY + ', ' + 1 + ')'
|
||||
browserCanvasContext.stroke()
|
||||
|
||||
browserCanvasContext.beginPath()
|
||||
browserCanvasContext.moveTo(handleTopPoint.x, handleTopPoint.y)
|
||||
browserCanvasContext.lineTo(handleBottomPoint.x, handleBottomPoint.y)
|
||||
browserCanvasContext.closePath()
|
||||
browserCanvasContext.setLineDash([0, 0])
|
||||
browserCanvasContext.lineWidth = 4
|
||||
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.PATINATED_TURQUOISE + ', ' + 1 + ')'
|
||||
browserCanvasContext.stroke()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+212
-212
@@ -1,244 +1,244 @@
|
||||
function newLeftRightButton () {
|
||||
let thisObject = {
|
||||
container: undefined,
|
||||
fitFunction: undefined,
|
||||
parentContainer: undefined,
|
||||
status: undefined,
|
||||
setStatus: setStatus,
|
||||
physics: physics,
|
||||
draw: draw,
|
||||
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
}
|
||||
|
||||
let isInitialized = false
|
||||
/* Cointainer stuff */
|
||||
|
||||
thisObject.container = newContainer()
|
||||
thisObject.container.name = 'Left Right Button'
|
||||
thisObject.container.initialize()
|
||||
thisObject.container.isClickeable = true
|
||||
thisObject.container.isDraggeable = false
|
||||
thisObject.container.frame.containerName = 'Left Right Button'
|
||||
|
||||
thisObject.status = 'left'
|
||||
let leftPosition = {}
|
||||
let rightPosition = {}
|
||||
let transitionPosition = {}
|
||||
|
||||
let onMouseClickEventSuscriptionId
|
||||
return thisObject
|
||||
|
||||
function finalize () {
|
||||
thisObject.container.eventHandler.stopListening(onMouseClickEventSuscriptionId)
|
||||
thisObject.container.finalize()
|
||||
thisObject.container = undefined
|
||||
thisObject.fitFunction = undefined
|
||||
thisObject.parentContainer = undefined
|
||||
|
||||
thisObject.status = undefined
|
||||
leftPosition = undefined
|
||||
rightPosition = undefined
|
||||
transitionPosition = undefined
|
||||
}
|
||||
|
||||
function initialize () {
|
||||
thisObject.container.frame.width = 12
|
||||
thisObject.container.frame.height = 12
|
||||
|
||||
let position = {
|
||||
x: thisObject.container.frame.parentFrame.width * 2.25 / 8 - thisObject.container.frame.width / 2,
|
||||
y: 40 * 4 / 8 - thisObject.container.frame.height / 2
|
||||
function newLeftRightButton() {
|
||||
let thisObject = {
|
||||
container: undefined,
|
||||
fitFunction: undefined,
|
||||
parentContainer: undefined,
|
||||
status: undefined,
|
||||
setStatus: setStatus,
|
||||
physics: physics,
|
||||
draw: draw,
|
||||
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
}
|
||||
|
||||
thisObject.container.frame.position = position
|
||||
let isInitialized = false
|
||||
/* Cointainer stuff */
|
||||
|
||||
leftPosition.x = thisObject.parentContainer.frame.position.x
|
||||
leftPosition.y = thisObject.parentContainer.frame.position.y
|
||||
thisObject.container = newContainer()
|
||||
thisObject.container.name = 'Left Right Button'
|
||||
thisObject.container.initialize()
|
||||
thisObject.container.isClickeable = true
|
||||
thisObject.container.isDraggeable = false
|
||||
thisObject.container.frame.containerName = 'Left Right Button'
|
||||
|
||||
rightPosition.x = thisObject.parentContainer.frame.position.x
|
||||
rightPosition.y = canvas.chartingSpace.viewport.visibleArea.bottomRight.y
|
||||
thisObject.status = 'left'
|
||||
let leftPosition = {}
|
||||
let rightPosition = {}
|
||||
let transitionPosition = {}
|
||||
|
||||
transitionPosition.x = leftPosition.x
|
||||
transitionPosition.y = leftPosition.y
|
||||
let onMouseClickEventSuscriptionId
|
||||
return thisObject
|
||||
|
||||
/* Lets listen to our own events to react when we have a Mouse Click */
|
||||
onMouseClickEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick)
|
||||
function finalize() {
|
||||
thisObject.container.eventHandler.stopListening(onMouseClickEventSuscriptionId)
|
||||
thisObject.container.finalize()
|
||||
thisObject.container = undefined
|
||||
thisObject.fitFunction = undefined
|
||||
thisObject.parentContainer = undefined
|
||||
|
||||
isInitialized = true
|
||||
}
|
||||
|
||||
function setStatus (value) {
|
||||
if (value === 'left' && thisObject.status === 'right') {
|
||||
thisObject.status = 'going left'
|
||||
thisObject.status = undefined
|
||||
leftPosition = undefined
|
||||
rightPosition = undefined
|
||||
transitionPosition = undefined
|
||||
}
|
||||
if (value === 'right' && thisObject.status === 'left') {
|
||||
thisObject.status = 'going right'
|
||||
|
||||
function initialize() {
|
||||
thisObject.container.frame.width = 12
|
||||
thisObject.container.frame.height = 12
|
||||
|
||||
let position = {
|
||||
x: thisObject.container.frame.parentFrame.width * 2.25 / 8 - thisObject.container.frame.width / 2,
|
||||
y: 40 * 4 / 8 - thisObject.container.frame.height / 2
|
||||
}
|
||||
|
||||
thisObject.container.frame.position = position
|
||||
|
||||
leftPosition.x = thisObject.parentContainer.frame.position.x
|
||||
leftPosition.y = thisObject.parentContainer.frame.position.y
|
||||
|
||||
rightPosition.x = thisObject.parentContainer.frame.position.x
|
||||
rightPosition.y = canvas.chartingSpace.viewport.visibleArea.bottomRight.y
|
||||
|
||||
transitionPosition.x = leftPosition.x
|
||||
transitionPosition.y = leftPosition.y
|
||||
|
||||
/* Lets listen to our own events to react when we have a Mouse Click */
|
||||
onMouseClickEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick)
|
||||
|
||||
isInitialized = true
|
||||
}
|
||||
}
|
||||
|
||||
function onMouseClick (event) {
|
||||
if (thisObject.status === 'left') {
|
||||
transitionPosition.x = leftPosition.x
|
||||
transitionPosition.y = leftPosition.y
|
||||
|
||||
thisObject.status = 'going right'
|
||||
} else {
|
||||
transitionPosition.x = rightPosition.x
|
||||
transitionPosition.y = rightPosition.y
|
||||
|
||||
thisObject.status = 'going left'
|
||||
function setStatus(value) {
|
||||
if (value === 'left' && thisObject.status === 'right') {
|
||||
thisObject.status = 'going left'
|
||||
}
|
||||
if (value === 'right' && thisObject.status === 'left') {
|
||||
thisObject.status = 'going right'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function physics () {
|
||||
if (isInitialized === false) { return }
|
||||
function onMouseClick(event) {
|
||||
if (thisObject.status === 'left') {
|
||||
transitionPosition.x = leftPosition.x
|
||||
transitionPosition.y = leftPosition.y
|
||||
|
||||
leftPosition.x = canvas.chartingSpace.viewport.visibleArea.topLeft.x
|
||||
leftPosition.y = thisObject.parentContainer.frame.position.y
|
||||
thisObject.status = 'going right'
|
||||
} else {
|
||||
transitionPosition.x = rightPosition.x
|
||||
transitionPosition.y = rightPosition.y
|
||||
|
||||
rightPosition.x = canvas.chartingSpace.viewport.visibleArea.bottomRight.x
|
||||
rightPosition.y = thisObject.parentContainer.frame.position.y
|
||||
|
||||
if (thisObject.status === 'going right') {
|
||||
if (transitionPosition.x < rightPosition.x) {
|
||||
transitionPosition.x = transitionPosition.x + 50
|
||||
thisObject.parentContainer.frame.position.x = transitionPosition.x
|
||||
} else {
|
||||
thisObject.parentContainer.frame.position.x = rightPosition.x
|
||||
thisObject.status = 'right'
|
||||
}
|
||||
thisObject.status = 'going left'
|
||||
}
|
||||
}
|
||||
if (thisObject.status === 'going left') {
|
||||
if (transitionPosition.x > leftPosition.x) {
|
||||
transitionPosition.x = transitionPosition.x - 50
|
||||
thisObject.parentContainer.frame.position.x = transitionPosition.x
|
||||
} else {
|
||||
thisObject.parentContainer.frame.position.x = leftPosition.x
|
||||
thisObject.status = 'left'
|
||||
}
|
||||
|
||||
function physics() {
|
||||
if (isInitialized === false) { return }
|
||||
|
||||
leftPosition.x = canvas.chartingSpace.viewport.visibleArea.topLeft.x
|
||||
leftPosition.y = thisObject.parentContainer.frame.position.y
|
||||
|
||||
rightPosition.x = canvas.chartingSpace.viewport.visibleArea.bottomRight.x
|
||||
rightPosition.y = thisObject.parentContainer.frame.position.y
|
||||
|
||||
if (thisObject.status === 'going right') {
|
||||
if (transitionPosition.x < rightPosition.x) {
|
||||
transitionPosition.x = transitionPosition.x + 50
|
||||
thisObject.parentContainer.frame.position.x = transitionPosition.x
|
||||
} else {
|
||||
thisObject.parentContainer.frame.position.x = rightPosition.x
|
||||
thisObject.status = 'right'
|
||||
}
|
||||
}
|
||||
if (thisObject.status === 'going left') {
|
||||
if (transitionPosition.x > leftPosition.x) {
|
||||
transitionPosition.x = transitionPosition.x - 50
|
||||
thisObject.parentContainer.frame.position.x = transitionPosition.x
|
||||
} else {
|
||||
thisObject.parentContainer.frame.position.x = leftPosition.x
|
||||
thisObject.status = 'left'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function draw () {
|
||||
if (isInitialized === false) { return }
|
||||
function draw() {
|
||||
if (isInitialized === false) { return }
|
||||
|
||||
drawButton()
|
||||
}
|
||||
|
||||
function getContainer (point, purpose) {
|
||||
let container
|
||||
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
||||
return thisObject.container
|
||||
drawButton()
|
||||
}
|
||||
}
|
||||
|
||||
function drawButton () {
|
||||
let point1
|
||||
let point2
|
||||
let point3
|
||||
|
||||
switch (thisObject.status) {
|
||||
case 'left': {
|
||||
point1 = {
|
||||
x: 3,
|
||||
y: 3
|
||||
function getContainer(point, purpose) {
|
||||
let container
|
||||
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
||||
return thisObject.container
|
||||
}
|
||||
|
||||
point2 = {
|
||||
x: 3,
|
||||
y: thisObject.container.frame.height - 3
|
||||
}
|
||||
|
||||
point3 = {
|
||||
x: thisObject.container.frame.width - 3,
|
||||
y: thisObject.container.frame.height / 2
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
case 'going right': {
|
||||
point1 = {
|
||||
x: 4,
|
||||
y: 4
|
||||
}
|
||||
|
||||
point2 = {
|
||||
x: 4,
|
||||
y: thisObject.container.frame.height - 4
|
||||
}
|
||||
|
||||
point3 = {
|
||||
x: thisObject.container.frame.width - 4,
|
||||
y: thisObject.container.frame.height / 2
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
case 'going left': {
|
||||
point1 = {
|
||||
x: thisObject.container.frame.width - 4,
|
||||
y: 4
|
||||
}
|
||||
|
||||
point2 = {
|
||||
x: thisObject.container.frame.width - 4,
|
||||
y: thisObject.container.frame.height - 4
|
||||
}
|
||||
|
||||
point3 = {
|
||||
x: 4,
|
||||
y: thisObject.container.frame.height / 2
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
case 'right': {
|
||||
point1 = {
|
||||
x: thisObject.container.frame.width - 3,
|
||||
y: 3
|
||||
}
|
||||
|
||||
point2 = {
|
||||
x: thisObject.container.frame.width - 3,
|
||||
y: thisObject.container.frame.height - 3
|
||||
}
|
||||
|
||||
point3 = {
|
||||
x: 3,
|
||||
y: thisObject.container.frame.height / 2
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
function drawButton() {
|
||||
let point1
|
||||
let point2
|
||||
let point3
|
||||
|
||||
switch (thisObject.status) {
|
||||
case 'left': {
|
||||
point1 = {
|
||||
x: 3,
|
||||
y: 3
|
||||
}
|
||||
|
||||
point2 = {
|
||||
x: 3,
|
||||
y: thisObject.container.frame.height - 3
|
||||
}
|
||||
|
||||
point3 = {
|
||||
x: thisObject.container.frame.width - 3,
|
||||
y: thisObject.container.frame.height / 2
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
case 'going right': {
|
||||
point1 = {
|
||||
x: 4,
|
||||
y: 4
|
||||
}
|
||||
|
||||
point2 = {
|
||||
x: 4,
|
||||
y: thisObject.container.frame.height - 4
|
||||
}
|
||||
|
||||
point3 = {
|
||||
x: thisObject.container.frame.width - 4,
|
||||
y: thisObject.container.frame.height / 2
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
case 'going left': {
|
||||
point1 = {
|
||||
x: thisObject.container.frame.width - 4,
|
||||
y: 4
|
||||
}
|
||||
|
||||
point2 = {
|
||||
x: thisObject.container.frame.width - 4,
|
||||
y: thisObject.container.frame.height - 4
|
||||
}
|
||||
|
||||
point3 = {
|
||||
x: 4,
|
||||
y: thisObject.container.frame.height / 2
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
case 'right': {
|
||||
point1 = {
|
||||
x: thisObject.container.frame.width - 3,
|
||||
y: 3
|
||||
}
|
||||
|
||||
point2 = {
|
||||
x: thisObject.container.frame.width - 3,
|
||||
y: thisObject.container.frame.height - 3
|
||||
}
|
||||
|
||||
point3 = {
|
||||
x: 3,
|
||||
y: thisObject.container.frame.height / 2
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
/* Now the transformations. */
|
||||
|
||||
point1 = thisObject.container.frame.frameThisPoint(point1)
|
||||
point2 = thisObject.container.frame.frameThisPoint(point2)
|
||||
point3 = thisObject.container.frame.frameThisPoint(point3)
|
||||
point1 = thisObject.container.frame.frameThisPoint(point1)
|
||||
point2 = thisObject.container.frame.frameThisPoint(point2)
|
||||
point3 = thisObject.container.frame.frameThisPoint(point3)
|
||||
|
||||
if (thisObject.fitFunction !== undefined) {
|
||||
point1 = thisObject.fitFunction(point1)
|
||||
point2 = thisObject.fitFunction(point2)
|
||||
point3 = thisObject.fitFunction(point3)
|
||||
}
|
||||
if (thisObject.fitFunction !== undefined) {
|
||||
point1 = thisObject.fitFunction(point1)
|
||||
point2 = thisObject.fitFunction(point2)
|
||||
point3 = thisObject.fitFunction(point3)
|
||||
}
|
||||
|
||||
/* Lets start the drawing. */
|
||||
|
||||
browserCanvasContext.beginPath()
|
||||
browserCanvasContext.moveTo(point1.x, point1.y)
|
||||
browserCanvasContext.lineTo(point2.x, point2.y)
|
||||
browserCanvasContext.lineTo(point3.x, point3.y)
|
||||
browserCanvasContext.lineTo(point1.x, point1.y)
|
||||
browserCanvasContext.closePath()
|
||||
browserCanvasContext.beginPath()
|
||||
browserCanvasContext.moveTo(point1.x, point1.y)
|
||||
browserCanvasContext.lineTo(point2.x, point2.y)
|
||||
browserCanvasContext.lineTo(point3.x, point3.y)
|
||||
browserCanvasContext.lineTo(point1.x, point1.y)
|
||||
browserCanvasContext.closePath()
|
||||
|
||||
browserCanvasContext.strokeStyle = 'rgba(250, 250, 250, 1)'
|
||||
browserCanvasContext.lineWidth = 1
|
||||
browserCanvasContext.stroke()
|
||||
browserCanvasContext.strokeStyle = 'rgba(250, 250, 250, 1)'
|
||||
browserCanvasContext.lineWidth = 1
|
||||
browserCanvasContext.stroke()
|
||||
|
||||
browserCanvasContext.fillStyle = 'rgba(250, 250, 250, 1)'
|
||||
browserCanvasContext.fill()
|
||||
}
|
||||
browserCanvasContext.fillStyle = 'rgba(250, 250, 250, 1)'
|
||||
browserCanvasContext.fill()
|
||||
}
|
||||
}
|
||||
@@ -1,84 +1,84 @@
|
||||
function newPanelsVisibleButton () {
|
||||
let thisObject = {
|
||||
container: undefined,
|
||||
fitFunction: undefined,
|
||||
parentContainer: undefined,
|
||||
panels: undefined,
|
||||
showPanels: true,
|
||||
draw: draw,
|
||||
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
}
|
||||
|
||||
/* Cointainer stuff */
|
||||
thisObject.container = newContainer()
|
||||
thisObject.container.name = 'Panels Visible Button'
|
||||
thisObject.container.initialize()
|
||||
thisObject.container.isClickeable = true
|
||||
thisObject.container.isDraggeable = false
|
||||
thisObject.container.frame.containerName = 'Panels Visible Button'
|
||||
|
||||
let onMouseClickEventSuscriptionId
|
||||
return thisObject
|
||||
|
||||
function finalize () {
|
||||
thisObject.container.eventHandler.stopListening(onMouseClickEventSuscriptionId)
|
||||
thisObject.container.finalize()
|
||||
thisObject.container = undefined
|
||||
thisObject.fitFunction = undefined
|
||||
thisObject.parentContainer = undefined
|
||||
thisObject.panels = undefined
|
||||
}
|
||||
|
||||
function initialize (panels) {
|
||||
thisObject.panels = panels
|
||||
setPanelVisibility()
|
||||
|
||||
thisObject.container.frame.width = 25
|
||||
thisObject.container.frame.height = 25
|
||||
|
||||
let position = {
|
||||
x: thisObject.container.frame.width * 1 / 8,
|
||||
y: 45
|
||||
function newPanelsVisibleButton() {
|
||||
let thisObject = {
|
||||
container: undefined,
|
||||
fitFunction: undefined,
|
||||
parentContainer: undefined,
|
||||
panels: undefined,
|
||||
showPanels: true,
|
||||
draw: draw,
|
||||
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
}
|
||||
|
||||
thisObject.container.frame.position = position
|
||||
/* Cointainer stuff */
|
||||
thisObject.container = newContainer()
|
||||
thisObject.container.name = 'Panels Visible Button'
|
||||
thisObject.container.initialize()
|
||||
thisObject.container.isClickeable = true
|
||||
thisObject.container.isDraggeable = false
|
||||
thisObject.container.frame.containerName = 'Panels Visible Button'
|
||||
|
||||
/* Lets listen to our own events to react when we have a Mouse Click */
|
||||
onMouseClickEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick)
|
||||
}
|
||||
let onMouseClickEventSuscriptionId
|
||||
return thisObject
|
||||
|
||||
function onMouseClick (event) {
|
||||
if (thisObject.showPanels === false) {
|
||||
thisObject.showPanels = true
|
||||
} else {
|
||||
thisObject.showPanels = false
|
||||
}
|
||||
setPanelVisibility()
|
||||
}
|
||||
|
||||
function setPanelVisibility () {
|
||||
for (let i = 0; i < thisObject.panels.length; i++) {
|
||||
panel = canvas.panelsSpace.getPanel(thisObject.panels[i])
|
||||
panel.isVisible = thisObject.showPanels
|
||||
}
|
||||
}
|
||||
|
||||
function getContainer (point) {
|
||||
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
||||
return thisObject.container
|
||||
}
|
||||
}
|
||||
|
||||
function draw () {
|
||||
let icon
|
||||
if (thisObject.showPanels === true) {
|
||||
icon = canvas.designSpace.iconCollection.get('plotter-panel')
|
||||
} else {
|
||||
icon = canvas.designSpace.iconCollection.get('toggle-panel-off')
|
||||
function finalize() {
|
||||
thisObject.container.eventHandler.stopListening(onMouseClickEventSuscriptionId)
|
||||
thisObject.container.finalize()
|
||||
thisObject.container = undefined
|
||||
thisObject.fitFunction = undefined
|
||||
thisObject.parentContainer = undefined
|
||||
thisObject.panels = undefined
|
||||
}
|
||||
|
||||
drawIcon(icon, 1 / 2, 1 / 2, 0, 0, 14, thisObject.container)
|
||||
}
|
||||
function initialize(panels) {
|
||||
thisObject.panels = panels
|
||||
setPanelVisibility()
|
||||
|
||||
thisObject.container.frame.width = 25
|
||||
thisObject.container.frame.height = 25
|
||||
|
||||
let position = {
|
||||
x: thisObject.container.frame.width * 1 / 8,
|
||||
y: 45
|
||||
}
|
||||
|
||||
thisObject.container.frame.position = position
|
||||
|
||||
/* Lets listen to our own events to react when we have a Mouse Click */
|
||||
onMouseClickEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick)
|
||||
}
|
||||
|
||||
function onMouseClick(event) {
|
||||
if (thisObject.showPanels === false) {
|
||||
thisObject.showPanels = true
|
||||
} else {
|
||||
thisObject.showPanels = false
|
||||
}
|
||||
setPanelVisibility()
|
||||
}
|
||||
|
||||
function setPanelVisibility() {
|
||||
for (let i = 0; i < thisObject.panels.length; i++) {
|
||||
panel = canvas.panelsSpace.getPanel(thisObject.panels[i])
|
||||
panel.isVisible = thisObject.showPanels
|
||||
}
|
||||
}
|
||||
|
||||
function getContainer(point) {
|
||||
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
||||
return thisObject.container
|
||||
}
|
||||
}
|
||||
|
||||
function draw() {
|
||||
let icon
|
||||
if (thisObject.showPanels === true) {
|
||||
icon = canvas.designSpace.iconCollection.get('plotter-panel')
|
||||
} else {
|
||||
icon = canvas.designSpace.iconCollection.get('toggle-panel-off')
|
||||
}
|
||||
|
||||
drawIcon(icon, 1 / 2, 1 / 2, 0, 0, 14, thisObject.container)
|
||||
}
|
||||
}
|
||||
+161
-161
@@ -1,174 +1,174 @@
|
||||
|
||||
function newPlotterPanel () {
|
||||
const MODULE_NAME = 'Plotter Panel'
|
||||
const ERROR_LOG = true
|
||||
const INTENSIVE_LOG = false
|
||||
const logger = newWebDebugLog()
|
||||
logger.fileName = MODULE_NAME
|
||||
function newPlotterPanel() {
|
||||
const MODULE_NAME = 'Plotter Panel'
|
||||
const ERROR_LOG = true
|
||||
const INTENSIVE_LOG = false
|
||||
const logger = newWebDebugLog()
|
||||
logger.fileName = MODULE_NAME
|
||||
|
||||
let thisObject = {
|
||||
fitFunction: undefined,
|
||||
container: undefined,
|
||||
isVisible: true,
|
||||
onRecordChange: onRecordChange,
|
||||
draw: draw,
|
||||
getContainer: getContainer,
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
}
|
||||
|
||||
thisObject.container = newContainer()
|
||||
thisObject.container.initialize('Plotter Panel')
|
||||
|
||||
let heightFactor = 1
|
||||
let currentRecord
|
||||
let upDownButton
|
||||
let panelNode
|
||||
|
||||
return thisObject
|
||||
|
||||
function finalize () {
|
||||
thisObject.container.finalize()
|
||||
thisObject.container = undefined
|
||||
thisObject.fitFunction = undefined
|
||||
thisObject.isVisible = undefined
|
||||
|
||||
heightFactor = undefined
|
||||
currentRecord = undefined
|
||||
upDownButton.finalize()
|
||||
upDownButton = undefined
|
||||
panelNode = undefined
|
||||
}
|
||||
|
||||
function initialize (pPanelNode) {
|
||||
panelNode = pPanelNode
|
||||
thisObject.container.frame.containerName = panelNode.name
|
||||
|
||||
thisObject.container.frame.width = UI_PANEL.WIDTH.NORMAL
|
||||
thisObject.container.frame.height = UI_PANEL.HEIGHT.NORMAL
|
||||
|
||||
thisObject.container.frame.position.x = canvas.chartingSpace.viewport.visibleArea.topRight.x - thisObject.container.frame.width - thisObject.container.frame.width * Math.random() * 8
|
||||
thisObject.container.frame.position.y = canvas.chartingSpace.viewport.visibleArea.bottomLeft.y - thisObject.container.frame.height - thisObject.container.frame.height * Math.random() * 1.5
|
||||
|
||||
upDownButton = newUpDownButton()
|
||||
upDownButton.parentContainer = thisObject.container
|
||||
upDownButton.container.frame.parentFrame = thisObject.container.frame
|
||||
upDownButton.fitFunction = thisObject.fitFunction
|
||||
upDownButton.initialize()
|
||||
}
|
||||
|
||||
function getContainer (point) {
|
||||
if (thisObject.isVisible !== true) { return }
|
||||
let container
|
||||
|
||||
container = upDownButton.getContainer(point)
|
||||
if (container !== undefined) { return container }
|
||||
|
||||
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
||||
let checkPoint = {
|
||||
x: point.x,
|
||||
y: point.y
|
||||
}
|
||||
|
||||
checkPoint = thisObject.fitFunction(checkPoint)
|
||||
|
||||
if (point.x === checkPoint.x && point.y === checkPoint.y) {
|
||||
return thisObject.container
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onRecordChange (pCurrentRecord) {
|
||||
currentRecord = pCurrentRecord
|
||||
}
|
||||
|
||||
function draw () {
|
||||
if (thisObject.isVisible !== true) { return }
|
||||
|
||||
thisObject.container.frame.draw(false, false, true, thisObject.fitFunction)
|
||||
plotCurrentRecordData()
|
||||
upDownButton.draw()
|
||||
}
|
||||
|
||||
function plotCurrentRecordData () {
|
||||
const frameBodyHeight = thisObject.container.frame.getBodyHeight()
|
||||
const frameTitleHeight = thisObject.container.frame.height - frameBodyHeight
|
||||
|
||||
const X_AXIS = thisObject.container.frame.width / 2
|
||||
const Y_AXIS = frameTitleHeight + frameBodyHeight / 2
|
||||
|
||||
const PANEL_HEIGHT = UI_PANEL.HEIGHT.NORMAL
|
||||
|
||||
if (currentRecord === undefined) { return }
|
||||
let record = currentRecord
|
||||
|
||||
/* First we execute code if provided. */
|
||||
if (panelNode.javascriptCode !== undefined) {
|
||||
try {
|
||||
eval(panelNode.javascriptCode.code)
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] plotCurrentRecordData -> err = ' + err.stack) }
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] plotCurrentRecordData -> javascriptCode.code = ' + panelNode.javascriptCode.code) }
|
||||
}
|
||||
let thisObject = {
|
||||
fitFunction: undefined,
|
||||
container: undefined,
|
||||
isVisible: true,
|
||||
onRecordChange: onRecordChange,
|
||||
draw: draw,
|
||||
getContainer: getContainer,
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
}
|
||||
|
||||
/* 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]
|
||||
thisObject.container = newContainer()
|
||||
thisObject.container.initialize('Plotter Panel')
|
||||
|
||||
let labelText = panelData.name
|
||||
let labelPosition = i * 10 + 12
|
||||
let valuePosition = i * 10 + 17
|
||||
let value = 'No value defined.'
|
||||
let heightFactor = 1
|
||||
let currentRecord
|
||||
let upDownButton
|
||||
let panelNode
|
||||
|
||||
if (valuePosition > 100) {
|
||||
thisObject.container.frame.height = UI_PANEL.HEIGHT.NORMAL * 1.25
|
||||
}
|
||||
return thisObject
|
||||
|
||||
if (valuePosition > 125) {
|
||||
thisObject.container.frame.height = UI_PANEL.HEIGHT.NORMAL * 1.50
|
||||
}
|
||||
function finalize() {
|
||||
thisObject.container.finalize()
|
||||
thisObject.container = undefined
|
||||
thisObject.fitFunction = undefined
|
||||
thisObject.isVisible = undefined
|
||||
|
||||
if (valuePosition > 150) {
|
||||
thisObject.container.frame.height = UI_PANEL.HEIGHT.NORMAL * 1.75
|
||||
}
|
||||
heightFactor = undefined
|
||||
currentRecord = undefined
|
||||
upDownButton.finalize()
|
||||
upDownButton = undefined
|
||||
panelNode = undefined
|
||||
}
|
||||
|
||||
if (valuePosition > 175) {
|
||||
thisObject.container.frame.height = UI_PANEL.HEIGHT.NORMAL * 2.00
|
||||
}
|
||||
function initialize(pPanelNode) {
|
||||
panelNode = pPanelNode
|
||||
thisObject.container.frame.containerName = panelNode.name
|
||||
|
||||
if (panelData.dataFormula !== undefined) {
|
||||
try {
|
||||
value = eval(panelData.dataFormula.code)
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] plotCurrentRecordData -> err = ' + err.stack) }
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] plotCurrentRecordData -> dataFormula.code = ' + panelData.dataFormula.code) }
|
||||
thisObject.container.frame.width = UI_PANEL.WIDTH.NORMAL
|
||||
thisObject.container.frame.height = UI_PANEL.HEIGHT.NORMAL
|
||||
|
||||
thisObject.container.frame.position.x = canvas.chartingSpace.viewport.visibleArea.topRight.x - thisObject.container.frame.width - thisObject.container.frame.width * Math.random() * 8
|
||||
thisObject.container.frame.position.y = canvas.chartingSpace.viewport.visibleArea.bottomLeft.y - thisObject.container.frame.height - thisObject.container.frame.height * Math.random() * 1.5
|
||||
|
||||
upDownButton = newUpDownButton()
|
||||
upDownButton.parentContainer = thisObject.container
|
||||
upDownButton.container.frame.parentFrame = thisObject.container.frame
|
||||
upDownButton.fitFunction = thisObject.fitFunction
|
||||
upDownButton.initialize()
|
||||
}
|
||||
|
||||
function getContainer(point) {
|
||||
if (thisObject.isVisible !== true) { return }
|
||||
let container
|
||||
|
||||
container = upDownButton.getContainer(point)
|
||||
if (container !== undefined) { return container }
|
||||
|
||||
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
||||
let checkPoint = {
|
||||
x: point.x,
|
||||
y: point.y
|
||||
}
|
||||
|
||||
checkPoint = thisObject.fitFunction(checkPoint)
|
||||
|
||||
if (point.x === checkPoint.x && point.y === checkPoint.y) {
|
||||
return thisObject.container
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onRecordChange(pCurrentRecord) {
|
||||
currentRecord = pCurrentRecord
|
||||
}
|
||||
|
||||
function draw() {
|
||||
if (thisObject.isVisible !== true) { return }
|
||||
|
||||
thisObject.container.frame.draw(false, false, true, thisObject.fitFunction)
|
||||
plotCurrentRecordData()
|
||||
upDownButton.draw()
|
||||
}
|
||||
|
||||
function plotCurrentRecordData() {
|
||||
const frameBodyHeight = thisObject.container.frame.getBodyHeight()
|
||||
const frameTitleHeight = thisObject.container.frame.height - frameBodyHeight
|
||||
|
||||
const X_AXIS = thisObject.container.frame.width / 2
|
||||
const Y_AXIS = frameTitleHeight + frameBodyHeight / 2
|
||||
|
||||
const PANEL_HEIGHT = UI_PANEL.HEIGHT.NORMAL
|
||||
|
||||
if (currentRecord === undefined) { return }
|
||||
let record = currentRecord
|
||||
|
||||
/* First we execute code if provided. */
|
||||
if (panelNode.javascriptCode !== undefined) {
|
||||
try {
|
||||
eval(panelNode.javascriptCode.code)
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] plotCurrentRecordData -> err = ' + err.stack) }
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] plotCurrentRecordData -> javascriptCode.code = ' + panelNode.javascriptCode.code) }
|
||||
}
|
||||
}
|
||||
|
||||
/* 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 + 12
|
||||
let valuePosition = i * 10 + 17
|
||||
let value = 'No value defined.'
|
||||
|
||||
if (valuePosition > 100) {
|
||||
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) {
|
||||
try {
|
||||
value = eval(panelData.dataFormula.code)
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] plotCurrentRecordData -> err = ' + err.stack) }
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] plotCurrentRecordData -> dataFormula.code = ' + panelData.dataFormula.code) }
|
||||
}
|
||||
}
|
||||
|
||||
if (panelData.config.valueDecimals !== undefined) {
|
||||
if (value !== undefined) {
|
||||
if (isNaN(value) === false) {
|
||||
value = dynamicDecimals(value, panelData.config.valueDecimals)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (panelData.config.labelText !== undefined) {
|
||||
labelText = panelData.config.labelText
|
||||
}
|
||||
|
||||
if (panelData.config.labelPosition !== undefined) {
|
||||
labelPosition = panelData.config.labelPosition
|
||||
}
|
||||
|
||||
if (panelData.config.valuePosition !== undefined) {
|
||||
valuePosition = panelData.config.valuePosition
|
||||
}
|
||||
|
||||
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, false, true)
|
||||
}
|
||||
}
|
||||
|
||||
if (panelData.config.valueDecimals !== undefined) {
|
||||
if (value !== undefined) {
|
||||
if (isNaN(value) === false) {
|
||||
value = dynamicDecimals(value, panelData.config.valueDecimals)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (panelData.config.labelText !== undefined) {
|
||||
labelText = panelData.config.labelText
|
||||
}
|
||||
|
||||
if (panelData.config.labelPosition !== undefined) {
|
||||
labelPosition = panelData.config.labelPosition
|
||||
}
|
||||
|
||||
if (panelData.config.valuePosition !== undefined) {
|
||||
valuePosition = panelData.config.valuePosition
|
||||
}
|
||||
|
||||
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, false, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
+212
-212
@@ -1,244 +1,244 @@
|
||||
function newUpDownButton () {
|
||||
let thisObject = {
|
||||
container: undefined,
|
||||
fitFunction: undefined,
|
||||
parentContainer: undefined,
|
||||
status: undefined,
|
||||
setStatus: setStatus,
|
||||
physics: physics,
|
||||
draw: draw,
|
||||
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
}
|
||||
|
||||
let isInitialized = false
|
||||
/* Cointainer stuff */
|
||||
|
||||
thisObject.container = newContainer()
|
||||
thisObject.container.name = 'Up Down Button'
|
||||
thisObject.container.initialize()
|
||||
thisObject.container.isClickeable = true
|
||||
thisObject.container.isDraggeable = false
|
||||
thisObject.container.frame.containerName = 'Up Down Button'
|
||||
|
||||
thisObject.status = 'up'
|
||||
let upPosition = {}
|
||||
let downPosition = {}
|
||||
let transitionPosition = {}
|
||||
|
||||
let onMouseClickEventSuscriptionId
|
||||
return thisObject
|
||||
|
||||
function finalize () {
|
||||
thisObject.container.eventHandler.stopListening(onMouseClickEventSuscriptionId)
|
||||
thisObject.container.finalize()
|
||||
thisObject.container = undefined
|
||||
thisObject.fitFunction = undefined
|
||||
thisObject.parentContainer = undefined
|
||||
|
||||
thisObject.status = undefined
|
||||
upPosition = undefined
|
||||
downPosition = undefined
|
||||
transitionPosition = undefined
|
||||
}
|
||||
|
||||
function initialize () {
|
||||
thisObject.container.frame.width = 12
|
||||
thisObject.container.frame.height = 12
|
||||
|
||||
let position = {
|
||||
x: thisObject.container.frame.parentFrame.width * 5.75 / 8 - thisObject.container.frame.width / 2,
|
||||
y: 40 * 4 / 8 - thisObject.container.frame.height / 2
|
||||
function newUpDownButton() {
|
||||
let thisObject = {
|
||||
container: undefined,
|
||||
fitFunction: undefined,
|
||||
parentContainer: undefined,
|
||||
status: undefined,
|
||||
setStatus: setStatus,
|
||||
physics: physics,
|
||||
draw: draw,
|
||||
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
}
|
||||
|
||||
thisObject.container.frame.position = position
|
||||
let isInitialized = false
|
||||
/* Cointainer stuff */
|
||||
|
||||
upPosition.x = thisObject.parentContainer.frame.position.x
|
||||
upPosition.y = thisObject.parentContainer.frame.position.y
|
||||
thisObject.container = newContainer()
|
||||
thisObject.container.name = 'Up Down Button'
|
||||
thisObject.container.initialize()
|
||||
thisObject.container.isClickeable = true
|
||||
thisObject.container.isDraggeable = false
|
||||
thisObject.container.frame.containerName = 'Up Down Button'
|
||||
|
||||
downPosition.x = thisObject.parentContainer.frame.position.x
|
||||
downPosition.y = canvas.chartingSpace.viewport.visibleArea.bottomRight.y
|
||||
thisObject.status = 'up'
|
||||
let upPosition = {}
|
||||
let downPosition = {}
|
||||
let transitionPosition = {}
|
||||
|
||||
transitionPosition.x = upPosition.x
|
||||
transitionPosition.y = upPosition.y
|
||||
let onMouseClickEventSuscriptionId
|
||||
return thisObject
|
||||
|
||||
/* Lets listen to our own events to react when we have a Mouse Click */
|
||||
onMouseClickEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick)
|
||||
function finalize() {
|
||||
thisObject.container.eventHandler.stopListening(onMouseClickEventSuscriptionId)
|
||||
thisObject.container.finalize()
|
||||
thisObject.container = undefined
|
||||
thisObject.fitFunction = undefined
|
||||
thisObject.parentContainer = undefined
|
||||
|
||||
isInitialized = true
|
||||
}
|
||||
|
||||
function setStatus (value) {
|
||||
if (value === 'up' && thisObject.status === 'down') {
|
||||
thisObject.status = 'going up'
|
||||
thisObject.status = undefined
|
||||
upPosition = undefined
|
||||
downPosition = undefined
|
||||
transitionPosition = undefined
|
||||
}
|
||||
if (value === 'down' && thisObject.status === 'up') {
|
||||
thisObject.status = 'going down'
|
||||
|
||||
function initialize() {
|
||||
thisObject.container.frame.width = 12
|
||||
thisObject.container.frame.height = 12
|
||||
|
||||
let position = {
|
||||
x: thisObject.container.frame.parentFrame.width * 5.75 / 8 - thisObject.container.frame.width / 2,
|
||||
y: 40 * 4 / 8 - thisObject.container.frame.height / 2
|
||||
}
|
||||
|
||||
thisObject.container.frame.position = position
|
||||
|
||||
upPosition.x = thisObject.parentContainer.frame.position.x
|
||||
upPosition.y = thisObject.parentContainer.frame.position.y
|
||||
|
||||
downPosition.x = thisObject.parentContainer.frame.position.x
|
||||
downPosition.y = canvas.chartingSpace.viewport.visibleArea.bottomRight.y
|
||||
|
||||
transitionPosition.x = upPosition.x
|
||||
transitionPosition.y = upPosition.y
|
||||
|
||||
/* Lets listen to our own events to react when we have a Mouse Click */
|
||||
onMouseClickEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick)
|
||||
|
||||
isInitialized = true
|
||||
}
|
||||
}
|
||||
|
||||
function onMouseClick (event) {
|
||||
if (thisObject.status === 'up') {
|
||||
transitionPosition.x = upPosition.x
|
||||
transitionPosition.y = upPosition.y
|
||||
|
||||
thisObject.status = 'going down'
|
||||
} else {
|
||||
transitionPosition.x = downPosition.x
|
||||
transitionPosition.y = downPosition.y
|
||||
|
||||
thisObject.status = 'going up'
|
||||
function setStatus(value) {
|
||||
if (value === 'up' && thisObject.status === 'down') {
|
||||
thisObject.status = 'going up'
|
||||
}
|
||||
if (value === 'down' && thisObject.status === 'up') {
|
||||
thisObject.status = 'going down'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function physics () {
|
||||
if (isInitialized === false) { return }
|
||||
function onMouseClick(event) {
|
||||
if (thisObject.status === 'up') {
|
||||
transitionPosition.x = upPosition.x
|
||||
transitionPosition.y = upPosition.y
|
||||
|
||||
upPosition.x = thisObject.parentContainer.frame.position.x
|
||||
upPosition.y = canvas.chartingSpace.viewport.visibleArea.topRight.y
|
||||
thisObject.status = 'going down'
|
||||
} else {
|
||||
transitionPosition.x = downPosition.x
|
||||
transitionPosition.y = downPosition.y
|
||||
|
||||
downPosition.x = thisObject.parentContainer.frame.position.x
|
||||
downPosition.y = canvas.chartingSpace.viewport.visibleArea.bottomRight.y
|
||||
|
||||
if (thisObject.status === 'going down') {
|
||||
if (transitionPosition.y < downPosition.y) {
|
||||
transitionPosition.y = transitionPosition.y + 50
|
||||
thisObject.parentContainer.frame.position.y = transitionPosition.y
|
||||
} else {
|
||||
thisObject.parentContainer.frame.position.y = downPosition.y
|
||||
thisObject.status = 'down'
|
||||
}
|
||||
thisObject.status = 'going up'
|
||||
}
|
||||
}
|
||||
if (thisObject.status === 'going up') {
|
||||
if (transitionPosition.y > upPosition.y) {
|
||||
transitionPosition.y = transitionPosition.y - 50
|
||||
thisObject.parentContainer.frame.position.y = transitionPosition.y
|
||||
} else {
|
||||
thisObject.parentContainer.frame.position.y = upPosition.y
|
||||
thisObject.status = 'up'
|
||||
}
|
||||
|
||||
function physics() {
|
||||
if (isInitialized === false) { return }
|
||||
|
||||
upPosition.x = thisObject.parentContainer.frame.position.x
|
||||
upPosition.y = canvas.chartingSpace.viewport.visibleArea.topRight.y
|
||||
|
||||
downPosition.x = thisObject.parentContainer.frame.position.x
|
||||
downPosition.y = canvas.chartingSpace.viewport.visibleArea.bottomRight.y
|
||||
|
||||
if (thisObject.status === 'going down') {
|
||||
if (transitionPosition.y < downPosition.y) {
|
||||
transitionPosition.y = transitionPosition.y + 50
|
||||
thisObject.parentContainer.frame.position.y = transitionPosition.y
|
||||
} else {
|
||||
thisObject.parentContainer.frame.position.y = downPosition.y
|
||||
thisObject.status = 'down'
|
||||
}
|
||||
}
|
||||
if (thisObject.status === 'going up') {
|
||||
if (transitionPosition.y > upPosition.y) {
|
||||
transitionPosition.y = transitionPosition.y - 50
|
||||
thisObject.parentContainer.frame.position.y = transitionPosition.y
|
||||
} else {
|
||||
thisObject.parentContainer.frame.position.y = upPosition.y
|
||||
thisObject.status = 'up'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function draw () {
|
||||
if (isInitialized === false) { return }
|
||||
function draw() {
|
||||
if (isInitialized === false) { return }
|
||||
|
||||
drawButton()
|
||||
}
|
||||
|
||||
function getContainer (point, purpose) {
|
||||
let container
|
||||
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
||||
return thisObject.container
|
||||
drawButton()
|
||||
}
|
||||
}
|
||||
|
||||
function drawButton () {
|
||||
let point1
|
||||
let point2
|
||||
let point3
|
||||
|
||||
switch (thisObject.status) {
|
||||
case 'up': {
|
||||
point1 = {
|
||||
x: 3,
|
||||
y: 3
|
||||
function getContainer(point, purpose) {
|
||||
let container
|
||||
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
||||
return thisObject.container
|
||||
}
|
||||
|
||||
point2 = {
|
||||
x: thisObject.container.frame.width - 3,
|
||||
y: 3
|
||||
}
|
||||
|
||||
point3 = {
|
||||
x: thisObject.container.frame.width / 2,
|
||||
y: thisObject.container.frame.height - 3
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
case 'going down': {
|
||||
point1 = {
|
||||
x: 4,
|
||||
y: 4
|
||||
}
|
||||
|
||||
point2 = {
|
||||
x: thisObject.container.frame.width - 4,
|
||||
y: 4
|
||||
}
|
||||
|
||||
point3 = {
|
||||
x: thisObject.container.frame.width / 2,
|
||||
y: thisObject.container.frame.height - 4
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
case 'going up': {
|
||||
point1 = {
|
||||
x: 4,
|
||||
y: thisObject.container.frame.height - 4
|
||||
}
|
||||
|
||||
point2 = {
|
||||
x: thisObject.container.frame.width - 4,
|
||||
y: thisObject.container.frame.height - 4
|
||||
}
|
||||
|
||||
point3 = {
|
||||
x: thisObject.container.frame.width / 2,
|
||||
y: 4
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
case 'down': {
|
||||
point1 = {
|
||||
x: 3,
|
||||
y: thisObject.container.frame.height - 3
|
||||
}
|
||||
|
||||
point2 = {
|
||||
x: thisObject.container.frame.width - 3,
|
||||
y: thisObject.container.frame.height - 3
|
||||
}
|
||||
|
||||
point3 = {
|
||||
x: thisObject.container.frame.width / 2,
|
||||
y: 3
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
function drawButton() {
|
||||
let point1
|
||||
let point2
|
||||
let point3
|
||||
|
||||
switch (thisObject.status) {
|
||||
case 'up': {
|
||||
point1 = {
|
||||
x: 3,
|
||||
y: 3
|
||||
}
|
||||
|
||||
point2 = {
|
||||
x: thisObject.container.frame.width - 3,
|
||||
y: 3
|
||||
}
|
||||
|
||||
point3 = {
|
||||
x: thisObject.container.frame.width / 2,
|
||||
y: thisObject.container.frame.height - 3
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
case 'going down': {
|
||||
point1 = {
|
||||
x: 4,
|
||||
y: 4
|
||||
}
|
||||
|
||||
point2 = {
|
||||
x: thisObject.container.frame.width - 4,
|
||||
y: 4
|
||||
}
|
||||
|
||||
point3 = {
|
||||
x: thisObject.container.frame.width / 2,
|
||||
y: thisObject.container.frame.height - 4
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
case 'going up': {
|
||||
point1 = {
|
||||
x: 4,
|
||||
y: thisObject.container.frame.height - 4
|
||||
}
|
||||
|
||||
point2 = {
|
||||
x: thisObject.container.frame.width - 4,
|
||||
y: thisObject.container.frame.height - 4
|
||||
}
|
||||
|
||||
point3 = {
|
||||
x: thisObject.container.frame.width / 2,
|
||||
y: 4
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
case 'down': {
|
||||
point1 = {
|
||||
x: 3,
|
||||
y: thisObject.container.frame.height - 3
|
||||
}
|
||||
|
||||
point2 = {
|
||||
x: thisObject.container.frame.width - 3,
|
||||
y: thisObject.container.frame.height - 3
|
||||
}
|
||||
|
||||
point3 = {
|
||||
x: thisObject.container.frame.width / 2,
|
||||
y: 3
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
/* Now the transformations. */
|
||||
|
||||
point1 = thisObject.container.frame.frameThisPoint(point1)
|
||||
point2 = thisObject.container.frame.frameThisPoint(point2)
|
||||
point3 = thisObject.container.frame.frameThisPoint(point3)
|
||||
point1 = thisObject.container.frame.frameThisPoint(point1)
|
||||
point2 = thisObject.container.frame.frameThisPoint(point2)
|
||||
point3 = thisObject.container.frame.frameThisPoint(point3)
|
||||
|
||||
if (thisObject.fitFunction !== undefined) {
|
||||
point1 = thisObject.fitFunction(point1)
|
||||
point2 = thisObject.fitFunction(point2)
|
||||
point3 = thisObject.fitFunction(point3)
|
||||
}
|
||||
if (thisObject.fitFunction !== undefined) {
|
||||
point1 = thisObject.fitFunction(point1)
|
||||
point2 = thisObject.fitFunction(point2)
|
||||
point3 = thisObject.fitFunction(point3)
|
||||
}
|
||||
|
||||
/* Lets start the drawing. */
|
||||
|
||||
browserCanvasContext.beginPath()
|
||||
browserCanvasContext.moveTo(point1.x, point1.y)
|
||||
browserCanvasContext.lineTo(point2.x, point2.y)
|
||||
browserCanvasContext.lineTo(point3.x, point3.y)
|
||||
browserCanvasContext.lineTo(point1.x, point1.y)
|
||||
browserCanvasContext.closePath()
|
||||
browserCanvasContext.beginPath()
|
||||
browserCanvasContext.moveTo(point1.x, point1.y)
|
||||
browserCanvasContext.lineTo(point2.x, point2.y)
|
||||
browserCanvasContext.lineTo(point3.x, point3.y)
|
||||
browserCanvasContext.lineTo(point1.x, point1.y)
|
||||
browserCanvasContext.closePath()
|
||||
|
||||
browserCanvasContext.strokeStyle = 'rgba(250, 250, 250, 1)'
|
||||
browserCanvasContext.lineWidth = 1
|
||||
browserCanvasContext.stroke()
|
||||
browserCanvasContext.strokeStyle = 'rgba(250, 250, 250, 1)'
|
||||
browserCanvasContext.lineWidth = 1
|
||||
browserCanvasContext.stroke()
|
||||
|
||||
browserCanvasContext.fillStyle = 'rgba(250, 250, 250, 1)'
|
||||
browserCanvasContext.fill()
|
||||
}
|
||||
browserCanvasContext.fillStyle = 'rgba(250, 250, 250, 1)'
|
||||
browserCanvasContext.fill()
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user