Examples of DocumentRange


Examples of org.encog.bot.browse.range.DocumentRange

   *            The index to begin loading at.
   * @param tag
   *            The beginning tag.
   */
  protected final void loadTitle(final int index, final Tag tag) {
    final DocumentRange title = new DocumentRange(this.page);
    title.setBegin(index);
    title.setEnd(findEndTag(index + 1, tag));
    this.page.setTitle(title);
  }
View Full Code Here

Examples of org.encog.bot.browse.range.DocumentRange

      DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent();
      if( node!=null )
      {
        if( node.getUserObject() instanceof DocumentRange )
        {
          DocumentRange range = (DocumentRange)node.getUserObject();
          this.dataText.setText(range.getTextOnly());
        }
      }
    }
   
  }
View Full Code Here

Examples of org.encog.bot.browse.range.DocumentRange

  {
    LoadWebPage load = new LoadWebPage(null);
    WebPage page = load.load("<a href=\"index.html\">Link <b>1</b></a>");
    Assert.assertEquals(1,page.getContents().size());
   
    DocumentRange span = page.getContents().get(0);
    Assert.assertEquals(0, span.getBegin());
    Assert.assertEquals(5, span.getEnd());
    Assert.assertTrue(span instanceof Link);
    Link link = (Link)span;
    Assert.assertEquals("index.html",link.getTarget().getOriginal().toString());
    Address address = link.getTarget();
    Assert.assertNotNull(address.toString());
View Full Code Here

Examples of org.encog.bot.browse.range.DocumentRange

   *            The index to begin loading at.
   * @param tag
   *            The beginning tag.
   */
  protected final void loadTitle(final int index, final Tag tag) {
    final DocumentRange title = new DocumentRange(this.page);
    title.setBegin(index);
    title.setEnd(findEndTag(index + 1, tag));
    this.page.setTitle(title);
  }
View Full Code Here

Examples of org.encog.bot.browse.range.DocumentRange

  {
    LoadWebPage load = new LoadWebPage(null);
    WebPage page = load.load("<a href=\"index.html\">Link <b>1</b></a>");
    Assert.assertEquals(1,page.getContents().size());
   
    DocumentRange span = page.getContents().get(0);
    Assert.assertEquals(0, span.getBegin());
    Assert.assertEquals(5, span.getEnd());
    Assert.assertTrue(span instanceof Link);
    Link link = (Link)span;
    Assert.assertEquals("index.html",link.getTarget().getOriginal().toString());
    Address address = link.getTarget();
    Assert.assertNotNull(address.toString());
View Full Code Here

Examples of org.fife.ui.rsyntaxtextarea.DocumentRange

    String text = context.getSearchFor();
    boolean forward = context.getSearchForward();

    // Find the next location of the text we're searching for.
    DocumentRange range = null;
    if (!context.isRegularExpression()) {
      int pos = getNextMatchPos(text, findIn, forward,
                context.getMatchCase(), context.getWholeWord());
      findIn = null; // May help garbage collecting.
      if (pos!=-1) {
        range = new DocumentRange(pos, pos+text.length());
      }
    }

    else {
      // Regex matches can have varying widths.  The returned point's
      // x- and y-values represent the start and end indices of the
      // match in findIn.
      Point regExPos = null;
      int start = 0;
      do {
        regExPos = getNextMatchPosRegEx(text, findIn.substring(start),
          forward, context.getMatchCase(), context.getWholeWord());
        if (regExPos!=null) {
          if (regExPos.x!=regExPos.y) {
            regExPos.translate(start, start);
            range = new DocumentRange(regExPos.x, regExPos.y);
          }
          else {
            start += regExPos.x + 1;
          }
        }
View Full Code Here

Examples of org.fife.ui.rsyntaxtextarea.DocumentRange

        findIn = findIn.toLowerCase();
      }

      SearchResult res = SearchEngine.findImpl(findIn, context);
      while (res.wasFound()) {
        DocumentRange match = res.getMatchRange().translate(start);
        if (match.isZeroLength()) {
          // Searched for a regex like "foo|".  The "empty string"
          // part of the regex matches space between chars.  We want
          // to skip these in the case of mark-all.
          start = match.getEndOffset() + 1;
          if (start>findIn.length()) {
            break;
          }
        }
        else {
          highlights.add(match);
          start = match.getEndOffset();
        }
        res = SearchEngine.findImpl(findIn.substring(start), context);
      }
      textArea.markAll(highlights);
      markAllCount = highlights.size();
View Full Code Here

Examples of org.fife.ui.rsyntaxtextarea.DocumentRange

    // Find the next location of the text we're searching for.
    RegExReplaceInfo info = getRegExReplaceInfo(findIn, context);

    // If a match was found, do the replace and return!
    DocumentRange range = null;
    if (info!=null) {

      // Without this, if JTextArea isn't in focus, selection won't
      // appear selected.
      c.setSelectionVisible(true);

      int matchStart = info.getStartIndex();
      int matchEnd = info.getEndIndex();
      if (forward) {
        matchStart += start;
        matchEnd += start;
      }
      textArea.setSelectionStart(matchStart);
      textArea.setSelectionEnd(matchEnd);
      String replacement = info.getReplacement();
      textArea.replaceSelection(replacement);

      // If there is another match, find and select it.
      int dot = matchStart + replacement.length();
      findIn = getFindInCharSequence(textArea, dot, forward);
      info = getRegExReplaceInfo(findIn, context);
      if (info!=null) {
        matchStart = info.getStartIndex();
        matchEnd = info.getEndIndex();
        if (forward) {
          matchStart += dot;
          matchEnd += dot;
        }
        range = new DocumentRange(matchStart, matchEnd);
      }
      else {
        range = new DocumentRange(dot, dot);
      }
      RSyntaxUtilities.selectAndPossiblyCenter(textArea, range, true);

    }
View Full Code Here

Examples of org.fife.ui.rsyntaxtextarea.DocumentRange

          dot += length;
        }
        textArea.setCaretPosition(dot);

        SearchResult next = find(textArea, context);
        DocumentRange range;
        if (next.wasFound()) {
          range = next.getMatchRange();
        }
        else {
          range = new DocumentRange(dot, dot);
        }
        res.setMatchRange(range);
        RSyntaxUtilities.selectAndPossiblyCenter(textArea, range, true);

      }
View Full Code Here

Examples of org.fife.ui.rsyntaxtextarea.DocumentRange

    List<DocumentRange> list = new ArrayList<DocumentRange>(
        markAllHighlights.size());
    for (HighlightInfo info : markAllHighlights) {
      int start = info.getStartOffset();
      int end = info.getEndOffset() + 1; // HACK
      DocumentRange range = new DocumentRange(start, end);
      list.add(range);
    }
    return list;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.