javax.swing.text.Element.getParentElement()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(285)

本文整理了Java中javax.swing.text.Element.getParentElement()方法的一些代码示例,展示了Element.getParentElement()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.getParentElement()方法的具体详情如下:
包路径:javax.swing.text.Element
类名称:Element
方法名:getParentElement

Element.getParentElement介绍

暂无

代码示例

代码示例来源:origin: robotframework/SwingLibrary

  1. public Element getParentElement() {
  2. return element.getParentElement();
  3. }

代码示例来源:origin: freeplane/freeplane

  1. private Element getStandAloneElement(final Element element) {
  2. final String name = element.getName();
  3. if (name.equals("ul") || name.equals("ol") || name.equals("table") || name.equals("html")) {
  4. return element;
  5. }
  6. return getStandAloneElement(element.getParentElement());
  7. }

代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-ui

  1. /**
  2. * Method for inserting list elements
  3. */
  4. public void insertListStyle(Element element) throws BadLocationException, IOException {
  5. if (element.getParentElement().getName() == "ol") {
  6. actionListOrdered.actionPerformed(new ActionEvent(new Object(), 0, "newListPoint"));
  7. } else {
  8. actionListUnordered.actionPerformed(new ActionEvent(new Object(), 0, "newListPoint"));
  9. }
  10. }

代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-ui

  1. /**
  2. * Method that handles initial list insertion and deletion
  3. */
  4. public void manageListElement(Element element) {
  5. Element h = htmlUtilities.getListItemParent();
  6. Element listElement = h.getParentElement();
  7. if (h != null) {
  8. htmlUtilities.removeTag(h, true);
  9. }
  10. }

代码示例来源:origin: nz.ac.waikato.cms.weka.thirdparty/bounce

  1. private int getRealStart() {
  2. fixedStart = start.getParentElement().getElementIndex(start.getStartOffset());
  3. return fixedStart;
  4. }

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib

  1. /** Get the total count of lines in the document */
  2. public static int getRowCount(BaseDocument doc) {
  3. return doc.getParagraphElement(0).getParentElement().getElementCount();
  4. }

代码示例来源:origin: nz.ac.waikato.cms.weka.thirdparty/bounce

  1. private int getRealEnd() {
  2. return end.getParentElement().getElementIndex(end.getStartOffset());
  3. }

代码示例来源:origin: com.google.code.findbugs/findbugs

  1. public Integer getLineNumber() {
  2. Element element = this.getElement();
  3. Integer result = elementLineNumberCache.get(element);
  4. if (result != null) {
  5. return result;
  6. }
  7. Element parent = element.getParentElement();
  8. int count = parent.getElementCount();
  9. for (int i = 0; i < count; i++) {
  10. elementLineNumberCache.put(parent.getElement(i), i + 1);
  11. }
  12. result = elementLineNumberCache.get(element);
  13. if (result != null) {
  14. return result;
  15. }
  16. return -1;
  17. }
  18. }

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib

  1. /** Count of rows between these two positions */
  2. public static int getRowCount(BaseDocument doc, int startPos, int endPos)
  3. throws BadLocationException {
  4. if (startPos > endPos) {
  5. return 0;
  6. }
  7. Element lineRoot = doc.getParagraphElement(0).getParentElement();
  8. return lineRoot.getElementIndex(endPos) - lineRoot.getElementIndex(startPos) + 1;
  9. }

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-editor-document

  1. public static int getLineCount(@NonNull LineDocument doc) {
  2. return doc.getParagraphElement(0).getParentElement().getElementCount();
  3. }

