public static Bitmap Render(Dimension d, LatticeLayoutMethod method, bool ShowOnlyMultilevelRelationships)
    {
        if (ShowOnlyMultilevelRelationships)
        {
            if (d.Attributes.Count == 1)
            {
                //avoid an error
                ShowOnlyMultilevelRelationships = false;
            }
        }
        LatticeDrawing ld = new LatticeDrawing(d.Name);
        ld.LayoutMethod = method;
        foreach (DimensionAttribute a in d.Attributes)
        {
            ld.Nodes.Add(a.ID, new LatticeNode(a.Name));
            if (d.KeyAttribute == a)
            {
                ld.Nodes[a.ID].IsKey = true;
            }
            ld.Nodes[a.ID].Visible = a.AttributeHierarchyVisible;
            ld.Nodes[a.ID].Enabled = a.AttributeHierarchyEnabled;
        }
        foreach (DimensionAttribute a in d.Attributes)
        {
            foreach (AttributeRelationship r in a.AttributeRelationships)
            {
                ld.Nodes[a.ID].Relationships.Add(new LatticeRelationship(ld.Nodes[r.AttributeID], r.RelationshipType, r.Visible));
                if (d.KeyAttribute != a)
                {
                    ld.Nodes[r.AttributeID].NonKeyReferenceCount++;
                }
            }
        }
        if (ShowOnlyMultilevelRelationships)
        {
            foreach (DimensionAttribute a in d.Attributes)
            {
                if (a.AttributeRelationships.Count == 0 && ld.Nodes[a.ID].NonKeyReferenceCount == 0)
                {
                    ld.Nodes.Remove(a.ID);
                }
            }
            foreach (LatticeNode ln in ld.Nodes.Values)
            {
                for (int i = 0; i < ln.Relationships.Count; i++)
                {
                    LatticeRelationship lr = ln.Relationships[i];
                    if (!ld.Nodes.ContainsValue(lr.node))
                    {
                        ln.Relationships.Remove(lr);
                        i--;
                    }
                }
            }
        }


        ld.LayoutMethod = method;
        return ld.Render();
    }
Exemple #2
0
    public static Bitmap Render(Dimension d, LatticeLayoutMethod method, bool ShowOnlyMultilevelRelationships)
    {
        if (ShowOnlyMultilevelRelationships)
        {
            if (d.Attributes.Count == 1)
            {
                //avoid an error
                ShowOnlyMultilevelRelationships = false;
            }
        }
        LatticeDrawing ld = new LatticeDrawing(d.Name);

        ld.LayoutMethod = method;
        foreach (DimensionAttribute a in d.Attributes)
        {
            ld.Nodes.Add(a.ID, new LatticeNode(a.Name));
            if (d.KeyAttribute == a)
            {
                ld.Nodes[a.ID].IsKey = true;
            }
            ld.Nodes[a.ID].Visible = a.AttributeHierarchyVisible;
            ld.Nodes[a.ID].Enabled = a.AttributeHierarchyEnabled;
        }
        foreach (DimensionAttribute a in d.Attributes)
        {
            foreach (AttributeRelationship r in a.AttributeRelationships)
            {
                ld.Nodes[a.ID].Relationships.Add(new LatticeRelationship(ld.Nodes[r.AttributeID], r.RelationshipType, r.Visible));
                if (d.KeyAttribute != a)
                {
                    ld.Nodes[r.AttributeID].NonKeyReferenceCount++;
                }
            }
        }
        if (ShowOnlyMultilevelRelationships)
        {
            foreach (DimensionAttribute a in d.Attributes)
            {
                if (a.AttributeRelationships.Count == 0 && ld.Nodes[a.ID].NonKeyReferenceCount == 0)
                {
                    ld.Nodes.Remove(a.ID);
                }
            }
            foreach (LatticeNode ln in ld.Nodes.Values)
            {
                for (int i = 0; i < ln.Relationships.Count; i++)
                {
                    LatticeRelationship lr = ln.Relationships[i];
                    if (!ld.Nodes.ContainsValue(lr.node))
                    {
                        ln.Relationships.Remove(lr);
                        i--;
                    }
                }
            }
        }


        ld.LayoutMethod = method;
        return(ld.Render());
    }