コード例 #1
0
 private void ApplyLayoutRecursive(
     [NotNull] GroupLayoutInfo groupLayoutInfo,
     [NotNull][ItemNotNull] ICollection <DiagramShapeEventBase> events,
     [NotNull] IDictionary <ModelNodeId, IDiagramNode> updatedNodes,
     [NotNull] IDictionary <ModelRelationshipId, IDiagramConnector> updatedConnectors)
 {
     ApplyNodeLayout(groupLayoutInfo.Boxes, events, updatedNodes, updatedConnectors);
     ApplyConnectorLayout(groupLayoutInfo.Lines, events, updatedConnectors);
 }
コード例 #2
0
 public GroupLayoutInfo CalculateAbsoluteLayout([NotNull] GroupLayoutInfo root)
 {
     return(CalculateAbsoluteLayoutRecursive(
                root,
                Point2D.Zero,
                Size2D.Zero,
                Rect2D.Zero,
                0));
 }
コード例 #3
0
        private IEnumerable <LineLayoutInfo> CreateDirectRoutes(
            [NotNull][ItemNotNull] IEnumerable <IDiagramConnector> connectors,
            [NotNull] IDiagram diagram,
            [NotNull] GroupLayoutInfo groupLayoutInfo)
        {
            var nodeRects       = diagram.Nodes.ToDictionary(i => i.Id, i => groupLayoutInfo.GetBoxById(i.ShapeId).Rect);
            var connectorRoutes = _crossLayoutGroupConnectorRoutingAlgorithm.Calculate(connectors, nodeRects);

            return(connectorRoutes.Select(i => new LineLayoutInfo(i.Key.ToShapeId(), i.Value)));
        }
コード例 #4
0
        public DiagramEvent ApplyLayout(GroupLayoutInfo diagramLayout)
        {
            var events            = new List <DiagramShapeEventBase>();
            var updatedNodes      = new Dictionary <ModelNodeId, IDiagramNode>();
            var updatedConnectors = new Dictionary <ModelRelationshipId, IDiagramConnector>();

            ApplyLayoutRecursive(diagramLayout, events, updatedNodes, updatedConnectors);

            var newDiagram = CreateInstance(Model, _nodes.SetItems(updatedNodes), _connectors.SetItems(updatedConnectors));

            return(DiagramEvent.Create(newDiagram, events));
        }
コード例 #5
0
        private GroupLayoutInfo CalculateAbsoluteLayoutRecursive(
            GroupLayoutInfo groupLayoutInfo,
            Point2D parentTopLeft,
            Size2D parentPayloadAreaSize,
            Rect2D parentChildrenAreaRect,
            double padding)
        {
            if (groupLayoutInfo == null)
            {
                return(null);
            }

            var childTranslateVector =
                parentTopLeft +
                new Point2D(0, parentPayloadAreaSize.Height) +
                new Point2D(padding, padding) +
                parentChildrenAreaRect.TopLeft;

            var absoluteBoxLayout = new List <BoxLayoutInfo>();

            foreach (var boxLayoutInfo in groupLayoutInfo.Boxes)
            {
                var boxTopLeft = boxLayoutInfo.TopLeft + childTranslateVector;

                var childGroup = CalculateAbsoluteLayoutRecursive(
                    boxLayoutInfo.ChildGroup,
                    boxTopLeft,
                    boxLayoutInfo.PayloadAreaSize,
                    boxLayoutInfo.ChildGroup?.Rect ?? Rect2D.Undefined,
                    _childrenAreaPadding);

                var absoluteBoxLayoutInfo = new BoxLayoutInfo(
                    boxLayoutInfo.ShapeId,
                    boxTopLeft,
                    boxLayoutInfo.PayloadAreaSize,
                    childGroup?.Rect.Size.WithMargin(_childrenAreaPadding) ?? Size2D.Zero,
                    childGroup);

                absoluteBoxLayout.Add(absoluteBoxLayoutInfo);
            }

            var absoluteLineLayout = groupLayoutInfo.Lines.Select(i => i.Translate(childTranslateVector));

            return(new GroupLayoutInfo(absoluteBoxLayout, absoluteLineLayout));
        }
コード例 #6
0
 public void ApplyLayout(GroupLayoutInfo diagramLayout)
 {
     MutateWithLockThenRaiseEvents(() => LatestDiagram.ApplyLayout(diagramLayout));
 }