Skip to content

Commit

Permalink
Skip directories with same size as child MaibornWolff#904
Browse files Browse the repository at this point in the history
  • Loading branch information
lurichte committed Apr 15, 2020
1 parent 77d156f commit 7ca988d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
10 changes: 7 additions & 3 deletions visualization/app/codeCharta/util/streetLayoutGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ export class StreetLayoutGenerator {
const isDeltaState = state.files.isDeltaState()
const metricName = state.dynamicSettings.areaMetric
const treeMapStartDepth = state.appSettings.treeMapStartDepth
const childBoxes = this.createBoxes(map, metricName, state, StreetOrientation.Vertical, 0, treeMapStartDepth)
const rootStreet = new HorizontalStreet(map, childBoxes, 0)
const mergedMap = StreetLayoutHelper.mergeDirectories(map, metricName)
const childBoxes = this.createBoxes(mergedMap, metricName, state, StreetOrientation.Vertical, 0, treeMapStartDepth)
const rootStreet = new HorizontalStreet(mergedMap, childBoxes, 0)
rootStreet.calculateDimension(metricName)
const margin = state.dynamicSettings.margin * StreetLayoutGenerator.MARGIN_SCALING_FACTOR
const layoutNodes: StreetLayoutValuedCodeMapNode[] = rootStreet.layout(new Point(0, 0), margin)
Expand All @@ -49,7 +50,9 @@ export class StreetLayoutGenerator {
treeMapStartDepth: number
): BoundingBox[] {
const children: BoundingBox[] = []
for (const child of node.children) {
const areaMetric = state.dynamicSettings.areaMetric
const mergedNode = StreetLayoutHelper.mergeDirectories(node, areaMetric)
for (let child of mergedNode.children) {
if (CodeMapHelper.isBlacklisted(child, state.fileSettings.blacklist, BlacklistType.exclude)) {
continue
}
Expand All @@ -63,6 +66,7 @@ export class StreetLayoutGenerator {
const treeMap = StreetLayoutGenerator.createTreeMap(child, TreeMapAlgorithm.Squarified)
children.push(treeMap)
} else {
child = StreetLayoutHelper.mergeDirectories(child, areaMetric)
const streetChildren = StreetLayoutGenerator.createBoxes(
child,
metricName,
Expand Down
15 changes: 15 additions & 0 deletions visualization/app/codeCharta/util/streetLayoutHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,19 @@ export class StreetLayoutHelper {
public static isNodeLeaf(node: CodeMapNode): boolean {
return !node.children || node.children.length === 0
}

public static mergeDirectories(node: CodeMapNode, metricName: string): CodeMapNode {
let mergedNode = node
for (const child of node.children) {
if (!StreetLayoutHelper.isNodeLeaf(child)) {
const nodeSize = StreetLayoutHelper.calculateSize(node, metricName)
const childSize = StreetLayoutHelper.calculateSize(child, metricName)
if (nodeSize === childSize) {
mergedNode = child
break
}
}
}
return mergedNode
}
}

0 comments on commit 7ca988d

Please sign in to comment.