コード例 #1
0
 /// <summary>
 /// Creates a new cluster with no minimum size within the specified parent cluster.  Clusters allow creating a subset of
 /// nodes that must be within a distinct rectangle.
 /// </summary>
 /// <param name="parentCluster">The cluster this cluster is to be a member of; if null, this is the root of a
 ///                             new hierarchy, otherwise must be non-NULL (perhaps DefaultClusterHierarchy).</param>
 /// <param name="userData">An object that is passed through.</param>
 /// <param name="openBorderInfo">Information about the Left (if isHorizontal, else Top) border.</param>
 /// <param name="closeBorderInfo">Information about the Right (if isHorizontal, else Bottom) border.</param>
 /// <param name="openBorderInfoP">Same as OpenBorder, but in the secondary (Perpendicular) axis.</param>
 /// <param name="closeBorderInfoP">Same as CloseBorder, but in the secondary (Perpendicular) axis.</param>
 /// <returns>The new Cluster.</returns>
 ///
 public OverlapRemovalCluster AddCluster(OverlapRemovalCluster parentCluster, object userData,
                                         BorderInfo openBorderInfo, BorderInfo closeBorderInfo,
                                         BorderInfo openBorderInfoP, BorderInfo closeBorderInfoP)
 {
     return(AddCluster(parentCluster, userData, 0.0 /*minSize*/, 0.0 /*minSizeP*/,
                       openBorderInfo, closeBorderInfo, openBorderInfoP, closeBorderInfoP));
 }
コード例 #2
0
 /// <summary>
 /// Releases the lock on all four borders
 /// </summary>
 public void Unlock()
 {
     LeftBorderInfo   = new BorderInfo(LeftBorderInfo.InnerMargin);
     RightBorderInfo  = new BorderInfo(RightBorderInfo.InnerMargin);
     TopBorderInfo    = new BorderInfo(TopBorderInfo.InnerMargin);
     BottomBorderInfo = new BorderInfo(BottomBorderInfo.InnerMargin);
 }
コード例 #3
0
        /// <summary>
        /// Creates a lock on all four borders
        /// </summary>
        /// <param name="left"></param>
        /// <param name="right"></param>
        /// <param name="top"></param>
        /// <param name="bottom"></param>
        public void Lock(double left, double right, double top, double bottom)
        {
            double weight = 1e4;

            LeftBorderInfo   = new BorderInfo(LeftBorderInfo.InnerMargin, left, weight);
            RightBorderInfo  = new BorderInfo(RightBorderInfo.InnerMargin, right, weight);
            TopBorderInfo    = new BorderInfo(TopBorderInfo.InnerMargin, top, weight);
            BottomBorderInfo = new BorderInfo(BottomBorderInfo.InnerMargin, bottom, weight);
        }
コード例 #4
0
        /// <summary>
        /// Creates a new cluster with a minimum size within the specified parent cluster.  Clusters allow creating a subset of
        /// nodes that must be within a distinct rectangle.
        /// </summary>
        /// <param name="parentCluster">The cluster this cluster is to be a member of; if null, this is the root of a
        ///                             new hierarchy, otherwise must be non-NULL (perhaps DefaultClusterHierarchy).</param>
        /// <param name="userData">An object that is passed through.</param>
        /// <param name="minimumSize">Minimum cluster size along the primary axis.</param>
        /// <param name="minimumSizeP">Minimum cluster size along the perpendicular axis.</param>
        /// <param name="openBorderInfo">Information about the Left (if isHorizontal, else Top) border.</param>
        /// <param name="closeBorderInfo">Information about the Right (if isHorizontal, else Bottom) border.</param>
        /// <param name="openBorderInfoP">Same as OpenBorder, but in the secondary (Perpendicular) axis.</param>
        /// <param name="closeBorderInfoP">Same as CloseBorder, but in the secondary (Perpendicular) axis.</param>
        /// <returns>The new Cluster.</returns>
        ///
        public OverlapRemovalCluster AddCluster(OverlapRemovalCluster parentCluster, object userData,
                                                double minimumSize, double minimumSizeP,
                                                BorderInfo openBorderInfo, BorderInfo closeBorderInfo,
                                                BorderInfo openBorderInfoP, BorderInfo closeBorderInfoP)
        {
            var newCluster = new OverlapRemovalCluster(this.nextNodeId, parentCluster, userData, minimumSize, minimumSizeP,
                                                       this.Padding, this.PaddingP, this.ClusterPadding, this.ClusterPaddingP,
                                                       openBorderInfo, closeBorderInfo, openBorderInfoP, closeBorderInfoP);

            this.nextNodeId += OverlapRemovalCluster.NumInternalNodes;
            if (null == parentCluster)
            {
                this.clusterHierarchies.Add(newCluster);
            }
            else
            {
                // @@DCR: Enforce that Clusters live in only one hierarchy - they can have only one parent, so add a
                //          Cluster.parentCluster to enforce this.
                parentCluster.AddNode(newCluster);
            }
            return(newCluster);
        }