代码示例来源:origin: org.netbeans.api/org-openide-text

  1. /** Find the root element of all lines.
  2. * All conforming NetBeans documents
  3. * should return a valid element.
  4. *
  5. * @param doc styled document (expecting NetBeans document)
  6. * @return the root element
  7. * @exception NullPointerException If the <code>doc</code> parameter
  8. * is <code>null</code>.
  9. */
  10. public static Element findLineRootElement(StyledDocument doc) {
  11. checkDocParameter(doc);
  12. Element e = doc.getParagraphElement(0).getParentElement();
  13. if (e == null) {
  14. // try default root (should work for text/plain)
  15. e = doc.getDefaultRootElement();
  16. }
  17. return e;
  18. }

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-editor-document

  1. /**
  2. * Return line index (line number - 1) for the given offset in the document.
  3. *
  4. * @param doc document to operate on
  5. * @param offset position in document where to start searching
  6. */
  7. public static int getLineIndex(@NonNull LineDocument doc, int offset) throws BadLocationException {
  8. checkOffsetValid(doc, offset);
  9. Element lineRoot = doc.getParagraphElement(0).getParentElement();
  10. return lineRoot.getElementIndex(offset);
  11. }

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-editor-document

  1. /** Count of rows between these two positions */
  2. public static int getLineCount(@NonNull LineDocument doc, int startOffset, int endOffset) {
  3. if (startOffset > endOffset) {
  4. return 0;
  5. }
  6. Element lineRoot = doc.getParagraphElement(0).getParentElement();
  7. return lineRoot.getElementIndex(endOffset) - lineRoot.getElementIndex(startOffset) + 1;
  8. }

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib

  1. /** Return line offset (line number - 1) for some position in the document
  2. * @param doc document to operate on
  3. * @param offset position in document where to start searching
  4. */
  5. public static int getLineOffset(BaseDocument doc, int offset)
  6. throws BadLocationException {
  7. checkOffsetValid(offset, doc.getLength() + 1);
  8. Element lineRoot = doc.getParagraphElement(0).getParentElement();
  9. return lineRoot.getElementIndex(offset);
  10. }

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib

  1. /**
  2. * Get the line at which the insert/remove occured.
  3. * @deprecated
  4. */
  5. public int getLine() {
  6. Element lineRoot = ((BaseDocument)getDocument()).getParagraphElement(0).getParentElement();
  7. int lineIndex = lineRoot.getElementIndex(getOffset());
  8. return lineIndex;
  9. // return (getModifyUndoEdit() != null) ? getModifyUndoEdit().getLine() : 0;
  10. }

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib

  1. /** Return start offset of the line
  2. * @param lineIndex line index starting from 0
  3. * @return start position of the line or -1 if lineIndex was invalid
  4. */
  5. public static int getRowStartFromLineOffset(BaseDocument doc, int lineIndex) {
  6. Element lineRoot = doc.getParagraphElement(0).getParentElement();
  7. if (lineIndex < 0 || lineIndex >= lineRoot.getElementCount()) {
  8. return -1; // invalid line number
  9. } else {
  10. return lineRoot.getElement(lineIndex).getStartOffset();
  11. }
  12. }

代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-ui

  1. public boolean checkParentsTag(HTML.Tag tag)
  2. {
  3. Element e = parent.getExtendedHtmlDoc().getParagraphElement(parent.getCaretPosition());
  4. String tagString = tag.toString();
  5. if(e.getName().equalsIgnoreCase(tag.toString()))
  6. {
  7. return true;
  8. }
  9. do
  10. {
  11. if((e = e.getParentElement()).getName().equalsIgnoreCase(tagString))
  12. {
  13. return true;
  14. }
  15. } while(!(e.getName().equalsIgnoreCase("html")));
  16. return false;
  17. }

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-editor-document

  1. /**
  2. * Return start offset of the line with the given index.
  3. *
  4. * @param lineIndex line index starting from 0
  5. * @return start offset of the line or -1 if lineIndex was invalid
  6. */
  7. public static int getLineStartFromIndex(@NonNull LineDocument doc, int lineIndex) {
  8. Element lineRoot = doc.getParagraphElement(0).getParentElement();
  9. if (lineIndex < 0 || lineIndex >= lineRoot.getElementCount()) {
  10. return -1; // invalid line number
  11. } else {
  12. return lineRoot.getElement(lineIndex).getStartOffset();
  13. }
  14. }

代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-ui

  1. public Element getListItemParent()
  2. {
  3. String listItemTag = HTML.Tag.LI.toString();
  4. Element eleSearch = parent.getExtendedHtmlDoc().getCharacterElement(parent.getCaretPosition());
  5. do
  6. {
  7. if(listItemTag.equals(eleSearch.getName()))
  8. {
  9. return eleSearch;
  10. }
  11. eleSearch = eleSearch.getParentElement();
  12. } while(eleSearch.getName() != HTML.Tag.HTML.toString());
  13. return null;
  14. }

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib

  1. private View getExpandedView(){
  2. Element parentElem = getElement().getParentElement();
  3. int sei = parentElem.getElementIndex(getStartOffset());
  4. int so = parentElem.getElement(sei).getStartOffset();
  5. int eei = parentElem.getElementIndex(getEndOffset());
  6. int eo = parentElem.getElement(eei).getEndOffset();
  7. LockView fakeView = new LockView(
  8. new DrawEngineFakeDocView(parentElem, so, eo, false)
  9. );
  10. RootView rootView = new RootView();
  11. rootView.setView(fakeView);
  12. return fakeView;
  13. }

相关文章