Beispiel #1
0
        private IEnumerable <ILayoutAction> CalculateAbsoluteLayout()
        {
            var newVertexCenters = AbsolutePositionCalculator.GetVertexCenters(
                _relativeLayoutCalculator.RelativeLayout, HorizontalGap, VerticalGap);

            var layoutActions = CreateLayoutActions(newVertexCenters);

            SaveCurrentPositions(newVertexCenters);
            return(layoutActions);
        }
Beispiel #2
0
        public IDictionary <ModelNodeId, Rect2D> Calculate(IEnumerable <IDiagramNode> nodes, IEnumerable <IDiagramConnector> connectors)
        {
            var diagramNodeToLayoutVertexMap    = new Map <ModelNodeId, DiagramNodeLayoutVertex>();
            var diagramConnectorToLayoutPathMap = new Map <ModelRelationshipId, LayoutPath>();

            var layoutVertices = nodes.Select(i => CreateLayoutVertex(i, diagramNodeToLayoutVertexMap)).OrderBy(i => i.DiagramNode.AddedAt).ThenBy(i => i.Name)
                                 .ToList();
            var layoutPaths = connectors.Select(i => CreateLayoutPath(i, diagramNodeToLayoutVertexMap, diagramConnectorToLayoutPathMap)).ToList();

            var relativeLayout         = RelativeLayoutCalculator.Calculate(layoutVertices, layoutPaths);
            var layoutVertexToPointMap = AbsolutePositionCalculator.GetVertexCenters(relativeLayout, HorizontalGap, VerticalGap);

            return(diagramNodeToLayoutVertexMap.ToDictionary(
                       i => i.Key,
                       i => Rect2D.CreateFromCenterAndSize(layoutVertexToPointMap.Get(i.Value), i.Value.Size)));
        }