private boolean isSeparateElement(final Element current) { return !current.isLeaf(); }
public boolean isLeaf() { return element.isLeaf(); }
private Element getElementAt( Element parent, int offset ) { if( parent.isLeaf() ) { return parent; } return getElementAt( parent.getElement( parent.getElementIndex( offset ) ), offset ); } }
result.append("'").append(text).append("'"); result.append("<br />"); if (e.isLeaf() && e.getParentElement() != null) { Element parent = e.getParentElement(); int elementIndex = parent.getElementIndex(e.getStartOffset());
private Element getElementAt( Element parent, int offset ) { if( parent.isLeaf() ) { return parent; } return getElementAt( parent.getElement( parent.getElementIndex( offset ) ), offset ); } }
/** * Output the text of the subelements of the given element. * * @param element */ public static void debugContents(Element element, StringBuilder b) { Document doc = element.getDocument(); b.append("["); if (element.isLeaf()) { try { String text = doc.getText( element.getStartOffset(), element.getEndOffset() - element.getStartOffset()); b.append("'").append(text).append("'"); } catch (BadLocationException ex) { System.out.println("Bad location"); } } else { for (int i = 0; i < element.getElementCount(); i++) { Element child = element.getElement(i); debugContents(child, b); } } b.append("]"); }
public Element getParagraphElement(int pos) { Element e = getDefaultRootElement(); if (e != null && !e.isLeaf()) { int index = e.getElementIndex(pos); e = e.getElement(index); } else { e = getLeafElement(); } return e; }
private Element getParentElement(final HTMLDocument doc) { final Element htmlRoot = doc.getDefaultRootElement(); final Element bodyElement = htmlRoot.getElement(htmlRoot.getElementCount() - 1); Element parentCandidate = bodyElement; do { if (parentCandidate.getElementCount() > 1) { return parentCandidate; } parentCandidate = parentCandidate.getElement(0); } while (!(parentCandidate.isLeaf() || parentCandidate.getName().equalsIgnoreCase("p-implied"))); return bodyElement; }
private Element getParentElement(final HTMLDocument doc) { final Element htmlRoot = doc.getDefaultRootElement(); Element parentCandidate = htmlRoot.getElement(htmlRoot.getElementCount() - 1); do { if (parentCandidate.getElementCount() > 1) { return parentCandidate; } parentCandidate = parentCandidate.getElement(0); } while (!(parentCandidate.isLeaf() || parentCandidate.getName().equalsIgnoreCase("p-implied"))); return null; }
@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) + "\""); } } }
+ "', children: " + element.getElementCount() + ", attributes: " + attrSet.getAttributeCount() + ", leaf: " + element.isLeaf()); Enumeration attrNames = attrSet.getAttributeNames(); while (attrNames.hasMoreElements()) {
private void clearImages(Element element) { Long imageId = (Long)element.getAttributes().getAttribute(Attribute.IMAGE_ID); if (imageId != null) { kit.clearImage(imageId); } if (!element.isLeaf()) { for (int i=0; i<element.getElementCount(); i++) { clearImages(element.getElement(i)); } } }
if ( elem.isLeaf() ) {
+ "', children: " + element.getElementCount() + ", attributes: " + attrSet.getAttributeCount() + ", leaf: " + element.isLeaf()); Enumeration attrNames = attrSet.getAttributeNames(); while (attrNames.hasMoreElements()) {
if (line.isLeaf()) { drawElement(lineIndex, line, g, x, y); } else {
for (int i = 0; i < elementCount; i++) { final Element current = parent.getElement(i); if(current.isLeaf() && ! current.getName().equals(HTML.Tag.BR.toString()) && i < elementCount - 1) continue; final int end = current.getEndOffset();
public void insertUpdate(final DocumentEvent de) { final Document d; //Runnable r; d = de.getDocument(); final int i1, i2; final int l; i1 = de.getOffset(); i2 = de.getLength(); l = d.getLength(); if (l == i1 + i2) { Element e1 = d.getDefaultRootElement(); Element e2 = e1.getElement(e1.getElementIndex(i1)); while (!e2.isLeaf()) e2 = e2.getElement(e2.getElementIndex(i1)); final Element e3 = e2; AttributeSet as = e3.getAttributes(); if (as.isDefined(tubeSortieFenetre)) if (getCaretPosition() != l) { setCaretPosition(l); } } }
private Element process( final javax.swing.text.Element textElement ) throws BadLocationException { if ( textElement.isLeaf() ) { final int endOffset = textElement.getEndOffset(); final int startOffset = textElement.getStartOffset(); final String text = textElement.getDocument().getText( startOffset, endOffset - startOffset ); final Element result = new Element(); result.setElementType( LabelType.INSTANCE ); result.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, text ); configureStyle( textElement.getAttributes(), result ); return result; } final Band band = new Band(); configureStyle( textElement.getAttributes(), band ); configureBand( textElement, band ); final int size = textElement.getElementCount(); for ( int i = 0; i < size; i++ ) { final Element element = process( textElement.getElement( i ) ); band.addElement( element ); } return band; }
if ( textElement.isLeaf() ) { final AttributeSet attributes = textElement.getAttributes(); if ( HTML.Tag.IMG.equals( attributes.getAttribute( StyleConstants.NameAttribute ) ) ) {