use of javax.swing.text.Element in project Universal-G-Code-Sender by winder.
the class EditorListener method caretUpdate.
@Override
public void caretUpdate(CaretEvent e) {
if (e.getSource() instanceof JEditorPane) {
JEditorPane jep = (JEditorPane) e.getSource();
Element map = jep.getDocument().getDefaultRootElement();
int startIndex = map.getElementIndex(jep.getSelectionStart());
int endIndex = map.getElementIndex(jep.getSelectionEnd());
if (highlight != null) {
highlight.setHighlightedLines(startIndex, endIndex);
}
}
}
use of javax.swing.text.Element in project freeplane by freeplane.
the class AutoSpellChecker method checkElements.
/**
* Check the Elements on the given position.
*/
private void checkElements(int offset, final int length) {
final int end = offset + length;
final Document document = jText.getDocument();
Element element;
do {
try {
// We need to use a ParagraphElement because a CharacterElement produce problems with formating in a word
element = ((AbstractDocument) document).getParagraphElement(offset);
} catch (final java.lang.Exception ex) {
return;
}
removeHighlighters(element);
checkElement(element);
offset = element.getEndOffset();
} while (offset <= end && offset < document.getLength());
}
use of javax.swing.text.Element in project freeplane by freeplane.
the class FixedHTMLWriter method writeAttributes.
/*
* (non-Javadoc)
* @seejavax.swing.text.html.HTMLWriter#writeAttributes(javax.swing.text.
* AttributeSet)
*/
@Override
protected void writeAttributes(final AttributeSet attr) throws IOException {
if (attr instanceof Element) {
final Element elem = (Element) attr;
if (elem.isLeaf() || elem.getName().equalsIgnoreCase("p-implied")) {
super.writeAttributes(attr);
return;
}
}
convAttr.removeAttributes(convAttr);
FixedHTMLWriter.convertToHTML(attr, convAttr);
final Enumeration<?> names = convAttr.getAttributeNames();
while (names.hasMoreElements()) {
final Object name = names.nextElement();
if (name instanceof HTML.Tag || name instanceof StyleConstants || name == HTML.Attribute.ENDTAG) {
continue;
}
write(" " + name + "=\"" + convAttr.getAttribute(name) + "\"");
}
}
use of javax.swing.text.Element in project freeplane by freeplane.
the class HtmlUtils method getCurrentLinkElement.
public static Element getCurrentLinkElement(HTMLDocument doc, int pos) {
Element element2 = null;
Element element = doc.getCharacterElement(pos);
// elem.getAttributes().getAttribute(HTML.Tag.A);
Object linkAttribute = null;
Object href = null;
while (element != null && linkAttribute == null) {
element2 = element;
linkAttribute = element.getAttributes().getAttribute(HTML.Tag.A);
if (linkAttribute != null) {
href = ((AttributeSet) linkAttribute).getAttribute(HTML.Attribute.HREF);
}
element = element.getParentElement();
}
if (linkAttribute != null && href != null) {
return element2;
} else {
return null;
}
}
use of javax.swing.text.Element in project freeplane by freeplane.
the class HtmlUtils method getURLOfExistingLink.
/**
* Gets the string URL of an existing link, or null if none.
*/
public static String getURLOfExistingLink(HTMLDocument doc, int pos) {
// setIgnoreActions(true);
final Element linkElement = HtmlUtils.getCurrentLinkElement(doc, pos);
final boolean foundLink = (linkElement != null);
if (!foundLink) {
return null;
}
final AttributeSet elemAttrs = linkElement.getAttributes();
final Object linkAttr = elemAttrs.getAttribute(HTML.Tag.A);
final Object href = ((AttributeSet) linkAttr).getAttribute(HTML.Attribute.HREF);
return href != null ? href.toString() : null;
}
Aggregations