-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for custom edge overlays.
- Allow users to upload an edge overlays data json file. Each file can contain a list of edge overlays. - User can specify color, edge width, label size for each overlay. - User can enable/disable overlays from the dropdown, or delete overlay set. PiperOrigin-RevId: 684974829
- Loading branch information
1 parent
59263f1
commit 7da3c4f
Showing
22 changed files
with
1,171 additions
and
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/** | ||
* @license | ||
* Copyright 2024 The Model Explorer Authors. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* ============================================================================== | ||
*/ | ||
|
||
import {TaskData, TaskType} from './task'; | ||
|
||
/** The data for edge overlays. */ | ||
export declare interface EdgeOverlaysData extends TaskData { | ||
type: TaskType.EDGE_OVERLAYS; | ||
|
||
/** The name of this set of overlays, for UI display purposes. */ | ||
name: string; | ||
|
||
/** A list of edge overlays. */ | ||
overlays: EdgeOverlay[]; | ||
} | ||
|
||
/** An edge overlay. */ | ||
export declare interface EdgeOverlay { | ||
/** The name displayed in the UI to identify this overlay. */ | ||
name: string; | ||
|
||
/** The edges that define the overlay. */ | ||
edges: Edge[]; | ||
|
||
/** | ||
* The color of the overlay edges. | ||
* | ||
* They are rendered in this color when any of the nodes in this overlay is | ||
* selected. | ||
*/ | ||
edgeColor: string; | ||
|
||
/** The width of the overlay edges. Default to 2. */ | ||
edgeWidth?: number; | ||
|
||
/** The font size of the edge labels. Default to 7.5. */ | ||
edgeLabelFontSize?: number; | ||
} | ||
|
||
/** An edge in the overlay. */ | ||
export declare interface Edge { | ||
/** The id of the source node. Op node only. */ | ||
sourceNodeId: string; | ||
|
||
/** The id of the target node. Op node only. */ | ||
targetNodeId: string; | ||
|
||
/** Label shown on the edge. */ | ||
label?: string; | ||
} | ||
|
||
/** The processed edge overlays data. */ | ||
export declare interface ProcessedEdgeOverlaysData extends EdgeOverlaysData { | ||
/** A random id. */ | ||
id: string; | ||
|
||
processedOverlays: ProcessedEdgeOverlay[]; | ||
} | ||
|
||
/** The processed edge overlay. */ | ||
export declare interface ProcessedEdgeOverlay extends EdgeOverlay { | ||
/** A random id. */ | ||
id: string; | ||
|
||
/** The set of node ids that are in this overlay. */ | ||
nodeIds: Set<string>; | ||
} |
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
97 changes: 97 additions & 0 deletions
97
src/ui/src/components/visualizer/edge_overlays_dropdown.ng.html
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,97 @@ | ||
<!-- | ||
@license | ||
Copyright 2024 The Model Explorer Authors. All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
============================================================================== | ||
--> | ||
|
||
<div class="container" | ||
[bubble]="help" | ||
[overlaySize]="helpPopupSize" | ||
[hoverDelayMs]="10"> | ||
<div class="mat-icon-container view" | ||
[bubbleClick]="edgeOverlaysPopup" | ||
[overlaySize]="edgeOverlaysPopupSize" | ||
(opened)="opened=true" | ||
(closed)="opened=false" | ||
(click)="handleClickOnEdgeOverlaysButton()"> | ||
<mat-icon class="toolbar-icon">polyline</mat-icon> | ||
</div> | ||
</div> | ||
|
||
<ng-template #help> | ||
<div class="model-explorer-help-popup"> | ||
Show custom edge overlays on graph | ||
</div> | ||
</ng-template> | ||
|
||
<ng-template #edgeOverlaysPopup> | ||
<div class="model-explorer-edge-overlays-popup"> | ||
<div class="label"> | ||
<div>Edge overlays</div> | ||
<div class="icon-container close" bubbleClose> | ||
<mat-icon>close</mat-icon> | ||
</div> | ||
</div> | ||
|
||
<!-- Loaded overlays --> | ||
<div class="loaded-overlays-container"> | ||
@if (overlaysSets().length === 0) { | ||
<div class="no-overlays-label"> | ||
No loaded edge overlays | ||
</div> | ||
} @else { | ||
@for (overlaySet of overlaysSets(); track overlaySet.id) { | ||
<div class="overlay-set-container"> | ||
<div class="overlay-set-label"> | ||
{{overlaySet.name}} | ||
<div class="icon-container delete" (click)="handleDeleteOverlaySet(overlaySet)"> | ||
<mat-icon>delete</mat-icon> | ||
</div> | ||
</div> | ||
@for (overlay of overlaySet.overlays; track overlay.id) { | ||
<div class="overlay-item"> | ||
<label> | ||
<input type="checkbox" [checked]="overlay.selected" | ||
(change)="toggleOverlaySelection(overlay)"/> | ||
{{overlay.name}} | ||
</label> | ||
@if (overlay.selected) { | ||
<div class="view-label" (click)="handleClickViewOverlay(overlay)"> | ||
View | ||
</div> | ||
} | ||
</div> | ||
} | ||
</div> | ||
} | ||
} | ||
</div> | ||
|
||
<!-- Buttons to load the json --> | ||
<div class="upload-container"> | ||
<div class="description">Load from computer</div> | ||
<button class="upload-json-file-button upload" | ||
mat-flat-button color="primary" | ||
(click)="input.click()"> | ||
Upload | ||
</button> | ||
</div> | ||
<input class="upload-json-file-input" | ||
type="file" #input | ||
multiple | ||
accept=".json" | ||
(change)="handleClickUpload(input)"> | ||
</div> | ||
</ng-template> |
Oops, something went wrong.