Package javax.swing.text

Examples of javax.swing.text.Segment


     *
     * @param doc
     *            the document with Xml Information.
     */
    public XMLInputStream( Document doc) {
        this.segment = new Segment();
        this.document = doc;

        end = document.getLength();
        pos = 0;

View Full Code Here


            if ( style != lastStyle && lastStyle != null) {
                // color change, flush what we have
                g.setColor( forceColor != null ? forceColor : context.getForeground( lastStyle));
                g.setFont( g.getFont().deriveFont( context.getFontStyle( lastStyle)));

                Segment text = getLineBuffer();
                doc.getText( mark, start - mark, text);

                x = Utilities.drawTabbedText( text, x, y, g, (TabExpander)view, mark);
                mark = start;
            }

            lastToken = scanner.token;
            lastStyle = style;
            start = p;
        }

        // flush remaining
        g.setColor( forceColor != null ? forceColor : context.getForeground( lastStyle));
        g.setFont( g.getFont().deriveFont( context.getFontStyle( lastStyle)));
        Segment text = getLineBuffer();
        doc.getText( mark, end - mark, text);

        x = Utilities.drawTabbedText( text, x, y, g, (TabExpander)view, mark);

        return x;
View Full Code Here

            // If the style changes, do paint...
            if ( style != lastStyle && lastStyle != null) {
                // color change, flush what we have
                g.setFont( g.getFont().deriveFont( context.getFontStyle( lastStyle)));

                Segment text = getLineBuffer();
                doc.getText( mark, start - mark, text);

                x = Utilities.drawTabbedText( text, x, y, g, (TabExpander)view, mark);
                mark = start;
            }

            lastToken = scanner.token;
            lastStyle = style;
            start = p;
        }

        // flush remaining
        g.setFont( g.getFont().deriveFont( context.getFontStyle( lastStyle)));
        Segment text = getLineBuffer();
        doc.getText( mark, end - mark, text);

        x = Utilities.drawTabbedText( text, x, y, g, (TabExpander)view, mark);

        return x;
View Full Code Here

        return elementEnd;
    }
   
    private static Segment getLineBuffer() {
        if (lineBuffer == null) {
            lineBuffer = new Segment();
        }
        return lineBuffer;
    }
View Full Code Here

    progress.setMinimum(0);
    progress.setMaximum((int) doc.getLength());
   
    // start writing
    Writer out = new FileWriter(f);
                Segment text = new Segment();
                text.setPartialReturn(true);
                int charsLeft = doc.getLength();
    int offset = 0;
                while (charsLeft > 0) {
                    doc.getText(offset, Math.min(4096, charsLeft), text);
                    out.write(text.array, text.offset, text.count);
View Full Code Here

  }


  // A terrible headache...
  public void appendFormattedLine(StringBuffer cf, int line) {
    Segment segment = new Segment();

    TextAreaPainter painter = textarea.getPainter();
    TokenMarker tokenMarker = textarea.getTokenMarker();

    // Use painter's cached info for speed
//    FontMetrics fm = painter.getFontMetrics();

    // get line text from parent text area
    textarea.getLineText(line, segment);

    char[] segmentArray = segment.array;
    int limit = segment.getEndIndex();
    int segmentOffset = segment.offset;
    int segmentCount = segment.count;
//    int width = 0;

    // If syntax coloring is disabled, do simple translation
View Full Code Here

  @Test
  public void testUnderstanding() {
   
    String code = "f = function(x) {\n return(1+x);\n}";
    JavaScriptTokenMaker tokenMaker = new JavaScriptTokenMaker();
    Token tokenList = tokenMaker.getTokenList(new Segment(code.toCharArray(), 0, code.length()), 0, 0);
   
    tokenList = dumpTokenList(tokenList);
  }
View Full Code Here

  @Test
  public void testRenjin() {
   
    String code = "f <- function(x) {\n return(1+x);\n}";
    RenjinTokenMaker tokenMaker = new RenjinTokenMaker();
    Token tokenList = tokenMaker.getTokenList(new Segment(code.toCharArray(), 0, code.length()), 0, 0);
   
    tokenList = dumpTokenList(tokenList);
  }
View Full Code Here

    /** Index of end of current segment in document. */
    private int segmentEnd;

    DocumentCharacterIterator(Document doc) {
        this.doc = doc;
        text = new Segment();
        text.setPartialReturn(true);

        try {
            doc.getText(0, doc.getLength(), text);
        } catch (BadLocationException e) {
View Full Code Here

 
  public void testConstructor2(TestHarness harness)
  {
    harness.checkPoint("(char[], int, int)");
    char[] ch = new char[] {'A', 'B', 'C'};
    Segment s = new Segment(ch, 1, 2);
    harness.check(s.offset, 1);
    harness.check(s.count, 2);
    harness.check(s.array, ch);
    harness.check(s.toString(), "BC");
    harness.check(s.getIndex(), 0);
    harness.check(s.getBeginIndex(), 1);
    harness.check(s.getEndIndex(), 3);
   
    // try offset out of range - this creates an instance with a bad state
    s = new Segment(ch, 4, 1);
    harness.check(s.offset, 4);
    harness.check(s.count, 1);
    harness.check(s.array, ch);
   
    // null array
    s = new Segment(null, 0, 1);
    harness.check(s.offset, 0);
    harness.check(s.count, 1);
    harness.check(s.array, null);
   
    // negative offsets
    s = new Segment(ch, -4, 1);
    harness.check(s.offset, -4);
    harness.check(s.count, 1);
    harness.check(s.array, ch);
   
  }
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.