scale improvements

This commit is contained in:
Luis Fernando Molina committed 2020-04-01 14:00:14 +02:00
1 parent 42cdc1ba05
commit 6798b4bf0f
6 files changed
+52 -21

No files matched your search

+14 -10
View File
@@ -19,6 +19,10 @@ function newCoordinateSystem () {
autoMaxXScale: true,
autoMinYScale: true,
autoMaxYScale: true,
HORIZONTAL_MARGIN_FACTOR: 0.80,
VERTICAL_MARGIN_FACTOR: 0.90,
HORIZONTAL_MARGIN_INVERSE_FACTOR: 0.20,
VERTICAL_MARGIN_INVERSE_FACTOR: 0.10,
physics: physics,
reportXValue: reportXValue,
reportYValue: reportYValue,
@@ -193,8 +197,8 @@ function newCoordinateSystem () {
}
function recalculateScale (event) {
thisObject.scale.x = thisObject.maxWidth / (thisObject.max.x - thisObject.min.x)
thisObject.scale.y = thisObject.maxHeight / (thisObject.max.y - thisObject.min.y)
thisObject.scale.x = thisObject.maxWidth * thisObject.HORIZONTAL_MARGIN_FACTOR / (thisObject.max.x - thisObject.min.x)
thisObject.scale.y = thisObject.maxHeight * thisObject.VERTICAL_MARGIN_FACTOR / (thisObject.max.y - thisObject.min.y)
thisObject.eventHandler.raiseEvent('Scale Changed', event)
}
@@ -230,8 +234,8 @@ function newCoordinateSystem () {
*/
point = {
x: (point.x - thisObject.min.x) * thisObject.scale.x,
y: thisObject.maxHeight - (point.y - thisObject.min.y) * thisObject.scale.y
x: (point.x - thisObject.min.x) * thisObject.scale.x + thisObject.maxWidth * thisObject.HORIZONTAL_MARGIN_INVERSE_FACTOR / 2,
y: thisObject.maxHeight - (point.y - thisObject.min.y) * thisObject.scale.y - thisObject.maxHeight * thisObject.VERTICAL_MARGIN_INVERSE_FACTOR / 2
}
return point
@@ -239,8 +243,8 @@ function newCoordinateSystem () {
function transformThisPoint2 (point) {
point = {
x: (point.x - thisObject.min.x) * thisObject.scale.x,
y: (thisObject.maxHeight - point.y - thisObject.min.y) * thisObject.scale.y
x: (point.x - thisObject.min.x) * thisObject.scale.x + thisObject.maxWidth * thisObject.HORIZONTAL_MARGIN_INVERSE_FACTOR / 2,
y: (thisObject.maxHeight - point.y - thisObject.min.y) * thisObject.scale.y - thisObject.maxHeight * thisObject.VERTICAL_MARGIN_INVERSE_FACTOR / 2
}
return point
@@ -248,8 +252,8 @@ function newCoordinateSystem () {
function unInverseTransform (point, inverseY) {
point = {
x: (point.x / thisObject.scale.x) + thisObject.min.x,
y: (inverseY - point.y) / thisObject.scale.y + thisObject.min.y
x: ((point.x - thisObject.maxWidth * thisObject.HORIZONTAL_MARGIN_INVERSE_FACTOR / 2) / thisObject.scale.x) + thisObject.min.x,
y: (inverseY * thisObject.VERTICAL_MARGIN_FACTOR - point.y + thisObject.maxHeight * thisObject.VERTICAL_MARGIN_INVERSE_FACTOR / 2) / thisObject.scale.y + thisObject.min.y
}
return point
@@ -257,8 +261,8 @@ function newCoordinateSystem () {
function inverseTransformUncappedY (point, inverseY) {
point = {
x: (point.x - thisObject.min.x) * thisObject.scale.x,
y: (inverseY - point.y) * thisObject.scale.y
x: (point.x - thisObject.min.x) * thisObject.scale.x + thisObject.maxWidth * thisObject.HORIZONTAL_MARGIN_INVERSE_FACTOR / 2,
y: (inverseY * thisObject.VERTICAL_MARGIN_FACTOR - point.y) * thisObject.scale.y - thisObject.maxHeight * thisObject.VERTICAL_MARGIN_INVERSE_FACTOR / 2
}
return point
+3 -2
View File
@@ -268,6 +268,7 @@ function newEdgeEditor () {
}
function draggingPhysics () {
if (coordinateSystemWhenDragStarted === undefined) { return }
if (thisObject.container.frame.position.x === 0 && thisObject.container.frame.position.y === 0) { return }
let mouseNoZoom = canvas.chartingSpace.viewport.unTransformThisPoint(mouse.position)
@@ -324,7 +325,7 @@ function newEdgeEditor () {
break
case 'left or right arrow key pressed': {
let point = {
x: -dragVector.x,
x: -dragVector.x + thisObject.container.frame.width * coordinateSystem.HORIZONTAL_MARGIN_INVERSE_FACTOR / 2,
y: 0
}
@@ -342,7 +343,7 @@ function newEdgeEditor () {
case 'up or down arrow key pressed': {
let point = {
x: 0,
y: -dragVector.y
y: -dragVector.y + thisObject.container.frame.height * coordinateSystem.VERTICAL_MARGIN_INVERSE_FACTOR / 2
}
let newMaxRate = getRateFromPointAtContainer(point, thisObject.container.parentContainer, coordinateSystem)
+16 -2
View File
@@ -12,6 +12,7 @@ function newUiObjectTitle () {
editMode: undefined,
container: undefined,
payload: undefined,
isDefault: undefined,
enterEditMode: enterEditMode,
exitEditMode: exitEditMode,
physics: physics,
@@ -81,6 +82,19 @@ function newUiObjectTitle () {
}
function physics () {
inheritancePhysics()
defaultPhysics()
}
function defaultPhysics () {
if (thisObject.payload.title !== 'New ' + thisObject.payload.node.type && thisObject.payload.title !== 'My ' + thisObject.payload.node.type) {
thisObject.isDefault = false
} else {
thisObject.isDefault = true
}
}
function inheritancePhysics () {
if (thisObject.payload.title === undefined) { return }
/* It is possible to override the default title by setting the APP SCHEMA property 'title' */
@@ -255,7 +269,7 @@ function newUiObjectTitle () {
}
function draw () {
if (thisObject.isOnFocus === true || thisObject.allwaysVisible === true) {
if (thisObject.isOnFocus === true || thisObject.allwaysVisible === true || thisObject.isDefault === false) {
if (thisObject.payload.uiObject.codeEditor !== undefined) {
if (thisObject.payload.uiObject.codeEditor.visible !== true) {
drawTitleBackground()
@@ -291,7 +305,7 @@ function newUiObjectTitle () {
let fontSize = thisObject.payload.floatingObject.currentFontSize
let label
if (radius > 6 && (thisObject.isOnFocus === true || thisObject.allwaysVisible === true)) {
if (radius > 6 && (thisObject.isOnFocus === true || thisObject.allwaysVisible === true || thisObject.isDefault === false)) {
browserCanvasContext.strokeStyle = thisObject.payload.floatingObject.labelStrokeStyle
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY
+17 -5
View File
@@ -85,10 +85,10 @@ function newAutoScaleButton () {
currentStatus = 2
}
if (thisObject.autoMinScale === false && thisObject.autoMaxScale === true) {
currentStatus = 3
currentStatus = 4
}
if (thisObject.autoMinScale === true && thisObject.autoMaxScale === true) {
currentStatus = 4
currentStatus = 6
}
}
function onMouseWheel (event) {
@@ -100,8 +100,8 @@ function newAutoScaleButton () {
delta = 1
}
currentStatus = currentStatus + delta
if (currentStatus === 5) { currentStatus = 1 }
if (currentStatus === 0) { currentStatus = 4 }
if (currentStatus === 7) { currentStatus = 1 }
if (currentStatus === 0) { currentStatus = 6 }
switch (currentStatus) {
case 1: {
@@ -118,11 +118,23 @@ function newAutoScaleButton () {
}
case 3: {
thisObject.autoMinScale = false
thisObject.autoMaxScale = true
thisObject.autoMaxScale = false
update()
return
}
case 4: {
thisObject.autoMinScale = false
thisObject.autoMaxScale = true
update()
return
}
case 5: {
thisObject.autoMinScale = false
thisObject.autoMaxScale = false
update()
return
}
case 6: {
thisObject.autoMinScale = true
thisObject.autoMaxScale = true
update()
@@ -582,7 +582,7 @@
let digit = record.begin.toFixed(0).substring(7,8)
let positionY = recordPoint3.y - (recordPoint3.y - recordPoint1.y) / 2 + (Number(digit) * 10 - 50)
if (canvas.chartingSpace.viewport.zoomLevel >= ZOOM_OUT_THRESHOLD_FOR_HIDDING_CHARTS_LABELS) {
if (record.triggerOnSituation !== "My Situation") {
if (record.triggerOnSituation !== "New Situation") {
printLabel(record.triggerOnSituation, recordPoint1.x + 5, positionY, '1', 12);
}
}
@@ -522,7 +522,7 @@
let line1 = '';
let line2 = '';
if (line0 === 'My Situation') {
if (line0 === 'New Situation') {
line0 = ''
}