public static GAtomicElement _getGAtomicElementFromString(String s) { GAtomicElement atomic_elements = GAtomicElement.NEUTRAL; if (s == "HYD") { atomic_elements = GAtomicElement.HYDROGEN; } else if (s == "OXY") { atomic_elements = GAtomicElement.OXYGEN; } else if (s == "NIT") { atomic_elements = GAtomicElement.NITROGEN; } else if (s == "SUL") { atomic_elements = GAtomicElement.SULFUR; } else if (s == "CAR") { atomic_elements = GAtomicElement.CARBON; } else if (s == "NEU") { atomic_elements = GAtomicElement.NEUTRAL; } else if (s == "PHS") { atomic_elements = GAtomicElement.PHOSPHORUS; } else if (s == "FLU") { atomic_elements = GAtomicElement.FLUORIDE; } else if (s == "BOR") { atomic_elements = GAtomicElement.BORANE; } else if (s == "VLK") { atomic_elements = GAtomicElement.VERTICAL_LINE_LINK; } else if (s == "HLK") { atomic_elements = GAtomicElement.HORIZONTAL_LINE_LINK; } else { atomic_elements = GAtomicElement.UKNOWN_ELEMENT; } return(atomic_elements); }
public static String _getGAtomicElementsString(GAtomicElement element) { String s = ""; if (element == GAtomicElement.HYDROGEN) { s = "HYD"; } else if (element == GAtomicElement.OXYGEN) { s = "OXY"; } else if (element == GAtomicElement.NITROGEN) { s = "NIT"; } else if (element == GAtomicElement.SULFUR) { s = "SUL"; } else if (element == GAtomicElement.CARBON) { s = "CAR"; } else if (element == GAtomicElement.NEUTRAL) { s = "NEU"; } else if (element == GAtomicElement.PHOSPHORUS) { s = "PHS"; } else if (element == GAtomicElement.FLUORIDE) { s = "FLU"; } else if (element == GAtomicElement.BORANE) { s = "BOR"; } else if (element == GAtomicElement.VERTICAL_LINE_LINK) { s = "VLK"; } else if (element == GAtomicElement.HORIZONTAL_LINE_LINK) { s = "HLK"; } else { s = "UKN"; } return(s); }
/// /// element constructor without the dimensions and index (default values) /// public GAtomicElementObject(GAtomicElement elem, GAtomicConnectionElement[] conn_elems) : base(new Point(0, 0), 0, 0, 0) { element = elem; index_in_list = 0; if (conn_elems == null) { connection_elements = null; } else { connection_elements = new GAtomicConnectionElement[conn_elems.Length]; int k = 0; for (; k < conn_elems.Length; k++) { connection_elements[k] = conn_elems[k]; } bool valid = true; for (k = 0; k < conn_elems.Length; k++) { for (int y = 0; y < conn_elems.Length; y++) { if (y != k) { if (((GAtomicConnectionElement)connection_elements[y]).DirectionOfConnectingElement == ((GAtomicConnectionElement)connection_elements[k]).DirectionOfConnectingElement) { // same direction twice, conceptual error valid = false; break; } } } } if (!valid) { throw new GAtomicElementObjectInvalidException(); } } }
public static GAtomicElementObject _getAtomicElementFromString(String s, Point p, int row, int col, int object_size, int ind_list) { String atomic_element_string = s.Substring(0, 3); GAtomicElement atomic_element = GAtomicObject._getGAtomicElementFromString(atomic_element_string); int number_of_connections = 0; String connections_string = s.Substring(3); if (connections_string.Length != (int)GAtomicConnectionDirection.TRIPLE_LEFT + 1) { return(null); } int index = connections_string.IndexOf("1"); while (index != -1) { number_of_connections++; index = connections_string.IndexOf("1", index + 1); } GAtomicConnectionElement[] connections = new GAtomicConnectionElement[number_of_connections]; index = 0; int array_index = 0; while (index < connections_string.Length) { if (connections_string.Substring(index++, 1) == "1") { connections[array_index++] = new GAtomicConnectionElement(null, (GAtomicConnectionDirection)(index - 1)); } } GAtomicElementObject a = new GAtomicElementObject(p, row, col , object_size , atomic_element, connections, ind_list); return(a); }