// Generated by Haxe 4.3.1
package schema;

import haxe.root.*;

@SuppressWarnings(value={"rawtypes", "unchecked"})
public class MCDToSVG extends haxe.lang.HxObject
{
	static
	{
		//line 6 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		{
			//line 6 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			java.lang.Object __temp_odecl2 = null;
			//line 6 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			{
				//line 6 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
				java.lang.Object __temp_odecl1 = new haxe.lang.DynamicObject(new java.lang.String[]{"SuppressWarnings"}, new java.lang.Object[]{new haxe.root.Array(new java.lang.Object[]{"checkstyle:ParameterNumber"})}, new java.lang.String[]{}, new double[]{});
				//line 6 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
				__temp_odecl2 = new haxe.lang.DynamicObject(new java.lang.String[]{"generateLineCardsSVG"}, new java.lang.Object[]{__temp_odecl1}, new java.lang.String[]{}, new double[]{});
			}
			
			//line 6 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			schema.MCDToSVG.__meta__ = new haxe.lang.DynamicObject(new java.lang.String[]{"statics"}, new java.lang.Object[]{__temp_odecl2}, new java.lang.String[]{}, new double[]{});
		}
		
	}
	
	public MCDToSVG(haxe.lang.EmptyObject empty)
	{
	}
	
	
	public MCDToSVG()
	{
		//line 6 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		schema.MCDToSVG.__hx_ctor_schema_MCDToSVG(this);
	}
	
	
	protected static void __hx_ctor_schema_MCDToSVG(schema.MCDToSVG __hx_this)
	{
	}
	
	
	public static java.lang.Object __meta__;
	
	public static haxe.root.Xml generateSVG(model.Diagram diagram)
	{
		//line 13 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		haxe.root.Xml doc = haxe.root.Xml.createDocument();
		//line 14 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		haxe.root.Xml svg = schema.Svg.initSvg(doc);
		//line 16 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		{
			//line 16 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			java.lang.Object set = diagram.iterator();
			//line 16 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			while (haxe.lang.Runtime.toBool(((java.lang.Boolean) (haxe.lang.Runtime.callField(set, "hasNext", null)) )))
			{
				//line 16 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
				model.Set set1 = ((model.Set) (haxe.lang.Runtime.callField(set, "next", null)) );
				//line 17 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
				if (haxe.root.Std.isOfType(set1, model.Association.class)) 
				{
					//line 18 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
					set1.svg = schema.MCDToSVG.generateAssociationSVG(((model.Association) (set1) ));
				}
				else
				{
					//line 20 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
					set1.svg = schema.MCDToSVG.generateSetSVG(set1);
				}
				
				//line 22 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
				svg.addChild(set1.svg);
			}
			
		}
		
		//line 25 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		schema.Svg.placeObjects(diagram, svg, diagram.height, diagram.width, null);
		//line 26 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		schema.MCDToSVG.drawLines(diagram, svg);
		//line 27 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		return doc;
	}
	
	
	public static haxe.root.Xml generateAssociationSVG(model.Association set)
	{
		//line 31 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		int fieldsCount = 0;
		//line 32 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		int chrWidth = set.name.length();
		//line 33 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		{
			//line 33 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			int _g = 0;
			//line 33 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			haxe.root.Array<model.Field> _g1 = set.fields;
			//line 33 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			while (( _g < _g1.length ))
			{
				//line 33 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
				model.Field field = _g1.__get(_g);
				//line 33 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
				 ++ _g;
				//line 34 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
				 ++ fieldsCount;
				//line 35 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
				if (( field.name.length() > chrWidth )) 
				{
					//line 36 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
					chrWidth = field.name.length();
				}
				
			}
			
		}
		
		//line 39 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		haxe.root.Xml g = haxe.root.Xml.createElement("g");
		//line 40 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		if (set.isAgregation) 
		{
			//line 41 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			haxe.root.Xml rect = haxe.root.Xml.createElement("rect");
			//line 42 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			g.addChild(rect);
			//line 43 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			rect.set("height", haxe.root.Std.string(( ( (( (( fieldsCount == 0 )) ? (2) : (( fieldsCount + 1 )) )) * 16 ) + 10 )));
			//line 44 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			rect.set("width", haxe.root.Std.string(( ( ( chrWidth * 10.0 ) + 10 ) + 10. )));
			//line 45 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			rect.set("style", "fill:white");
		}
		
		//line 47 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		haxe.root.Xml rect1 = haxe.root.Xml.createElement("rect");
		//line 48 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		g.addChild(rect1);
		//line 49 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		rect1.set("height", haxe.root.Std.string(( ( (( (( fieldsCount == 0 )) ? (2) : (( fieldsCount + 1 )) )) * 16 ) + 10 )));
		//line 50 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		rect1.set("width", haxe.root.Std.string(( ( ( chrWidth * 10.0 ) + 10 ) + 10. )));
		//line 51 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		rect1.set("rx", "20");
		//line 52 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		rect1.set("ry", "20");
		//line 53 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		rect1.set("style", "fill:lightgrey");
		//line 55 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		haxe.root.Xml line = haxe.root.Xml.createElement("line");
		//line 56 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		g.addChild(line);
		//line 57 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		line.set("x1", "0");
		//line 58 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		line.set("x2", haxe.root.Std.string(( ( ( chrWidth * 10.0 ) + 10 ) + 10. )));
		//line 59 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		line.set("y1", "21");
		//line 60 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		line.set("y2", "21");
		//line 62 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		haxe.root.Xml title = haxe.root.Xml.createElement("text");
		//line 63 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		g.addChild(title);
		//line 64 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		title.addChild(haxe.root.Xml.createPCData(set.name));
		//line 65 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		title.set("x", haxe.root.Std.string(( 10. + ( ( (( chrWidth - set.name.length() )) * 10.0 ) / 2 ) )));
		//line 66 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		title.set("y", "17");
		//line 68 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		haxe.root.Xml text = haxe.root.Xml.createElement("text");
		//line 69 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		g.addChild(text);
		//line 70 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		{
			//line 70 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			int _g2 = 0;
			//line 70 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			int _g3 = set.fields.length;
			//line 70 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			while (( _g2 < _g3 ))
			{
				//line 70 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
				int i = _g2++;
				//line 71 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
				haxe.root.Xml tspan = haxe.root.Xml.createElement("tspan");
				//line 72 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
				text.addChild(tspan);
				//line 73 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
				tspan.set("x", haxe.root.Std.string(10.));
				//line 74 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
				tspan.set("y", haxe.root.Std.string(( ( 16 * (( i + 2 )) ) + 5 )));
				//line 75 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
				tspan.addChild(haxe.root.Xml.createPCData(set.fields.__get(i).name));
			}
			
		}
		
		//line 77 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		return g;
	}
	
	
	public static haxe.root.Xml generateSetSVG(model.Set set)
	{
		//line 81 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		int fieldsCount = 0;
		//line 82 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		int chrWidth = set.name.length();
		//line 83 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		{
			//line 83 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			int _g = 0;
			//line 83 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			haxe.root.Array<model.Field> _g1 = set.fields;
			//line 83 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			while (( _g < _g1.length ))
			{
				//line 83 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
				model.Field field = _g1.__get(_g);
				//line 83 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
				 ++ _g;
				//line 84 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
				if ( ! (field.isStatic) ) 
				{
					//line 85 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
					 ++ fieldsCount;
					//line 86 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
					if (( field.name.length() > chrWidth )) 
					{
						//line 87 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
						chrWidth = field.name.length();
					}
					
				}
				
			}
			
		}
		
		//line 91 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		haxe.root.Xml g = haxe.root.Xml.createElement("g");
		//line 92 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		haxe.root.Xml rect = haxe.root.Xml.createElement("rect");
		//line 93 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		g.addChild(rect);
		//line 94 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		rect.set("height", haxe.root.Std.string(( ( (( (( fieldsCount == 0 )) ? (2) : (( fieldsCount + 1 )) )) * 16 ) + 10 )));
		//line 95 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		rect.set("width", haxe.root.Std.string(((int) (( ( chrWidth * 10.0 ) + 10 )) )));
		//line 96 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		rect.set("style", "fill:white");
		//line 98 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		haxe.root.Xml titleBG = haxe.root.Xml.createElement("rect");
		//line 99 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		g.addChild(titleBG);
		//line 100 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		titleBG.set("height", "21");
		//line 101 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		titleBG.set("width", haxe.root.Std.string(( ( chrWidth * 10.0 ) + 10 )));
		//line 102 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		titleBG.set("style", "fill:lightgrey");
		//line 104 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		haxe.root.Xml title = haxe.root.Xml.createElement("text");
		//line 105 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		g.addChild(title);
		//line 106 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		title.addChild(haxe.root.Xml.createPCData(set.name));
		//line 107 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		title.set("x", haxe.root.Std.string(( 5 + ( ( (( chrWidth - set.name.length() )) * 10.0 ) / 2 ) )));
		//line 108 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		title.set("y", "16");
		//line 110 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		haxe.root.Xml text = haxe.root.Xml.createElement("text");
		//line 111 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		g.addChild(text);
		//line 112 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		{
			//line 112 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			int _g2 = 0;
			//line 112 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			int _g3 = set.fields.length;
			//line 112 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			while (( _g2 < _g3 ))
			{
				//line 112 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
				int i = _g2++;
				//line 113 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
				if ( ! (set.fields.__get(i).isStatic) ) 
				{
					//line 114 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
					haxe.root.Xml tspan = haxe.root.Xml.createElement("tspan");
					//line 115 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
					text.addChild(tspan);
					//line 116 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
					tspan.set("x", haxe.root.Std.string(2.5));
					//line 117 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
					tspan.set("y", haxe.root.Std.string(( ( 16 * (( i + 2 )) ) + 5 )));
					//line 118 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
					if (( set.id.indexOf(set.fields.__get(i).name, null) != -1 )) 
					{
						//line 119 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
						tspan.set("style", "text-decoration:underline");
					}
					
					//line 121 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
					tspan.addChild(haxe.root.Xml.createPCData(set.fields.__get(i).name));
				}
				
			}
			
		}
		
		//line 125 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		if (( set.subsets.length != 0 )) 
		{
			//line 126 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			java.lang.String set1 = set.subsetType;
			//line 126 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			if (( ( g.nodeType != haxe.root.Xml.Document ) && ( g.nodeType != haxe.root.Xml.Element ) )) 
			{
				//line 126 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
				throw ((java.lang.RuntimeException) (haxe.Exception.thrown(( "Bad node type, expected Element or Document but found " + _Xml.XmlType_Impl_.toString(g.nodeType) ))) );
			}
			
			//line 126 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			java.lang.Object tmp = haxe.root.Std.parseInt(g.children.__get(0).get("width"));
			//line 126 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			if (( ( g.nodeType != haxe.root.Xml.Document ) && ( g.nodeType != haxe.root.Xml.Element ) )) 
			{
				//line 126 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
				throw ((java.lang.RuntimeException) (haxe.Exception.thrown(( "Bad node type, expected Element or Document but found " + _Xml.XmlType_Impl_.toString(g.nodeType) ))) );
			}
			
			//line 126 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			g.addChild(schema.MCDToSVG.generateInheritanceSVG(set1, ((int) (haxe.lang.Runtime.toInt(tmp)) ), ((int) (haxe.lang.Runtime.toInt(haxe.root.Std.parseInt(g.children.__get(0).get("height")))) )));
		}
		
		//line 128 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		return g;
	}
	
	
	public static haxe.root.Xml generateInheritanceSVG(java.lang.String type, int setWidth, int setHeight)
	{
		//line 133 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		int w = 40;
		//line 134 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		int h = ((int) (( ((double) (w) ) / 2 )) );
		//line 135 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		haxe.root.Xml g = haxe.root.Xml.createElement("g");
		//line 137 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		haxe.root.Xml line = haxe.root.Xml.createElement("line");
		//line 138 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		g.addChild(line);
		//line 139 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		line.set("x1", haxe.root.Std.string(((int) (( ((double) (w) ) / 2 )) )));
		//line 140 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		line.set("x2", haxe.root.Std.string(((int) (( ((double) (w) ) / 2 )) )));
		//line 141 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		line.set("y1", "0");
		//line 142 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		line.set("y2", "5");
		//line 144 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		haxe.root.Xml path = haxe.root.Xml.createElement("path");
		//line 145 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		g.addChild(path);
		//line 146 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		path.set("d", ( ( ( ( ( ( ( ( "M " + w ) + " " ) + (( h + 5 )) ) + " a1,1 0 1,0 -" ) + w ) + " 0 l " ) + w ) + " 0" ));
		//line 147 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		path.set("style", "fill:lightgrey");
		//line 149 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		haxe.root.Xml title = haxe.root.Xml.createElement("text");
		//line 150 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		g.addChild(title);
		//line 151 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		title.addChild(haxe.root.Xml.createPCData(type));
		//line 152 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		title.set("x", haxe.root.Std.string(( 10. + ( ( (( 2 - type.length() )) * 10.0 ) / 2 ) )));
		//line 153 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		title.set("y", "22");
		//line 155 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		g.set("transform", ( ( ( ( "translate(" + haxe.root.Std.string(((int) (( ((double) ((( setWidth - w ))) ) / 2 )) )) ) + "," ) + haxe.root.Std.string(setHeight) ) + ")" ));
		//line 156 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		return g;
	}
	
	
	public static void drawLines(model.Diagram diagram, haxe.root.Xml svg)
	{
		//line 160 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		{
			//line 160 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			java.lang.Object assoc = new haxe.ds._StringMap.StringMapValueIterator<model.Association>(((haxe.ds.StringMap<model.Association>) (diagram.associations) ));
			//line 160 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			while (haxe.lang.Runtime.toBool(((java.lang.Boolean) (haxe.lang.Runtime.callField(assoc, "hasNext", null)) )))
			{
				//line 160 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
				model.Association assoc1 = ((model.Association) (haxe.lang.Runtime.callField(assoc, "next", null)) );
				//line 161 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
				int i = 0;
				//line 162 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
				if (( ( assoc1.links.length == 2 ) && haxe.lang.Runtime.valEq(assoc1.links.__get(0).set.name, assoc1.links.__get(1).set.name) )) 
				{
					//line 163 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
					svg.addChild(schema.MCDToSVG.generateLineCardsSVG(assoc1, assoc1.links.__get(0).set, false, assoc1.links.__get(0).hasArrow, assoc1.links.__get(0).getMCDCards(), 1, false));
					//line 164 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
					svg.addChild(schema.MCDToSVG.generateLineCardsSVG(assoc1, assoc1.links.__get(0).set, false, assoc1.links.__get(1).hasArrow, assoc1.links.__get(1).getMCDCards(), -1, false));
					//line 165 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
					i = 2;
				}
				
				//line 167 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
				{
					//line 167 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
					int _g = i;
					//line 167 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
					int _g1 = assoc1.links.length;
					//line 167 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
					while (( _g < _g1 ))
					{
						//line 167 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
						int j = _g++;
						//line 168 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
						svg.addChild(schema.MCDToSVG.generateLineCardsSVG(assoc1, assoc1.links.__get(j).set, assoc1.links.__get(j).isWeak, assoc1.links.__get(j).hasArrow, assoc1.links.__get(j).getMCDCards(), null, false));
					}
					
				}
				
			}
			
		}
		
		//line 172 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		{
			//line 172 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			java.lang.Object p = new haxe.ds._StringMap.StringMapValueIterator<model.Set>(((haxe.ds.StringMap<model.Set>) (diagram.sets) ));
			//line 172 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			while (haxe.lang.Runtime.toBool(((java.lang.Boolean) (haxe.lang.Runtime.callField(p, "hasNext", null)) )))
			{
				//line 172 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
				model.Set p1 = ((model.Set) (haxe.lang.Runtime.callField(p, "next", null)) );
				//line 173 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
				if (( p1.subsets.length != 0 )) 
				{
					//line 174 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
					int _g2 = 0;
					//line 174 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
					haxe.root.Array<model.Set> _g3 = p1.subsets;
					//line 174 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
					while (( _g2 < _g3.length ))
					{
						//line 174 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
						model.Set c = _g3.__get(_g2);
						//line 174 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
						 ++ _g2;
						//line 175 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
						svg.addChild(schema.MCDToSVG.generateLineCardsSVG(p1, c, false, false, "", null, true));
					}
					
				}
				
			}
			
		}
		
	}
	
	
	public static haxe.root.Xml generateLineCardsSVG(model.Set set1, model.Set set2, boolean isWeak, boolean hasArrow, java.lang.String cards, java.lang.Object bend, boolean inheritance)
	{
		//line 183 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		int bend1 = ( (haxe.lang.Runtime.eq(bend, null)) ? (0) : (((int) (haxe.lang.Runtime.toInt(bend)) )) );
		//line 184 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		if (isWeak) 
		{
			//line 185 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			cards = ( ( "(" + cards ) + ")" );
		}
		
		//line 187 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		schema.Line line = schema.Svg.getLine(set1, set2, "", cards, bend1);
		//line 188 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		if (inheritance) 
		{
			//line 189 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			int x1 = ((int) (haxe.lang.Runtime.toInt(haxe.root.Std.parseInt(haxe.lang.StringExt.split(schema.Svg.coordRE.replace(set1.svg.get("transform"), "$1"), ",").__get(0)))) );
			//line 190 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			int y1 = ((int) (haxe.lang.Runtime.toInt(haxe.root.Std.parseInt(haxe.lang.StringExt.split(schema.Svg.coordRE.replace(set1.svg.get("transform"), "$1"), ",").__get(1)))) );
			//line 191 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			haxe.root.Xml _this = set1.svg;
			//line 191 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			if (( ( _this.nodeType != haxe.root.Xml.Document ) && ( _this.nodeType != haxe.root.Xml.Element ) )) 
			{
				//line 191 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
				throw ((java.lang.RuntimeException) (haxe.Exception.thrown(( "Bad node type, expected Element or Document but found " + _Xml.XmlType_Impl_.toString(_this.nodeType) ))) );
			}
			
			//line 191 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			int w1 = ((int) (haxe.lang.Runtime.toInt(haxe.root.Std.parseInt(_this.children.__get(0).get("width")))) );
			//line 192 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			haxe.root.Xml _this1 = set1.svg;
			//line 192 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			if (( ( _this1.nodeType != haxe.root.Xml.Document ) && ( _this1.nodeType != haxe.root.Xml.Element ) )) 
			{
				//line 192 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
				throw ((java.lang.RuntimeException) (haxe.Exception.thrown(( "Bad node type, expected Element or Document but found " + _Xml.XmlType_Impl_.toString(_this1.nodeType) ))) );
			}
			
			//line 192 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			int h1 = ((int) (haxe.lang.Runtime.toInt(haxe.root.Std.parseInt(_this1.children.__get(0).get("height")))) );
			//line 193 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			line.x1 = ( x1 + ((int) (( ((double) (w1) ) / 2 )) ) );
			//line 194 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
			line.y1 = ( ( ( y1 + h1 ) + 20 ) + 5 );
		}
		
		//line 196 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		haxe.root.Xml g = haxe.root.Xml.createElement("g");
		//line 197 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		g.addChild(schema.Svg.getSvgLine(line, bend1, ( (hasArrow) ? (haxe.lang.Runtime.toString(haxe.lang.Runtime.getField(schema.Svg.MARKERS.__get(0), "id", true))) : (null) )));
		//line 199 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		haxe.root.Xml mm = haxe.root.Xml.createElement("text");
		//line 200 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		mm.addChild(haxe.root.Xml.createPCData(cards));
		//line 204 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		mm.set("x", haxe.root.Std.string(line.cx2));
		//line 205 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		mm.set("y", haxe.root.Std.string(line.cy2));
		//line 206 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		g.addChild(mm);
		//line 207 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/schema/MCDToSVG.hx"
		return g;
	}
	
	
}


