use of javax.swing.text.AttributeSet in project omegat by omegat-org.
the class SegmentBuilder method insertTextWithTags.
/**
* Inserts the texts and formats the text
* @param text source or translation text
* @param isSource true if it is a source text, false if it is a translation
* @throws BadLocationException
*/
private String insertTextWithTags(String text, boolean isSource) throws BadLocationException {
if (!isSource && hasRTL && controller.targetLangIsRTL) {
text = EditorUtils.addBidiAroundTags(text, ste);
}
AttributeSet normal = attrs(isSource, false, false, false);
insert(text, normal);
return text;
}
use of javax.swing.text.AttributeSet in project omegat by omegat-org.
the class SegmentBuilder method addOtherLanguagePart.
/**
* Add inactive segment part, without segment begin/end marks.
*
* @param text other language translation text
* @throws BadLocationException
*/
private void addOtherLanguagePart(String text, Language language) throws BadLocationException {
int prevOffset = offset;
boolean rtl = Language.isRTL(language.getLanguageCode());
insertDirectionEmbedding(false);
AttributeSet normal = attrs(true, false, false, false);
insert(language.getLanguage() + ": ", normal);
insertDirectionEndEmbedding();
insertDirectionEmbedding(rtl);
AttributeSet attrs = settings.getOtherLanguageTranslationAttributeSet();
insert(text, attrs);
insertDirectionEndEmbedding();
insert("\n", null);
setAlignment(prevOffset, offset, rtl);
}
use of javax.swing.text.AttributeSet in project omegat by omegat-org.
the class GlossaryTextArea method getToolTipText.
@Override
public String getToolTipText(MouseEvent event) {
StyledDocument doc = getStyledDocument();
Element elem = doc.getCharacterElement(Java8Compat.viewToModel(this, event.getPoint()));
AttributeSet as = elem.getAttributes();
Object attr = as.getAttribute(TooltipAttribute.ATTRIBUTE_KEY);
if (attr instanceof TooltipAttribute) {
return ((TooltipAttribute) attr).getPayload();
} else {
return super.getToolTipText(event);
}
}
use of javax.swing.text.AttributeSet in project jphp by jphp-compiler.
the class WrapHyperlinkEvent method __getAttributes.
@Signature
protected Memory __getAttributes(Environment env, Memory... args) {
AttributeSet attrs = event.getSourceElement().getAttributes();
List<?> keys = Collections.list(attrs.getAttributeNames());
ArrayMemory result = new ArrayMemory();
for (Object key : keys) {
result.put(key.toString(), new StringMemory(attrs.getAttribute(key).toString()));
}
return result.toConstant();
}
use of javax.swing.text.AttributeSet in project gradle by gradle.
the class TextPaneSearchInteraction method highlightText.
/**
* This highlights the text within the specified range
*
* @param startingIndex where to start the highlight
* @param endingIndex where to end the highlight
* @param ensureVisible true to scroll to the text
* @param isEmphasized true to use an emphasized highlight (versus a regular highlight). Useful for showing the 'current' highlighted result.
*/
public void highlightText(int startingIndex, int endingIndex, boolean ensureVisible, boolean isEmphasized) {
int length = endingIndex - startingIndex;
AttributeSet style;
if (isEmphasized) {
style = emphasizedHighlightStyle;
} else {
style = highlightStyle;
}
((DefaultStyledDocument) textComponentToSearch.getDocument()).setCharacterAttributes(startingIndex, length, style, true);
if (ensureVisible) {
Utility.scrollToText(textComponentToSearch, startingIndex, endingIndex);
textComponentToSearch.setCaretPosition(endingIndex);
}
textComponentToSearch.repaint();
}
Aggregations