public GOM_Link(System.Xml.XmlNode node, GOM_ResourceArrays resources)
        {
            m_startStyle	= GOMLib.GOM_Terminal_Style.None;
            m_endStyle		= GOMLib.GOM_Terminal_Style.Triangle;
            m_drawingStyle	= new GOMLib.GOM_Style_Drawing();
            m_linkingStyle	= GOM_Linking_Style.Line;
            m_keyPts		= new GOM_Points();

            m_drawingStyle.id = "default";

            LoadFromXML(node, resources);
        }
        public GOM_Link(GOM_Interface_Graphic_Object startObj, GOM_Point startPt, GOM_Interface_Graphic_Object endObj, GOM_Point endPt, GOM_Style_Drawing drawingStyle, GOM_Linking_Style linkingStyle, GOM_Terminal_Style startStyle, GOM_Terminal_Style endStyle)
        {
            m_startObj		= startObj;
            m_endObj		= endObj;
            m_startPt		= startPt;
            m_endPt			= endPt;
            m_startStyle	= startStyle;
            m_endStyle		= endStyle;
            m_drawingStyle	= drawingStyle;
            m_linkingStyle	= linkingStyle;
            m_keyPts		= new GOM_Points();

            m_drawingStyle.id = "default";
        }
        /// <summary>
        /// Load the link from XmlNode.
        /// </summary>
        /// <param name="node">The XmlNode.</param>
        /// <param name="resources">GOM resource.</param>
        public void LoadFromXML(System.Xml.XmlNode node, GOM_ResourceArrays resources)
        {
            GOM_Utility.VerifyXmlNode(node, GOM_TAGS.CONNECTION);

            for( int i=0; i<node.Attributes.Count; i++ )
            {
            //				if ( string.Compare(node.Attributes[i].Name,GOM_TAGS.DRAWING_STYLE) == 0 )
            //				{
            //					this.m_drawingStyle = resources.DrawingStyles[node.Attributes[i].Value];
            //				}
                if ( string.Compare(node.Attributes[i].Name,GOM_TAGS.LINKING_STYLE) == 0 )
                {
                    this.m_linkingStyle = ConvertStringToLinkingStyle(node.Attributes[i].Value);
                }
            }

            GOM_Utility.VerifyXmlNode(node.ChildNodes[0], GOM_TAGS.POINT);
            GOM_Utility.VerifyXmlNode(node.ChildNodes[1], GOM_TAGS.POINT);
            // 1st pass
            //   objectID
            for( int i=0; i<node.ChildNodes[0].Attributes.Count; i++ )
            {
                if ( string.Compare(node.ChildNodes[0].Attributes[i].Name, GOM_TAGS.OBJECTID) == 0 )
                {
                    this.m_startObj = GOM_Utility.RecursiveFindObject(node.ChildNodes[0].Attributes[i].Value, resources.Objects);
                }
            }
            for( int i=0; i<node.ChildNodes[1].Attributes.Count; i++ )
            {
                if ( string.Compare(node.ChildNodes[1].Attributes[i].Name, GOM_TAGS.OBJECTID) == 0 )
                {
                    this.m_endObj = GOM_Utility.RecursiveFindObject(node.ChildNodes[1].Attributes[i].Value, resources.Objects);
                }
            }
            if ( m_startObj==null || m_endObj==null )
            {
                throw new System.Xml.XmlException("Missing points in the connection.");
            }

            //			if ( !(m_startObj is GOM_Object_Primitive) || !(m_endObj is GOM_Object_Primitive) )
            //			{
            //				throw new System.Xml.XmlException("Terminal points' objects are not all primitives.");
            //			}

            // 2nd pass
            //   pointID
            //   terminalStyle
            for( int i=0; i<node.ChildNodes[0].Attributes.Count; i++ )
            {
                if ( string.Compare(node.ChildNodes[0].Attributes[i].Name, GOM_TAGS.POINTID) == 0 )
                {
                    this.m_startPt = m_startObj.GetPointByName(node.ChildNodes[0].Attributes[i].Value);
                }
                if ( string.Compare(node.ChildNodes[0].Attributes[i].Name, GOM_TAGS.TERMINAL_STYLE) == 0 )
                {
                    this.m_startStyle = ConvertStringToTerminalStyle(node.ChildNodes[0].Attributes[i].Value);
                }
            }
            for( int i=0; i<node.ChildNodes[1].Attributes.Count; i++ )
            {
                if ( string.Compare(node.ChildNodes[1].Attributes[i].Name, GOM_TAGS.POINTID) == 0 )
                {
                    this.m_endPt = m_endObj.GetPointByName(node.ChildNodes[1].Attributes[i].Value);
                }
                if ( string.Compare(node.ChildNodes[1].Attributes[i].Name, GOM_TAGS.TERMINAL_STYLE) == 0 )
                {
                    this.m_endStyle = ConvertStringToTerminalStyle(node.ChildNodes[1].Attributes[i].Value);
                }
            }

            if ( m_startPt==null || m_endPt==null )
            {
                throw new System.Xml.XmlException("Cannot find find terminal points.");
            }

            // Drawing style
            this.m_drawingStyle.LoadFromXML( node.ChildNodes[2], resources );

            // Key points
            GOM_Utility.VerifyXmlNode(node.ChildNodes[3], GOM_TAGS.KEYPOINTS);
            for(int i=0; i<node.ChildNodes[3].ChildNodes.Count; i++ )
            {
                if ( string.Compare(node.ChildNodes[3].ChildNodes[i].Name, GOM_TAGS.POINT, true) == 0 )
                {
                    GOM_Point keyPoint = new GOM_Point();
                    for(int j=0; j<node.ChildNodes[3].ChildNodes[i].Attributes.Count; j++ )
                    {
                        if ( string.Compare(node.ChildNodes[3].ChildNodes[i].Attributes[j].Name, GOM_TAGS.X, true) == 0 )
                        {
                            keyPoint.x = float.Parse(node.ChildNodes[3].ChildNodes[i].Attributes[j].Value);
                        }
                        if ( string.Compare(node.ChildNodes[3].ChildNodes[i].Attributes[j].Name, GOM_TAGS.Y, true) == 0 )
                        {
                            keyPoint.y = float.Parse(node.ChildNodes[3].ChildNodes[i].Attributes[j].Value);
                        }
                    }
                    m_keyPts.Add(keyPoint);
                }
            }
        }
 /// <summary>
 /// Convert the LinkingStyle to a string.
 /// </summary>
 /// <param name="linkingStyle">The LinkingStyle.</param>
 /// <returns>A string</returns>
 public string ConvertLinkingStyleToString( GOM_Linking_Style linkingStyle )
 {
     switch(linkingStyle)
     {
         case GOM_Linking_Style.Line:
             return "line";
         case GOM_Linking_Style.Polyline:
             return "polyline";
         case GOM_Linking_Style.Curve:
             return "curve";
     }
     throw new ArgumentException("Unknown LinkingStyle["+linkingStyle.ToString()+"].");
 }