Tabnine Logo
DefaultStyledDocument.getDefaultRootElement
Code IndexAdd Tabnine to your IDE (free)

How to use
getDefaultRootElement
method
in
javax.swing.text.DefaultStyledDocument

Best Java code snippets using javax.swing.text.DefaultStyledDocument.getDefaultRootElement (Showing top 17 results out of 315)

origin: chatty/chatty

/**
 * Checks if the given line exists in this document.
 * 
 * @param line The line to check
 * @return true if the line was found in the document, false otherwise
 */
private boolean doesLineExist(Object line) {
  int count = doc.getDefaultRootElement().getElementCount();
  for (int i=0;i<count;i++) {
    if (doc.getDefaultRootElement().getElement(i) == line) {
      return true;
    }
  }
  return false;
}

origin: nz.ac.waikato.cms.weka/weka-stable

/**
 * Initializes the document.
 * 
 * @param props the properties to obtain the setup from
 */
public SyntaxDocument(Properties props) {
 m_Self = this;
 m_RootElement = m_Self.getDefaultRootElement();
 m_Keywords = new HashMap<String, MutableAttributeSet>();
 m_FontSize = DEFAULT_FONT_SIZE;
 m_FontName = DEFAULT_FONT_FAMILY;
 putProperty(DefaultEditorKit.EndOfLineStringProperty, "\n");
 setup(props);
}
origin: Waikato/weka-trunk

/**
 * Initializes the document.
 * 
 * @param props the properties to obtain the setup from
 */
public SyntaxDocument(Properties props) {
 m_Self = this;
 m_RootElement = m_Self.getDefaultRootElement();
 m_Keywords = new HashMap<String, MutableAttributeSet>();
 m_FontSize = DEFAULT_FONT_SIZE;
 m_FontName = DEFAULT_FONT_FAMILY;
 putProperty(DefaultEditorKit.EndOfLineStringProperty, "\n");
 setup(props);
}
origin: chatty/chatty

/**
 * Searches the Document for all lines by the given user.
 * 
 * @param nick
 * @return 
 */
private ArrayList<Integer> getLinesFromUser(User user, String id, boolean onlyUserMessages) {
  Element root = doc.getDefaultRootElement();
  ArrayList<Integer> result = new ArrayList<>();
  for (int i=0;i<root.getElementCount();i++) {
    Element line = root.getElement(i);
    if (isLineFromUserAndId(line, user, id, onlyUserMessages)) {
      result.add(i);
    }
  }
  return result;
}

origin: chatty/chatty

/**
 * Removes some chat lines from the top, depending on the current
 * scroll position.
 */
private void clearSomeChat() {
  if (scrollManager.fixedChat) {
    return;
  }
  if (!scrollManager.isScrollPositionNearEnd()) {
    return;
  }
  int count = doc.getDefaultRootElement().getElementCount();
  int max = styles.bufferSize();
  if (count > max) {
    removeFirstLines(2);
  }
}
origin: chatty/chatty

private java.util.List<Userline> getUserLines(User searchUser) {
  java.util.List<Userline> result = new ArrayList<>();
  Element root = doc.getDefaultRootElement();
  for (int i = root.getElementCount() - 1; i >= 0; i--) {
    Element line = root.getElement(i);
    Element userElement = getUserElementFromLine(line, false);
    if (userElement != null) {
      User foundUser = (User)userElement.getAttributes().getAttribute(Attribute.USER);
      if (searchUser == null || foundUser == searchUser) {
        result.add(new Userline(searchUser, userElement, line));
      }
    }
  }
  return result;
}

origin: chatty/chatty

  public void removeOldLines() {
    if (messageTimeout > 0) {
      Element paragraph = doc.getDefaultRootElement().getElement(0);
      if (doc.getLength() > 1 && getTimeAgo(paragraph) > messageTimeout * 1000) {
//                removeFirstLines(1);
        
        // Don't use doc.remove() for this, since removing one line with
        // it seems to copy paragraph attributes to the follow line
        // (visible if alternating backgrounds are showing)
        if (doc.getDefaultRootElement().getElementCount() > 1) {
          // Can't use this if it's the last element
          doc.removeElement(doc.getDefaultRootElement().getElement(0));
        } else {
          clearAll();
        }
        scrollDownIfNecessary();
        resetNewlineRequired();
      }
    }
  }
  
origin: chatty/chatty

