Package javax.swing.text

Examples of javax.swing.text.Segment


        SimSystem.report(e1);
      }

      // only render numbers if showNumbes is true
      if (showNumbers) {
        Segment s =
            new Segment(Integer.toString(i + 1).toCharArray(), 0, Integer
                .toString(i + 1).length());
        int w = Utilities.getTabbedTextWidth(s, g.getFontMetrics(), 0, null, 0);
        Utilities.drawTabbedText(s, getWidth() - w - 3, r.y + r.height
            - g.getFontMetrics().getDescent(), g, null, 0);
      }
View Full Code Here


    if (showIcons) {
      width += iconWidth + 1;
    }
    if (showNumbers) {
      width +=
          Utilities.getTabbedTextWidth(new Segment(Integer.toString(maxLine)
              .toCharArray(), 0, Integer.toString(maxLine).length()),
              getFontMetrics(getFont()), 0, null, 0) + 4;
    }

    // old with so we might be able to skip the revalidating step
View Full Code Here


  public DocumentWordTokenizer(Document document) {
    this.document = document;
    //Create a text segment over the etire document
    text = new Segment();
    sentanceIterator = BreakIterator.getSentenceInstance();
    try {
      document.getText(0, document.getLength(), text);
      sentanceIterator.setText(text);
      currentWordPos = getNextWordStart(text, 0);
View Full Code Here

  private int drawText(Graphics g, int x, int y, int p0, int p1,
      boolean selectionMode) throws BadLocationException {
    Graphics2D g2d = (Graphics2D) g;

    // find tokens at position p0 to p1
    Segment s = getLineBuffer();
    int xe = x;
    Font defaultFont = g2d.getFont();
    Color defaultColor = g2d.getColor();

    // could also use SystemColor class
View Full Code Here

   * @throws BadLocationException
   *           the bad location exception
   */
  private int getOffset(int offset, int p0, int p1) throws BadLocationException {
    // find tokens at position p0 to p1
    Segment s = getLineBuffer();
    int xe = offset;

    if (getGraphics() == null) {
      return 0;
    }
View Full Code Here

    // determine span from the start of the line
    int tabBase = lineArea.x;
    Element line = map.getElement(lineIndex);
    int p0 = line.getStartOffset();
    Segment s = getLineBuffer();
    doc.getText(p0, pos - p0, s);

    int x = getOffset(tabBase, p0, pos);

    // fill in the results and return
View Full Code Here

        // it might be necessary to retrieve more than one segment
        // depending
        // on how many chars a segment can return without copying
        while (length > 0) {
          try {
            Segment text = new Segment();
            text.setPartialReturn(true);
            document.getText(offset, length, text);
            segments.add(text);

            length -= text.getEndIndex() - text.getBeginIndex();
            offset = text.getEndIndex();
          } catch (BadLocationException e) {
            throw new TextProcessingException(
                "Creating the document reader for the document " + doc
                    + " failed.", e);
          }
View Full Code Here

      if (segments == null) {
        segments = new ArrayDeque<>();
      }
      segments.clear();
      String s = document.getText(0, document.getLength());
      Segment text = new Segment(s.toCharArray(), 0, s.length());
      segments.add(text);
      if (documentFilter != null) {
        ((AbstractDocument) document).setDocumentFilter(documentFilter
            .getOriginalFilter());
      }
View Full Code Here


    synchronized void returnPressed() {
        Document doc = getDocument();
        int len = doc.getLength();
        Segment segment = new Segment();
        try {
            doc.getText(outputMark, len - outputMark, segment);
        } catch(javax.swing.text.BadLocationException ignored) {
            ignored.printStackTrace();
        }
        if(segment.count > 0) {
            history.add(segment.toString());
        }
        historyIndex = history.size();
        inPipe.write(segment.array, segment.offset, segment.count);
        append("\n");
        outputMark = doc.getLength();
View Full Code Here

    String s = ""; //$NON-NLS-1$
    try {
      s = source.getParentDocument().get(startOffset, length);
    } catch (BadLocationException e) {
    }
    Segment segment = new Segment(s.toCharArray(), 0, s.length());
    return new SimpleTextSequence(source, segment, 0, segment.count,
        startOffset);
  }
View Full Code Here

TOP

Related Classes of javax.swing.text.Segment

Copyright © 2018 www.massapicom. 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.