Search in sources :

Example 1 with LogBox

use of com.glitchcog.fontificator.gui.controls.panel.LogBox in project ChatGameFontificator by GlitchCog.

the class FontificatorMain method main.

/**
     * The main method for the program
     * 
     * @param args
     *            unused
     * @throws Exception
     */
public static void main(String[] args) {
    // Configure the logger
    BasicConfigurator.configure(new ConsoleAppender(LOG_PATTERN_LAYOUT));
    Logger.getRootLogger().setLevel(Level.INFO);
    try {
        UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
    } catch (Exception e) {
        logger.error(e.toString(), e);
    }
    LogBox logBox = new LogBox();
    // These properties contain all the configuration for the program
    FontificatorProperties fProps = new FontificatorProperties();
    // The ChatWindow is the main window and shows the visualization of the chat
    ChatWindow chatWindow = new ChatWindow();
    // The ControlWindow is the dependent window that has all the options for modifying the properties of the chat
    final ControlWindow controlWindow = new ControlWindow(chatWindow, fProps, logBox);
    // Attempt to load the last opened data, or fall back to defaults if nothing has been loaded or if there are any
    // errors loading
    controlWindow.loadLastData(chatWindow);
    try {
        // Feed the properties into the chat to give it hooks into the properties' configuration models; Feed the
        // ControlWindow into the ChatWindow to give the chat hooks back into the controls; Sets the loaded member
        // Boolean in the chat to indicate it has everything it needs to begin rendering the visualization
        chatWindow.initChat(fProps, controlWindow);
    } catch (Exception e) {
        logger.error(e.toString(), e);
        ChatWindow.popup.handleProblem(e.toString(), e);
        System.exit(1);
    }
    // Build the GUI of the control window
    controlWindow.build(logBox);
    // Load after init takes care of the (mostly chat window based) configurations that require the window be already set up
    controlWindow.loadAfterInit();
    // Give the chat panel the message dialog so it can read censorship rules and call for the manual censorship
    // list to be redrawn when a message is posted
    chatWindow.getChatPanel().setMessageCensor(controlWindow.getMessageDialog().getCensorPanel());
    // Give the debug tab to the chat panel, since it doesn't have a shared reference to a config object for the settings
    chatWindow.getChatPanel().setDebugSettings(controlWindow.getDebugPanel());
    // Finally, display the chat and control windows now that everything has been constructed and connected
    chatWindow.setVisible(true);
    try {
        // Do it ugly but thread safe
        SwingUtilities.invokeAndWait(new Runnable() {

            @Override
            public void run() {
                controlWindow.setVisible(true);
            }
        });
    } catch (Exception e) {
        logger.error("Unable to display control window on initialization", e);
    }
}
Also used : ConsoleAppender(org.apache.log4j.ConsoleAppender) ChatWindow(com.glitchcog.fontificator.gui.chat.ChatWindow) FontificatorProperties(com.glitchcog.fontificator.config.FontificatorProperties) ControlWindow(com.glitchcog.fontificator.gui.controls.ControlWindow) LogBox(com.glitchcog.fontificator.gui.controls.panel.LogBox)

Aggregations

FontificatorProperties (com.glitchcog.fontificator.config.FontificatorProperties)1 ChatWindow (com.glitchcog.fontificator.gui.chat.ChatWindow)1 ControlWindow (com.glitchcog.fontificator.gui.controls.ControlWindow)1 LogBox (com.glitchcog.fontificator.gui.controls.panel.LogBox)1 ConsoleAppender (org.apache.log4j.ConsoleAppender)1