Exemple #1
0
        /// <inheritdoc />
        protected override ILayoutAlgorithm CreateConfiguredLayout(GraphControl graphControl)
        {
            var layout = new SeriesParallelLayout();

            layout.GeneralGraphHandling = true;

            layout.LayoutOrientation = OrientationItem;

            layout.VerticalAlignment = VerticalAlignmentItem;
            layout.FromSketchMode    = UseDrawingAsSketchItem;

            layout.MinimumNodeToNodeDistance = MinimumNodeToNodeDistanceItem;
            layout.MinimumNodeToEdgeDistance = MinimumNodeToEdgeDistanceItem;
            layout.MinimumEdgeToEdgeDistance = MinimumEdgeToEdgeDistanceItem;

            layout.ConsiderNodeLabels     = ConsiderNodeLabelsItem;
            layout.IntegratedEdgeLabeling = PlaceEdgeLabelsItem;

            var portAssignment = (DefaultPortAssignment)layout.DefaultPortAssignment;

            portAssignment.Mode      = PortStyleItem;
            portAssignment.ForkStyle = RouteEdgesInFlowDirectionItem ? ForkStyle.OutsideNode : ForkStyle.AtNode;

            layout.RoutingStyle = RoutingStyleItem;
            if (RoutingStyleItem == RoutingStyle.Octilinear)
            {
                layout.PreferredOctilinearSegmentLength = PreferredOctilinearSegmentLengthItem;
            }
            else if (RoutingStyleItem == RoutingStyle.Polyline)
            {
                layout.MinimumPolylineSegmentLength = MinimumPolylineSegmentLengthItem;
                layout.MinimumSlope = MinimumSlopeItem;
            }

            if (RoutingStyleNonSeriesParallelItem == NonSeriesParallelRoutingStyle.Orthogonal)
            {
                var edgeRouter = new EdgeRouter {
                    Rerouting = true,
                    Scope     = Scope.RouteAffectedEdges
                };
                layout.NonSeriesParallelEdgeRouter = edgeRouter;
                layout.NonSeriesParallelEdgesDpKey = edgeRouter.AffectedEdgesDpKey;
            }
            else if (RoutingStyleNonSeriesParallelItem == NonSeriesParallelRoutingStyle.Organic)
            {
                var edgeRouter = new OrganicEdgeRouter();
                layout.NonSeriesParallelEdgeRouter = edgeRouter;
                layout.NonSeriesParallelEdgesDpKey = OrganicEdgeRouter.AffectedEdgesDpKey;
            }
            else if (RoutingStyleNonSeriesParallelItem == NonSeriesParallelRoutingStyle.Straight)
            {
                var edgeRouter = new StraightLineEdgeRouter {
                    Scope = Scope.RouteAffectedEdges
                };
                layout.NonSeriesParallelEdgeRouter = edgeRouter;
                layout.NonSeriesParallelEdgesDpKey = edgeRouter.AffectedEdgesDpKey;
            }

            var edgeLayoutDescriptor = layout.DefaultEdgeLayoutDescriptor;

            edgeLayoutDescriptor.MinimumFirstSegmentLength = MinimumFirstSegmentLengthItem;
            edgeLayoutDescriptor.MinimumLastSegmentLength  = MinimumLastSegmentLengthItem;
            edgeLayoutDescriptor.MinimumLength             = MinimumEdgeLengthItem;

            return(layout);
        }