コード例 #5
0
 void WriteBorderInfo(GeometryToken token, BorderInfo borderInfo) {
     WriteStartElement(token);
     WriteAttribute(GeometryToken.InnerMargin, borderInfo.InnerMargin);
     WriteAttribute(GeometryToken.FixedPosition, borderInfo.FixedPosition);
     WriteAttribute(GeometryToken.Weight, borderInfo.Weight);
     WriteEndElement();
 }
コード例 #6
0
        private void AddOlapClusters(ConstraintGenerator generator, OverlapRemovalCluster olapParentCluster, Cluster incClus, InitialCenterDelegateType nodeCenter)
        {
            LayoutAlgorithmSettings settings = clusterSettings(incClus);
            double nodeSeparationH = settings.NodeSeparation;
            double nodeSeparationV = settings.NodeSeparation + 1e-4;
            double innerPaddingH = settings.ClusterMargin;
            double innerPaddingV = settings.ClusterMargin + 1e-4;

            // Creates the OverlapRemoval (Olap) Cluster/Node objects for our FastIncrementalLayout (FIL) objects.
            // If !isHorizontal this overwrites the Olap members of the Incremental.Clusters and Msagl.Nodes.

            // First create the olapCluster for the current incCluster.  If olapParentCluster is null, then
            // incCluster is the root of a new hierarchy.
            RectangularClusterBoundary rb = incClus.RectangularBoundary;
            if (IsHorizontal)
            {
                rb.olapCluster = generator.AddCluster(
                    olapParentCluster,
                    incClus /* userData */,
                    rb.MinWidth,
                    rb.MinHeight,
                    rb.LeftBorderInfo,
                    rb.RightBorderInfo,
                    rb.BottomBorderInfo,
                    rb.TopBorderInfo);
                rb.olapCluster.NodePadding = nodeSeparationH;
                rb.olapCluster.NodePaddingP = nodeSeparationV;
                rb.olapCluster.ClusterPadding = innerPaddingH;
                rb.olapCluster.ClusterPaddingP = innerPaddingV;
            }
            else
            {
                var postXLeftBorderInfo = new BorderInfo(rb.LeftBorderInfo.InnerMargin, rb.Rect.Left, rb.LeftBorderInfo.Weight);
                var postXRightBorderInfo = new BorderInfo(rb.RightBorderInfo.InnerMargin, rb.Rect.Right, rb.RightBorderInfo.Weight);
                rb.olapCluster = generator.AddCluster(
                    olapParentCluster,
                    incClus /* userData */,
                    rb.MinHeight,
                    rb.MinWidth,
                    rb.BottomBorderInfo,
                    rb.TopBorderInfo,
                    postXLeftBorderInfo,
                    postXRightBorderInfo);
                rb.olapCluster.NodePadding = nodeSeparationV;
                rb.olapCluster.NodePaddingP = nodeSeparationH;
                rb.olapCluster.ClusterPadding = innerPaddingV;
                rb.olapCluster.ClusterPaddingP = innerPaddingH;
            }
            rb.olapCluster.TranslateChildren = rb.GenerateFixedConstraints;
            // Note: Incremental.Cluster always creates child List<Cluster|Node> so we don't have to check for null here.
            // Add our child nodes.
            foreach (var filNode in incClus.Nodes)
            {
                AddOlapNode(generator, rb.olapCluster, (FiNode)filNode.AlgorithmData, nodeCenter);
            }

            // Now recurse through all child clusters.
            foreach (var incChildClus in incClus.Clusters)
            {
                AddOlapClusters(generator, rb.olapCluster, incChildClus, nodeCenter);
            }
        }
 /// <summary>
 /// Releases the lock on all four borders
 /// </summary>
 public void Unlock() {
     LeftBorderInfo = new BorderInfo(LeftBorderInfo.InnerMargin);
     RightBorderInfo = new BorderInfo(RightBorderInfo.InnerMargin);
     TopBorderInfo = new BorderInfo(TopBorderInfo.InnerMargin);
     BottomBorderInfo = new BorderInfo(BottomBorderInfo.InnerMargin);
 }
 /// <summary>
 /// Creates a lock on all four borders
 /// </summary>
 /// <param name="left"></param>
 /// <param name="right"></param>
 /// <param name="top"></param>
 /// <param name="bottom"></param>
 public void Lock(double left, double right, double top, double bottom) {
     double weight = 1e4;
     LeftBorderInfo = new BorderInfo(LeftBorderInfo.InnerMargin, left, weight);
     RightBorderInfo = new BorderInfo(RightBorderInfo.InnerMargin, right, weight);
     TopBorderInfo = new BorderInfo(TopBorderInfo.InnerMargin, top, weight);
     BottomBorderInfo = new BorderInfo(BottomBorderInfo.InnerMargin, bottom, weight);
 }
