Update of /cvsroot/rails/18xx/rails/util
In directory sfp-cvsdas-4.v30.ch3.sourceforge.com:/tmp/cvs-serv5010/rails/util
Modified Files:
Tag.java ConvertTilesXML.java
Log Message:
Replaced XML of Goderich/Hamburg red tile #-939 by handmade XML including a City (not OffBoardCity).
Index: ConvertTilesXML.java
===================================================================
RCS file: /cvsroot/rails/18xx/rails/util/ConvertTilesXML.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** ConvertTilesXML.java 4 Jun 2008 19:00:39 -0000 1.9
--- ConvertTilesXML.java 30 Apr 2010 15:22:42 -0000 1.10
***************
*** 26,29 ****
--- 26,30 ----
private static List<String> directories = new ArrayList<String>();
private static String inputFilePath = "TileDictionary.xml";
+ private static String handmadeFilePath = "HandmadeTiles.xml";
private static String outputFilePath = "Tiles.xml";
***************
*** 31,34 ****
--- 32,38 ----
private static Map<String, String[]> stationMap;
private static Map<String, String> junctionPosition;
+
+ private static Map<Integer, Element> handmadeTiles
+ = new HashMap<Integer, Element>();
/** Maps non-edge non-station junctions to tracks ending there. */
***************
*** 162,169 ****
private ConvertTilesXML() throws ConfigurationException {
directories.add("tiles");
! Element inputTopElement =
! Tag.findTopTagInFile(inputFilePath, directories, "tiles").getElement();
try {
--- 166,183 ----
private ConvertTilesXML() throws ConfigurationException {
+
+ int tileId;
directories.add("tiles");
!
! Tag handmadeTopTag =
! Tag.findTopTagInFile(handmadeFilePath, directories, "Tiles");
! for (Tag tag : handmadeTopTag.getChildren("Tile")) {
! tileId = tag.getAttributeAsInteger("id");
! handmadeTiles.put(tileId, tag.getElement());
! }
!
! Tag inputTopElement =
! Tag.findTopTagInFile(inputFilePath, directories, "tiles");
try {
***************
*** 187,199 ****
}
! private void convertXML(Element inputElement, Document outputDoc)
throws ConfigurationException {
!
! NodeList children = inputElement.getElementsByTagName("tile");
! for (int i = 0; i < children.getLength(); i++) {
! Element inputTile = (Element) children.item(i);
! Element outputTile = outputDoc.createElement("Tile");
! outputDoc.getDocumentElement().appendChild(outputTile);
! convertTile(inputTile, outputTile);
}
--- 201,220 ----
}
! private void convertXML(Tag inputTag, Document outputDoc)
throws ConfigurationException {
!
! for (Tag tag : inputTag.getChildren("tile")) {
! int tileId = Integer.parseInt(tag.getChild("ID").getText());
! if (handmadeTiles.containsKey(tileId)) {
! Element outputTile = handmadeTiles.get(tileId);
! Node dup = outputDoc.importNode(outputTile, true);
! outputDoc.getDocumentElement().appendChild(dup);
! System.out.println("Copied handmade tile #"+tileId);
! } else {
! Element inputTile = tag.getElement();
! Element outputTile = outputDoc.createElement("Tile");
! outputDoc.getDocumentElement().appendChild(outputTile);
! convertTile(inputTile, outputTile);
! }
}
Index: Tag.java
===================================================================
RCS file: /cvsroot/rails/18xx/rails/util/Tag.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** Tag.java 31 Jan 2010 22:22:37 -0000 1.15
--- Tag.java 30 Apr 2010 15:22:42 -0000 1.16
***************
*** 383,393 ****
}
- /**
- * @deprecated This is a stop-gap, needed until all XML parsing code has
- * been converted to use Tag. This method is now only called from
- * some external utilities.
- * @return
- */
- @Deprecated
public Element getElement() {
return element;
--- 383,386 ----
|