private void ApplyOptions(CompactOrthogonalLayout layout) { OptionGroup topLevelGroup = Handler.GetGroupByName(TOP_LEVEL); IOptionItem gridItem = topLevelGroup.GetItemByName(GRID); layout.GridSpacing = (int)gridItem.Value; double ar = (double)topLevelGroup.GetItemByName(ASPECT_RATIO).Value; // this needs to be done as a final step since it will reconfigure // layout stages which support aspect ratio accordingly layout.AspectRatio = ar; }
/// <summary> /// configures the layout algorithm according to the settings of the option handler. /// </summary> protected override void ConfigureLayout() { CompactOrthogonalLayout compactOrthogonal = new CompactOrthogonalLayout(); compactOrthogonal.InterEdgeRouter = ConfigureInterEdgeRouter(); compactOrthogonal.PartitionPlacer = ConfigurePartitionPlacer(); ApplyOptions((OrthogonalLayout)compactOrthogonal.CoreLayout); ApplyOptions(compactOrthogonal); LayoutAlgorithm = new HideGroupsStage(compactOrthogonal) { HidingEmptyGroupNodes = false }; }
/// <summary> /// Creates the core layouts and populates the layouts box /// </summary> private void InitializeCoreLayouts() { coreLayouts = new Dictionary <string, ILayoutAlgorithm>(); coreLayouts["Hierarchic"] = new HierarchicLayout { ConsiderNodeLabels = true, IntegratedEdgeLabeling = true, OrthogonalRouting = true }; coreLayouts["Circular"] = new CircularLayout(); coreLayouts["Compact Orthogonal"] = new CompactOrthogonalLayout(); coreLayouts["Organic"] = new OrganicLayout { MinimumNodeDistance = 10, Deterministic = true }; coreLayouts["Orthogonal"] = new OrthogonalLayout(); coreLayoutComboBox.ItemsSource = coreLayouts.Keys; coreLayoutComboBox.SelectedIndex = 0; }
/// <summary> /// sets up the option handler for specifying the layout parameters. /// </summary> protected override void SetupHandler() { // use an instance of the layout as a defaults provider CompactOrthogonalLayout layout = new CompactOrthogonalLayout(); var topLevelGroup = Handler.AddGroup(TOP_LEVEL); topLevelGroup.SetAttribute(TableEditorFactory.RENDERING_HINTS_ATTRIBUTE, (int)TableEditorFactory.RenderingHints.Invisible); topLevelGroup.SetAttribute(DefaultEditorFactory.RENDERING_HINTS_ATTRIBUTE, (int)DefaultEditorFactory.RenderingHints.Invisible); OrthogonalLayout cl = (OrthogonalLayout)layout.CoreLayout; topLevelGroup.AddList(ORTHOGONAL_LAYOUT_STYLE, new [] { NORMAL, NORMAL_TREE, FIXED_BOX_NODES, FIXED_MIXED }, str2styles[cl.LayoutStyle]); topLevelGroup.AddList(PLACEMENT_STRATEGY, new[] { STYLE_ROWS, STYLE_PACKED_COMPACT_RECTANGLE }, str2componentStyles[ComponentArrangementStyles.PackedCompactRectangle]); topLevelGroup.AddDouble(ASPECT_RATIO, layout.AspectRatio); topLevelGroup.AddInt(GRID, layout.GridSpacing, 1, int.MaxValue); OrthogonalPatternEdgeRouter oper = new OrthogonalPatternEdgeRouter(); IOptionItem bendCostOptionItem = topLevelGroup.AddDouble(BEND_COST, oper.BendCost); IOptionItem nodeCrossingCostOptionItem = topLevelGroup.AddDouble(NODE_CROSSING_COST, oper.NodeCrossingCost); IOptionItem edgeCrossingCostOptionItem = topLevelGroup.AddDouble(EDGE_CROSSING_COST, oper.EdgeCrossingCost); IOptionItem minimumDistanceOptionItem = topLevelGroup.AddDouble(MINIMUM_DISTANCE, oper.MinimumDistance); IOptionItem pathFinderOptionItem = topLevelGroup.AddList(PATH_FINDER, PATH_FINDER_ENUM, ORTHOGONAL_SHORTESTPATH_PATH_FINDER); ConstraintManager cm = new ConstraintManager(Handler); cm.SetEnabledOnValueEquals(pathFinderOptionItem, ORTHOGONAL_PATTERN_PATH_FINDER, bendCostOptionItem); cm.SetEnabledOnValueEquals(pathFinderOptionItem, ORTHOGONAL_PATTERN_PATH_FINDER, nodeCrossingCostOptionItem); cm.SetEnabledOnValueEquals(pathFinderOptionItem, ORTHOGONAL_PATTERN_PATH_FINDER, edgeCrossingCostOptionItem); cm.SetEnabledOnValueEquals(pathFinderOptionItem, ORTHOGONAL_PATTERN_PATH_FINDER, minimumDistanceOptionItem); topLevelGroup.AddBool(ROUTE_ALL_EDGES, !layout.InterEdgeRouter.RouteInterEdgesOnly); }