Blame |
Last modification |
View Log
| RSS feed
/*
* Copyright (C) 2014 Steve Ratcliffe
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 or
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
package test.svg;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter;
/**
* Convert a nod file to svg to show the routing relationships.
*
* @author Steve Ratcliffe
*/
public class Main
{
private SvgDoc doc
;
/**
* Create an XML document.
*/
private void createDoc
() {
doc =
new SvgDoc
();
doc.
createDoc();
}
/**
* Write the document.
*/
private void writeDoc
() {
doc.
setTransform(doc.
getLeftOffset(), doc.
getTopOffset());
try {
OutputFormat fmt = OutputFormat.
createPrettyPrint();
XMLWriter output =
new XMLWriter
(new FileWriter( new File("out.svg") ), fmt
);
output.
write(doc.
getDoc());
output.
close();
} catch (IOException e
) {
e.
printStackTrace();
}
}
private void run
(String name
) {
createDoc
();
// Draw the road network
//Roads roads = new Roads();
//roads.run(doc, name);
// Draw the route network
Route route =
new Route
();
route.
run(doc, name
);
writeDoc
();
}
public static void main
(String[] args
) {
if (args.
length < 1) {
System.
err.
println("Usage: nod2svg <filename>");
System.
exit(1);
}
Main main =
new Main
();
String name = args
[0];
main.
run(name
);
}
}