<commit_before>/*
 * $Id$
 * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
 * For details on use and redistribution please refer to the
 * LICENSE file included with these sources.
 */

package org.apache.fop.apps;
/*
 * originally contributed by
 * <NAME>: <EMAIL>,
 * <NAME>: <EMAIL>,
 * <NAME>: <EMAIL>
 * Modified to use streaming API by <NAME>, <EMAIL>
 */
import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.viewer.*;
import org.apache.fop.render.awt.*;


import javax.swing.UIManager;
import java.awt.*;

// SAX
import org.xml.sax.XMLReader;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;



// Java
import java.io.FileReader;
import java.io.File;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.FileNotFoundException;
import java.io.FileInputStream;
import java.io.InputStream;
import java.net.URL;
import java.util.*;



/**
 * initialize AWT previewer
 */

public class AWTStarter extends CommandLineStarter {

    PreviewDialog frame;
    AWTRenderer renderer;
    public static String TRANSLATION_PATH =
        "/org/apache/fop/viewer/resources/";

    private Translator resource;

    public AWTStarter(CommandLineOptions commandLineOptions)
    throws FOPException {
        super(commandLineOptions);
        init();
    }

    private void init() {
        try {
            UIManager.setLookAndFeel(new javax.swing.plaf.metal.MetalLookAndFeel());
        } catch (Exception e) {
            e.printStackTrace();
        }

        String language = commandLineOptions.getLanguage();

        if (language == null)
            language = System.getProperty("user.language");

        resource = getResourceBundle(TRANSLATION_PATH + "resources."
                                     + language);

        UserMessage.setTranslator(getResourceBundle(TRANSLATION_PATH
                                  + "messages."
                                  + language));

        resource.setMissingEmphasized(false);
        renderer = new AWTRenderer(resource);
        frame = createPreviewDialog(renderer, resource);
        renderer.setProgressListener(frame);
        renderer.setComponent(frame);
        MessageHandler.setOutputMethod(MessageHandler.EVENT);
        MessageHandler.addListener(frame);
    }


    public void run() throws FOPException {
        Driver driver = new Driver();
        if (errorDump) {<commit_msg>catches SecurityException for (future) use in security of webstart<commit_after>/*
 * $Id$
 * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
 * For details on use and redistribution please refer to the
 * LICENSE file included with these sources.
 */

package org.apache.fop.apps;
/*
 * originally contributed by
 * <NAME>: <EMAIL>,
 * <NAME>: <EMAIL>,
 * <NAME>: <EMAIL>
 * Modified to use streaming API by <NAME>, <EMAIL>
 */
import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.viewer.*;
import org.apache.fop.render.awt.*;


import javax.swing.UIManager;
import java.awt.*;

// SAX
import org.xml.sax.XMLReader;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;



// Java
import java.io.FileReader;
import java.io.File;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.FileNotFoundException;
import java.io.FileInputStream;
import java.io.InputStream;
import java.net.URL;
import java.util.*;



/**
 * initialize AWT previewer
 */

public class AWTStarter extends CommandLineStarter {

    PreviewDialog frame;
    AWTRenderer renderer;
    public static String TRANSLATION_PATH =
        "/org/apache/fop/viewer/resources/";

    private Translator resource;

    public AWTStarter(CommandLineOptions commandLineOptions)
    throws FOPException {
        super(commandLineOptions);
        init();
    }

    private void init() {
        try {
            UIManager.setLookAndFeel(new javax.swing.plaf.metal.MetalLookAndFeel());
        } catch (Exception e) {
            e.printStackTrace();
        }

        String language = commandLineOptions.getLanguage();

        if (language == null) {
            try {
                language = System.getProperty("user.language");
            } catch(SecurityException se) {
                // if this is running in a secure place
            }
        }
        resource = getResourceBundle(TRANSLATION_PATH + "resources."
                                     + language);

        UserMessage.setTranslator(getResourceBundle(TRANSLATION_PATH
                                  + "messages."
                                  + language));

        resource.setMissingEmphasized(false);
        renderer = new AWTRenderer(resource);
        frame = createPreviewDialog(renderer, resource);
        renderer.setProgressListener(frame);
        renderer.setComponent(frame);
        MessageHandler.setOutputMethod(MessageHandler.EVENT);
        MessageHandler.addListener(frame);
    }


    public void run() throws FOPException {
        Driver driver = new Driver();
        if (errorDump) {
{'fraction_non_alphanumeric': 0.10258387967605091, 'fraction_numerical': 0.0015426147319706903, 'mean_word_length': 2.689189189189189, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '809346', 'n_tokens_mistral': 1481, 'n_tokens_neox': 1425, 'n_words': 341}