Exemple #2
0
        protected override void ConfigureLayout()
        {
            OptionGroup generalGroup = Handler.GetGroupByName(GENERAL);

            SeriesParallelLayout series = new SeriesParallelLayout {
                GeneralGraphHandling = true
            };

            series.LayoutOrientation = orientations[(string)Handler.GetValue(GENERAL, ORIENTATION)];

            series.VerticalAlignment = verticalAlignments[(string)Handler.GetValue(GENERAL, VERTICAL_ALIGNMENT)];

            RoutingStyle routingStyle = routingStyles[(string)Handler.GetValue(EDGE_SETTINGS, ROUTING_STYLE)];

            series.RoutingStyle = routingStyle;
            switch (routingStyle)
            {
            case RoutingStyle.Octilinear:
                series.PreferredOctilinearSegmentLength =
                    (double)Handler.GetValue(EDGE_SETTINGS, PREFERRED_OCTILINEAR_SEGMENT_LENGTH);
                break;

            case RoutingStyle.Polyline:
                series.MinimumPolylineSegmentLength = (double)Handler.GetValue(EDGE_SETTINGS, POLYLINE_DISTANCE);
                series.MinimumSlope = (double)Handler.GetValue(EDGE_SETTINGS, MINIMUM_SLOPE);
                break;
            }


            ((DefaultPortAssignment)series.DefaultPortAssignment).ForkStyle =
                (bool)Handler.GetValue(EDGE_SETTINGS, ROUTE_IN_FLOW)
              ? ForkStyle.OutsideNode
              : ForkStyle.AtNode;
            series.FromSketchMode = (bool)Handler.GetValue(GENERAL, FROM_SKETCH_MODE);


            string nonSeriesParallelRoutingStyle =
                (string)Handler.GetValue(GENERAL, ROUTING_STYLE_FOR_NON_SERIES_PARALLEL_EDGES);

            switch (nonSeriesParallelRoutingStyle)
            {
            case ROUTE_ORGANIC:
                series.NonSeriesParallelEdgeRouter = new OrganicEdgeRouter();
                series.NonSeriesParallelEdgesDpKey = OrganicEdgeRouter.AffectedEdgesDpKey;
                break;

            case ROUTE_ORTHOGONAL:
                var orthogonal = new EdgeRouter();
                orthogonal.Rerouting = true;
                orthogonal.Scope     = Scope.RouteAffectedEdges;
                series.NonSeriesParallelEdgeRouter = orthogonal;
                series.NonSeriesParallelEdgesDpKey = orthogonal.AffectedEdgesDpKey;
                break;

            case ROUTE_STRAIGHTLINE:
                var straightLine = new StraightLineEdgeRouter();
                straightLine.Scope = Scope.RouteAffectedEdges;
                series.NonSeriesParallelEdgeRouter = straightLine;
                series.NonSeriesParallelEdgesDpKey = straightLine.AffectedEdgesDpKey;
                break;
            }

            series.MinimumNodeToNodeDistance = (double)Handler.GetValue(GENERAL, NODE_TO_NODE_DISTANCE);
            series.MinimumNodeToEdgeDistance = (double)Handler.GetValue(GENERAL, NODE_TO_EDGE_DISTANCE);
            series.MinimumEdgeToEdgeDistance = (double)Handler.GetValue(GENERAL, EDGE_TO_EDGE_DISTANCE);

            Object portStyle = Handler.GetValue(EDGE_SETTINGS, PORT_STYLE);

            if (CENTER_PORTS == portStyle)
            {
                ((DefaultPortAssignment)series.DefaultPortAssignment).Mode = PortAssignmentMode.Center;
            }
            else
            {
                ((DefaultPortAssignment)series.DefaultPortAssignment).Mode = PortAssignmentMode.Distributed;
            }
            EdgeLayoutDescriptor eld = series.DefaultEdgeLayoutDescriptor;

            eld.MinimumFirstSegmentLength = (double)Handler.GetValue(EDGE_SETTINGS, MINIMUM_FIRST_SEGMENT_LENGTH);
            eld.MinimumLastSegmentLength  = (double)Handler.GetValue(EDGE_SETTINGS, MINIMUM_LAST_SEGMENT_LENGTH);
            eld.MinimumLength             = (double)Handler.GetValue(EDGE_SETTINGS, MINIMUM_EDGE_LENGTH);

            series.ConsiderNodeLabels     = (bool)Handler.GetValue(GENERAL, CONSIDER_NODE_LABELS);
            series.IntegratedEdgeLabeling = (bool)Handler.GetValue(GENERAL, INTEGRATED_EDGE_LABELING);
            LayoutAlgorithm = series;
        }