<commit_before>/*
 * LICENSE
 *
 * Copyright 2015 <NAME> Licensed under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with the
 * License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

package co.andrewbates.windtalker;

import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.text.BadLocationException;

public class LogField extends JScrollPane {
    private static final long serialVersionUID = 6678508751403261470L;
    private JTextArea textArea;
    private int maxLength;

    public LogField(String text, int columns, int maxLength) {
        textArea = new JTextArea(text, 0, columns);
        textArea.setLineWrap(false);
        textArea.setEditable(false);
        this.maxLength = maxLength;
        setViewportView(textArea);
    }

    public void setMaxLength(int maxLength) {
        this.maxLength = maxLength;
        truncate();
    }

    public void log(String message) {
        if (!message.endsWith("\n")) {
            message += "\n";
        }
        textArea.append(message);
        truncate();
        textArea.setRows(textArea.getLineCount());
        textArea.setCaretPosition(textArea.getDocument().getLength());
    }<commit_msg>Added javadoc to the LogField class<commit_after>/*
 * LICENSE
 *
 * Copyright 2015 <NAME> Licensed under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with the
 * License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

package co.andrewbates.windtalker;

import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.text.BadLocationException;

/**
 * @author <NAME>
 * 
 *         LogField is a Swing widget that provides a scrolling pane for log
 *         messages. The pain will automatically add new messages to the bottom
 *         of the pane as well as automatically scroll to the bottom as new
 *         messages are added.
 */
public class LogField extends JScrollPane {
    private static final long serialVersionUID = 6678508751403261470L;
    private JTextArea textArea;
    private int maxLength;

    /**
     * Initializes a new log field setting the initial text as well as the width
     * in columns and the length in lines
     * 
     * @param text
     *            default text to display
     * @param width
     *            of the field in text columns
     * @param maxLength
     *            length of the field in text lines
     */
    public LogField(String text, int columns, int maxLength) {
        textArea = new JTextArea(text, 0, columns);
        textArea.setLineWrap(false);
        textArea.setEditable(false);
        this.maxLength = maxLength;
        setViewportView(textArea);
    }

    /**
     * Append a message to the field
     * 
     * @param message
     *            the message to append to the log field
     */
    public void log(String message) {
        if (!message.endsWith("\n")) {
            message += "\n";
        }
        textArea.append(message);
        truncate();
        textArea.setRows(textArea.getLineCount());
        textArea.setCaretPosition(textArea.getDocument().getLength());
    }

    /**
     * Set the maximum length of the scroll back buffer
     * 
     * @param maxLength
     *            the length (in lines) of the scroll buffer
     */
    public void setMaxLength(int maxLength) {
        this.maxLength = maxLength;
        truncate();
    }
{'fraction_non_alphanumeric': 0.08210376011423132, 'fraction_numerical': 0.013326987148976678, 'mean_word_length': 2.7030837004405286, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5890054', 'n_tokens_mistral': 1160, 'n_tokens_neox': 1108, 'n_words': 413}