4813 composedTextAttribute = new SimpleAttributeSet(); |
4813 composedTextAttribute = new SimpleAttributeSet(); |
4814 composedTextAttribute.addAttribute(StyleConstants.ComposedTextAttribute, |
4814 composedTextAttribute.addAttribute(StyleConstants.ComposedTextAttribute, |
4815 new AttributedString(text, composedIndex, text.getEndIndex())); |
4815 new AttributedString(text, composedIndex, text.getEndIndex())); |
4816 } |
4816 } |
4817 |
4817 |
4818 private boolean saveComposedText(int pos) { |
4818 /** |
|
4819 * Saves composed text around the specified position. |
|
4820 * |
|
4821 * The composed text (if any) around the specified position is saved |
|
4822 * in a backing store and removed from the document. |
|
4823 * |
|
4824 * @param pos document position to identify the composed text location |
|
4825 * @return {@code true} if the composed text exists and is saved, |
|
4826 * {@code false} otherwise |
|
4827 * @see #restoreComposedText |
|
4828 */ |
|
4829 protected boolean saveComposedText(int pos) { |
4819 if (composedTextExists()) { |
4830 if (composedTextExists()) { |
4820 int start = composedTextStart.getOffset(); |
4831 int start = composedTextStart.getOffset(); |
4821 int len = composedTextEnd.getOffset() - |
4832 int len = composedTextEnd.getOffset() - |
4822 composedTextStart.getOffset(); |
4833 composedTextStart.getOffset(); |
4823 if (pos >= start && pos <= start + len) { |
4834 if (pos >= start && pos <= start + len) { |
4828 } |
4839 } |
4829 } |
4840 } |
4830 return false; |
4841 return false; |
4831 } |
4842 } |
4832 |
4843 |
4833 private void restoreComposedText() { |
4844 /** |
|
4845 * Restores composed text previously saved by {@code saveComposedText}. |
|
4846 * |
|
4847 * The saved composed text is inserted back into the document. This method |
|
4848 * should be invoked only if {@code saveComposedText} returns {@code true}. |
|
4849 * |
|
4850 * @see #saveComposedText |
|
4851 */ |
|
4852 protected void restoreComposedText() { |
4834 Document doc = getDocument(); |
4853 Document doc = getDocument(); |
4835 try { |
4854 try { |
4836 doc.insertString(caret.getDot(), |
4855 doc.insertString(caret.getDot(), |
4837 composedTextContent, |
4856 composedTextContent, |
4838 composedTextAttribute); |
4857 composedTextAttribute); |