/** @see java.awt.Toolkit#mapInputMethodHighlight */ static Map<TextAttribute, ?> mapInputMethodHighlight(InputMethodHighlight highlight) { int index; int state = highlight.getState(); if (state == InputMethodHighlight.RAW_TEXT) { index = 0; } else if (state == InputMethodHighlight.CONVERTED_TEXT) { index = 2; } else { return null; } if (highlight.isSelected()) { index += 1; } return highlightStyles[index]; }
/** Return a Map with entries from oldStyles, as well as input method entries, if any. */ static Map addInputMethodAttrs(Map oldStyles) { Object value = oldStyles.get(TextAttribute.INPUT_METHOD_HIGHLIGHT); try { if (value != null) { if (value instanceof Annotation) { value = ((Annotation) value).getValue(); } InputMethodHighlight hl; hl = (InputMethodHighlight) value; Map imStyles = null; try { imStyles = hl.getStyle(); } catch (NoSuchMethodError e) { } if (imStyles == null) { Toolkit tk = Toolkit.getDefaultToolkit(); imStyles = tk.mapInputMethodHighlight(hl); } if (imStyles != null) { Hashtable newStyles = new Hashtable(5, (float) 0.9); newStyles.putAll(oldStyles); newStyles.putAll(imStyles); return newStyles; } } } catch (ClassCastException e) { } return oldStyles; }