|
1 | 1 | /* |
2 | | - * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | 4 | * |
5 | 5 | * This code is free software; you can redistribute it and/or modify it |
@@ -1097,7 +1097,7 @@ private static int getTableBorder(AttributeSet tableAttr) { |
1097 | 1097 | * up a translation from StyleConstants (i.e. the <em>well known</em> |
1098 | 1098 | * attributes) to the associated CSS attributes. |
1099 | 1099 | */ |
1100 | | - private static final Hashtable<Object, Attribute> styleConstantToCssMap = new Hashtable<Object, Attribute>(17); |
| 1100 | + private static final Map<Object, Attribute> styleConstantToCssMap; |
1101 | 1101 | /** Maps from HTML value to a CSS value. Used in internal mapping. */ |
1102 | 1102 | private static final Hashtable<String, CSS.Value> htmlValueToCssValueMap = new Hashtable<String, CSS.Value>(8); |
1103 | 1103 | /** Maps from CSS value (string) to internal value. */ |
@@ -1167,38 +1167,40 @@ private static int getTableBorder(AttributeSet tableAttr) { |
1167 | 1167 | ); |
1168 | 1168 |
|
1169 | 1169 | // initialize StyleConstants mapping |
1170 | | - styleConstantToCssMap.put(StyleConstants.FontFamily, |
1171 | | - CSS.Attribute.FONT_FAMILY); |
1172 | | - styleConstantToCssMap.put(StyleConstants.FontSize, |
1173 | | - CSS.Attribute.FONT_SIZE); |
1174 | | - styleConstantToCssMap.put(StyleConstants.Bold, |
1175 | | - CSS.Attribute.FONT_WEIGHT); |
1176 | | - styleConstantToCssMap.put(StyleConstants.Italic, |
1177 | | - CSS.Attribute.FONT_STYLE); |
1178 | | - styleConstantToCssMap.put(StyleConstants.Underline, |
1179 | | - CSS.Attribute.TEXT_DECORATION); |
1180 | | - styleConstantToCssMap.put(StyleConstants.StrikeThrough, |
1181 | | - CSS.Attribute.TEXT_DECORATION); |
1182 | | - styleConstantToCssMap.put(StyleConstants.Superscript, |
1183 | | - CSS.Attribute.VERTICAL_ALIGN); |
1184 | | - styleConstantToCssMap.put(StyleConstants.Subscript, |
1185 | | - CSS.Attribute.VERTICAL_ALIGN); |
1186 | | - styleConstantToCssMap.put(StyleConstants.Foreground, |
1187 | | - CSS.Attribute.COLOR); |
1188 | | - styleConstantToCssMap.put(StyleConstants.Background, |
1189 | | - CSS.Attribute.BACKGROUND_COLOR); |
1190 | | - styleConstantToCssMap.put(StyleConstants.FirstLineIndent, |
1191 | | - CSS.Attribute.TEXT_INDENT); |
1192 | | - styleConstantToCssMap.put(StyleConstants.LeftIndent, |
1193 | | - CSS.Attribute.MARGIN_LEFT); |
1194 | | - styleConstantToCssMap.put(StyleConstants.RightIndent, |
1195 | | - CSS.Attribute.MARGIN_RIGHT); |
1196 | | - styleConstantToCssMap.put(StyleConstants.SpaceAbove, |
1197 | | - CSS.Attribute.MARGIN_TOP); |
1198 | | - styleConstantToCssMap.put(StyleConstants.SpaceBelow, |
1199 | | - CSS.Attribute.MARGIN_BOTTOM); |
1200 | | - styleConstantToCssMap.put(StyleConstants.Alignment, |
1201 | | - CSS.Attribute.TEXT_ALIGN); |
| 1170 | + styleConstantToCssMap = Map.ofEntries( |
| 1171 | + Map.entry(StyleConstants.FontFamily, |
| 1172 | + CSS.Attribute.FONT_FAMILY), |
| 1173 | + Map.entry(StyleConstants.FontSize, |
| 1174 | + CSS.Attribute.FONT_SIZE), |
| 1175 | + Map.entry(StyleConstants.Bold, |
| 1176 | + CSS.Attribute.FONT_WEIGHT), |
| 1177 | + Map.entry(StyleConstants.Italic, |
| 1178 | + CSS.Attribute.FONT_STYLE), |
| 1179 | + Map.entry(StyleConstants.Underline, |
| 1180 | + CSS.Attribute.TEXT_DECORATION), |
| 1181 | + Map.entry(StyleConstants.StrikeThrough, |
| 1182 | + CSS.Attribute.TEXT_DECORATION), |
| 1183 | + Map.entry(StyleConstants.Superscript, |
| 1184 | + CSS.Attribute.VERTICAL_ALIGN), |
| 1185 | + Map.entry(StyleConstants.Subscript, |
| 1186 | + CSS.Attribute.VERTICAL_ALIGN), |
| 1187 | + Map.entry(StyleConstants.Foreground, |
| 1188 | + CSS.Attribute.COLOR), |
| 1189 | + Map.entry(StyleConstants.Background, |
| 1190 | + CSS.Attribute.BACKGROUND_COLOR), |
| 1191 | + Map.entry(StyleConstants.FirstLineIndent, |
| 1192 | + CSS.Attribute.TEXT_INDENT), |
| 1193 | + Map.entry(StyleConstants.LeftIndent, |
| 1194 | + CSS.Attribute.MARGIN_LEFT), |
| 1195 | + Map.entry(StyleConstants.RightIndent, |
| 1196 | + CSS.Attribute.MARGIN_RIGHT), |
| 1197 | + Map.entry(StyleConstants.SpaceAbove, |
| 1198 | + CSS.Attribute.MARGIN_TOP), |
| 1199 | + Map.entry(StyleConstants.SpaceBelow, |
| 1200 | + CSS.Attribute.MARGIN_BOTTOM), |
| 1201 | + Map.entry(StyleConstants.Alignment, |
| 1202 | + CSS.Attribute.TEXT_ALIGN) |
| 1203 | + ); |
1202 | 1204 |
|
1203 | 1205 | // HTML->CSS |
1204 | 1206 | htmlValueToCssValueMap.put("disc", CSS.Value.DISC); |
|
0 commit comments