@@ -28,10 +28,22 @@ public class LabelFontAndBGTransform implements ModelVersionTransformation {
2828 /** The end label tag that we want to replace. */
2929 private static final String endLabelTag = "</net.rptools.maptool.model.Label>" ;
3030
31+ /** The pattern that we want o match for 0 foreground color. */
32+ private static final String replace0ForegroundTags =
33+ "<foregroundColor>0</foregroundColor>[^<]*" + endLabelTag ;
34+
35+ /**
36+ * The foreground color that we want to use for the label where the legacy foreground color is 0.
37+ */
38+ private static final Color legacyForegroundColor = new Color (0.0f , 0.0f , 0.0f , 1.0f );
39+
40+ private static final String foreground0Replacement =
41+ "<foregroundColor>" + legacyForegroundColor .getRGB () + "</foregroundColor>\n " + endLabelTag ;
42+
3143 /** The background color that we want to use for the new label tag. */
3244 private static final Color legacyBackgroundColor = new Color (0.82f , 0.82f , 0.82f , 1.0f );
3345
34- /** The replacement string that we want to use for the end label tag. */
46+ /** The replacement string that we want to use for the new label tag. */
3547 private static final String replacement =
3648 "<backgroundColor>"
3749 + legacyBackgroundColor .getRGB ()
@@ -54,8 +66,13 @@ public class LabelFontAndBGTransform implements ModelVersionTransformation {
5466 /** The pattern that we want to use to match the end label tag. */
5567 private static final Pattern pattern = Pattern .compile (endLabelTag , Pattern .DOTALL );
5668
69+ /** The pattern that we want to use to match the legacy foreground color of 0. */
70+ private static final Pattern replace0Foreground =
71+ Pattern .compile (replace0ForegroundTags , Pattern .DOTALL );
72+
5773 @ Override
5874 public String transform (String xml ) {
59- return pattern .matcher (xml ).replaceAll (replacement );
75+ String replace0 = replace0Foreground .matcher (xml ).replaceAll (foreground0Replacement );
76+ return pattern .matcher (replace0 ).replaceAll (replacement );
6077 }
6178}
0 commit comments