Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scale Factor calculation fix #190

Merged
merged 1 commit into from
Aug 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading