| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | |
package net.sourceforge.jeuclid.elements.support.attributes; |
| 20 | |
|
| 21 | |
import java.awt.Color; |
| 22 | |
import java.util.HashMap; |
| 23 | |
import java.util.Locale; |
| 24 | |
import java.util.Map; |
| 25 | |
import java.util.StringTokenizer; |
| 26 | |
|
| 27 | |
import net.sourceforge.jeuclid.Constants; |
| 28 | |
import net.sourceforge.jeuclid.LayoutContext; |
| 29 | |
import net.sourceforge.jeuclid.elements.AbstractJEuclidElement; |
| 30 | |
import net.sourceforge.jeuclid.elements.support.GraphicsSupport; |
| 31 | |
import net.sourceforge.jeuclid.elements.support.operatordict.OperatorDictionary; |
| 32 | |
|
| 33 | |
import org.apache.commons.logging.Log; |
| 34 | |
import org.apache.commons.logging.LogFactory; |
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | |
|
| 41 | |
public final class AttributesHelper { |
| 42 | |
|
| 43 | |
|
| 44 | |
|
| 45 | |
|
| 46 | |
public static final String COLOR_TRANSPARENT = "transparent"; |
| 47 | |
|
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
public static final String VERYVERYTHINMATHSPACE = "0.0555556em"; |
| 52 | |
|
| 53 | |
|
| 54 | |
|
| 55 | |
|
| 56 | |
public static final String VERYTHINMATHSPACE = "0.111111em"; |
| 57 | |
|
| 58 | |
|
| 59 | |
|
| 60 | |
|
| 61 | |
public static final String THINMATHSPACE = "0.166667em"; |
| 62 | |
|
| 63 | |
|
| 64 | |
|
| 65 | |
|
| 66 | |
public static final String MEDIUMMATHSPACE = "0.222222em"; |
| 67 | |
|
| 68 | |
|
| 69 | |
|
| 70 | |
|
| 71 | |
public static final String THICKMATHSPACE = "0.277778em"; |
| 72 | |
|
| 73 | |
|
| 74 | |
|
| 75 | |
|
| 76 | |
public static final String VERYTHICKMATHSPACE = "0.333333em"; |
| 77 | |
|
| 78 | |
|
| 79 | |
|
| 80 | |
|
| 81 | |
public static final String VERYVERYTHICKMATHSPACE = "0.388889em"; |
| 82 | |
|
| 83 | |
|
| 84 | |
|
| 85 | |
|
| 86 | |
public static final String PT = "pt"; |
| 87 | |
|
| 88 | |
|
| 89 | |
|
| 90 | |
|
| 91 | |
public static final String INFINITY = "9999999pt"; |
| 92 | |
|
| 93 | |
private static final String ERROR_PARSING_NUMBER = "Error Parsing number: "; |
| 94 | |
|
| 95 | |
private static final int HASHSHORT_ALPHA = 5; |
| 96 | |
|
| 97 | |
private static final int HASHSHORT_NO_ALPHA = 4; |
| 98 | |
|
| 99 | |
private static final int SHORT_INDEX_RED = 1; |
| 100 | |
|
| 101 | |
private static final int SHORT_INDEX_GREEN = 2; |
| 102 | |
|
| 103 | |
private static final int SHORT_INDEX_BLUE = 3; |
| 104 | |
|
| 105 | |
private static final int HASHLEN_ALPHA = 9; |
| 106 | |
|
| 107 | |
private static final int HASHLEN_NO_ALPHA = 7; |
| 108 | |
|
| 109 | |
private static final int HEXBASE = 16; |
| 110 | |
|
| 111 | |
private static final float MAX_HEXCHAR_AS_FLOAT = 15f; |
| 112 | |
|
| 113 | |
private static final int MAX_BYTE = 255; |
| 114 | |
|
| 115 | |
private static final float MAX_PERCENT_AS_FLOAT = 100.0f; |
| 116 | |
|
| 117 | |
private static final float MAX_BYTE_AS_FLOAT = 255f; |
| 118 | |
|
| 119 | |
private static final String PERCENT_SIGN = "%"; |
| 120 | |
|
| 121 | |
private static final String COMMA = ","; |
| 122 | |
|
| 123 | |
|
| 124 | |
|
| 125 | |
|
| 126 | |
|
| 127 | |
|
| 128 | |
|
| 129 | |
|
| 130 | |
private static final float EM = 0.83888888888888888888f; |
| 131 | |
|
| 132 | |
|
| 133 | |
|
| 134 | |
|
| 135 | |
|
| 136 | |
|
| 137 | |
|
| 138 | |
|
| 139 | |
private static final float EX = 0.5f; |
| 140 | |
|
| 141 | |
|
| 142 | |
|
| 143 | |
|
| 144 | |
private static final float DPI = 72.0f; |
| 145 | |
|
| 146 | |
private static final float PERCENT = 0.01f; |
| 147 | |
|
| 148 | |
private static final float CM_PER_INCH = 2.54f; |
| 149 | |
|
| 150 | |
private static final float MM_PER_INCH = AttributesHelper.CM_PER_INCH * 10.0f; |
| 151 | |
|
| 152 | |
private static final float PT_PER_PC = 12.0f; |
| 153 | |
|
| 154 | 209 | private static final Map<String, String> SIZETRANSLATIONS = new HashMap<String, String>(); |
| 155 | |
|
| 156 | 209 | private static final Map<String, Float> RELATIVE_UNITS = new HashMap<String, Float>(); |
| 157 | |
|
| 158 | 209 | private static final Map<String, Float> ABSOLUTE_UNITS = new HashMap<String, Float>(); |
| 159 | |
|
| 160 | 209 | private static final Map<String, Color> COLOR_MAPPINGS = new HashMap<String, Color>(); |
| 161 | |
|
| 162 | |
|
| 163 | |
|
| 164 | |
|
| 165 | 209 | private static final Log LOGGER = LogFactory |
| 166 | |
.getLog(AbstractJEuclidElement.class); |
| 167 | |
|
| 168 | |
|
| 169 | |
|
| 170 | |
|
| 171 | |
|
| 172 | 0 | private AttributesHelper() { |
| 173 | 0 | } |
| 174 | |
|
| 175 | |
|
| 176 | |
|
| 177 | |
|
| 178 | |
|
| 179 | |
|
| 180 | |
|
| 181 | |
|
| 182 | |
|
| 183 | |
|
| 184 | |
|
| 185 | |
|
| 186 | |
public static float parseRelativeSize(final String sizeString, |
| 187 | |
final LayoutContext context, final float relativeTo) { |
| 188 | 15048 | if (sizeString == null) { |
| 189 | 0 | return relativeTo; |
| 190 | |
} |
| 191 | 15048 | final String tSize = AttributesHelper.prepareSizeString(sizeString); |
| 192 | |
float retVal; |
| 193 | |
try { |
| 194 | 15048 | if (tSize.length() >= 2) { |
| 195 | 7524 | final int valueLen = tSize.length() - 2; |
| 196 | 7524 | final String unit = tSize.substring(valueLen); |
| 197 | 7524 | final float value = Float.parseFloat(tSize.substring(0, |
| 198 | |
valueLen)); |
| 199 | 7524 | if (AttributesHelper.ABSOLUTE_UNITS.containsKey(unit)) { |
| 200 | 7524 | retVal = AttributesHelper.convertSizeToPt(sizeString, |
| 201 | |
context, AttributesHelper.PT); |
| 202 | 0 | } else if (AttributesHelper.RELATIVE_UNITS.containsKey(unit)) { |
| 203 | 0 | retVal = value * relativeTo |
| 204 | |
* AttributesHelper.RELATIVE_UNITS.get(unit); |
| 205 | |
} else { |
| 206 | 0 | retVal = Float.parseFloat(tSize) * relativeTo; |
| 207 | |
} |
| 208 | 7524 | } else { |
| 209 | 7524 | retVal = Float.parseFloat(tSize) * relativeTo; |
| 210 | |
} |
| 211 | 0 | } catch (final NumberFormatException nfe) { |
| 212 | 0 | retVal = relativeTo; |
| 213 | 0 | AttributesHelper.LOGGER.warn(AttributesHelper.ERROR_PARSING_NUMBER |
| 214 | |
+ sizeString); |
| 215 | 15048 | } |
| 216 | 15048 | return retVal; |
| 217 | |
} |
| 218 | |
|
| 219 | |
|
| 220 | |
|
| 221 | |
|
| 222 | |
|
| 223 | |
|
| 224 | |
|
| 225 | |
|
| 226 | |
|
| 227 | |
|
| 228 | |
|
| 229 | |
|
| 230 | |
|
| 231 | |
public static float convertSizeToPt(final String sizeString, |
| 232 | |
final LayoutContext context, final String defaultUnit) { |
| 233 | 94259 | final String tSize = AttributesHelper.prepareSizeString(sizeString); |
| 234 | 94259 | if (tSize.length() == 0) { |
| 235 | 0 | return 0; |
| 236 | |
} |
| 237 | |
float retVal; |
| 238 | |
try { |
| 239 | |
final String unit; |
| 240 | |
final float value; |
| 241 | 94259 | if (tSize.length() <= 2) { |
| 242 | 3344 | unit = defaultUnit; |
| 243 | 3344 | value = Float.parseFloat(tSize); |
| 244 | |
} else { |
| 245 | 90915 | final int valueLen = tSize.length() - 2; |
| 246 | 90915 | unit = tSize.substring(valueLen); |
| 247 | 90915 | value = Float.parseFloat(tSize.substring(0, valueLen)); |
| 248 | |
} |
| 249 | 94259 | if (value == 0) { |
| 250 | 46189 | retVal = 0.0f; |
| 251 | 48070 | } else if (AttributesHelper.RELATIVE_UNITS.containsKey(unit)) { |
| 252 | 40546 | retVal = value * GraphicsSupport.getFontsizeInPoint(context) |
| 253 | |
* AttributesHelper.RELATIVE_UNITS.get(unit); |
| 254 | 7524 | } else if (AttributesHelper.ABSOLUTE_UNITS.containsKey(unit)) { |
| 255 | 7524 | retVal = value * AttributesHelper.ABSOLUTE_UNITS.get(unit); |
| 256 | 0 | } else if (defaultUnit.length() > 0) { |
| 257 | 0 | retVal = AttributesHelper.convertSizeToPt(sizeString |
| 258 | |
+ defaultUnit, context, ""); |
| 259 | |
} else { |
| 260 | 0 | retVal = Float.parseFloat(tSize); |
| 261 | 0 | AttributesHelper.LOGGER.warn("Error Parsing attribute: " |
| 262 | |
+ sizeString + " assuming " + retVal |
| 263 | |
+ AttributesHelper.PT); |
| 264 | |
} |
| 265 | 0 | } catch (final NumberFormatException nfe) { |
| 266 | 0 | retVal = 1.0f; |
| 267 | 0 | AttributesHelper.LOGGER.warn(AttributesHelper.ERROR_PARSING_NUMBER |
| 268 | |
+ sizeString + " falling back to " + retVal |
| 269 | |
+ AttributesHelper.PT); |
| 270 | 94259 | } |
| 271 | 94259 | return retVal; |
| 272 | |
} |
| 273 | |
|
| 274 | |
private static String prepareSizeString(final String sizeString) { |
| 275 | 109307 | if (sizeString == null) { |
| 276 | 0 | return ""; |
| 277 | |
} |
| 278 | 109307 | String tSize = sizeString.trim().toLowerCase(Locale.ENGLISH); |
| 279 | |
|
| 280 | 109307 | final String translatesTo = AttributesHelper.SIZETRANSLATIONS |
| 281 | |
.get(tSize); |
| 282 | 109307 | if (translatesTo != null) { |
| 283 | 18183 | tSize = translatesTo; |
| 284 | |
} |
| 285 | 109307 | if (tSize.endsWith(AttributesHelper.PERCENT_SIGN)) { |
| 286 | |
|
| 287 | 0 | tSize = new StringBuilder(tSize).append(' ').toString(); |
| 288 | |
} |
| 289 | 109307 | return tSize; |
| 290 | |
} |
| 291 | |
|
| 292 | |
|
| 293 | |
|
| 294 | |
|
| 295 | |
|
| 296 | |
|
| 297 | |
|
| 298 | |
|
| 299 | |
|
| 300 | |
|
| 301 | |
|
| 302 | |
|
| 303 | |
|
| 304 | |
|
| 305 | |
|
| 306 | |
|
| 307 | |
|
| 308 | |
|
| 309 | |
|
| 310 | |
|
| 311 | |
|
| 312 | |
|
| 313 | |
|
| 314 | |
public static Color stringToColor(final String value, |
| 315 | |
final Color defaultValue) { |
| 316 | 17974 | if (value == null) { |
| 317 | 17347 | return null; |
| 318 | |
} |
| 319 | |
|
| 320 | 627 | final String lowVal = value.toLowerCase(Locale.ENGLISH); |
| 321 | 627 | Color parsedColor = null; |
| 322 | |
|
| 323 | 627 | if (AttributesHelper.COLOR_MAPPINGS.containsKey(lowVal)) { |
| 324 | 209 | parsedColor = AttributesHelper.COLOR_MAPPINGS.get(lowVal); |
| 325 | |
} else { |
| 326 | 418 | if (value.charAt(0) == '#') { |
| 327 | 0 | parsedColor = AttributesHelper.parseWithHash(value); |
| 328 | 418 | } else if (value.startsWith("rgb(")) { |
| 329 | 209 | parsedColor = AttributesHelper.parseAsRGB(value); |
| 330 | 209 | } else if (value.startsWith("java.awt.Color")) { |
| 331 | 0 | parsedColor = AttributesHelper.parseAsJavaAWTColor(value); |
| 332 | |
} |
| 333 | |
|
| 334 | 418 | if (parsedColor == null) { |
| 335 | 209 | parsedColor = defaultValue; |
| 336 | |
} |
| 337 | |
|
| 338 | 418 | if (parsedColor != null) { |
| 339 | 209 | AttributesHelper.COLOR_MAPPINGS.put(value, parsedColor); |
| 340 | |
} |
| 341 | |
} |
| 342 | 627 | return parsedColor; |
| 343 | |
} |
| 344 | |
|
| 345 | |
|
| 346 | |
|
| 347 | |
|
| 348 | |
|
| 349 | |
|
| 350 | |
|
| 351 | |
|
| 352 | |
|
| 353 | |
private static Color parseAsJavaAWTColor(final String value) { |
| 354 | |
final Color parsedColor; |
| 355 | 0 | final int poss = value.indexOf('['); |
| 356 | 0 | final int pose = value.indexOf(']'); |
| 357 | 0 | if ((poss == -1) || (pose == -1)) { |
| 358 | 0 | parsedColor = null; |
| 359 | |
} else { |
| 360 | 0 | parsedColor = AttributesHelper.parseCommaSeparatedString(value |
| 361 | |
.substring(poss + 1, pose)); |
| 362 | |
} |
| 363 | 0 | return parsedColor; |
| 364 | |
} |
| 365 | |
|
| 366 | |
|
| 367 | |
|
| 368 | |
|
| 369 | |
|
| 370 | |
|
| 371 | |
|
| 372 | |
|
| 373 | |
private static Color parseAsRGB(final String value) { |
| 374 | |
final Color parsedColor; |
| 375 | 209 | final int poss = value.indexOf('('); |
| 376 | 209 | final int pose = value.indexOf(')'); |
| 377 | 209 | if ((poss == -1) || (pose == -1)) { |
| 378 | 0 | parsedColor = null; |
| 379 | |
} else { |
| 380 | 209 | parsedColor = AttributesHelper.parseCommaSeparatedString(value |
| 381 | |
.substring(poss + 1, pose)); |
| 382 | |
} |
| 383 | 209 | return parsedColor; |
| 384 | |
} |
| 385 | |
|
| 386 | |
private static Color parseCommaSeparatedString(final String value) { |
| 387 | |
Color parsedColor; |
| 388 | 209 | final StringTokenizer st = new StringTokenizer(value, |
| 389 | |
AttributesHelper.COMMA); |
| 390 | |
try { |
| 391 | 209 | float red = 0.0f; |
| 392 | 209 | float green = 0.0f; |
| 393 | 209 | float blue = 0.0f; |
| 394 | 209 | if (st.hasMoreTokens()) { |
| 395 | 209 | final String str = st.nextToken().trim(); |
| 396 | 209 | red = AttributesHelper.parseFloatOrPercent(str); |
| 397 | |
} |
| 398 | 209 | if (st.hasMoreTokens()) { |
| 399 | 209 | final String str = st.nextToken().trim(); |
| 400 | 209 | green = AttributesHelper.parseFloatOrPercent(str); |
| 401 | |
} |
| 402 | 209 | if (st.hasMoreTokens()) { |
| 403 | 209 | final String str = st.nextToken().trim(); |
| 404 | 209 | blue = AttributesHelper.parseFloatOrPercent(str); |
| 405 | |
} |
| 406 | 209 | parsedColor = new Color(red, green, blue); |
| 407 | 0 | } catch (final NumberFormatException e) { |
| 408 | 0 | AttributesHelper.LOGGER.warn(e); |
| 409 | 0 | parsedColor = null; |
| 410 | 209 | } |
| 411 | 209 | return parsedColor; |
| 412 | |
} |
| 413 | |
|
| 414 | |
private static float parseFloatOrPercent(final String str) { |
| 415 | |
final float value; |
| 416 | 627 | if (str.endsWith(AttributesHelper.PERCENT_SIGN)) { |
| 417 | 0 | value = Float.parseFloat(str.substring(0, str.length() - 1)) |
| 418 | |
/ AttributesHelper.MAX_PERCENT_AS_FLOAT; |
| 419 | |
} else { |
| 420 | 627 | value = Float.parseFloat(str) / AttributesHelper.MAX_BYTE_AS_FLOAT; |
| 421 | |
} |
| 422 | 627 | if ((value < 0.0f) || (value > 1.0f)) { |
| 423 | 0 | throw new NumberFormatException(str + " is out of Range"); |
| 424 | |
} |
| 425 | 627 | return value; |
| 426 | |
} |
| 427 | |
|
| 428 | |
|
| 429 | |
|
| 430 | |
|
| 431 | |
|
| 432 | |
|
| 433 | |
|
| 434 | |
|
| 435 | |
private static Color parseWithHash(final String value) { |
| 436 | 0 | Color parsedColor = null; |
| 437 | |
try { |
| 438 | 0 | final int len = value.length(); |
| 439 | 0 | if ((len >= AttributesHelper.HASHSHORT_NO_ALPHA) |
| 440 | |
&& (len <= AttributesHelper.HASHSHORT_ALPHA)) { |
| 441 | |
|
| 442 | 0 | final float red = Integer.parseInt(value.substring( |
| 443 | |
AttributesHelper.SHORT_INDEX_RED, |
| 444 | |
AttributesHelper.SHORT_INDEX_RED + 1), |
| 445 | |
AttributesHelper.HEXBASE) |
| 446 | |
/ AttributesHelper.MAX_HEXCHAR_AS_FLOAT; |
| 447 | 0 | final float green = Integer.parseInt(value.substring( |
| 448 | |
AttributesHelper.SHORT_INDEX_GREEN, |
| 449 | |
AttributesHelper.SHORT_INDEX_GREEN + 1), |
| 450 | |
AttributesHelper.HEXBASE) |
| 451 | |
/ AttributesHelper.MAX_HEXCHAR_AS_FLOAT; |
| 452 | 0 | final float blue = Integer.parseInt(value.substring( |
| 453 | |
AttributesHelper.SHORT_INDEX_BLUE, |
| 454 | |
AttributesHelper.SHORT_INDEX_BLUE + 1), |
| 455 | |
AttributesHelper.HEXBASE) |
| 456 | |
/ AttributesHelper.MAX_HEXCHAR_AS_FLOAT; |
| 457 | 0 | float alpha = 1.0f; |
| 458 | 0 | if (len == AttributesHelper.HASHSHORT_ALPHA) { |
| 459 | 0 | alpha = Integer.parseInt(value |
| 460 | |
.substring(AttributesHelper.HASHSHORT_NO_ALPHA), |
| 461 | |
AttributesHelper.HEXBASE) |
| 462 | |
/ AttributesHelper.MAX_HEXCHAR_AS_FLOAT; |
| 463 | |
} |
| 464 | 0 | parsedColor = new Color(red, green, blue, alpha); |
| 465 | 0 | } else if ((len == AttributesHelper.HASHLEN_NO_ALPHA) |
| 466 | |
|| (len == AttributesHelper.HASHLEN_ALPHA)) { |
| 467 | 0 | final int red = Integer.parseInt(value.substring(1, 3), |
| 468 | |
AttributesHelper.HEXBASE); |
| 469 | 0 | final int green = Integer.parseInt(value.substring(3, 5), |
| 470 | |
AttributesHelper.HEXBASE); |
| 471 | 0 | final int blue = Integer.parseInt(value.substring(5, |
| 472 | |
AttributesHelper.HASHLEN_NO_ALPHA), |
| 473 | |
AttributesHelper.HEXBASE); |
| 474 | 0 | int alpha = AttributesHelper.MAX_BYTE; |
| 475 | 0 | if (len == AttributesHelper.HASHLEN_ALPHA) { |
| 476 | 0 | alpha = Integer.parseInt(value |
| 477 | |
.substring(AttributesHelper.HASHLEN_NO_ALPHA), |
| 478 | |
AttributesHelper.HEXBASE); |
| 479 | |
} |
| 480 | 0 | parsedColor = new Color(red, green, blue, alpha); |
| 481 | 0 | } else { |
| 482 | 0 | throw new NumberFormatException(); |
| 483 | |
} |
| 484 | 0 | } catch (final NumberFormatException e) { |
| 485 | 0 | return null; |
| 486 | 0 | } |
| 487 | 0 | return parsedColor; |
| 488 | |
} |
| 489 | |
|
| 490 | |
|
| 491 | |
|
| 492 | |
|
| 493 | |
|
| 494 | |
|
| 495 | |
|
| 496 | |
|
| 497 | |
|
| 498 | |
|
| 499 | |
|
| 500 | |
public static String colorTOsRGBString(final Color color) { |
| 501 | 209 | if (color == null) { |
| 502 | 0 | return AttributesHelper.COLOR_TRANSPARENT; |
| 503 | |
} |
| 504 | 209 | final StringBuffer sbuf = new StringBuffer(10); |
| 505 | 209 | sbuf.append('#'); |
| 506 | 209 | String s = Integer.toHexString(color.getRed()); |
| 507 | 209 | if (s.length() == 1) { |
| 508 | 0 | sbuf.append('0'); |
| 509 | |
} |
| 510 | 209 | sbuf.append(s); |
| 511 | 209 | s = Integer.toHexString(color.getGreen()); |
| 512 | 209 | if (s.length() == 1) { |
| 513 | 0 | sbuf.append('0'); |
| 514 | |
} |
| 515 | 209 | sbuf.append(s); |
| 516 | 209 | s = Integer.toHexString(color.getBlue()); |
| 517 | 209 | if (s.length() == 1) { |
| 518 | 0 | sbuf.append('0'); |
| 519 | |
} |
| 520 | 209 | sbuf.append(s); |
| 521 | 209 | if (color.getAlpha() != AttributesHelper.MAX_BYTE) { |
| 522 | 0 | s = Integer.toHexString(color.getAlpha()); |
| 523 | 0 | if (s.length() == 1) { |
| 524 | 0 | sbuf.append('0'); |
| 525 | |
} |
| 526 | 0 | sbuf.append(s); |
| 527 | |
} |
| 528 | 209 | return sbuf.toString(); |
| 529 | |
|
| 530 | |
} |
| 531 | |
|
| 532 | |
|
| 533 | |
static { |
| 534 | |
|
| 535 | |
|
| 536 | 209 | AttributesHelper.SIZETRANSLATIONS.put( |
| 537 | |
OperatorDictionary.NAME_VERYVERYTHINMATHSPACE, |
| 538 | |
AttributesHelper.VERYVERYTHINMATHSPACE); |
| 539 | 209 | AttributesHelper.SIZETRANSLATIONS.put( |
| 540 | |
OperatorDictionary.NAME_VERYTHINMATHSPACE, |
| 541 | |
AttributesHelper.VERYTHINMATHSPACE); |
| 542 | 209 | AttributesHelper.SIZETRANSLATIONS.put( |
| 543 | |
OperatorDictionary.NAME_THINMATHSPACE, |
| 544 | |
AttributesHelper.THINMATHSPACE); |
| 545 | 209 | AttributesHelper.SIZETRANSLATIONS.put( |
| 546 | |
OperatorDictionary.NAME_MEDIUMMATHSPACE, |
| 547 | |
AttributesHelper.MEDIUMMATHSPACE); |
| 548 | 209 | AttributesHelper.SIZETRANSLATIONS.put( |
| 549 | |
OperatorDictionary.NAME_THICKMATHSPACE, |
| 550 | |
AttributesHelper.THICKMATHSPACE); |
| 551 | 209 | AttributesHelper.SIZETRANSLATIONS.put( |
| 552 | |
OperatorDictionary.NAME_VERYTHICKMATHSPACE, |
| 553 | |
AttributesHelper.VERYTHICKMATHSPACE); |
| 554 | 209 | AttributesHelper.SIZETRANSLATIONS.put( |
| 555 | |
OperatorDictionary.NAME_VERYVERYTHICKMATHSPACE, |
| 556 | |
AttributesHelper.VERYVERYTHICKMATHSPACE); |
| 557 | 209 | AttributesHelper.SIZETRANSLATIONS.put(OperatorDictionary.NAME_INFINITY, |
| 558 | |
AttributesHelper.INFINITY); |
| 559 | 209 | AttributesHelper.SIZETRANSLATIONS.put("small", "68%"); |
| 560 | 209 | AttributesHelper.SIZETRANSLATIONS.put("normal", "100%"); |
| 561 | 209 | AttributesHelper.SIZETRANSLATIONS.put("big", "147%"); |
| 562 | |
|
| 563 | |
|
| 564 | 209 | AttributesHelper.SIZETRANSLATIONS.put("thin", "0.5"); |
| 565 | 209 | AttributesHelper.SIZETRANSLATIONS.put("medium", "1"); |
| 566 | 209 | AttributesHelper.SIZETRANSLATIONS.put("thick", "2"); |
| 567 | |
|
| 568 | 209 | AttributesHelper.SIZETRANSLATIONS.put("null", Constants.ZERO); |
| 569 | |
|
| 570 | 209 | AttributesHelper.RELATIVE_UNITS.put("em", AttributesHelper.EM); |
| 571 | 209 | AttributesHelper.RELATIVE_UNITS.put("ex", AttributesHelper.EX); |
| 572 | 209 | AttributesHelper.RELATIVE_UNITS.put("% ", AttributesHelper.PERCENT); |
| 573 | |
|
| 574 | 209 | AttributesHelper.ABSOLUTE_UNITS.put("px", 1.0f); |
| 575 | 209 | AttributesHelper.ABSOLUTE_UNITS.put("in", AttributesHelper.DPI); |
| 576 | 209 | AttributesHelper.ABSOLUTE_UNITS.put("cm", AttributesHelper.DPI |
| 577 | |
/ AttributesHelper.CM_PER_INCH); |
| 578 | 209 | AttributesHelper.ABSOLUTE_UNITS.put("mm", AttributesHelper.DPI |
| 579 | |
/ AttributesHelper.MM_PER_INCH); |
| 580 | 209 | AttributesHelper.ABSOLUTE_UNITS.put(AttributesHelper.PT, 1.0f); |
| 581 | 209 | AttributesHelper.ABSOLUTE_UNITS.put("pc", AttributesHelper.PT_PER_PC); |
| 582 | |
|
| 583 | |
|
| 584 | 209 | AttributesHelper.COLOR_MAPPINGS.put("aqua", new Color(0, 255, 255)); |
| 585 | 209 | AttributesHelper.COLOR_MAPPINGS.put("black", Color.BLACK); |
| 586 | 209 | AttributesHelper.COLOR_MAPPINGS.put("blue", Color.BLUE); |
| 587 | 209 | AttributesHelper.COLOR_MAPPINGS.put("fuchsia", new Color(255, 0, 255)); |
| 588 | 209 | AttributesHelper.COLOR_MAPPINGS.put("gray", Color.GRAY); |
| 589 | 209 | AttributesHelper.COLOR_MAPPINGS.put("green", Color.GREEN); |
| 590 | 209 | AttributesHelper.COLOR_MAPPINGS.put("lime", new Color(0, 255, 0)); |
| 591 | 209 | AttributesHelper.COLOR_MAPPINGS.put("maroon", new Color(128, 0, 0)); |
| 592 | 209 | AttributesHelper.COLOR_MAPPINGS.put("navy", new Color(0, 0, 128)); |
| 593 | 209 | AttributesHelper.COLOR_MAPPINGS.put("olive", new Color(128, 128, 0)); |
| 594 | 209 | AttributesHelper.COLOR_MAPPINGS.put("purple", new Color(128, 0, 128)); |
| 595 | 209 | AttributesHelper.COLOR_MAPPINGS.put("red", Color.RED); |
| 596 | 209 | AttributesHelper.COLOR_MAPPINGS.put("silver", new Color(192, 192, 192)); |
| 597 | 209 | AttributesHelper.COLOR_MAPPINGS.put("teal", new Color(0, 128, 128)); |
| 598 | 209 | AttributesHelper.COLOR_MAPPINGS.put("white", Color.WHITE); |
| 599 | 209 | AttributesHelper.COLOR_MAPPINGS.put("yellow", Color.YELLOW); |
| 600 | |
|
| 601 | |
|
| 602 | 209 | AttributesHelper.COLOR_MAPPINGS.put(AttributesHelper.COLOR_TRANSPARENT, |
| 603 | |
null); |
| 604 | 209 | AttributesHelper.COLOR_MAPPINGS.put("null", null); |
| 605 | 209 | AttributesHelper.COLOR_MAPPINGS.put("", null); |
| 606 | 209 | } |
| 607 | |
|
| 608 | |
} |