<commit_before>/**
 * Copyright 2011 multibit.org
 *
 * Licensed under the MIT license (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://opensource.org/licenses/mit-license.php
 *
 * 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 org.multibit.viewsystem.swing.browser;

/*
 * Animation of loading of URLs:
 * Copyright (c) 2000 <NAME>.  All rights reserved.
 * This code is from the book Java Examples in a Nutshell, 2nd Edition.
 * It is provided AS-IS, WITHOUT ANY WARRANTY either expressed or implied.
 * You may study, use, and modify it for any non-commercial purpose.
 * You may distribute it non-commercially as long as you retain this notice.
 * For a commercial use license, or to purchase the book (recommended),
 * visit http://www.davidflanagan.com/javaexamples2.
 */

import org.multibit.controller.MultiBitController;
import org.multibit.viewsystem.swing.ColorAndFontConstants;
import org.multibit.viewsystem.swing.MultiBitFrame;
import org.multibit.viewsystem.swing.view.HelpContentsPanel;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.IOException;
import java.net.URL;

public class Browser extends javax.swing.JEditorPane implements PropertyChangeListener {
    private static final long serialVersionUID = 1L;

    private MultiBitFrame mainFrame;

    private String loadingMessage;
    
    /**
     * Creates a new <code>JEditorPane</code>. The document model is set to
     * <code>null</code>.
     */
    public Browser(MultiBitController controller, MultiBitFrame mainFrame, String currentHref) {
        super();
        this.mainFrame = mainFrame;

        addHyperlinkListener(new ActivatedHyperlinkListener(mainFrame, this, currentHref));

        loadingMessage = controller.getLocaliser().getString("browser.loadingMessage");
        setEditable(false);
        addPropertyChangeListener(this);
        setBackground(ColorAndFontConstants.VERY_LIGHT_BACKGROUND_COLOR);

        visit(currentHref);
    }

    public static String getLoadingMessage(String href, String loadingMessage) {<commit_msg>font name and size now applied to help<commit_after>/**
 * Copyright 2011 multibit.org
 *
 * Licensed under the MIT license (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://opensource.org/licenses/mit-license.php
 *
 * 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 org.multibit.viewsystem.swing.browser;

/*
 * Animation of loading of URLs:
 * Copyright (c) 2000 <NAME>.  All rights reserved.
 * This code is from the book Java Examples in a Nutshell, 2nd Edition.
 * It is provided AS-IS, WITHOUT ANY WARRANTY either expressed or implied.
 * You may study, use, and modify it for any non-commercial purpose.
 * You may distribute it non-commercially as long as you retain this notice.
 * For a commercial use license, or to purchase the book (recommended),
 * visit http://www.davidflanagan.com/javaexamples2.
 */

import java.awt.Cursor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.IOException;
import java.net.URL;

import javax.swing.text.Document;
import javax.swing.text.html.HTMLEditorKit;

import org.multibit.controller.MultiBitController;
import org.multibit.model.MultiBitModel;
import org.multibit.viewsystem.swing.ColorAndFontConstants;
import org.multibit.viewsystem.swing.MultiBitFrame;
import org.multibit.viewsystem.swing.view.HelpContentsPanel;

public class Browser extends javax.swing.JEditorPane implements PropertyChangeListener {
    private static final long serialVersionUID = 1L;

    private MultiBitFrame mainFrame;

    private String loadingMessage;
    
    /**
     * Creates a new <code>JEditorPane</code>. The document model is set to
     * <code>null</code>.
     */
    public Browser(MultiBitController controller, MultiBitFrame mainFrame, String currentHref) {
        super();
        this.mainFrame = mainFrame;

        addHyperlinkListener(new ActivatedHyperlinkListener(mainFrame, this, currentHref));

        loadingMessage = controller.getLocaliser().getString("browser.loadingMessage");
        setEditable(false);
        addPropertyChangeListener(this);
        setBackground(ColorAndFontConstants.VERY_LIGHT_BACKGROUND_COLOR);

        String fontName = controller.getModel().getUserPreference(MultiBitModel.FONT_NAME);
        if (fontName == null || "".equals(fontName)) {
            fontName = ColorAndFontConstants.MULTIBIT_DEFAULT_FONT_NAME;
        }
        // add in san-serif as a fallback
        fontName = fontName + ", san-serif";

        int fontSize = ColorAndFontConstants.MULTIBIT_DEFAULT_FONT_SIZE;
        String fontSizeString = controller.getModel().getUserPreference(MultiBitModel.FONT_SIZE);
        if (fontSizeString != null && !"".equals(fontSizeString)) {
            try {
                fontSize = Integer.parseInt(fontSizeString);
            } catch (NumberFormatException nfe) {
                // use default
            }
        }
        
        HTMLEditorKit kit = new HTMLEditorKit();
        setEditorKit(kit);
        javax.swing.text.html.StyleSheet styleSheet = kit.getStyleSheet();
        styleSheet.addRule("body {font-size:" + fontSize + "pt; font-family:" + fontName + ";}");
        Document doc = kit.createDefaultDocument();
        setDocument(doc);
        visit(currentHref);
    }

    public static String getLoadingMessage(String href, String loadingMessage) {
{'fraction_non_alphanumeric': 0.08603510991617903, 'fraction_numerical': 0.003479361062786652, 'mean_word_length': 3.737078651685393, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '2403882', 'n_tokens_mistral': 1726, 'n_tokens_neox': 1668, 'n_words': 533}