Skip to content

Commit

Permalink
support for top-down scalefactor (#153)
Browse files Browse the repository at this point in the history
new render scaling to scale children of nodes
  • Loading branch information
Eddykasp authored Feb 28, 2024
1 parent 2b5de15 commit caeff1b
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions packages/klighd-core/src/views-rendering.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,15 @@ export function renderChildArea(
</g>
)

return element
// get scale factor and apply to child area
if (
(parent as any).properties === undefined ||
(parent as any).properties['org.eclipse.elk.topdown.scaleFactor'] === undefined
) {
return element
}
const topdownScaleFactor = (parent as any).properties['org.eclipse.elk.topdown.scaleFactor'] as number
return <g transform={`scale (${topdownScaleFactor})`}>${element}</g>
}

/**
Expand Down Expand Up @@ -1525,9 +1533,18 @@ export function getJunctionPointRenderings(edge: SKEdge, context: SKGraphModelRe
}

const renderings: VNode[] = []

let topdownScaleFactor = 1
if (
(edge.parent as any).properties === undefined ||
(edge.parent as any).properties['org.eclipse.elk.topdown.scaleFactor'] === undefined
) {
topdownScaleFactor = (edge.parent as any).properties['org.eclipse.elk.topdown.scaleFactor'] as number
}

edge.junctionPoints.forEach((junctionPoint) => {
const junctionPointVNode = <g transform={`translate(${junctionPoint.x},${junctionPoint.y})`}>{vNode}</g>
renderings.push(junctionPointVNode)
renderings.push(<g transform={`scale (${topdownScaleFactor})`}>${junctionPointVNode}</g>)
})
return renderings
}

0 comments on commit caeff1b

Please sign in to comment.