/// <summary>
        /// Builds the children and returns newly built nodes
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="parent">The parent.</param>
        /// <param name="source">The source.</param>
        /// <param name="defShapeType">Type of the definition shape.</param>
        /// <param name="defLinkType">Type of the definition link.</param>
        /// <param name="doDegradeImportance">if set to <c>true</c> [do degrade importance].</param>
        /// <returns></returns>
        public List <diagramNode> buildChildren(diagramModel model, diagramNode parent, IEnumerable source, diagramNodeShapeEnum defShapeType = diagramNodeShapeEnum.normal, diagramLinkTypeEnum defLinkType = diagramLinkTypeEnum.normal, bool doDegradeImportance = true)
        {
            List <diagramNode> childNodes = new List <diagramNode>();

            if (source == null)
            {
                return(childNodes);
            }

            foreach (IObjectWithPathAndChildSelector child in source)
            {
                diagramNode node = buildNode(model, child);
                node.shapeType = getShapeTypeEnum(child, defShapeType);
                //node.relatedObject = child;
                childNodes.Add(node);
                if (doDegradeImportance)
                {
                    node.importance = parent.importance - 1;
                }
                node.color = getColor(node);
            }

            foreach (diagramNode child in childNodes)
            {
                diagramLink link = model.AddLink(parent, child, diagramLinkTypeEnum.normal);
                link.type        = getLinkTypeEnum(child, defLinkType);
                link.description = getLinkDescription(link, "");
            }
            return(childNodes);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds the link.
        /// </summary>
        /// <param name="from">From.</param>
        /// <param name="to">To.</param>
        /// <param name="type">The type.</param>
        /// <param name="description">The description.</param>
        /// <returns></returns>
        public diagramLink AddLink(diagramNode from, diagramNode to, diagramLinkTypeEnum type, string description = "", string __hash = "", ILogBuilder logger = null)
        {
            diagramLink output = new diagramLink();

            output.from        = from;
            output.to          = to;
            output.type        = type;
            output.name        = getUID(output);
            output.description = description;
            links.Add(output);
            output.parent = this;

            if (!__hash.isNullOrEmpty())
            {
                if (linkByHash.ContainsKey(__hash))
                {
                    if (logger != null)
                    {
                        logger.log("AddLink() failed :: " + __hash);
                    }
                }
                else
                {
                    linkByHash.Add(__hash, output);
                }
            }
            return(output);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the universal ID name for specified element
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="autoSet">if set to <c>true</c> [automatic set].</param>
        /// <param name="useRelatedObject">if set to <c>true</c> [use related object].</param>
        /// <returns></returns>
        internal string getUID(diagramElementBase element, bool autoSet = true, bool useRelatedObject = false)
        {
            string output = "";

            if (element is diagramNode)
            {
                if (useRelatedObject)
                {
                    if (element.relatedObject is IObjectWithPath)
                    {
                        IObjectWithPath element_relatedObject_IObjectWithPath = (IObjectWithPath)element.relatedObject;
                        string          ptname = element_relatedObject_IObjectWithPath.path.getCleanPropertyName();
                        output = nodes.makeUniqueDictionaryName(ptname, ref _lastNamingIteration, 10);
                    }
                    else if (element.relatedObject is IObjectWithName)
                    {
                        IObjectWithName withName = (IObjectWithName)element.relatedObject;
                        output = nodes.makeUniqueDictionaryName(withName.name.getCleanPropertyName(), ref _lastNamingIteration, 100);
                    }
                }
                if (output.isNullOrEmpty())
                {
                    output = ((long)nodeCount).DecimalToOrdinalLetterSystem();
                }
            }
            else if (element is diagramLink)
            {
                if (useRelatedObject)
                {
                    diagramLink link = element as diagramLink;
                    if (link.isConnected)
                    {
                        output = link.from.name + "to" + link.to.name;
                    }
                }
                if (output.isNullOrEmpty())
                {
                    output = ((long)linkCount).DecimalToOrdinalLetterSystem() + "_link";
                }
            }

            if (autoSet)
            {
                element.name = output;
            }

            return(output);
        }
 public override string getLinkDescription(diagramLink child, string defDescription = "")
 {
     if (child.relatedObject is IContentBlock)
     {
         return("block");
     }
     if (child.relatedObject is IContentParagraph)
     {
         return("paragraph");
     }
     if (child.relatedObject is IContentSentence)
     {
         return("sentence");
     }
     if (child.relatedObject is IContentToken)
     {
         return("token");
     }
     return(defDescription);
 }
        /// <summary>
        /// Gets the link declaration.
        /// </summary>
        /// <param name="link">The link.</param>
        /// <returns></returns>
        public override string getLinkDeclaration(diagramLink link)
        {
            string fromPart = "N";
            string toPart   = "N";
            string output   = "";
            string middle   = "";

            fromPart = fromPart + link.from.name;

            if (link.isFromDirected)
            {
                middle = middle + "<";
            }

            if (link.description.isNullOrEmpty())
            {
                switch (link.type)
                {
                case diagramLinkTypeEnum.dotted:
                    middle += "-.-";
                    break;

                default:
                case diagramLinkTypeEnum.normal:
                    middle += "--";
                    break;

                case diagramLinkTypeEnum.thick:
                    middle += "==";
                    break;
                }
            }
            else
            {
                switch (link.type)
                {
                case diagramLinkTypeEnum.dotted:
                    middle += "-." + link.description + ".-";
                    break;

                default:
                case diagramLinkTypeEnum.normal:
                    middle += "--" + link.description + "--";
                    break;

                case diagramLinkTypeEnum.thick:
                    middle += "==" + link.description + "==";
                    break;
                }
            }

            if (link.isToDirected)
            {
                middle = middle + ">";
            }
            toPart = toPart + link.to.name;

            output = fromPart.add(middle).add(toPart);
            output = output + ";";
            return("    " + output);
        }
Exemplo n.º 6
0
 public virtual string getLinkDescription(diagramLink child, string defDescription = "")
 {
     return(defDescription);
 }
 public abstract string getLinkDeclaration(diagramLink link);