Menues per subtype

This commit is contained in:
Luis Fernando Molina committed 2019-05-04 08:56:10 +02:00
1 parent f7f27159e3
commit 4d2e9dcf63
5 files changed
+123 -89

No files matched your search

+14 -15
View File
@@ -15,6 +15,7 @@ function newFloatingObject () {
payload: undefined, // This is a reference to an object controlled by a Plotter. The plotter can change its internal value and we will see them from here.
type: undefined, // Currently there are two types of Floating Objects: Profile Balls, and Notes.
underlayingObject: undefined,
physicsEnabled: false,
@@ -58,21 +59,19 @@ function newFloatingObject () {
}
let underlayingObject
thisObject.eventHandler = newEventHandler()
return thisObject
function initialize (pType, floatingLayer, callBackFunction) {
function initialize (pType, pSubType, floatingLayer, callBackFunction) {
try {
if (INFO_LOG === true) { logger.write('[INFO] initialize -> Entering function.') }
switch (pType) {
case 'Profile Ball': {
underlayingObject = newProfileBall()
underlayingObject.initialize(onInitialized)
thisObject.underlayingObject = newProfileBall()
thisObject.underlayingObject.initialize(onInitialized)
function onInitialized (err) {
@@ -81,8 +80,8 @@ function newFloatingObject () {
break
}
case 'Note': {
underlayingObject = newNote()
underlayingObject.initialize(onInitialized)
thisObject.underlayingObject = newNote()
thisObject.underlayingObject.initialize(onInitialized)
function onInitialized (err) {
@@ -91,8 +90,8 @@ function newFloatingObject () {
}
case 'Strategy Part': {
underlayingObject = newStrategyPart()
underlayingObject.initialize(floatingLayer, onInitialized)
thisObject.underlayingObject = newStrategyPart()
thisObject.underlayingObject.initialize(floatingLayer, pSubType, onInitialized)
function onInitialized (err) {
@@ -124,7 +123,7 @@ function newFloatingObject () {
try {
if (INFO_LOG === true) { logger.write('[INFO] initialize -> Entering function.') }
underlayingObject.physicsLoop()
thisObject.underlayingObject.physicsLoop()
if (callBackFunction !== undefined) { callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) }
} catch (err) {
@@ -138,7 +137,7 @@ function newFloatingObject () {
thisObject.targetImageSize = thisObject.rawImageSize * 2.5
thisObject.targetFontSize = thisObject.rawFontSize * 2.5
underlayingObject.onMouseOver()
thisObject.underlayingObject.onMouseOver()
}
function onMouseNotOver () {
@@ -146,19 +145,19 @@ function newFloatingObject () {
thisObject.targetImageSize = thisObject.rawImageSize * 1
thisObject.targetFontSize = thisObject.rawFontSize * 1
underlayingObject.onMouseNotOver()
thisObject.underlayingObject.onMouseNotOver()
}
function onMouseClick (pPoint) {
underlayingObject.onMouseClick(pPoint, thisObject)
thisObject.underlayingObject.onMouseClick(pPoint, thisObject)
}
function drawBackground () {
underlayingObject.drawBackground(thisObject)
thisObject.underlayingObject.drawBackground(thisObject)
}
function drawForeground () {
underlayingObject.drawForeground(thisObject)
thisObject.underlayingObject.drawForeground(thisObject)
}
function initializeMass (suggestedValue) {
+1 -1
View File
@@ -219,7 +219,7 @@ function newNoteSets () {
*/
let floatingObject = newFloatingObject()
floatingObject.initialize('Note', floatingLayer, onInitialized)
floatingObject.initialize('Note', '', floatingLayer, onInitialized)
function onInitialized (err) {
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> Entering function.') }
+1 -1
View File
@@ -41,7 +41,7 @@ function newProfileBalls () {
function createNewProfileBall (pPayload, callBackFunction) {
let floatingObject = newFloatingObject()
floatingObject.initialize('Profile Ball', floatingLayer, onInitialized)
floatingObject.initialize('Profile Ball', '', floatingLayer, onInitialized)
function onInitialized (err) {
floatingObject.payload = pPayload
+93 -59
View File
@@ -1,7 +1,7 @@
function newStrategyPart () {
let thisObject = {
type: undefined,
physicsLoop: physicsLoop,
onMouseOver: onMouseOver,
onMouseClick: onMouseClick,
@@ -12,53 +12,89 @@ function newStrategyPart () {
}
let ballStringMenu = [
{
visible: false,
imagePathOn: 'Images/menu.icon.on.1.gif',
imagePathOff: 'Images/menu.icon.off.1.gif',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: 60
},
{
visible: false,
imagePathOn: 'Images/menu.icon.on.2.gif',
imagePathOff: 'Images/menu.icon.off.2.gif',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: 20 * 1
},
{
visible: false,
imagePathOn: 'Images/menu.icon.on.3.gif',
imagePathOff: 'Images/menu.icon.off.3.gif',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: -20
},
{
visible: false,
imagePathOn: 'Images/menu.icon.on.4.gif',
imagePathOff: 'Images/menu.icon.off.4.gif',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: -60
}
]
let ballStringMenu = []
let floatingLayer
let isMouseOver = false
return thisObject
function initialize (pFloatingLayer, callBackFunction) {
function initialize (pFloatingLayer, pType, callBackFunction) {
floatingLayer = pFloatingLayer
switch (pType) {
case 'Strategy': {
break
}
case 'Strategy Entry': {
break
}
case 'Strategy Exit': {
break
}
case 'Trade Entry': {
break
}
case 'Trade Exit': {
break
}
case 'Stop': {
break
}
case 'Take Profit': {
break
}
case 'Phase': {
break
}
case 'Situation': {
break
}
case 'Condition': {
ballStringMenu = [
{
visible: false,
imagePathOn: 'Images/icons/style-01/html.png',
imagePathOff: 'Images/icons/style-01/html.png',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: 60
},
{
visible: false,
imagePathOn: 'Images/icons/style-01/settings.png',
imagePathOff: 'Images/icons/style-01/settings.png',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: 20 * 1
},
{
visible: false,
imagePathOn: 'Images/icons/style-01/tools.png',
imagePathOff: 'Images/icons/style-01/tools.png',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: -20
},
{
visible: false,
imagePathOn: 'Images/icons/style-01/trash.png',
imagePathOff: 'Images/icons/style-01/trash.png',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: -60
}]
break
}
default: {
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> Part Type not Recognized -> type = ' + pType) }
}
}
for (let i = 0; i < ballStringMenu.length; i++) {
let menuItem = ballStringMenu[i]
@@ -106,7 +142,7 @@ function newStrategyPart () {
for (let i = 0; i < ballStringMenu.length; i++) {
let menuItem = ballStringMenu[i]
menuItem.targetRadius = menuItem.rawRadius * 2.5
menuItem.targetRadius = menuItem.rawRadius * 1.5
}
isMouseOver = true
@@ -177,14 +213,13 @@ function newStrategyPart () {
}
function drawBackground (pFloatingObject) {
if (pFloatingObject.payload.parentNode === undefined) { return }
/* Here we do the trick of recalculation the position of the anchor by setting it to the position of its parent */
let parentFloatingObject = floatingLayer.getFloatingObject(pFloatingObject.payload.parentNode.handle)
if (pFloatingObject.payload.parentNode !== undefined) {
let parentFloatingObject = floatingLayer.getFloatingObject(pFloatingObject.payload.parentNode.handle)
pFloatingObject.payload.profile.position.x = parentFloatingObject.currentPosition.x
pFloatingObject.payload.profile.position.y = parentFloatingObject.currentPosition.y
}
pFloatingObject.payload.profile.position.x = parentFloatingObject.currentPosition.x
pFloatingObject.payload.profile.position.y = parentFloatingObject.currentPosition.y
/* Here I continue painting the background */
@@ -202,7 +237,7 @@ function newStrategyPart () {
browserCanvasContext.moveTo(pFloatingObject.currentPosition.x, pFloatingObject.currentPosition.y)
browserCanvasContext.lineTo(point.x, point.y)
browserCanvasContext.strokeStyle = 'rgba(204, 204, 204, 0.5)'
browserCanvasContext.setLineDash([4, 2])
browserCanvasContext.setLineDash([1, 4])
browserCanvasContext.lineWidth = 1
browserCanvasContext.stroke()
browserCanvasContext.setLineDash([0, 0])
@@ -224,28 +259,19 @@ function newStrategyPart () {
function drawForeground (pFloatingObject) {
if (pFloatingObject.currentRadius > 5) {
/* Contourn */
/*
browserCanvasContext.beginPath()
browserCanvasContext.arc(pFloatingObject.currentPosition.x, pFloatingObject.currentPosition.y, pFloatingObject.currentRadius, 0, Math.PI * 2, true)
browserCanvasContext.closePath()
browserCanvasContext.strokeStyle = 'rgba(30, 30, 30, 0.75)'
browserCanvasContext.lineWidth = 1
browserCanvasContext.stroke()
*/
}
if (pFloatingObject.currentRadius > 0.5) {
/* Main FloatingObject */
var alphaA
if (pFloatingObject.currentRadius < 3) {
alphaA = 1
} else {
alphaA = 0.75
}
alphaA = 0.75
browserCanvasContext.beginPath()
browserCanvasContext.arc(pFloatingObject.currentPosition.x, pFloatingObject.currentPosition.y, pFloatingObject.currentRadius * 2 / 3, 0, Math.PI * 2, true)
browserCanvasContext.closePath()
@@ -253,6 +279,14 @@ function newStrategyPart () {
browserCanvasContext.fillStyle = pFloatingObject.fillStyle
browserCanvasContext.fill()
browserCanvasContext.beginPath()
browserCanvasContext.arc(pFloatingObject.currentPosition.x, pFloatingObject.currentPosition.y, pFloatingObject.currentRadius * 1 / 3, 0, Math.PI * 2, true)
browserCanvasContext.closePath()
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.BLACK + ', 1)'
browserCanvasContext.fill()
}
/* Image */
+14 -13
View File
@@ -34,7 +34,8 @@ function newStrategyParts () {
function createNewStrategyPart (type, pPayload, callBackFunction) {
let floatingObject = newFloatingObject()
floatingObject.initialize('Strategy Part', floatingLayer, onInitialized)
floatingObject.initialize('Strategy Part', type, floatingLayer, onInitialized)
floatingObject.underlayingObject.type = type
function onInitialized (err) {
const FRICTION = 0.97
@@ -90,8 +91,8 @@ function newStrategyParts () {
floatingObject.friction = FRICTION
floatingObject.initializeMass(100)
floatingObject.initializeRadius(60)
floatingObject.initializeImageSize(110)
floatingObject.initializeRadius(45)
floatingObject.initializeImageSize(80)
floatingObject.initializeFontSize(10)
floatingObject.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)'
@@ -101,8 +102,8 @@ function newStrategyParts () {
floatingObject.friction = FRICTION
floatingObject.initializeMass(50)
floatingObject.initializeRadius(45)
floatingObject.initializeImageSize(80)
floatingObject.initializeRadius(40)
floatingObject.initializeImageSize(70)
floatingObject.initializeFontSize(10)
floatingObject.fillStyle = 'rgba(' + UI_COLOR.GREEN + ', 1)'
@@ -112,8 +113,8 @@ function newStrategyParts () {
floatingObject.friction = FRICTION
floatingObject.initializeMass(10)
floatingObject.initializeRadius(40)
floatingObject.initializeImageSize(70)
floatingObject.initializeRadius(35)
floatingObject.initializeImageSize(60)
floatingObject.initializeFontSize(10)
floatingObject.fillStyle = 'rgba(' + UI_COLOR.RUSTED_RED + ', 1)'
@@ -123,22 +124,22 @@ function newStrategyParts () {
floatingObject.friction = FRICTION
floatingObject.initializeMass(10)
floatingObject.initializeRadius(35)
floatingObject.initializeImageSize(60)
floatingObject.initializeRadius(30)
floatingObject.initializeImageSize(50)
floatingObject.initializeFontSize(10)
floatingObject.fillStyle = 'rgba(' + UI_COLOR.PATINATED_TURQUOISE + ', 1)'
floatingObject.fillStyle = 'rgba(' + UI_COLOR.TITANIUM_YELLOW + ', 1)'
}
function level_5 () {
floatingObject.friction = FRICTION
floatingObject.initializeMass(10)
floatingObject.initializeRadius(30)
floatingObject.initializeImageSize(50)
floatingObject.initializeRadius(25)
floatingObject.initializeImageSize(40)
floatingObject.initializeFontSize(10)
floatingObject.fillStyle = 'rgba(' + UI_COLOR.MANGANESE_PURPLE + ', 1)'
floatingObject.fillStyle = 'rgba(' + UI_COLOR.RED + ', 1)'
}
floatingObject.labelStrokeStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)'