private static void Uml2Tex(IEnumerable <string> umlfiles, string target)
{
List <IUmlObject> allObjects = new List <IUmlObject> ();
foreach (string umlfile in umlfiles)
{
IParser parser = new UmlParser();
Console.WriteLine("Read: " + umlfile);
allObjects.AddRange(parser.Parse(umlfile));
}
Console.WriteLine("Write: " + target);
List <string> lines = new List <string> ();
lines.AddRange(UmlObject.TexHeader);
foreach (string package in Packages.PackageMap.Keys)
{
lines.Add(@"\section{Paket " + package + @"}");
lines.Add(@"\subsection{Klassen}");
foreach (UmlClass obj in allObjects.OfType <UmlClass>().Where((c) => Packages.IsInPackage(package, c.Name)))
{
if (obj.type != ClassType.Interface)
{
lines.Add(obj.ToTexCode());
lines.Add("");
}
}
lines.Add(@"\subsection{Schnittstellen}");
foreach (UmlClass obj in allObjects.OfType <UmlClass>().Where((c) => Packages.IsInPackage(package, c.Name)))
{
if (obj.type == ClassType.Interface)
{
lines.Add(obj.ToTexCode());
lines.Add("");
}
}
lines.Add(@"\subsection{Enumerationen}");
foreach (UmlEnum obj in allObjects.OfType <UmlEnum>().Where((c) => Packages.IsInPackage(package, c.Name)))
{
lines.Add(obj.ToTexCode());
lines.Add("");
}
}
Files.WriteLines(target, lines);
lines.Clear();
newCommand(ref lines, "CountClasses", "" + allObjects.OfType <UmlClass> ()
.Where((o) => o.type == ClassType.Class).Count()
);
newCommand(ref lines, "CountInterfaces", "" + allObjects.OfType <UmlClass> ()
.Where((o) => o.type == ClassType.Interface).Count()
);
newCommand(ref lines, "CountEnums", "" + allObjects.OfType <UmlEnum> ()
.Count()
);
newCommand(ref lines, "CountAll", ""
+ (allObjects.OfType <UmlClass> ()
.Where((o) => o.type == ClassType.Class).Count()
+ allObjects.OfType <UmlClass> ()
.Where((o) => o.type == ClassType.Interface).Count()
+ allObjects.OfType <UmlEnum> () /* Strukturen? */
.Count())
);
Files.WriteLines(Path.GetDirectoryName(target) + "/Definitionen.gentex", lines);
if (IsRunningOnMono())
{
foreach (UmlClass obj in allObjects.OfType <UmlClass>())
{
// write class diagram
ClassDiagram dia = new ClassDiagram(new IUmlObject[] { obj });
string filename = Path.GetDirectoryName(target) + "/Klassen/" + obj.Name.Clean();
Files.WriteLines(filename + ".dot", dia.DotCode("", "ffffff", 200));
//GraphViz.Dot ("svg", filename + ".dot", filename + ".svg");
//GraphViz.Dot ("jpg", filename + ".dot", filename + ".jpg");
//GraphViz.Dot ("png", filename + ".dot", filename + ".png");
GraphViz.Dot("svg", filename + ".dot", filename + ".svg");
//GraphViz.Convert ("-density 100", "svg:" + filename + ".svg", filename + ".png");
//GraphViz.RsvgConvert ("--dpi-x 120", "--dpi-y 120", filename + ".svg", ">", filename + ".png");
GraphViz.InkScape("--export-png=" + filename + ".png", "--export-dpi=150", filename + ".svg");
}
}
}