Commit 571c344a authored by Henrique Nakashima's avatar Henrique Nakashima Committed by Commit Bot

[Lorenz] Add option to group class nodes by Java package

Reheat the graph if node grouping criteria changes.

Bug: 1117259
Change-Id: I9be8e2dd6c1ed523fe0ae8a9a71fcb16176bfb18
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2360495
Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Reviewed-by: default avatarSamuel Huang <huangs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799186}
parent 0ff514a1
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
const HullDisplay = { const HullDisplay = {
NONE: 'none', NONE: 'none',
BUILD_TARGET: 'build-target', BUILD_TARGET: 'build-target',
JAVA_PACKAGE: 'java-package',
}; };
export { export {
......
...@@ -309,6 +309,10 @@ class GraphView { ...@@ -309,6 +309,10 @@ class GraphView {
this.colorEdgesOnlyOnHover_ = true; this.colorEdgesOnlyOnHover_ = true;
/** @private {string} */ /** @private {string} */
this.graphEdgeColor_ = GraphEdgeColor.DEFAULT; this.graphEdgeColor_ = GraphEdgeColor.DEFAULT;
/** @private {boolean} */
this.reheatRequested_ = false;
/** @private {?string} */
this.lastHullDisplay_ = null;
/** @private {!HoveredNodeManager} */ /** @private {!HoveredNodeManager} */
this.hoveredNodeManager_ = new HoveredNodeManager(); this.hoveredNodeManager_ = new HoveredNodeManager();
/** @private {!HullColorManager} */ /** @private {!HullColorManager} */
...@@ -731,6 +735,12 @@ class GraphView { ...@@ -731,6 +735,12 @@ class GraphView {
this.colorEdgesOnlyOnHover_ = colorOnlyOnHover; this.colorEdgesOnlyOnHover_ = colorOnlyOnHover;
this.graphEdgeColor_ = graphEdgeColor; this.graphEdgeColor_ = graphEdgeColor;
// Reheat if node grouping changed.
if (this.lastHullDisplay_ !== displaySettings.hullDisplay) {
this.lastHullDisplay_ = displaySettings.hullDisplay;
this.reheatRequested_ = true;
}
this.syncEdgeGradients(); this.syncEdgeGradients();
this.syncEdgePaths(); this.syncEdgePaths();
this.syncEdgeColors(); this.syncEdgeColors();
...@@ -897,7 +907,8 @@ class GraphView { ...@@ -897,7 +907,8 @@ class GraphView {
// The graph should not be reheated on a no-op (eg. adding a visible node to // The graph should not be reheated on a no-op (eg. adding a visible node to
// the filter which doesn't add/remove any new nodes). // the filter which doesn't add/remove any new nodes).
if (nodesAddedOrRemoved) { if (this.reheatRequested_ || nodesAddedOrRemoved) {
this.reheatRequested_ = false;
this.simulation_.stop(); this.simulation_.stop();
this.reheatSimulation(/* shouldEase */ true); this.reheatSimulation(/* shouldEase */ true);
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<template> <template>
<div id="hull-settings"> <div id="hull-settings">
<label>Convex hull display:</label> <label>Group nodes by:</label>
<div <div
v-for="hullDisplay in HullDisplay" v-for="hullDisplay in HullDisplay"
:key="hullDisplay" :key="hullDisplay"
...@@ -57,6 +57,7 @@ export default ClassGraphHullSettings; ...@@ -57,6 +57,7 @@ export default ClassGraphHullSettings;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
margin-bottom: 10px; margin-bottom: 10px;
padding-top: 10px;
} }
.hull-settings-option { .hull-settings-option {
......
...@@ -117,6 +117,14 @@ function getNodeBuildTarget(node) { ...@@ -117,6 +117,14 @@ function getNodeBuildTarget(node) {
return null; return null;
} }
/**
* @param {!ClassNode} node The node to get the Java package of.
* @return {?string} The Java package of the node.
*/
function getNodePackageName(node) {
return node.packageName;
}
// @vue/component // @vue/component
const ClassGraphPage = { const ClassGraphPage = {
components: { components: {
...@@ -163,6 +171,8 @@ const ClassGraphPage = { ...@@ -163,6 +171,8 @@ const ClassGraphPage = {
switch (this.displaySettingsData.hullDisplay) { switch (this.displaySettingsData.hullDisplay) {
case HullDisplay.BUILD_TARGET: case HullDisplay.BUILD_TARGET:
return getNodeBuildTarget; return getNodeBuildTarget;
case HullDisplay.JAVA_PACKAGE:
return getNodePackageName;
default: default:
return () => null; return () => null;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment