コード例 #1
0
        public void ExecuteLayout(Type type, bool resize) {
            bool suspend = this.Suspended;
            if (!suspend) {
                this.SuspendEvents = true;
                this.Suspend();
            }

            // Create Layout Graph
            Graph graph = new Graph();
            graph.AddDiagram(this);

            //
            Layout layout = null;

            if (type == typeof(TreeLayout)) {
                TreeLayout treeLayout = new TreeLayout();
                treeLayout.Direction = TreeLayoutSettings.Default.Direction;
                treeLayout.LevelDistance = TreeLayoutSettings.Default.LevelDistance;
                treeLayout.OrthogonalLayoutStyle = TreeLayoutSettings.Default.OrthogonalLayoutStyle;
                treeLayout.RootSelection = TreeLayoutSettings.Default.RootSelection;
                treeLayout.SiblingDistance = TreeLayoutSettings.Default.SiblingDistance;
                treeLayout.SubtreeDistance = TreeLayoutSettings.Default.SubtreeDistance;
                treeLayout.TreeDistance = TreeLayoutSettings.Default.TreeDistance;
                layout = treeLayout;
            }
            else if (type == typeof(OrthogonalLayout)) {
                OrthogonalLayout orthogonalLayout = new OrthogonalLayout();
                orthogonalLayout.ConnectedComponentDistance = OrthogonalLayoutSettings.Default.ConnectedComponentDistance;
                orthogonalLayout.CrossingQuality = OrthogonalLayoutSettings.Default.CrossingQuality;
                orthogonalLayout.Distance = OrthogonalLayoutSettings.Default.Distance;
                orthogonalLayout.Overhang = OrthogonalLayoutSettings.Default.Overhang;
                layout = orthogonalLayout;
            }
            else if (type == typeof(HierarchicalLayout)) {
                HierarchicalLayout hierarchicalLayout = new HierarchicalLayout();
                hierarchicalLayout.ConnectedComponentDistance = HierarchicalLayoutSettings.Default.ConnectedComponentDistance;
                hierarchicalLayout.Direction = HierarchicalLayoutSettings.Default.Direction;
                hierarchicalLayout.LayerDistance = HierarchicalLayoutSettings.Default.LayerDistance;
                hierarchicalLayout.ObjectDistance = HierarchicalLayoutSettings.Default.ObjectDistance;
                hierarchicalLayout.RespectLayer = HierarchicalLayoutSettings.Default.RespectLayer;
                layout = hierarchicalLayout;
            }
            else if (type == typeof(ForceDirectedLayout)) {
                ForceDirectedLayout forceDirectedLayout = new ForceDirectedLayout();
                forceDirectedLayout.ConnectedComponentDistance = ForcedDirectLayoutSettings.Default.ConnectedComponentDistance;
                forceDirectedLayout.Quality = ForcedDirectLayoutSettings.Default.Quality;
                forceDirectedLayout.Tuning = ForcedDirectLayoutSettings.Default.TuningType;
                layout = forceDirectedLayout;
            }
            else if (type == typeof(CircularLayout)) {
                CircularLayout circularLayout = new CircularLayout();
                circularLayout.CircleDistance = CircularLayoutSettings.Default.CircleDistance;
                circularLayout.ConnectedComponentDistance = CircularLayoutSettings.Default.ConnectedComponentDistance;
                circularLayout.LayerDistance = CircularLayoutSettings.Default.LayerDistance;
                circularLayout.ObjectDistance = CircularLayoutSettings.Default.ObjectDistance;
                layout = circularLayout;
            }

            //
            if (layout != null) {
                // Do Layout
                layout.DoLayout(graph);

                // Apply if Layout Succeeded
                if (layout.Status == LayoutStatus.Success) {
                    // Resize Diagram
                    RectangleF rectangle = graph.TotalArea();
                    rectangle.Inflate(50, 50);
                    if (resize) {
                        this.DiagramSize = rectangle.Size.ToSize();
                    }
                    graph.ScaleToFit(this.DiagramSize);

                    // Apply Layout
                    graph.Apply(this);
                }
            }

            if (!suspend) {
                this.Resume();
                this.SuspendEvents = false;
                this.Refresh();
            }
        }
コード例 #2
0
        public void DoLayout()
        {
            Graph graph = new Graph();
            graph.AddDiagram(model1);

            HierarchicalLayout layout = new HierarchicalLayout();
            /*layout.ConnectedComponentDistance = 20;
            layout.LayerDistance = 40;
            layout.ObjectDistance = 20;*/

            layout.DoLayout(graph);

            if (layout != null && layout.Status == LayoutStatus.Success)
            {
                graph.ScaleToFit(model1.DiagramSize);
                graph.Apply();
            }
            model1.Resume();
            model1.Refresh();
            DrawEntityTypes();
        }
