Skip to content

Commit

Permalink
Merge pull request #190 from kieler/nre/fix-189
Browse files Browse the repository at this point in the history
Scale Factor calculation fix
  • Loading branch information
NiklasRentzCAU authored Aug 5, 2024
2 parents 69ef274 + 320ef47 commit 4a3bb43
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions packages/klighd-core/src/depth-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* http://rtsys.informatik.uni-kiel.de/kieler
*
* Copyright 2021-2023 by
* Copyright 2021-2024 by
* + Kiel University
* + Department of Computer Science
* + Real-Time and Embedded Systems Group
Expand Down Expand Up @@ -200,6 +200,23 @@ export class DepthMap {
}

const kRendering = this.findRendering(element)

const current = element.parent as KNode

// compute own absolute scale and absolute position based on parent position
const parentAbsoluteScale = (element.parent as any).properties.absoluteScale
const scaleFactor = (element.parent as any).properties['org.eclipse.elk.topdown.scaleFactor'] ?? 1
element.properties.absoluteScale = parentAbsoluteScale * scaleFactor

if (element instanceof KNode) {
element.properties.absoluteX =
(current.properties.absoluteX as number) +
element.bounds.x * (element.properties.absoluteScale as number)
element.properties.absoluteY =
(current.properties.absoluteY as number) +
element.bounds.y * (element.properties.absoluteScale as number)
}

if (
element instanceof KNode &&
kRendering &&
Expand All @@ -218,20 +235,6 @@ export class DepthMap {
entry.providingRegion.parent = entry.containingRegion
entry.containingRegion.children.push(entry.providingRegion)

const current = element.parent as KNode

// compute own absolute scale and absolute position based on parent position
const parentAbsoluteScale = (element.parent as any).properties.absoluteScale
const scaleFactor = (element.parent as any).properties['org.eclipse.elk.topdown.scaleFactor'] ?? 1
element.properties.absoluteScale = parentAbsoluteScale * scaleFactor

element.properties.absoluteX =
(current.properties.absoluteX as number) +
element.bounds.x * (element.properties.absoluteScale as number)
element.properties.absoluteY =
(current.properties.absoluteY as number) +
element.bounds.y * (element.properties.absoluteScale as number)

entry.providingRegion.absolutePosition = {
x: element.properties.absoluteX as number,
y: element.properties.absoluteY as number,
Expand Down

0 comments on commit 4a3bb43

Please sign in to comment.