use of javax.swing.text.Element in project vcell by virtualcell.
the class MultiPurposeTextPanel method getLineStartOffset.
/**
* Insert the method's description here. Creation date: (10/10/2006 2:17:29
* PM)
*
* @return int
*/
public int getLineStartOffset(int line) throws javax.swing.text.BadLocationException {
Element map = getTextPane().getDocument().getDefaultRootElement();
Element lineElem = map.getElement(line);
return lineElem.getStartOffset();
}
use of javax.swing.text.Element 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.Element in project LauncherV3 by TechnicPack.
the class LimitLinesDocumentListener method removeLines.
private void removeLines(DocumentEvent e) {
// The root Element of the Document will tell us the total number
// of line in the Document.
Document document = e.getDocument();
Element root = document.getDefaultRootElement();
while (root.getElementCount() > maximumLines) {
if (isRemoveFromStart) {
removeFromStart(document, root);
} else {
removeFromEnd(document, root);
}
}
}
use of javax.swing.text.Element in project LauncherV3 by TechnicPack.
the class LimitLinesDocumentListener method removeFromStart.
private void removeFromStart(Document document, Element root) {
Element line = root.getElement(0);
int end = line.getEndOffset();
try {
document.remove(0, end);
} catch (BadLocationException ble) {
System.out.println(ble);
}
}
use of javax.swing.text.Element in project LauncherV3 by TechnicPack.
the class LimitLinesDocumentListener method removeFromEnd.
private void removeFromEnd(Document document, Element root) {
// We use start minus 1 to make sure we remove the newline
// character of the previous line
Element line = root.getElement(root.getElementCount() - 1);
int start = line.getStartOffset();
int end = line.getEndOffset();
try {
document.remove(start - 1, end - start);
} catch (BadLocationException ble) {
System.out.println(ble);
}
}
Aggregations