Fixed spelling mistake

This commit is contained in:
dragonmacher 2021-09-21 10:40:11 -04:00
parent 9ad8582225
commit f07c144db9
3 changed files with 20 additions and 25 deletions

View file

@ -124,7 +124,7 @@ class LayoutFunction
case HIERACHICAL: case HIERACHICAL:
return EdgeAwareTreeLayoutAlgorithm return EdgeAwareTreeLayoutAlgorithm
.<AttributedVertex, AttributedEdge>edgeAwareBuilder(); .<AttributedVertex, AttributedEdge>edgeAwareBuilder();
case COMPACT_HIERACHICAL: case COMPACT_HIERARCHICAL:
default: default:
return TidierTreeLayoutAlgorithm return TidierTreeLayoutAlgorithm
.<AttributedVertex, AttributedEdge> edgeAwareBuilder() .<AttributedVertex, AttributedEdge> edgeAwareBuilder()

View file

@ -62,18 +62,17 @@ class LayoutTransitionManager {
* Create an instance with passed parameters * Create an instance with passed parameters
* @param visualizationServer displays the graph * @param visualizationServer displays the graph
* @param rootPredicate selects root vertices * @param rootPredicate selects root vertices
* @param edgeTypePriorityList a {@code List} of EdgeType names in priority order * @param renderer the graph renderer
* @param favoredEdgePredicate q {@code Predicate} that will cause certain EdgeTypes to be favored during layout
*/ */
public LayoutTransitionManager( public LayoutTransitionManager(
VisualizationServer<AttributedVertex, AttributedEdge> visualizationServer, VisualizationServer<AttributedVertex, AttributedEdge> visualizationServer,
Predicate<AttributedVertex> rootPredicate, Predicate<AttributedVertex> rootPredicate, GraphRenderer renderer) {
GraphRenderer renderer) {
this.visualizationServer = visualizationServer; this.visualizationServer = visualizationServer;
this.rootPredicate = rootPredicate; this.rootPredicate = rootPredicate;
this.renderContext = visualizationServer.getRenderContext(); this.renderContext = visualizationServer.getRenderContext();
this.vertexBoundsFunction = visualizationServer.getRenderContext().getVertexBoundsFunction(); this.vertexBoundsFunction =
visualizationServer.getRenderContext().getVertexBoundsFunction();
this.layoutFunction = new LayoutFunction(renderer); this.layoutFunction = new LayoutFunction(renderer);
} }
@ -81,22 +80,22 @@ class LayoutTransitionManager {
* set the layout in order to configure the requested {@link LayoutAlgorithm} * set the layout in order to configure the requested {@link LayoutAlgorithm}
* @param layoutName the name of the layout algorithm to use * @param layoutName the name of the layout algorithm to use
*/ */
@SuppressWarnings("unchecked")
public void setLayout(String layoutName) { public void setLayout(String layoutName) {
LayoutAlgorithm.Builder<AttributedVertex, ?, ?> builder = layoutFunction.apply(layoutName); LayoutAlgorithm.Builder<AttributedVertex, ?, ?> builder = layoutFunction.apply(layoutName);
LayoutAlgorithm<AttributedVertex> layoutAlgorithm = builder.build(); LayoutAlgorithm<AttributedVertex> layoutAlgorithm = builder.build();
// layout algorithm considers the size of vertices // layout algorithm considers the size of vertices
if (layoutAlgorithm instanceof VertexBoundsFunctionConsumer) { if (layoutAlgorithm instanceof VertexBoundsFunctionConsumer) {
((VertexBoundsFunctionConsumer<AttributedVertex>) layoutAlgorithm) ((VertexBoundsFunctionConsumer<AttributedVertex>) layoutAlgorithm)
.setVertexBoundsFunction(vertexBoundsFunction); .setVertexBoundsFunction(vertexBoundsFunction);
} }
// mincross layouts are 'layered'. put some bounds on the number of // mincross layouts are 'layered'. put some bounds on the number of
// iterations of the level cross function based on the size of the graph // iterations of the level cross function based on the size of the graph
// very large graphs do not improve enough to out-weigh the cost of // very large graphs do not improve enough to out-weigh the cost of
// repeated iterations // repeated iterations
if (layoutAlgorithm instanceof Layered) { if (layoutAlgorithm instanceof Layered) {
((Layered<AttributedVertex, AttributedEdge>) layoutAlgorithm) ((Layered<AttributedVertex, AttributedEdge>) layoutAlgorithm).setMaxLevelCrossFunction(
.setMaxLevelCrossFunction(g -> g -> Math.max(1, Math.min(10, 500 / g.vertexSet().size())));
Math.max(1, Math.min(10, 500 / g.vertexSet().size())));
} }
// tree layouts need a way to determine which vertices are roots // tree layouts need a way to determine which vertices are roots
// especially when the graph is not a DAG // especially when the graph is not a DAG
@ -108,22 +107,18 @@ class LayoutTransitionManager {
removePaintable(radialLayoutRings); removePaintable(radialLayoutRings);
removePaintable(balloonLayoutRings); removePaintable(balloonLayoutRings);
if (layoutAlgorithm instanceof BalloonLayoutAlgorithm) { if (layoutAlgorithm instanceof BalloonLayoutAlgorithm) {
balloonLayoutRings = balloonLayoutRings = new LayoutPaintable.BalloonRings<>(visualizationServer,
new LayoutPaintable.BalloonRings<>( (BalloonLayoutAlgorithm<AttributedVertex>) layoutAlgorithm);
visualizationServer,
(BalloonLayoutAlgorithm<AttributedVertex>) layoutAlgorithm);
visualizationServer.addPreRenderPaintable(balloonLayoutRings); visualizationServer.addPreRenderPaintable(balloonLayoutRings);
} }
if (layoutAlgorithm instanceof RadialTreeLayout) { if (layoutAlgorithm instanceof RadialTreeLayout) {
radialLayoutRings = radialLayoutRings = new LayoutPaintable.RadialRings<>(visualizationServer,
new LayoutPaintable.RadialRings<>( (RadialTreeLayout<AttributedVertex>) layoutAlgorithm);
visualizationServer, (RadialTreeLayout<AttributedVertex>) layoutAlgorithm);
visualizationServer.addPreRenderPaintable(radialLayoutRings); visualizationServer.addPreRenderPaintable(radialLayoutRings);
} }
// apply the layout algorithm // apply the layout algorithm
LayoutAlgorithmTransition.apply(visualizationServer, LayoutAlgorithmTransition.apply(visualizationServer, layoutAlgorithm);
layoutAlgorithm);
} }
private void removePaintable(VisualizationServer.Paintable paintable) { private void removePaintable(VisualizationServer.Paintable paintable) {
@ -134,15 +129,15 @@ class LayoutTransitionManager {
/** /**
* Supplies the {@code LayoutAlgorithm} to be used for the initial @{code Graph} visualization * Supplies the {@code LayoutAlgorithm} to be used for the initial @{code Graph} visualization
* @return * @return the algorithm
*/ */
@SuppressWarnings("unchecked")
public LayoutAlgorithm<AttributedVertex> getInitialLayoutAlgorithm() { public LayoutAlgorithm<AttributedVertex> getInitialLayoutAlgorithm() {
LayoutAlgorithm<AttributedVertex> initialLayoutAlgorithm = LayoutAlgorithm<AttributedVertex> initialLayoutAlgorithm =
layoutFunction.apply(LayoutAlgorithmNames.COMPACT_HIERACHICAL).build(); layoutFunction.apply(LayoutAlgorithmNames.COMPACT_HIERARCHICAL).build();
if (initialLayoutAlgorithm instanceof TreeLayout) { if (initialLayoutAlgorithm instanceof TreeLayout) {
((TreeLayout<AttributedVertex>) initialLayoutAlgorithm) ((TreeLayout<AttributedVertex>) initialLayoutAlgorithm).setRootPredicate(rootPredicate);
.setRootPredicate(rootPredicate);
} }
if (initialLayoutAlgorithm instanceof VertexBoundsFunctionConsumer) { if (initialLayoutAlgorithm instanceof VertexBoundsFunctionConsumer) {
((VertexBoundsFunctionConsumer<AttributedVertex>) initialLayoutAlgorithm) ((VertexBoundsFunctionConsumer<AttributedVertex>) initialLayoutAlgorithm)

View file

@ -26,7 +26,7 @@ public class LayoutAlgorithmNames {
public static final String FORCED_BALANCED = "Force Balanced"; public static final String FORCED_BALANCED = "Force Balanced";
public static final String FORCE_DIRECTED = "Force Directed"; public static final String FORCE_DIRECTED = "Force Directed";
public static final String CIRCLE = "Circle"; public static final String CIRCLE = "Circle";
public static final String COMPACT_HIERACHICAL = "Compact Hierarchical"; public static final String COMPACT_HIERARCHICAL = "Compact Hierarchical";
public static final String COMPACT_RADIAL = "Compact Radial"; public static final String COMPACT_RADIAL = "Compact Radial";
public static final String MIN_CROSS_TOP_DOWN = "Hierarchical MinCross Top Down"; public static final String MIN_CROSS_TOP_DOWN = "Hierarchical MinCross Top Down";
public static final String MIN_CROSS_LONGEST_PATH = "Hierarchical MinCross Longest Path"; public static final String MIN_CROSS_LONGEST_PATH = "Hierarchical MinCross Longest Path";
@ -44,7 +44,7 @@ public class LayoutAlgorithmNames {
//@formatter:on //@formatter:on
public static List<String> getLayoutAlgorithmNames() { public static List<String> getLayoutAlgorithmNames() {
return Arrays.asList(COMPACT_HIERACHICAL, HIERACHICAL, return Arrays.asList(COMPACT_HIERARCHICAL, HIERACHICAL,
COMPACT_RADIAL, MIN_CROSS_TOP_DOWN, MIN_CROSS_LONGEST_PATH, COMPACT_RADIAL, MIN_CROSS_TOP_DOWN, MIN_CROSS_LONGEST_PATH,
MIN_CROSS_NETWORK_SIMPLEX, MIN_CROSS_COFFMAN_GRAHAM, CIRCLE, MIN_CROSS_NETWORK_SIMPLEX, MIN_CROSS_COFFMAN_GRAHAM, CIRCLE,
VERT_MIN_CROSS_TOP_DOWN, VERT_MIN_CROSS_TOP_DOWN,