コード例 #9
0
        // end Load()

        private static BorderInfo ParseBorderInfo(string strDir, string strLine, int lineNumber)
        {
            Match m = TestFileStrings.ParseClusterBorder.Match(strLine);
            if (m.Success)
            {
                string strRgxDir = m.Groups["dir"].ToString();
                if (strRgxDir != strDir)
                {
                    Validate.Fail(string.Format("Out-of-sequence CLUSTER Border line {0}: {1}", lineNumber, strLine));
                }
            }
            else
            {
                Validate.Fail(string.Format("Unparsable CLUSTER Border line {0}: {1}", lineNumber, strLine));
            }

            var bi = new BorderInfo
                { 
                    InnerMargin = double.Parse(m.Groups["margin"].ToString()),
                    FixedPosition = BorderInfo.NoFixedPosition,
                    Weight = BorderInfo.DefaultFreeWeight
                };
            string strFixedPos = m.Groups["fixedpos"].ToString();
            if (0 == string.Compare("Fixed", strFixedPos, StringComparison.OrdinalIgnoreCase))
            {
                // Slightly hacky; just set this to a non-NaN and we'll compute the value from the
                // variables that go into it.
                bi.FixedPosition = 0.0;
            }
            var weight = double.Parse(m.Groups["weight"].ToString());
            if (0.0 != weight)
            {
                bi.Weight = weight;
            }
            return bi;
        }
コード例 #10
0
 internal OverlapRemovalCluster(uint id, OverlapRemovalCluster parentCluster,
                 object userData, double minSize, double minSizeP,
                 double nodePadding, double nodePaddingP, double clusterPadding, double clusterPaddingP,
                 BorderInfo openBorderInfo, BorderInfo closeBorderInfo,
                 BorderInfo openBorderInfoP, BorderInfo closeBorderInfoP)
     : base(id, userData)
 {
     this.MinimumSize = minSize;
     this.MinimumSizeP = minSizeP;
     this.NodePadding = nodePadding;
     this.NodePaddingP = nodePaddingP;
     this.ClusterPadding = clusterPadding;
     this.ClusterPaddingP = clusterPaddingP;
     this.ParentCluster = parentCluster;
     this.OpenBorderInfo = openBorderInfo;
     this.OpenBorderInfo.EnsureWeight();
     this.CloseBorderInfo = closeBorderInfo;
     this.CloseBorderInfo.EnsureWeight();
     this.OpenBorderInfoP = openBorderInfoP;
     this.OpenBorderInfoP.EnsureWeight();
     this.CloseBorderInfoP = closeBorderInfoP;
     this.CloseBorderInfoP.EnsureWeight();
     CreateBorderNodes();
 }
