use of javax.swing.text.AttributeSet in project binnavi by google.
the class SyntaxDocument method highlightLinesAfter.
/*
* Highlight lines to start or end delimiter
*/
private void highlightLinesAfter(final String content, final int line) {
final int offset = rootElement.getElement(line).getEndOffset();
// Start/End delimiter not found, nothing to do
int startDelimiter = indexOf(content, getStartDelimiter(), offset);
int endDelimiter = indexOf(content, getEndDelimiter(), offset);
if (startDelimiter < 0) {
startDelimiter = content.length();
}
if (endDelimiter < 0) {
endDelimiter = content.length();
}
final int delimiter = Math.min(startDelimiter, endDelimiter);
if (delimiter < offset) {
return;
}
// Start/End delimiter found, reapply highlighting
final int endLine = rootElement.getElementIndex(delimiter);
for (int i = line + 1; i < endLine; i++) {
final Element branch = rootElement.getElement(i);
final Element leaf = doc.getCharacterElement(branch.getStartOffset());
final AttributeSet as = leaf.getAttributes();
if (as.isEqual(comment)) {
applyHighlighting(content, i);
}
}
}
use of javax.swing.text.AttributeSet in project android-classyshark by google.
the class BatchDocument method appendBatchLineFeed.
public void appendBatchLineFeed(AttributeSet a) {
batch.add(new ElementSpec(a, ElementSpec.ContentType, EOL_ARRAY, 0, 1));
Element paragraph = getParagraphElement(0);
AttributeSet pattern = paragraph.getAttributes();
batch.add(new ElementSpec(null, ElementSpec.EndTagType));
batch.add(new ElementSpec(pattern, ElementSpec.StartTagType));
}
use of javax.swing.text.AttributeSet in project java-swing-tips by aterai.
the class TooltipEditorKit method getSpanTitleAttribute.
private Optional<String> getSpanTitleAttribute(HTMLDocument doc, int pos) {
// HTMLDocument doc = (HTMLDocument) editor.getDocument();
Element elem = doc.getCharacterElement(pos);
// if (!doesElementContainLocation(editor, elem, pos, e.getX(), e.getY())) {
// elem = null;
// }
// if (elem != null) {
AttributeSet a = elem.getAttributes();
AttributeSet span = (AttributeSet) a.getAttribute(HTML.Tag.SPAN);
return Optional.ofNullable(span).map(s -> Objects.toString(s.getAttribute(HTML.Attribute.TITLE)));
}
use of javax.swing.text.AttributeSet in project java-swing-tips by aterai.
the class MainPanel method checkId.
public void checkId(Element element) {
AttributeSet attrs = element.getAttributes();
Object elementName = attrs.getAttribute(AbstractDocument.ElementNameAttribute);
Object name = Objects.isNull(elementName) ? attrs.getAttribute(StyleConstants.NameAttribute) : null;
HTML.Tag tag;
if (name instanceof HTML.Tag) {
tag = (HTML.Tag) name;
} else {
return;
}
textArea.append(String.format("%s%n", tag));
if (tag.isBlock()) {
// block
blockHighlight(element, attrs);
} else {
// inline
inlineHighlight(element, attrs);
}
}
Aggregations