예제 #1
0
        TestCollapsedAttributes()
        {
            // With vertex names.

            IVertex oAnchorVertex1 = new Vertex();
            IVertex oAnchorVertex2 = new Vertex();

            oAnchorVertex1.Name = "Name1";
            oAnchorVertex2.Name = "Name2";

            DConnectorMotif oDConnectorMotif = new DConnectorMotif(
                new List <IVertex>()
            {
                oAnchorVertex1, oAnchorVertex2
            });

            IVertex oSpanVertex1 = new Vertex();
            IVertex oSpanVertex2 = new Vertex();

            oDConnectorMotif.SpanVertices.Add(oSpanVertex1);
            oDConnectorMotif.SpanVertices.Add(oSpanVertex2);

            String sCollapsedAttributes = oDConnectorMotif.CollapsedAttributes;

            CollapsedGroupAttributes oCollapsedGroupAttributes =
                CollapsedGroupAttributes.FromString(sCollapsedAttributes);

            Assert.AreEqual(CollapsedGroupAttributeValues.DConnectorMotifType,
                            oCollapsedGroupAttributes[CollapsedGroupAttributeKeys.Type]);

            Assert.AreEqual("2", oCollapsedGroupAttributes[
                                CollapsedGroupAttributeKeys.AnchorVertices]);

            Assert.IsTrue(oCollapsedGroupAttributes.ContainsKey(
                              CollapsedGroupAttributeKeys.GetAnchorVertexNameKey(0)));

            Assert.IsTrue(oCollapsedGroupAttributes.ContainsKey(
                              CollapsedGroupAttributeKeys.GetAnchorVertexNameKey(1)));

            Assert.AreEqual("Name1", oCollapsedGroupAttributes[
                                CollapsedGroupAttributeKeys.GetAnchorVertexNameKey(0)]);

            Assert.AreEqual("Name2", oCollapsedGroupAttributes[
                                CollapsedGroupAttributeKeys.GetAnchorVertexNameKey(1)]);

            Assert.AreEqual("2", oCollapsedGroupAttributes[
                                CollapsedGroupAttributeKeys.SpanVertices]);

            Assert.IsTrue(oCollapsedGroupAttributes.ContainsKey(
                              CollapsedGroupAttributeKeys.SpanScale));

            Assert.AreEqual("1",
                            oCollapsedGroupAttributes[CollapsedGroupAttributeKeys.SpanScale]);
        }
예제 #2
0
        GetRowIDsToAverageForEdges
        (
            GroupInfo oGroup,
            CollapsedGroupAttributes oCollapsedGroupAttributes,
            Int32 iAnchorVertexIndex
        )
        {
            Debug.Assert(oGroup != null);
            Debug.Assert(oCollapsedGroupAttributes != null);
            Debug.Assert(iAnchorVertexIndex >= 0);

            List <Int32> oRowIDsOfRowsToAverage = new List <Int32>();

            String sAnchorVertexName;

            if (oCollapsedGroupAttributes.TryGetValue(

                    CollapsedGroupAttributeKeys.GetAnchorVertexNameKey(
                        iAnchorVertexIndex),

                    out sAnchorVertexName))
            {
                // The group's vertices are the span vertices.  Loop through them.

                foreach (IVertex oVertex in oGroup.Vertices)
                {
                    // We need to find the edge that is incident to the specified
                    // anchor vertex.

                    foreach (IEdge oIncidentEdge in oVertex.IncidentEdges)
                    {
                        IVertex oAdjacentVertex =
                            oIncidentEdge.GetAdjacentVertex(oVertex);

                        if (oAdjacentVertex.Name == sAnchorVertexName)
                        {
                            // The row ID is stored in the edge's Tag, as long as
                            // the edge row isn't hidden.

                            if (oIncidentEdge.Tag is Int32)
                            {
                                oRowIDsOfRowsToAverage.Add(
                                    (Int32)oIncidentEdge.Tag);
                            }

                            break;
                        }
                    }
                }
            }

            return(oRowIDsOfRowsToAverage);
        }
예제 #3
0
        TestCollapsedAttributes2()
        {
            // Without vertex names and with SpanScale set to a non-default value.

            IVertex oAnchorVertex1 = new Vertex();
            IVertex oAnchorVertex2 = new Vertex();

            DConnectorMotif oDConnectorMotif = new DConnectorMotif(
                new List <IVertex>()
            {
                oAnchorVertex1, oAnchorVertex2
            });

            IVertex oSpanVertex1 = new Vertex();
            IVertex oSpanVertex2 = new Vertex();

            oDConnectorMotif.SpanVertices.Add(oSpanVertex1);
            oDConnectorMotif.SpanVertices.Add(oSpanVertex2);

            oDConnectorMotif.SpanScale = 0.5;

            String sCollapsedAttributes = oDConnectorMotif.CollapsedAttributes;

            CollapsedGroupAttributes oCollapsedGroupAttributes =
                CollapsedGroupAttributes.FromString(sCollapsedAttributes);

            Assert.AreEqual(CollapsedGroupAttributeValues.DConnectorMotifType,
                            oCollapsedGroupAttributes[CollapsedGroupAttributeKeys.Type]);

            Assert.AreEqual("2", oCollapsedGroupAttributes[
                                CollapsedGroupAttributeKeys.AnchorVertices]);

            Assert.IsFalse(oCollapsedGroupAttributes.ContainsKey(
                               CollapsedGroupAttributeKeys.GetAnchorVertexNameKey(0)));

            Assert.IsFalse(oCollapsedGroupAttributes.ContainsKey(
                               CollapsedGroupAttributeKeys.GetAnchorVertexNameKey(1)));

            Assert.AreEqual("2", oCollapsedGroupAttributes[
                                CollapsedGroupAttributeKeys.SpanVertices]);

            Assert.IsTrue(oCollapsedGroupAttributes.ContainsKey(
                              CollapsedGroupAttributeKeys.SpanScale));

            Assert.AreEqual("0.5",
                            oCollapsedGroupAttributes[CollapsedGroupAttributeKeys.SpanScale]);
        }