-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/905/street map layout (#1585)
* initial street layout introduction * may be a fix for e2e filechooser test * street layout flattening fix, filechooser e2e fix, global setting dialog layout improvement, code refactoring * fixed TMStreet layout * added max treemap files * fixing linting, added remark about e2e falky test fix, added streetlayout todo * edited changelog * fixes after @BridgeAR review * updated changelog * Apply code formating #1543 * Update visualization/app/codeCharta/ui/maxTreeMapFiles/maxTreeMapFiles.component.ts * Update visualization/app/codeCharta/util/algorithm/streetLayout/horizontalStreet.ts * Update visualization/app/codeCharta/streetLayoutTodo.md * Update visualization/app/codeCharta/util/algorithm/streetLayout/streetViewHelper.ts * Update visualization/app/codeCharta/util/algorithm/streetLayout/verticalStreet.ts * Update visualization/app/codeCharta/util/algorithm/treeMapLayout/treeMapHelper.ts * Improve identation #905 * Merge main, Fix label position conflicts #905 * Fix scaling bug and improve performance * Fix label positioning bug on mouse move, Apply minor refactorings. * Add regression tests for label scaling/positioning bugs * Fix temporary label bug: reset on map move/turn Co-authored-by: Cedrik Bormann <cedrikbormann@gmail.com> Co-authored-by: Cedrik Bormann <26900540+ce-bo@users.noreply.github.com>
- Loading branch information
1 parent
24d1ad6
commit ff46492
Showing
70 changed files
with
2,078 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...ization/app/codeCharta/state/store/appSettings/layoutAlgorithm/layoutAlgorithm.actions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { CCAction, LayoutAlgorithm } from "../../../../codeCharta.model" | ||
|
||
export enum LayoutAlgorithmActions { | ||
SET_LAYOUT_ALGORITHM = "SET_LAYOUT_ALGORITHM" | ||
} | ||
|
||
export interface SetLayoutAlgorithmAction extends CCAction { | ||
type: LayoutAlgorithmActions.SET_LAYOUT_ALGORITHM | ||
payload: LayoutAlgorithm | ||
} | ||
|
||
export type LayoutAlgorithmAction = SetLayoutAlgorithmAction | ||
|
||
export function setLayoutAlgorithm(layoutAlgorithm: LayoutAlgorithm = defaultLayoutAlgorithm): SetLayoutAlgorithmAction { | ||
return { | ||
type: LayoutAlgorithmActions.SET_LAYOUT_ALGORITHM, | ||
payload: layoutAlgorithm | ||
} | ||
} | ||
|
||
export const defaultLayoutAlgorithm: LayoutAlgorithm = LayoutAlgorithm.SquarifiedTreeMap |
24 changes: 24 additions & 0 deletions
24
...on/app/codeCharta/state/store/appSettings/layoutAlgorithm/layoutAlgorithm.reducer.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { layoutAlgorithm } from "./layoutAlgorithm.reducer" | ||
import { LayoutAlgorithmAction, setLayoutAlgorithm } from "./layoutAlgorithm.actions" | ||
import { LayoutAlgorithm } from "../../../../codeCharta.model" | ||
|
||
describe("layoutAlgorithm", () => { | ||
describe("Default State", () => { | ||
it("should initialize the default state", () => { | ||
const result = layoutAlgorithm(undefined, {} as LayoutAlgorithmAction) | ||
expect(result).toEqual(LayoutAlgorithm.SquarifiedTreeMap) | ||
}) | ||
}) | ||
|
||
describe("setLayoutAlgorithm", () => { | ||
it("should set new layoutAlgorithm", () => { | ||
const result = layoutAlgorithm(LayoutAlgorithm.SquarifiedTreeMap, setLayoutAlgorithm(LayoutAlgorithm.StreetMap)) | ||
expect(result).toEqual(LayoutAlgorithm.StreetMap) | ||
}) | ||
|
||
it("should set default layoutAlgorithm", () => { | ||
const result = layoutAlgorithm(LayoutAlgorithm.StreetMap, setLayoutAlgorithm()) | ||
expect(result).toEqual(LayoutAlgorithm.SquarifiedTreeMap) | ||
}) | ||
}) | ||
}) |
11 changes: 11 additions & 0 deletions
11
...ization/app/codeCharta/state/store/appSettings/layoutAlgorithm/layoutAlgorithm.reducer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { LayoutAlgorithmAction, LayoutAlgorithmActions, setLayoutAlgorithm } from "./layoutAlgorithm.actions" | ||
import { LayoutAlgorithm } from "../../../../codeCharta.model" | ||
|
||
export function layoutAlgorithm(state: LayoutAlgorithm = setLayoutAlgorithm().payload, action: LayoutAlgorithmAction): LayoutAlgorithm { | ||
switch (action.type) { | ||
case LayoutAlgorithmActions.SET_LAYOUT_ALGORITHM: | ||
return action.payload | ||
default: | ||
return state | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
...on/app/codeCharta/state/store/appSettings/layoutAlgorithm/layoutAlgorithm.service.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import "../../../state.module" | ||
import { IRootScopeService } from "angular" | ||
import { StoreService } from "../../../store.service" | ||
import { getService, instantiateModule } from "../../../../../../mocks/ng.mockhelper" | ||
import { LayoutAlgorithmAction, LayoutAlgorithmActions } from "./layoutAlgorithm.actions" | ||
import { LayoutAlgorithmService } from "./layoutAlgorithm.service" | ||
import { withMockedEventMethods } from "../../../../util/dataMocks" | ||
import { LayoutAlgorithm } from "../../../../codeCharta.model" | ||
|
||
describe("LayoutAlgorithmService", () => { | ||
let layoutAlgorithmService: LayoutAlgorithmService | ||
let storeService: StoreService | ||
let $rootScope: IRootScopeService | ||
|
||
beforeEach(() => { | ||
restartSystem() | ||
rebuildService() | ||
withMockedEventMethods($rootScope) | ||
}) | ||
|
||
function restartSystem() { | ||
instantiateModule("app.codeCharta.state") | ||
|
||
$rootScope = getService<IRootScopeService>("$rootScope") | ||
storeService = getService<StoreService>("storeService") | ||
} | ||
|
||
function rebuildService() { | ||
layoutAlgorithmService = new LayoutAlgorithmService($rootScope, storeService) | ||
} | ||
|
||
describe("constructor", () => { | ||
it("should subscribe to store", () => { | ||
StoreService.subscribe = jest.fn() | ||
|
||
rebuildService() | ||
|
||
expect(StoreService.subscribe).toHaveBeenCalledWith($rootScope, layoutAlgorithmService) | ||
}) | ||
}) | ||
|
||
describe("onStoreChanged", () => { | ||
it("should notify all subscribers with the new layoutAlgorithm value", () => { | ||
const action: LayoutAlgorithmAction = { | ||
type: LayoutAlgorithmActions.SET_LAYOUT_ALGORITHM, | ||
payload: LayoutAlgorithm.StreetMap | ||
} | ||
storeService["store"].dispatch(action) | ||
|
||
layoutAlgorithmService.onStoreChanged(LayoutAlgorithmActions.SET_LAYOUT_ALGORITHM) | ||
|
||
expect($rootScope.$broadcast).toHaveBeenCalledWith("layout-algorithm-changed", { layoutAlgorithm: LayoutAlgorithm.StreetMap }) | ||
}) | ||
|
||
it("should not notify anything on non-layout-algorithm-events", () => { | ||
layoutAlgorithmService.onStoreChanged("ANOTHER_ACTION") | ||
|
||
expect($rootScope.$broadcast).not.toHaveBeenCalled() | ||
}) | ||
}) | ||
}) |
37 changes: 37 additions & 0 deletions
37
...ization/app/codeCharta/state/store/appSettings/layoutAlgorithm/layoutAlgorithm.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { StoreService, StoreSubscriber } from "../../../store.service" | ||
import { IRootScopeService } from "angular" | ||
import { LayoutAlgorithmActions } from "./layoutAlgorithm.actions" | ||
import { LayoutAlgorithm } from "../../../../codeCharta.model" | ||
import { isActionOfType } from "../../../../util/reduxHelper" | ||
|
||
export interface LayoutAlgorithmSubscriber { | ||
onLayoutAlgorithmChanged(layoutAlgorithm: LayoutAlgorithm) | ||
} | ||
|
||
export class LayoutAlgorithmService implements StoreSubscriber { | ||
private static LAYOUT_ALGORITHM_CHANGED_EVENT = "layout-algorithm-changed" | ||
|
||
constructor(private $rootScope: IRootScopeService, private storeService: StoreService) { | ||
StoreService.subscribe(this.$rootScope, this) | ||
} | ||
|
||
onStoreChanged(actionType: string) { | ||
if (isActionOfType(actionType, LayoutAlgorithmActions)) { | ||
this.notify(this.select()) | ||
} | ||
} | ||
|
||
private select() { | ||
return this.storeService.getState().appSettings.layoutAlgorithm | ||
} | ||
|
||
private notify(newState: LayoutAlgorithm) { | ||
this.$rootScope.$broadcast(LayoutAlgorithmService.LAYOUT_ALGORITHM_CHANGED_EVENT, { layoutAlgorithm: newState }) | ||
} | ||
|
||
static subscribe($rootScope: IRootScopeService, subscriber: LayoutAlgorithmSubscriber) { | ||
$rootScope.$on(LayoutAlgorithmService.LAYOUT_ALGORITHM_CHANGED_EVENT, (_event, data) => { | ||
subscriber.onLayoutAlgorithmChanged(data.layoutAlgorithm) | ||
}) | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...zation/app/codeCharta/state/store/appSettings/layoutAlgorithm/layoutAlgorithm.splitter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { LayoutAlgorithmAction, setLayoutAlgorithm } from "./layoutAlgorithm.actions" | ||
import { LayoutAlgorithm } from "../../../../codeCharta.model" | ||
|
||
export function splitLayoutAlgorithmAction(payload: LayoutAlgorithm): LayoutAlgorithmAction { | ||
return setLayoutAlgorithm(payload) | ||
} |
21 changes: 21 additions & 0 deletions
21
...ization/app/codeCharta/state/store/appSettings/maxTreeMapFiles/maxTreeMapFiles.actions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { CCAction } from "../../../../codeCharta.model" | ||
|
||
export enum MaxTreeMapFilesActions { | ||
SET_MAX_TREE_MAP_FILES = "SET_MAX_TREE_MAP_FILES" | ||
} | ||
|
||
export interface SetMaxTreeMapFilesAction extends CCAction { | ||
type: MaxTreeMapFilesActions.SET_MAX_TREE_MAP_FILES | ||
payload: number | ||
} | ||
|
||
export type MaxTreeMapFilesAction = SetMaxTreeMapFilesAction | ||
|
||
export function setMaxTreeMapFiles(maxTreeMapFiles: number = defaultMaxTreeMapFiles): SetMaxTreeMapFilesAction { | ||
return { | ||
type: MaxTreeMapFilesActions.SET_MAX_TREE_MAP_FILES, | ||
payload: maxTreeMapFiles | ||
} | ||
} | ||
|
||
export const defaultMaxTreeMapFiles = 100 |
26 changes: 26 additions & 0 deletions
26
...on/app/codeCharta/state/store/appSettings/maxTreeMapFiles/maxTreeMapFiles.reducer.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { maxTreeMapFiles } from "./maxTreeMapFiles.reducer" | ||
import { MaxTreeMapFilesAction, setMaxTreeMapFiles } from "./maxTreeMapFiles.actions" | ||
|
||
describe("maxTreeMapFiles", () => { | ||
describe("Default State", () => { | ||
it("should initialize the default state", () => { | ||
const result = maxTreeMapFiles(undefined, {} as MaxTreeMapFilesAction) | ||
|
||
expect(result).toEqual(100) | ||
}) | ||
}) | ||
|
||
describe("Action: SET_MAX_TREE_MAP_FILES", () => { | ||
it("should set new maxTreeMapFiles", () => { | ||
const result = maxTreeMapFiles(100, setMaxTreeMapFiles(200)) | ||
|
||
expect(result).toEqual(200) | ||
}) | ||
|
||
it("should set default maxTreeMapFiles", () => { | ||
const result = maxTreeMapFiles(200, setMaxTreeMapFiles()) | ||
|
||
expect(result).toEqual(100) | ||
}) | ||
}) | ||
}) |
10 changes: 10 additions & 0 deletions
10
...ization/app/codeCharta/state/store/appSettings/maxTreeMapFiles/maxTreeMapFiles.reducer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { MaxTreeMapFilesAction, MaxTreeMapFilesActions, setMaxTreeMapFiles } from "./maxTreeMapFiles.actions" | ||
|
||
export function maxTreeMapFiles(state: number = setMaxTreeMapFiles().payload, action: MaxTreeMapFilesAction): number { | ||
switch (action.type) { | ||
case MaxTreeMapFilesActions.SET_MAX_TREE_MAP_FILES: | ||
return action.payload | ||
default: | ||
return state | ||
} | ||
} |
Oops, something went wrong.