|
47 | 47 | import com.mxgraph.shape.mxStencilShape; |
48 | 48 | import com.mxgraph.svg2xml.XmlConfig.aspectType; |
49 | 49 |
|
| 50 | +import static java.lang.String.format; |
| 51 | + |
50 | 52 | /** |
51 | 53 | * Executes what is defined in Svg2XmlGui |
52 | 54 | */ |
@@ -104,6 +106,13 @@ public static void main(String[] args) |
104 | 106 | svg2Xml.convertToXml(sourceFiles.toArray(new File[0]), new File(args[1])); |
105 | 107 | } |
106 | 108 |
|
| 109 | + private boolean isInfoLogActivated = true; |
| 110 | + private void logInfo(String msg) { |
| 111 | + if (isInfoLogActivated) { |
| 112 | + System.out.println(format("Svg2Xml [INFO] %s", msg)); |
| 113 | + } |
| 114 | + } |
| 115 | + |
107 | 116 | public void convertToXml(File[] sourceFiles, File destPath) { |
108 | 117 | // order of actions: |
109 | 118 | //1. Config settings are given default values combined with the settings from the UI. |
@@ -190,7 +199,7 @@ public void convertToXml(File[] sourceFiles, File destPath) { |
190 | 199 | // construct destConfigDoc based on default values, groupConfigDoc and stencilConfigDoc |
191 | 200 | for (int i = 0; i < sourceFiles.length; i++) |
192 | 201 | { |
193 | | - System.out.println("Processing " + sourceFiles[i].getAbsolutePath()); |
| 202 | + logInfo("Processing " + sourceFiles[i].getAbsolutePath()); |
194 | 203 | groupBaos = new ByteArrayOutputStream(); |
195 | 204 | isLastInGroup = false; |
196 | 205 | isNewGroup = true; |
@@ -234,7 +243,7 @@ public void convertToXml(File[] sourceFiles, File destPath) { |
234 | 243 | testFile = null; |
235 | 244 |
|
236 | 245 | // now we have potentially both config files in String format |
237 | | - System.out.println("parsing " + shapeName + " using " + configCount + " configs"); |
| 246 | + logInfo("parsing " + shapeName + " using " + configCount + " configs"); |
238 | 247 |
|
239 | 248 | ArrayList<Connection> groupConnection = null; |
240 | 249 |
|
@@ -679,14 +688,14 @@ else if (aspectRatio.toLowerCase().equals("variable")) |
679 | 688 | String fileName = sourceFiles[i].getName(); |
680 | 689 | fileName = fileName.substring(0, fileName.lastIndexOf('.')) + ".xml"; |
681 | 690 | File destFile = new File(destPath, fileName); |
682 | | - System.out.println("Prepare writing to " + destFile); |
| 691 | + logInfo("Prepare writing to " + destFile); |
683 | 692 |
|
684 | 693 | // TODO try-with-resource to improve resources management |
685 | 694 | FileWriter fileWriter = new FileWriter(destFile); |
686 | 695 | BufferedWriter writer = new BufferedWriter(fileWriter); |
687 | 696 | writer.write(groupXml); |
688 | 697 | writer.close(); |
689 | | - System.out.println("File written"); |
| 698 | + logInfo("File written"); |
690 | 699 |
|
691 | 700 | if (!destPaths.contains(destPath)) |
692 | 701 | { |
|
0 commit comments