コード例 #11
0
 BorderInfo ReadBorderInfo(GeometryToken token) {
     XmlRead();
     CheckToken(token);
     var bi = new BorderInfo {
         InnerMargin = GetDoubleAttribute(GeometryToken.InnerMargin),
         FixedPosition = GetDoubleAttribute(GeometryToken.FixedPosition),
         Weight = GetDoubleAttribute(GeometryToken.Weight)
     };
     return bi;
 }
コード例 #12
0
 /// <summary>
 /// Creates a new cluster with a minimum size within the specified parent cluster.  Clusters allow creating a subset of
 /// nodes that must be within a distinct rectangle.
 /// </summary>
 /// <param name="parentCluster">The cluster this cluster is to be a member of; if null, this is the root of a
 ///                             new hierarchy, otherwise must be non-NULL (perhaps DefaultClusterHierarchy).</param>
 /// <param name="userData">An object that is passed through.</param>
 /// <param name="minimumSize">Minimum cluster size along the primary axis.</param>
 /// <param name="minimumSizeP">Minimum cluster size along the perpendicular axis.</param>
 /// <param name="openBorderInfo">Information about the Left (if isHorizontal, else Top) border.</param>
 /// <param name="closeBorderInfo">Information about the Right (if isHorizontal, else Bottom) border.</param>
 /// <param name="openBorderInfoP">Same as OpenBorder, but in the secondary (Perpendicular) axis.</param>
 /// <param name="closeBorderInfoP">Same as CloseBorder, but in the secondary (Perpendicular) axis.</param>
 /// <returns>The new Cluster.</returns>
 /// 
 public OverlapRemovalCluster AddCluster(OverlapRemovalCluster parentCluster, object userData,
                     double minimumSize, double minimumSizeP,
                     BorderInfo openBorderInfo, BorderInfo closeBorderInfo,
                     BorderInfo openBorderInfoP, BorderInfo closeBorderInfoP)
 {
     var newCluster = new OverlapRemovalCluster(this.nextNodeId, parentCluster, userData, minimumSize, minimumSizeP,
                     this.Padding, this.PaddingP, this.ClusterPadding, this.ClusterPaddingP,
                     openBorderInfo, closeBorderInfo, openBorderInfoP, closeBorderInfoP);
     this.nextNodeId += OverlapRemovalCluster.NumInternalNodes;
     if (null == parentCluster)
     {
         this.clusterHierarchies.Add(newCluster);
     }
     else
     {
         // @@DCR: Enforce that Clusters live in only one hierarchy - they can have only one parent, so add a 
         //          Cluster.parentCluster to enforce this.
         parentCluster.AddNode(newCluster);
     }
     return newCluster;
 }
コード例 #13
0
 /// <summary>
 /// Creates a new cluster with no minimum size within the specified parent cluster.  Clusters allow creating a subset of
 /// nodes that must be within a distinct rectangle.
 /// </summary>
 /// <param name="parentCluster">The cluster this cluster is to be a member of; if null, this is the root of a
 ///                             new hierarchy, otherwise must be non-NULL (perhaps DefaultClusterHierarchy).</param>
 /// <param name="userData">An object that is passed through.</param>
 /// <param name="openBorderInfo">Information about the Left (if isHorizontal, else Top) border.</param>
 /// <param name="closeBorderInfo">Information about the Right (if isHorizontal, else Bottom) border.</param>
 /// <param name="openBorderInfoP">Same as OpenBorder, but in the secondary (Perpendicular) axis.</param>
 /// <param name="closeBorderInfoP">Same as CloseBorder, but in the secondary (Perpendicular) axis.</param>
 /// <returns>The new Cluster.</returns>
 /// 
 public OverlapRemovalCluster AddCluster(OverlapRemovalCluster parentCluster, object userData,
                     BorderInfo openBorderInfo, BorderInfo closeBorderInfo,
                     BorderInfo openBorderInfoP, BorderInfo closeBorderInfoP)
 {
     return AddCluster(parentCluster, userData, 0.0 /*minSize*/, 0.0 /*minSizeP*/,
                     openBorderInfo, closeBorderInfo, openBorderInfoP, closeBorderInfoP);
 }