Beispiel #1
0
            internal void Insert(OverlapRemovalNode node)
            {
                Debug.Assert(null == this.nodeTree.Find(node), "node already exists in the rbtree");

                // RBTree's internal operations on insert/remove etc. mean the node can't cache the
                // RBNode returned by insert(); instead we must do find() on each call.
                this.nodeTree.Insert(node);
            }
        /// <summary>
        /// Add a new variable to the ConstraintGenerator.
        /// </summary>
        /// <param name="initialCluster">The cluster this node is to be a member of.  It may not be null; pass
        ///                     DefaultClusterHierarchy to create a node at the lowest level.  Subsequently a node
        ///                     may be added to additional clusters, but only to one cluster per hierarchy.</param>
        /// <param name="userData">An object that is passed through.</param>
        /// <param name="position">Position of the node in the primary axis; if isHorizontal, it contains horizontal
        ///                     position and size, else it contains vertical position and size.</param>
        /// <param name="size">Size of the node in the primary axis.</param>
        /// <param name="positionP">Position of the node in the secondary (Perpendicular) axis.</param>
        /// <param name="sizeP">Size of the node in the secondary (Perpendicular) axis.</param>
        /// <param name="weight">Weight of the node (indicates how freely it should move).</param>
        /// <returns>The created node.</returns>
        public OverlapRemovalNode AddNode(OverlapRemovalCluster initialCluster, object userData, double position,
                                          double positionP, double size, double sizeP, double weight)
        {
            ValidateArg.IsNotNull(initialCluster, "initialCluster");
            // @@PERF: Currently every node will have at least one constraint generated if there are any
            // other nodes along its line, regardless of whether the perpendicular coordinates result in overlap.
            // It might be worthwhile to add a check to avoid constraint generation in the case that there cannot
            // be such an overlap on a line, or if the nodes are separated by some amount of distance.
            Debug.Assert(null != initialCluster, "initialCluster must not be null");
            var nodNew = new OverlapRemovalNode(this.nextNodeId++, userData, position, positionP, size, sizeP, weight);

            initialCluster.AddNode(nodNew);
            return(nodNew);
        }
        public void AddNodeToCluster(OverlapRemovalCluster cluster, OverlapRemovalNode node)
        {
            // Node derives from Cluster so make sure we don't have this - the only way to create
            // cluster hierarchies is by AddCluster.
            ValidateArg.IsNotNull(cluster, "cluster");
            if (node is OverlapRemovalCluster)
            {
                throw new InvalidOperationException(
#if DEBUG
                          "Argument 'node' must not be a Cluster"
#endif // DEBUG
                          );
            }
            cluster.AddNode(node);
        }
Beispiel #4
0
            internal OverlapRemovalNode NextRight(OverlapRemovalNode node)
            {
                var succ = this.nodeTree.Next(this.nodeTree.Find(node));

                return((null != succ) ? succ.Item : null);
            }
Beispiel #5
0
            internal OverlapRemovalNode NextLeft(OverlapRemovalNode node)
            {
                var pred = this.nodeTree.Previous(this.nodeTree.Find(node));

                return((null != pred) ? pred.Item : null);
            }
Beispiel #6
0
 internal void Remove(OverlapRemovalNode node)
 {
     this.nodeTree.Remove(node);
 }
 internal Event(bool isForOpen, OverlapRemovalNode node, double position)
 {
     this.IsForOpen = isForOpen;
     this.Node      = node;
     this.Position  = position;
 }