コード例 #3
0
        public void ExecuteLayout(Type type, bool resize)
        {
            bool suspend = this.Suspended;

            if (!suspend)
            {
                this.SuspendEvents = true;
                this.Suspend();
            }

            // Create Layout Graph
            Graph graph = new Graph();

            graph.AddDiagram(this);

            //
            Layout layout = null;

            if (type == typeof(TreeLayout))
            {
                TreeLayout treeLayout = new TreeLayout();
                treeLayout.Direction             = TreeLayoutSettings.Default.Direction;
                treeLayout.LevelDistance         = TreeLayoutSettings.Default.LevelDistance;
                treeLayout.OrthogonalLayoutStyle = TreeLayoutSettings.Default.OrthogonalLayoutStyle;
                treeLayout.RootSelection         = TreeLayoutSettings.Default.RootSelection;
                treeLayout.SiblingDistance       = TreeLayoutSettings.Default.SiblingDistance;
                treeLayout.SubtreeDistance       = TreeLayoutSettings.Default.SubtreeDistance;
                treeLayout.TreeDistance          = TreeLayoutSettings.Default.TreeDistance;
                layout = treeLayout;
            }
            else if (type == typeof(OrthogonalLayout))
            {
                OrthogonalLayout orthogonalLayout = new OrthogonalLayout();
                orthogonalLayout.ConnectedComponentDistance = OrthogonalLayoutSettings.Default.ConnectedComponentDistance;
                orthogonalLayout.CrossingQuality            = OrthogonalLayoutSettings.Default.CrossingQuality;
                orthogonalLayout.Distance = OrthogonalLayoutSettings.Default.Distance;
                orthogonalLayout.Overhang = OrthogonalLayoutSettings.Default.Overhang;
                layout = orthogonalLayout;
            }
            else if (type == typeof(HierarchicalLayout))
            {
                HierarchicalLayout hierarchicalLayout = new HierarchicalLayout();
                hierarchicalLayout.ConnectedComponentDistance = HierarchicalLayoutSettings.Default.ConnectedComponentDistance;
                hierarchicalLayout.Direction      = HierarchicalLayoutSettings.Default.Direction;
                hierarchicalLayout.LayerDistance  = HierarchicalLayoutSettings.Default.LayerDistance;
                hierarchicalLayout.ObjectDistance = HierarchicalLayoutSettings.Default.ObjectDistance;
                hierarchicalLayout.RespectLayer   = HierarchicalLayoutSettings.Default.RespectLayer;
                layout = hierarchicalLayout;
            }
            else if (type == typeof(ForceDirectedLayout))
            {
                ForceDirectedLayout forceDirectedLayout = new ForceDirectedLayout();
                forceDirectedLayout.ConnectedComponentDistance = ForcedDirectLayoutSettings.Default.ConnectedComponentDistance;
                forceDirectedLayout.Quality = ForcedDirectLayoutSettings.Default.Quality;
                forceDirectedLayout.Tuning  = ForcedDirectLayoutSettings.Default.TuningType;
                layout = forceDirectedLayout;
            }
            else if (type == typeof(CircularLayout))
            {
                CircularLayout circularLayout = new CircularLayout();
                circularLayout.CircleDistance             = CircularLayoutSettings.Default.CircleDistance;
                circularLayout.ConnectedComponentDistance = CircularLayoutSettings.Default.ConnectedComponentDistance;
                circularLayout.LayerDistance  = CircularLayoutSettings.Default.LayerDistance;
                circularLayout.ObjectDistance = CircularLayoutSettings.Default.ObjectDistance;
                layout = circularLayout;
            }

            //
            if (layout != null)
            {
                // Do Layout
                layout.DoLayout(graph);

                // Apply if Layout Succeeded
                if (layout.Status == LayoutStatus.Success)
                {
                    // Resize Diagram
                    RectangleF rectangle = graph.TotalArea();
                    rectangle.Inflate(50, 50);
                    if (resize)
                    {
                        this.DiagramSize = rectangle.Size.ToSize();
                    }
                    graph.ScaleToFit(this.DiagramSize);

                    // Apply Layout
                    graph.Apply(this);
                }
            }

            if (!suspend)
            {
                this.Resume();
                this.SuspendEvents = false;
                this.Refresh();
            }
        }