Package javax.swing.text

Examples of javax.swing.text.Segment


        end = start;
        start = tmp;
      }

      StringBuffer buf = new StringBuffer();
      Segment seg = new Segment();

      for( int i = selectionStartLine; i <= selectionEndLine; i++ )
      {
        Element lineElement = map.getElement( i );
        int lineStart = lineElement.getStartOffset();
View Full Code Here


  public void tokenizeLines( int start, int len )
  {
    if( tokenMarker == null || !tokenMarker.supportsMultilineTokens() )
      return;

    Segment lineSegment = new Segment();
    Element map = getDefaultRootElement();

    len += start;

    try
View Full Code Here

    setOpaque( true );
    setBorder( null );

    ToolTipManager.sharedInstance().registerComponent( this );

    currentLine = new Segment();
    currentLineIndex = -1;

    setCursor( Cursor.getPredefinedCursor( Cursor.TEXT_CURSOR ) );

    setFont( new Font( "Monospaced", Font.PLAIN, 14 ) );
View Full Code Here

    {
        int caret = editor.getCaretPosition();
        Document doc = editor.getDocument();
        Element root = doc.getDefaultRootElement();
        Element elemento = null;
        Segment stexto = new Segment();
        int nele = root.getElementCount();
        int nlinea = linea;
        int ncolumna = 0;
       
        // si no viene la l�nea me recorro todos los elementos hasta que encuentra cual es el del caret.
        for(int i=0;i < nele;i++)
            if(root.getElement(i).getStartOffset() <= caret &&
                root.getElement(i).getEndOffset() >= caret)
            {
                nlinea = i+1;
                // break;
            }

        // la columna es igual al caret - el caret de la linea
        elemento = root.getElement(nlinea-1);
        ncolumna = caret - elemento.getStartOffset();
       
        // coge todo el texto de la fila
        try
        {
            doc.getText(elemento.getStartOffset(), elemento.getEndOffset() - elemento.getStartOffset(), stexto); //coge todo el texto
            String cadena = stexto.toString();
            // en cadena tenemos toda la l�nea, buscamos un sep�rador por delante y otro por detras desde la posici�n del cursor
            int posini = 0;
            char caracter = '\0';
            int tam = cadena.length();
            if(ncolumna >= tam)
View Full Code Here

        int linea = 0;
        int caret = editor.getCaretPosition();
        Document doc = editor.getDocument();
        Element root = doc.getDefaultRootElement();
        Element elemento = null;
        Segment stexto = new Segment();
        int nele = root.getElementCount();
        int nlinea = linea;
        int ncolumna = 0;
       
        // si no viene la l�nea me recorro todos los elementos hasta que encuentra cual es el del caret.
        for(int i=0;i < nele;i++)
            if(root.getElement(i).getStartOffset() <= caret &&
                root.getElement(i).getEndOffset() >= caret)
            {
                nlinea = i+1;
                // break;
            }

        // la columna es igual al caret - el caret de la linea
        elemento = root.getElement(nlinea-1);
        ncolumna = caret - elemento.getStartOffset();
       
        // coge todo el texto de la fila
        try
        {
            doc.getText(elemento.getStartOffset(), elemento.getEndOffset() - elemento.getStartOffset(), stexto); //coge todo el texto
            String cadena = stexto.toString();
            // en cadena tenemos toda la l�nea, buscamos un sep�rador por delante y otro por detras desde la posici�n del cursor
            int posini = 0;
            char caracter = '\0';
            int tam = cadena.length();
            if(ncolumna >= tam)
View Full Code Here

  private boolean startsSentence = true;

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

      buffer.readLock();

      boolean endOfLine = (buffer.getLineEndOffset(
        buffer.getLineOfOffset(end)) - 1 == end);

      Segment text = new Segment();
      int offset = start;

      HyperSearchResult lastResult = null;

loop:      for(int counter = 0; ; counter++)
View Full Code Here

    {
      view.getToolkit().beep();
      return false;
    }

    Segment text = new Segment();
    if(reverse)
      buffer.getText(0,start,text);
    else
      buffer.getText(start,buffer.getLength() - start,text);
View Full Code Here

    int occurCount = 0;

    boolean endOfLine = (buffer.getLineEndOffset(
      buffer.getLineOfOffset(end)) - 1 == end);

    Segment text = new Segment();
    int offset = start;
loop:    for(int counter = 0; ; counter++)
    {
      buffer.getText(offset,end - offset,text);
View Full Code Here

    {
      throw new ArrayIndexOutOfBoundsException(offset + ":"
        + buffer.getLineLength(line));
    }

    Segment lineText = new Segment();
    buffer.getLineText(line,lineText);

    char c = lineText.array[lineText.offset + offset];
    char cprime; // corresponding character
    boolean direction; // false - backwards, true - forwards
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.