use of y.layout.hierarchic.IncrementalHierarchicLayouter in project binnavi by google.
the class CGraphDialogs method showGraphSettingsDialog.
/**
* Shows the graph settings dialog for a given graph.
*
* @param parent Parent window of the dialog.
* @param graph Graph whose settings are edited in the dialog.
*/
public static void showGraphSettingsDialog(final JFrame parent, final ZyGraph graph) {
final CGraphSettingsDialog dlg = new CGraphSettingsDialog(parent, "Graph Settings", graph.getSettings(), false, false);
dlg.setVisible(true);
if (!dlg.wasCanceled()) {
if (graph.getSettings().getLayoutSettings().getCurrentLayouter() instanceof CircularLayouter) {
graph.getSettings().getLayoutSettings().setDefaultGraphLayout(LayoutStyle.CIRCULAR);
} else if (graph.getSettings().getLayoutSettings().getCurrentLayouter() instanceof IncrementalHierarchicLayouter) {
graph.getSettings().getLayoutSettings().setDefaultGraphLayout(LayoutStyle.HIERARCHIC);
} else if (graph.getSettings().getLayoutSettings().getCurrentLayouter() instanceof OrthogonalLayouter) {
graph.getSettings().getLayoutSettings().setDefaultGraphLayout(LayoutStyle.ORTHOGONAL);
}
if (dlg.needsLayouting()) {
CGraphLayouter.refreshLayout(parent, graph);
}
}
}
use of y.layout.hierarchic.IncrementalHierarchicLayouter in project binnavi by google.
the class ZyGraphLayouter method alignNodesToTopLayer.
public static void alignNodesToTopLayer(final Graph2D graph, final CanonicMultiStageLayouter multiStageLayouter) {
if (multiStageLayouter instanceof HierarchicLayouter) {
final HierarchicLayouter layouter = (HierarchicLayouter) multiStageLayouter;
layouter.setLayeringStrategy(HierarchicLayouter.LAYERING_HIERARCHICAL_OPTIMAL);
final OrientationLayouter ol = (OrientationLayouter) layouter.getOrientationLayouter();
layouter.setDrawer(new AlignmentDrawer(layouter.getDrawer()));
graph.addDataProvider(AlignmentDrawer.NODE_ALIGNMENT_POINT_DPKEY, ol.getOrientation() == OrientationLayouter.TOP_TO_BOTTOM ? new AlignmentDrawer.TopAlignmentDataProvider() : new AlignmentDrawer.LeftAlignmentDataProvider());
} else if (multiStageLayouter instanceof IncrementalHierarchicLayouter) {
final IncrementalHierarchicLayouter layouter = (IncrementalHierarchicLayouter) multiStageLayouter;
layouter.setFromScratchLayeringStrategy(IncrementalHierarchicLayouter.LAYERING_STRATEGY_HIERARCHICAL_OPTIMAL);
// sets the alignment of the node
layouter.getNodeLayoutDescriptor().setLayerAlignment(0);
// within its layer (0 means top
// aligned with respect to the
// drawing direction).
}
}
use of y.layout.hierarchic.IncrementalHierarchicLayouter in project binnavi by google.
the class ZyGraphLayouter method createHierarchicalLayouter.
public static CanonicMultiStageLayouter createHierarchicalLayouter(final HierarchicStyle style, final long minLayerDist, final long minNodeDist, final long minEdgeDist, final long minNodeEdgeDist, final HierarchicOrientation orientation) {
Preconditions.checkNotNull(style, "Internal Error: Layout style can't be null");
Preconditions.checkArgument(minLayerDist >= 0, "Internal Error: Minimum layer distance can't be negative");
Preconditions.checkArgument(minNodeDist >= 0, "Internal Error: Minimum node distance can't be negative");
Preconditions.checkArgument(minEdgeDist >= 0, "Internal Error: Minimum edge distance can't be negative");
final IncrementalHierarchicLayouter layouter = new IncrementalHierarchicLayouter();
layouter.setLayoutMode(IncrementalHierarchicLayouter.LAYOUT_MODE_FROM_SCRATCH);
layouter.setConsiderNodeLabelsEnabled(true);
layouter.setRecursiveGroupLayeringEnabled(true);
layouter.setLayoutOrientation(orientation == HierarchicOrientation.HORIZONTAL ? OrientationLayouter.TOP_TO_BOTTOM : OrientationLayouter.LEFT_TO_RIGHT);
layouter.setBackloopRoutingEnabled(true);
final EdgeLayoutDescriptor edgeLayout = layouter.getEdgeLayoutDescriptor();
edgeLayout.setSourcePortOptimizationEnabled(true);
edgeLayout.setTargetPortOptimizationEnabled(true);
edgeLayout.setMinimumFirstSegmentLength(25);
edgeLayout.setMinimumLastSegmentLength(25);
final NodeLayoutDescriptor nodeLayout = layouter.getNodeLayoutDescriptor();
nodeLayout.setLayerAlignment(0.0);
final SelfLoopLayouter sll = new SelfLoopLayouter(layouter);
sll.setSmartSelfloopPlacementEnabled(true);
switch(style) {
case OCTLINEAR_OPTIMAL:
{
setStyle(IncrementalHierarchicLayouter.LAYERING_STRATEGY_HIERARCHICAL_OPTIMAL, RoutingStyle.EDGE_STYLE_OCTILINEAR, true, layouter, edgeLayout);
break;
}
case ORTHOGONAL_OPTIMAL:
{
setStyle(IncrementalHierarchicLayouter.LAYERING_STRATEGY_HIERARCHICAL_OPTIMAL, RoutingStyle.EDGE_STYLE_ORTHOGONAL, true, layouter, edgeLayout);
break;
}
case POLYLINE_OPTIMAL:
{
setStyle(IncrementalHierarchicLayouter.LAYERING_STRATEGY_HIERARCHICAL_OPTIMAL, RoutingStyle.EDGE_STYLE_POLYLINE, false, layouter, edgeLayout);
break;
}
case OCTLINEAR_TOPMOST:
{
setStyle(IncrementalHierarchicLayouter.LAYERING_STRATEGY_HIERARCHICAL_TOPMOST, RoutingStyle.EDGE_STYLE_OCTILINEAR, true, layouter, edgeLayout);
break;
}
case ORTHOGONAL_TOPMOST:
{
setStyle(IncrementalHierarchicLayouter.LAYERING_STRATEGY_HIERARCHICAL_TOPMOST, RoutingStyle.EDGE_STYLE_ORTHOGONAL, true, layouter, edgeLayout);
break;
}
case POLYLINE_TOPMOST:
{
setStyle(IncrementalHierarchicLayouter.LAYERING_STRATEGY_HIERARCHICAL_TOPMOST, RoutingStyle.EDGE_STYLE_POLYLINE, true, layouter, edgeLayout);
break;
}
case OCTLINEAR_TIGHT_TREE:
{
setStyle(IncrementalHierarchicLayouter.LAYERING_STRATEGY_HIERARCHICAL_TIGHT_TREE, RoutingStyle.EDGE_STYLE_OCTILINEAR, true, layouter, edgeLayout);
break;
}
case ORTHOGONAL_TIGHT_TREE:
{
setStyle(IncrementalHierarchicLayouter.LAYERING_STRATEGY_HIERARCHICAL_TIGHT_TREE, RoutingStyle.EDGE_STYLE_ORTHOGONAL, true, layouter, edgeLayout);
break;
}
case POLYLINE_TIGHT_TREE:
{
setStyle(IncrementalHierarchicLayouter.LAYERING_STRATEGY_HIERARCHICAL_TIGHT_TREE, RoutingStyle.EDGE_STYLE_POLYLINE, true, layouter, edgeLayout);
break;
}
case OCTLINEAR_BFS:
{
setStyle(IncrementalHierarchicLayouter.LAYERING_STRATEGY_BFS, RoutingStyle.EDGE_STYLE_OCTILINEAR, true, layouter, edgeLayout);
break;
}
case ORTHOGONAL_BFS:
{
setStyle(IncrementalHierarchicLayouter.LAYERING_STRATEGY_BFS, RoutingStyle.EDGE_STYLE_ORTHOGONAL, true, layouter, edgeLayout);
break;
}
case POLYLINE_BFS:
{
setStyle(IncrementalHierarchicLayouter.LAYERING_STRATEGY_BFS, RoutingStyle.EDGE_STYLE_POLYLINE, false, layouter, edgeLayout);
break;
}
default:
throw new IllegalStateException("Internal Error: Unknown layout style");
}
layouter.setMinimumLayerDistance(minLayerDist);
layouter.setNodeToNodeDistance(minNodeDist);
layouter.setNodeToEdgeDistance(minEdgeDist);
layouter.setEdgeToEdgeDistance(minNodeEdgeDist);
return layouter;
}
use of y.layout.hierarchic.IncrementalHierarchicLayouter in project binnavi by google.
the class ZyGraphLayouter method createIncrementalHierarchicalLayouter.
public static CanonicMultiStageLayouter createIncrementalHierarchicalLayouter(final boolean orthogonalEdgeRooting, final long minLayerDist, final long minNodeDist, final HierarchicOrientation orientation) {
final IncrementalHierarchicLayouter layouter = new IncrementalHierarchicLayouter();
final OrientationLayouter ol = (OrientationLayouter) layouter.getOrientationLayouter();
ol.setOrientation(orientation == HierarchicOrientation.HORIZONTAL ? OrientationLayouter.TOP_TO_BOTTOM : OrientationLayouter.LEFT_TO_RIGHT);
layouter.setMinimumLayerDistance(minLayerDist);
layouter.setNodeToNodeDistance(minNodeDist);
layouter.setEdgeToEdgeDistance(25);
layouter.setNodeToEdgeDistance(25);
layouter.setBackloopRoutingEnabled(true);
layouter.setSelfLoopLayouterEnabled(true);
// layouter.setParallelEdgeLayouterEnabled(true);
layouter.setOrthogonallyRouted(orthogonalEdgeRooting);
return layouter;
}
Aggregations