int count = doc.getDefaultRootElement().getElementCount();
if (currentSelection != null && !doesLineExist(currentSelection)) {
  currentSelection = null;
  Element element = doc.getDefaultRootElement().getElement(i);
  User user = getUserFromLine(element);
  if (element == currentSelection) {
origin: chatty/chatty

/**
 * Remove text from chat, while also handling Emotes in the removed section
 * correctly.
 *
 * @param start Start offset
 * @param len Length of section to remove
 * @throws BadLocationException 
 */
private void remove(int start, int len) throws BadLocationException {
  Debugging.edt();
  int startLine = doc.getDefaultRootElement().getElementIndex(start);
  int endLine = doc.getDefaultRootElement().getElementIndex(start+len);
  Set<Long> before = Util.getImageIds(doc, startLine, endLine);
  doc.remove(start, len);
  if (!before.isEmpty()) {
    Set<Long> after = Util.getImageIds(doc, startLine, endLine);
    if (Debugging.isEnabled("gifd", "gifd2")) {
      Debugging.println(String.format("Removed %d+%d (Before: %s After: %s)",
          start, len, before, after));
    }
    before.removeAll(after);
    for (long id : before) {
      kit.clearImage(id);
    }
  }
}

origin: chatty/chatty

/**
 * Try to select the given line. Only selects chat messages. Also
 * selects all other messages in the buffer from the same user and
 * unselects any previously selected.
 * 
 * @param line The line to select
 * @return true if the line was selected (if it is a chat message),
 * false otherwise
 */
private boolean select(Element line) {
  if (isMessageLine(line)) {
    User user = getUserFromLine(line);
    clearSearchResult();
    highlightLine(line, true);
    currentSelection = line;
    currentUser = user;
    ArrayList<Integer> lines = getLinesFromUser(user, null, true);
    for (Integer lineNumber : lines) {
      Element otherLine = doc.getDefaultRootElement().getElement(lineNumber);
      if (otherLine != currentSelection) {
        highlightLine(otherLine, false);
      }
    }
    return true;
  }
  return false;
}

origin: chatty/chatty

  amount = 1;
if (doc.getDefaultRootElement().getElementCount() == 0) {
  return;
Element firstToRemove = doc.getDefaultRootElement().getElement(0);
Element lastToRemove = doc.getDefaultRootElement().getElement(amount - 1);
origin: chatty/chatty

int count = doc.getDefaultRootElement().getElementCount();
if (lastSearchPos != null && !doesLineExist(lastSearchPos)) {
  Element element = doc.getDefaultRootElement().getElement(i);
  if (element == lastSearchPos) {
origin: chatty/chatty

Element root = doc.getDefaultRootElement();
for (int i = 0; i < root.getElementCount(); i++) {
  Element paragraph = root.getElement(i);
origin: chatty/chatty

Element root = doc.getDefaultRootElement();
for (int i=root.getElementCount()-1;i>=0;i--) {
  Element line = root.getElement(i);
origin: stackoverflow.com

rootElement = doc.getDefaultRootElement();
putProperty( DefaultEditorKit.EndOfLineStringProperty, "\n" );
origin: stackoverflow.com

BranchElement rootElement = (BranchElement) getDefaultRootElement();
origin: chatty/chatty

private boolean printModLogInfo(ModLogInfo info) {
  Element root = doc.getDefaultRootElement();
  String command = info.makeCommand().trim();
  Debugging.println("modlog", "ModLog Command: %s", command);
javax.swing.textDefaultStyledDocumentgetDefaultRootElement

Popular methods of DefaultStyledDocument

  • <init>
  • getLength
  • insertString
  • getText
  • remove
  • setCharacterAttributes
  • addDocumentListener
  • setDocumentFilter
  • addUndoableEditListener
  • createPosition
  • getParagraphElement
  • getCharacterElement
  • getParagraphElement,
  • getCharacterElement,
  • setParagraphAttributes,
  • insert,
  • addStyle,
  • fireInsertUpdate,
  • fireRemoveUpdate,
  • getEndPosition,
  • getStyle

Popular in Java

  • Reactive rest calls using spring rest template
  • requestLocationUpdates (LocationManager)
  • getApplicationContext (Context)
  • onRequestPermissionsResult (Fragment)
  • BufferedInputStream (java.io)
    A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the i
  • OutputStream (java.io)
    A writable sink for bytes.Most clients will use output streams that write data to the file system (
  • Iterator (java.util)
    An iterator over a sequence of objects, such as a collection.If a collection has been changed since
  • Notification (javax.management)
  • LogFactory (org.apache.commons.logging)
    Factory for creating Log instances, with discovery and configuration features similar to that employ
  • Table (org.hibernate.mapping)
    A relational table
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now