From 7a65afbdb9da1f3ee93697b4e2af2c2acc722716 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 11 Nov 2020 11:45:41 +0100 Subject: [PATCH] Panel Improvements --- .../Spaces/Charting-Space/TimeMachine.js | 6 ++-- .../Spaces/Cockpit-Space/CockpitSpace.js | 2 +- .../Spaces/Panel-Space/PlotterPanel.js | 35 +++++++++++++++++-- Projects/Superalgos/Utilities/DrawPrint.js | 30 ++++++++++++---- 4 files changed, 59 insertions(+), 14 deletions(-) diff --git a/Projects/Superalgos/Spaces/Charting-Space/TimeMachine.js b/Projects/Superalgos/Spaces/Charting-Space/TimeMachine.js index 20208aa97..d3bd505de 100644 --- a/Projects/Superalgos/Spaces/Charting-Space/TimeMachine.js +++ b/Projects/Superalgos/Spaces/Charting-Space/TimeMachine.js @@ -665,7 +665,7 @@ function newTimeMachine() { if (description !== undefined) { label = description } - UI.projects.superalgos.utilities.drawPrint.printLabel(label, position.x + 20, position.y - 10, opacity, fontSize) + UI.projects.superalgos.utilities.drawPrint.printLabel(label, position.x + 20, undefined, undefined, position.y - 10, opacity, fontSize, undefined, 'Left') if (icon !== undefined) { if (icon.canDrawIcon === true) { @@ -730,7 +730,7 @@ function newTimeMachine() { } } - UI.projects.superalgos.utilities.drawPrint.printLabel(exchangeMarket.exchangeName, -5 + xOffSet, -30, opacity, fontSize, UI_COLOR.GREY) + UI.projects.superalgos.utilities.drawPrint.printLabel(exchangeMarket.exchangeName, -5 + xOffSet, undefined, undefined, -30, opacity, fontSize, UI_COLOR.GREY, 'Left') position.x = position.x + INTER_EXCHANGE_SPACE @@ -746,7 +746,7 @@ function newTimeMachine() { } } - UI.projects.superalgos.utilities.drawPrint.printLabel(exchangeMarket.marketName, -5 + xOffSet, -10, opacity, fontSize, UI_COLOR.GREY) + UI.projects.superalgos.utilities.drawPrint.printLabel(exchangeMarket.marketName, -5 + xOffSet, undefined, undefined, -10, opacity, fontSize, UI_COLOR.GREY, 'Left') icon = exchangeMarket.quotedAssetIcon if (icon !== undefined) { diff --git a/Projects/Superalgos/Spaces/Cockpit-Space/CockpitSpace.js b/Projects/Superalgos/Spaces/Cockpit-Space/CockpitSpace.js index 6b6673706..293ebc942 100644 --- a/Projects/Superalgos/Spaces/Cockpit-Space/CockpitSpace.js +++ b/Projects/Superalgos/Spaces/Cockpit-Space/CockpitSpace.js @@ -266,7 +266,7 @@ function newSuperalgosCockpitSpace() { x: thisObject.container.frame.width / 2, y: thisObject.container.frame.height / 2 + 5 } - UI.projects.superalgos.utilities.drawPrint.printLabel(statusText, position.x, position.y, 1, 15, textColor, 'Center', thisObject.container) + UI.projects.superalgos.utilities.drawPrint.printLabel(statusText, undefined, position.x, undefined, position.y, 1, 15, textColor, 'Center', thisObject.container) } if (UI.projects.superalgos.spaces.designSpace !== undefined) { diff --git a/Projects/Superalgos/Spaces/Panel-Space/PlotterPanel.js b/Projects/Superalgos/Spaces/Panel-Space/PlotterPanel.js index 9e7129fec..5cfe5b9be 100644 --- a/Projects/Superalgos/Spaces/Panel-Space/PlotterPanel.js +++ b/Projects/Superalgos/Spaces/Panel-Space/PlotterPanel.js @@ -93,7 +93,7 @@ function newPlotterPanel() { const frameBodyHeight = thisObject.container.frame.getBodyHeight() const frameTitleHeight = thisObject.container.frame.height - frameBodyHeight - const X_AXIS_A = thisObject.container.frame.width * 7 / 8 + const X_AXIS_A = thisObject.container.frame.width * 1 / 8 const X_AXIS_B = thisObject.container.frame.width * 7 / 8 const Y_AXIS = frameTitleHeight + frameBodyHeight / 2 @@ -177,8 +177,37 @@ function newPlotterPanel() { if (panelData.textStyle.config.paletteColor !== undefined) { paletteColor = eval(panelData.textStyle.config.paletteColor) } } - UI.projects.superalgos.utilities.drawPrint.printLabel(labelText, X_AXIS_A, UI_PANEL.HEIGHT.NORMAL * labelPosition / 100 / heightFactor, '0.60', undefined, undefined, 'Right', thisObject.container, thisObject.fitFunction) - UI.projects.superalgos.utilities.drawPrint.printLabel(value, X_AXIS_B, UI_PANEL.HEIGHT.NORMAL * valuePosition / 100 / heightFactor, opacity, fontSize, paletteColor, 'Right', thisObject.container, thisObject.fitFunction, false, true, undefined, true) + UI.projects.superalgos.utilities.drawPrint.printLabel( + labelText, + X_AXIS_A, + undefined, + undefined, + UI_PANEL.HEIGHT.NORMAL * labelPosition / 100 / heightFactor, + '0.60', + undefined, + undefined, + 'Left', + thisObject.container, + thisObject.fitFunction + ) + + UI.projects.superalgos.utilities.drawPrint.printLabel( + value, + X_AXIS_A, + X_AXIS_B, + undefined, + UI_PANEL.HEIGHT.NORMAL * valuePosition / 100 / heightFactor, + opacity, + fontSize, + paletteColor, + 'Left Numbers at Right', + thisObject.container, + thisObject.fitFunction, + false, + true, + undefined, + true + ) } } } diff --git a/Projects/Superalgos/Utilities/DrawPrint.js b/Projects/Superalgos/Utilities/DrawPrint.js index 3ba845744..e1e20c1a1 100644 --- a/Projects/Superalgos/Utilities/DrawPrint.js +++ b/Projects/Superalgos/Utilities/DrawPrint.js @@ -188,7 +188,9 @@ function newSuperalgosUtilitiesDrawPrint() { function printLabel( labelToPrint, - x, + xLeft, + xRight, + xCenter, y, opacity, fontSize, @@ -231,35 +233,49 @@ function newSuperalgosUtilitiesDrawPrint() { switch (align) { case 'Center': { labelPoint = { - x: x - getTextWidth(label) / 2, + x: xCenter - getTextWidth(label) / 2, y: y } break } case 'Left': { labelPoint = { - x: x, + x: xLeft, y: y } break } case 'Right': { labelPoint = { - x: x - getTextWidth(label), + x: xRight - getTextWidth(label), y: y } break } + case 'Left Numbers at Right': { + if (isItANumber === true) { + labelPoint = { + x: xRight - getTextWidth(label), + y: y + } + } else { + labelPoint = { + x: xLeft, + y: y + } + } + break + } default: { labelPoint = { - x: x, + x: xCenter - getTextWidth(label) / 2, y: y } } } if (isItANumber === true && simulateMonospace === true) { labelPoint = { - x: x, + x: xRight, y: y } } @@ -302,7 +318,7 @@ function newSuperalgosUtilitiesDrawPrint() { if (character === '.') { if (insignificantPointPossible === true) { characterOpacity = opacity / 4 - } + } } if (hasDecimals === true && character === '0' && insignificantZeroPossible === true) {