com.church.gateway.Global.java Source code

Java tutorial

Introduction

Here is the source code for com.church.gateway.Global.java

Source

/*
 * Church Software
 *
 * Package : com.church.gateway
 * Filename: Global.java
 * Author  : Felix Chandrakumar <i@fc.id.au>
 * Website : www.churchsw.org
 * 
 * PUBLIC DOMAIN
 * 
 * As the Word of God says,
 * 
 * Freely you have received, freely give. - (Mat 10:8). For all things are from Jesus Christ,
 * by Jesus Christ, and for Jesus Christ. - (Romans 11:36)
 * 
 * Free means completely free! Church Software has no restrictions at all. The source code, 
 * binary and everything that is not licensed by others but included in Church Software bundle
 * is released to public domain and you can modify anything to fit your church needs. Public 
 * domain simply means everyone can use it without any restrictions.
 * 
 * WHY PUBLIC DOMAIN?
 * 
 * The manifestation of the Spirit is given to each one for the profit of all: for to one is
 * given the word of wisdom through the Spirit, to another the word of knowledge through the
 * same Spirit, to another faith by the same Spirit, to another gifts of healings by the same
 * Spirit, to another the working of miracles, to another prophecy, to another discerning of
 * spirits, to another different kinds of tongues, to another the interpretation of tongues.
 * But one and the same Spirit works all these things, distributing to each one individually
 * as He wills. - 1 Co 12:7-11
 * 
 * Woe unto them! for they have gone in the way of Cain, and ran greedily after the error of
 * Balaam for reward, and perished in the rebellion of Korah. - Jud 1:11
 * 
 * Jesus Christ gives word of knowledge through Holy Spirit for the profit of all. I dont
 * want to run greedily after the error of Balaam for reward. Balaam is a prophet of God who
 * went greedily to Balak. Unfortunately, many christian organizations, churches, bands, song
 * writers, musicians etc market the gifts of Holy Spirit, doing the same error of Balam for
 * reward. My Bible says, Woe to them and I don't want to be a part of them.
 */
package com.church.gateway;

import java.awt.Font;
import java.awt.GraphicsEnvironment;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.Toolkit;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Properties;
import java.util.Vector;

import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.SwingConstants;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.plaf.FontUIResource;

import org.apache.log4j.Logger;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.Node;

import com.church.db.BiblePerson;
import com.church.db.BibleUtils;
import com.church.db.ChurchMemberUtils;
import com.church.tools.FileUtils;
import com.church.tools.Network;
import com.church.usermgmt.UserFunctions;
import com.ibm.icu.text.Transliterator;
import com.plugin.UI.Windows.DesktopUI;
import com.plugin.UI.Windows.ImagePanel;
import com.plugin.UI.Windows.PleaseWaitDialog;
import com.plugin.UI.Windows.PresentationScreen;
import com.plugin.UI.Windows.PreviewScreen;

/**
 * The Class Global.
 */
public class Global {

    /** The log. */
    Logger log = Logger.getLogger(this.getClass());

    /** The Constant SOFTWARE_NAME. */
    public static final String SOFTWARE_NAME = "Church Software";

    /** The Constant VERSION. */
    public static final String VERSION = "5.3";

    /** The Constant BUILD_DATE. */
    public static final String BUILD_DATE = "17-Jul-2011";

    /** The Constant WEBSITE. */
    public static final String WEBSITE = "www.churchsw.org";

    /** The Constant COPYRIGHT. */
    public static final String COPYRIGHT = "Public Domain";

    public static String USERDIR = System.getProperty("user.dir");

    /** The default unicode font. */
    public static String defaultUnicodeFont = "Arial Unicode MS";

    /** The _j main frame. */
    public static JFrame _jMainFrame = null;

    /** The Supported church languages. */
    public static String SupportedChurchLanguages[] = null;

    /** The Display caption languages. */
    public static String DisplayCaptionLanguages[] = null;

    /** The selected language. */
    public static String selectedLanguage = "English";

    /** The logged in user. */
    public static String loggedInUser = "guest";

    /** The Friendly login screen. */
    public static boolean FriendlyLoginScreen = false;

    /** The Internet available. */
    public static boolean InternetAvailable = false;

    /** The module classes. */
    public static ArrayList<String> moduleClasses = new ArrayList<String>();

    /** The module captions. */
    public static ArrayList<String> moduleCaptions = new ArrayList<String>();

    /** The module icons. */
    public static ArrayList<String> moduleIcons = new ArrayList<String>();

    /** The default english bible version. */
    public static String defaultEnglishBibleVersion = "ENGLISHKJV";

    /** The unicode font not found. */
    public static boolean unicodeFontNotFound = false;

    /** The Bible versions short. */
    public static String[] BibleVersionsShort = null;

    /** The Bible versions long. */
    public static String[] BibleVersionsLong = null;

    /** The Other lang versions. */
    public static String[] OtherLangVersions = null;

    /** The Other lang version names. */
    public static String[] OtherLangVersionNames = null;

    /** The selected other lang version. */
    public static String selectedOtherLangVersion = null;

    /** The Ui menus. */
    public static Properties UiMenus = null;

    /** The DPI. */
    public static int DPI = Toolkit.getDefaultToolkit().getScreenResolution();

    public static int AutoFillLanguage = 0;
    /** The church groups. */
    public static String[] churchGroups = UserFunctions.getGroupsListStrArray();

    /** The Video device. */
    //public static CaptureDeviceInfo VideoDevice = null;

    /** The Audio device. */
    //public static CaptureDeviceInfo AudioDevice = null;

    /** The pbs. */
    public static PresentationScreen pbs = null;

    /** The preview. */
    public static PreviewScreen preview = null;

    /** The standard other lang font. */
    public static String standardOtherLangFont = Global.defaultUnicodeFont;

    /** The standard other lang font size. */
    public static int standardOtherLangFontSize = 12;

    /** The THEM e_ selection. */
    public static int THEME_SELECTION = 0;

    public static int displayTextHorizontalAlignment = SwingConstants.CENTER;

    public static int displayTextVerticalAlignment = SwingConstants.TOP;
    /** The MENUS. */
    public static String MENUS = "";

    /** The presentation display screen. */
    public static int presentationDisplayScreen = 0;

    /** The SCREE n_ x. */
    public static int SCREEN_X = (int) Toolkit.getDefaultToolkit().getScreenSize().width;

    /** The SCREE n_ y. */
    public static int SCREEN_Y = (int) Toolkit.getDefaultToolkit().getScreenSize().height;

    /** The THEMEXML. */
    public static String THEMEXML = null;

    /** The theme_class. */
    static String theme_class[] = null;

    /** The other lang_fonts. */
    static String[] otherLang_fonts = null;

    /** The display text english. */
    public static String displayTextEnglish = "";

    /** The display text other lang. */
    public static String displayTextOtherLang = "";

    /** The preview text english. */
    public static String previewTextEnglish = "";

    /** The preview text other lang. */
    public static String previewTextOtherLang = "";

    /** The default template image. */
    public static String defaultTemplateImage = "Ocean.jpg";

    /** The church_logo. */
    public static String church_logo = "";

    /** The church_background. */
    public static String church_background = "";

    /** The wait. */

    public static PleaseWaitDialog wait = null;

    /** The Constant ADD_CHURCH_MEMBER. */
    public static final int ADD_CHURCH_MEMBER = 0;

    /** The Constant MODIFY_CHURCH_MEMBER. */
    public static final int MODIFY_CHURCH_MEMBER = 1;

    /** The Constant DELETE_CHURCH_MEMBER. */
    public static final int DELETE_CHURCH_MEMBER = 2;

    /** The Constant DISPLAY_CHURCH_MEMBER. */
    public static final int DISPLAY_CHURCH_MEMBER = 3;

    /** The Constant MAX_VISIBLE_SONGS_LIBRARY. */
    public static final int MAX_VISIBLE_SONGS_LIBRARY = 25;

    /** The prs_font_bold. */
    public static boolean prs_font_bold = false;

    /** The prs_font_italics. */
    public static boolean prs_font_italics = false;

    /** The prs_other lang_font_size. */
    public static int prs_otherLang_font_size = 34;

    /** The prs_english_font_size. */
    public static int prs_english_font_size = 34;

    /** The prs_other lang_font_name. */
    public static String prs_otherLang_font_name = Global.defaultUnicodeFont;

    /** The prs_english_font_name. */
    public static String prs_english_font_name = "Arial";

    /** The Selected language unicode prop. */
    public static Properties SelectedLanguageUnicodeProp = null;

    /** The bible persons. */
    public static ArrayList<BiblePerson> biblePersons = null;

    /** The BIBL e_ searc h_ containin g_ all. */
    public static int BIBLE_SEARCH_CONTAINING_ALL = 0;

    /** The BIBL e_ searc h_ containin g_ any. */
    public static int BIBLE_SEARCH_CONTAINING_ANY = 1;

    /** The BIBL e_ searc h_ containin g_ phrase. */
    public static int BIBLE_SEARCH_CONTAINING_PHRASE = 2;

    /** The bible reading plan prop. */
    public static Properties bibleReadingPlanProp = null;

    /** The bible book zero prefix. */
    public static boolean bibleBookZeroPrefix = false;

    /** The supported transitions. */
    public static String[] supportedTransitions = null;

    /** The supported transition classes. */
    public static String[] supportedTransitionClasses = null;

    public static HashMap<String, Object[]> transitionParameters = null;

    /** The default animation time. */
    public static float defaultAnimationTime = 2.0f;

    /** The SELECTE d_ theme. */
    public static String SELECTED_THEME = "Default";

    /** The words_per_line. */
    public static int words_per_line = 7;

    /** The MA x_ recen t_ history. */
    public static int MAX_RECENT_HISTORY = 10;

    /** The reload library. */
    public static boolean reloadLibrary = false;

    public static boolean useShadowsInPresentation = false;

    /** The default excel export date format. */
    public static String defaultExcelExportDateFormat = "dd-MMM-yyyy";

    /** The birthday celebrations bible ref. */
    public static ArrayList<Integer[]> birthdayCelebrationsBibleRef = null;

    /** The wedding aniv celebrations bible ref. */
    public static ArrayList<Integer[]> weddingAnivCelebrationsBibleRef = null;

    public static String[] Bible_Books = new String[] { "Genesis", "Exodus", "Leviticus", "Numbers", "Deuteronomy",
            "Joshua", "Judges", "Ruth", "1 Samuel", "2 Samuel", "1 Kings", "2 Kings", "1 Chronicles",
            "2 Chronicles", "Ezra", "Nehemiah", "Esther", "Job", "Psalm", "Proverbs", "Ecclesiastes",
            "Song of Solomon", "Isaiah", "Jeremiah", "Lamentations", "Ezekiel", "Daniel", "Hosea", "Joel", "Amos",
            "Obadiah", "Jonah", "Micah", "Nahum", "Habakkuk", "Zephaniah", "Haggai", "Zechariah", "Malachi",
            "Matthew", "Mark", "Luke", "John", "Acts", "Romans", "1 Corinthians", "2 Corinthians", "Galatians",
            "Ephesians", "Philippians", "Colossians", "1 Thessalonians", "2 Thessalonians", "1 Timothy",
            "2 Timothy", "Titus", "Philemon", "Hebrews", "James", "1 Peter", "2 Peter", "1 John", "2 John",
            "3 John", "Jude", "Revelation" };

    public static String[] Bible_Books_GoBible_Short = new String[] { "Gen", "Exo", "Lev", "Num", "Deu", "Jos",
            "Jdg", "Rut", "1Sa", "2Sa", "1Ki", "2Ki", "1Ch", "2Ch", "Ezr", "Neh", "Est", "Job", "Psa", "Pro", "Ecc",
            "Sol", "Isa", "Jer", "Lam", "Eze", "Dan", "Hos", "Joe", "Amo", "Oba", "Jon", "Mic", "Nah", "Hab", "Zep",
            "Hag", "Zec", "Mal", "Mat", "Mar", "Luk", "Joh", "Act", "Rom", "1Co", "2Co", "Gal", "Eph", "Phi", "Col",
            "1Th", "2Th", "1Ti", "2Ti", "Tit", "Phm", "Heb", "Jam", "1Pe", "2Pe", "1Jo", "2Jo", "3Jo", "Jud",
            "Rev" };

    public static String[] Bible_Books_BibleConvertor_Abbr = new String[] { "Gen", "Exod", "Lev", "Num", "Deut",
            "Josh", "Judg", "Ruth", "1 Sam", "2 Sam", "1 Kgs", "2 Kgs", "1 Chr", "2 Chr", "Ezra", "Neh", "Esth",
            "Job", "Ps", "Prov", "Eccl", "Song", "Isa", "Jer", "Lam", "Ezek", "Dan", "Hos", "Joel", "Amos", "Obad",
            "Jonah", "Mic", "Nah", "Hab", "Zeph", "Hag", "Zech", "Mal", "Matt", "Mark", "Luke", "John", "Acts",
            "Rom", "1 Cor", "2 Cor", "Gal", "Eph", "Phil", "Col", "1 Thess", "2 Thess", "1 Tim", "2 Tim", "Tit",
            "Phlm", "Heb", "Jas", "1 Pet", "2 Pet", "1 John", "2 John", "3 John", "Jude", "Rev" };

    public static int[] Bible_Books_BibleConvertor_Number = new int[] { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100,
            110, 120, 130, 140, 150, 160, 190, 220, 230, 240, 250, 260, 290, 300, 310, 330, 340, 350, 360, 370, 380,
            390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500, 510, 520, 530, 540, 550, 560, 570, 580, 590,
            600, 610, 620, 630, 640, 650, 660, 670, 680, 690, 700, 710, 720, 730 };

    public static int[] Bible_ChapterCount = new int[] { 50, 40, 27, 36, 34, 24, 21, 4, 31, 24, 22, 25, 29, 36, 10,
            13, 10, 42, 150, 31, 12, 8, 66, 52, 5, 48, 12, 14, 3, 9, 1, 4, 7, 3, 3, 3, 2, 14, 4, 28, 16, 24, 21, 28,
            16, 16, 13, 6, 6, 4, 4, 5, 3, 6, 4, 3, 1, 13, 5, 5, 3, 5, 1, 1, 1, 22 };

    /** The tables to backup. */
    public static String[] tablesToBackup = new String[] { "church_members", "budget_page", "budget_income",
            "budget_category", "budget_spent", "app_group", "app_user", "church_members_attendance" };

    public static String[] tablesToCompact = new String[] { "church_members", "budget_page", "budget_income",
            "budget_category", "budget_spent", "app_group", "app_user", "church_members_attendance",
            "bible_genealogy_names", "bible_genealogy_references", "dict_kjvc", "dict_kjvstrong", "dict_nasec",
            "dict_thayerbdb", "english_bible_kjvplus" };

    /** The Constant BACKUP_INFO_FILENAME. */
    public static final String BACKUP_INFO_FILENAME = "CSBackupInfo.xml";

    /** The prop files to backup. */
    public static String[] propFilesToBackup = new String[] { "brp.prop", "celebrations.ref",
            "defaultfontstyle.prop", "swui.prop", "theme.properties", BACKUP_INFO_FILENAME };

    /** The date pattern. */
    public static String datePattern = "dd/MM/yyyy";

    /** The use lang menus. */
    public static boolean useLangMenus = false;

    /** The church name. */
    public static String churchName = "Christ Church";

    /** The church location. */
    public static String churchLocation = "World";

    /** The enable quick search auto filling. */
    public static boolean enableQuickSearchAutoFilling = false;

    /** The temp directory. */
    public static String tempDirectory = "temp";

    /** The currency symbols. */
    public static ArrayList<String> currencySymbols = new ArrayList<String>();

    /** The presentation title. */
    public static String presentationTitle = "Presentation Console :: Bible Verse";

    /** The use simple member id. */
    public static boolean useSimpleMemberID = true;
    // true will not show the progress and simulates a feeling as if it is very
    // slow...
    // This is one of the reasons this is not included in SoftwareUI properties

    public static boolean enableAutoLogin = true;

    public static String autoLoginUser = "admin";

    /** The transliterate context. */
    public static Properties transliterateContext = new Properties();

    public static String BibleStudyResourceBundle = "MessagesBundle.properties";

    public static int PROJECTOR_MARGIN_TOP = 10;
    public static int PROJECTOR_MARGIN_LEFT = 5;
    public static int PROJECTOR_MARGIN_BOTTOM = 0;
    public static int PROJECTOR_MARGIN_RIGHT = 5;

    /**
     * Load default fonts and styles.
     */
    public static void loadDefaultFontsAndStyles() {
        Properties p = new Properties();
        try {
            p.load(new FileInputStream("defaultfontstyle.prop"));

            prs_font_bold = Boolean.parseBoolean(p.getProperty("font.bold"));
            prs_font_italics = Boolean.parseBoolean(p.getProperty("font.italics"));
            defaultTemplateImage = p.getProperty("background.template", "Blank Screen.png");
            prs_otherLang_font_size = Integer.parseInt(p.getProperty("otherLang.font.size", "34"));
            prs_english_font_size = Integer.parseInt(p.getProperty("english.font.size", "34"));
            prs_otherLang_font_name = p.getProperty("otherLang.font.name", Global.defaultUnicodeFont);
            prs_english_font_name = p.getProperty("english.font.name", "Arial");

        } catch (FileNotFoundException e) {
            Logger.getLogger(Global.class).error(e, e);
        } catch (IOException e) {
            Logger.getLogger(Global.class).error(e, e);
        }
    }

    /**
     * Load software ui.
     */
    public static void loadSoftwareUI() {
        Properties p = new Properties();
        try {
            p.load(new FileInputStream("swui.prop"));

            church_logo = p.getProperty("church_logo", "church.gif");
            churchName = p.getProperty("church_name", "Christ Church");
            churchLocation = p.getProperty("church_location", "World");
            church_background = p.getProperty("church_background", "church.gif");
            FriendlyLoginScreen = Boolean.parseBoolean(p.getProperty("friendly_login_screen", "true"));
            useSimpleMemberID = Boolean.parseBoolean(p.getProperty("useSimpleMemberID", "true"));
            enableQuickSearchAutoFilling = Boolean.parseBoolean(p.getProperty("quickSearchAutoFilling", "true"));
            selectedLanguage = p.getProperty("selectedLanguage", "English");
            selectedOtherLangVersion = p.getProperty("selectedLanguageVersion", "ENGLISHKJV");
            defaultEnglishBibleVersion = p.getProperty("selectedEnglishVersion", "ENGLISHKJV");
            AutoFillLanguage = Integer.parseInt(p.getProperty("AutoFillLanguage", "0"));
            Global.enableAutoLogin = Boolean.parseBoolean(p.getProperty("autologin.enable", "true"));
            Global.useShadowsInPresentation = Boolean.parseBoolean(p.getProperty("shadoweffects.enable", "false"));
            Global.autoLoginUser = p.getProperty("autologin.user", "admin");

            tempDirectory = p.getProperty("temp_directory", "temp");
            datePattern = p.getProperty("date_format", "dd-MMM-yyyy");
            MAX_RECENT_HISTORY = Integer.parseInt(p.getProperty("max_recent_verse", "50"));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
            Logger.getLogger(Global.class).error(e, e);
        } catch (IOException e) {
            e.printStackTrace();
            Logger.getLogger(Global.class).error(e, e);
        }
    }

    /**
     * Parses the theme xml.
     * 
     * @param xml
     *            the xml
     */
    private static void parseThemeXML(String xml) {
        try {
            Document doc = DocumentHelper.parseText(xml);
            Element elmt = doc.getRootElement();
            List l = elmt.selectNodes("/themes/theme");
            Element e = null;
            theme_class = new String[l.size()];
            for (int i = 0; i < l.size(); i++) {
                e = (Element) l.get(i);
                theme_class[i] = e.attribute("class").getValue();
            }
        } catch (DocumentException e) {
            System.out.println(e);
        }
    }

    /**
     * Load themes.
     */
    public static void loadThemes() {
        try {
            Global.THEMEXML = new String(Network.getLocalFile("themes.xml"));
            String xml = THEMEXML;
            parseThemeXML(xml.trim());
            FileInputStream fis = new FileInputStream("theme.properties");
            Properties p = new Properties();
            p.load(fis);
            int selected_idx = Integer.parseInt(p.getProperty("class"));
            Global.THEME_SELECTION = selected_idx;
            fis.close();
            UIManager.setLookAndFeel(Global.theme_class[selected_idx]);
        } catch (RuntimeException e) {
            System.out.println(e.getMessage());
        } catch (FileNotFoundException e) {
            Logger.getLogger(Global.class).error(e, e);
        } catch (IOException e) {
            Logger.getLogger(Global.class).error(e, e);
        } catch (ClassNotFoundException e) {
            Logger.getLogger(Global.class).error(e, e);
        } catch (InstantiationException e) {
            Logger.getLogger(Global.class).error(e, e);
        } catch (IllegalAccessException e) {
            Logger.getLogger(Global.class).error(e, e);
        } catch (UnsupportedLookAndFeelException e) {
            Logger.getLogger(Global.class).error(e, e);
        }
    }

    /**
     * Gets the available english fonts.
     * 
     * @return the available english fonts
     */
    public static Object[] getAvailableEnglishFonts() {
        // Vector<String> otherLang_font_vector = new Vector<String>();
        //
        // for (String tfont : otherLang_fonts) {
        // otherLang_font_vector.add(tfont);
        // }
        String available_fonts[] = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
        // Vector<String> v = new Vector<String>();
        // for (String afont : available_fonts) {
        // if (otherLang_font_vector.contains(afont))
        // continue;
        // else
        // v.add(afont);
        // }
        // return v.toArray();
        return available_fonts;
    }

    /**
     * Gets the available other lang fonts.
     * 
     * @return the available other lang fonts
     */
    public static Object[] getAvailableOtherLangFonts() {
        Vector<String> otherLang_font_vector = new Vector<String>();

        for (String tfont : otherLang_fonts) {
            otherLang_font_vector.add(tfont);
        }
        String available_fonts[] = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
        Vector<String> v = new Vector<String>();
        for (String afont : available_fonts) {
            if (otherLang_font_vector.contains(afont))
                v.add(afont);
            else
                continue;
        }
        return v.toArray();
    }

    /**
     * Sets the status.
     * 
     * @param msg
     *            the new status
     */
    public static void setStatus(String msg) {
        if (DesktopUI.statusBar != null)
            DesktopUI.statusBar.setText(msg);
    }

    /**
     * Load language specific.
     */
    public static void loadLanguageSpecific() {
        otherLang_fonts = SelectedLanguageUnicodeProp
                .getProperty(Global.selectedLanguage + ".Available", Global.defaultUnicodeFont).split("[,]");
        standardOtherLangFont = SelectedLanguageUnicodeProp.getProperty(Global.selectedLanguage + ".DefaultFont",
                Global.defaultUnicodeFont);
        standardOtherLangFontSize = Integer
                .parseInt(SelectedLanguageUnicodeProp.getProperty(Global.selectedLanguage + ".DefaultSize", "14"));
        bibleBookZeroPrefix = BibleUtils.getBibleBookZeroPrefix();
    }

    /**
     * Inits the default unicode font.
     */
    public static void initDefaultUnicodeFont() {
        Vector<String> excludeList = new Vector<String>();
        // excludeList.add("TextField.font");

        UIDefaults defaults = UIManager.getDefaults();
        Enumeration<Object> enum2 = defaults.keys();

        while (enum2.hasMoreElements()) {
            Object key = enum2.nextElement();
            if (key instanceof String) {
                String key2 = (String) key;
                if (excludeList.contains(key2))
                    continue;
                if (key2.endsWith("font") || key2.endsWith("Font")) {
                    Object obj = UIManager.get(key);
                    if (obj instanceof FontUIResource) {
                        FontUIResource res = (FontUIResource) obj;
                        int size = res.getSize();
                        FontUIResource resnew = new FontUIResource(
                                new Font(Global.defaultUnicodeFont, Font.PLAIN, size));
                        //System.out.println(key2);
                        UIManager.put(key2, resnew);
                    }
                }
            }
        }
    }

    /**
     * Gets the modified menu xml.
     * 
     * @param disallowed_modules
     *            the disallowed_modules
     * 
     * @return the modified menu xml
     * 
     * @throws Exception
     *             the exception
     */
    public static String getModifiedMenuXml(String[] disallowed_modules) throws Exception {
        Document doc = DocumentHelper.parseText(Global.MENUS);
        Element root = doc.getRootElement();
        List<Node> list = root.selectNodes("//menu/menu");
        for (Node node : list) {
            Element elmt = (Element) node;
            if (elmt.attribute("class") != null) {
                for (String module : disallowed_modules)
                    if (elmt.attribute("class").getValue().trim().equals(module))
                        elmt.addAttribute("visible", "false");
            }
        }
        return doc.asXML();
    }

    /**
     * Gets the disallowed lang.
     * 
     * @param lang
     *            the lang
     * 
     * @return the disallowed lang
     * 
     * @throws Exception
     *             the exception
     */
    public static String[] getDisallowedLang(String lang) throws Exception {
        String langarr = "";
        if (lang.equalsIgnoreCase("English"))
            langarr = SelectedLanguageUnicodeProp.getProperty("Menu.English");
        else {
            langarr = SelectedLanguageUnicodeProp.getProperty("Menu." + Global.selectedLanguage,
                    SelectedLanguageUnicodeProp.getProperty("Menu.OtherLang"));
        }
        return langarr.split("[,]");
    }

    /**
     * Start application.
     */
    public static void startApplication() {
        Global._jMainFrame = new DesktopUI();
    }

    /**
     * Do make dir.
     * 
     * @param filename
     *            the filename
     * 
     * @throws Exception
     *             the exception
     */
    private static void doMakeDir(String filename) throws Exception {
        String dir = new File(filename).getParent();
        if (dir != null) {
            new File(dir).mkdirs();
        }
    }

    /**
     * Gets the transliterate language.
     * 
     * @param engText
     *            the eng text
     * 
     * @return the transliterate language
     */
    public static String getTransliterateLanguage(String engText) {
        String langtext = "";
        try {
            String lang = Global.SelectedLanguageUnicodeProp
                    .getProperty(Global.selectedLanguage + ".Transliterations", Global.selectedLanguage)
                    .split("[,]")[0];
            Transliterator t = Transliterator.getInstance("Latin-" + lang);
            langtext = t.transliterate(engText);
        } catch (Exception e) {
            langtext = "";
        }
        return langtext;
    }

    /**
     * Gets the transliterate lang alone.
     * 
     * @return the transliterate lang alone
     */
    public static String getTransliterateLangAlone() {
        String lang = Global.SelectedLanguageUnicodeProp
                .getProperty(Global.selectedLanguage + ".Transliterations", Global.selectedLanguage)
                .split("[,]")[0];
        return lang;
    }

    /**
     * Gets the available transliterations.
     * 
     * @return the available transliterations
     */
    public static Object[] getAvailableTransliterations() {
        Enumeration<String> o = Transliterator.getAvailableIDs();
        ArrayList<String> arr = new ArrayList<String>();
        while (o.hasMoreElements()) {
            String str = o.nextElement();
            if (str.startsWith("Latin-"))
                arr.add(str.substring(str.indexOf("-") + 1));
        }
        return arr.toArray();
    }

    /**
     * Checks if is writing system valid.
     * 
     * @param writingSystem
     *            the writing system
     * 
     * @return true, if is writing system valid
     */
    public static boolean isWritingSystemValid(String writingSystem) {
        String langtext = "";
        boolean flag = false;
        try {
            Transliterator t = Transliterator.getInstance("Latin-" + writingSystem);
            langtext = t.transliterate("Church Software");
            flag = true;
        } catch (Exception e) {
            flag = false;
        }
        return flag;
    }

    /**
     * Gets the transliterate language reverse.
     * 
     * @param engText
     *            the eng text
     * 
     * @return the transliterate language reverse
     */
    public static String getTransliterateLanguageReverse(String engText) {
        String langtext = "";
        try {
            String lang = Global.SelectedLanguageUnicodeProp
                    .getProperty(Global.selectedLanguage + ".Transliterations", Global.selectedLanguage)
                    .split("[,]")[0];
            Transliterator t = Transliterator.getInstance(lang + "-Latin");
            langtext = t.transliterate(engText);
        } catch (Exception e) {
            langtext = "";
        }
        return langtext;
    }

    /**
     * Load at start up.
     * 
     * @param splash
     *            the splash
     * @param loadFaster
     *            the load faster
     * 
     * @throws Exception
     *             the exception
     */
    public static void loadAtStartUp(SplashScreen splash, boolean loadFaster) throws Exception {
        // 78% to 98%
        //
        Global.loadSoftwareUI();
        Global.loadProjectorMargins();
        if (!loadFaster) {
            Thread.sleep(10);
            splash.setPercentComplete(80);
            splash.setModuleLoading("Loading Software UI preferences");
        }
        //
        Global.loadCurrencies();
        Global.loadThemes();
        if (!loadFaster) {
            Thread.sleep(10);
            splash.setPercentComplete(81);
            splash.setModuleLoading("Loading Software Themes");
        }
        Global.loadDefaultFontsAndStyles();
        if (!loadFaster) {
            Thread.sleep(10);
            splash.setPercentComplete(82);
            splash.setModuleLoading("Loading default fonts and styles");
        }
        try {
            UserFunctions.loadUsers();
            if (!loadFaster) {
                Thread.sleep(10);
                splash.setPercentComplete(83);
                splash.setModuleLoading("Loading CS Users");
            }
        } catch (Exception e) {
            Logger.getLogger(Global.class).error(e, e);
        }
        if (GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices().length > 1)
            Global.presentationDisplayScreen = 1;

        SelectedLanguageUnicodeProp = new Properties();
        try {
            SelectedLanguageUnicodeProp.load(new FileInputStream("language.prop"));

            String _SupportedChurchLanguages[] = SelectedLanguageUnicodeProp.getProperty("Languages", "English")
                    .split(",");
            String _DisplayCaptionLanguages[] = SelectedLanguageUnicodeProp.getProperty("DisplayCaption", "English")
                    .split(",");
            ArrayList<String> lang = new ArrayList<String>();
            ArrayList<String> disp = new ArrayList<String>();

            String file = "";
            for (int i = 0; i < _SupportedChurchLanguages.length; i++) {
                //System.out.println("Checking.."+"["+_SupportedChurchLanguages[i]+"] ");
                String ver_code[] = SelectedLanguageUnicodeProp
                        .getProperty(_SupportedChurchLanguages[i] + ".Versions", _SupportedChurchLanguages[i])
                        .split(",");
                String ver_name[] = SelectedLanguageUnicodeProp
                        .getProperty(_SupportedChurchLanguages[i] + ".VersionNames", _SupportedChurchLanguages[i])
                        .split(",");
                ArrayList<String> vers = new ArrayList<String>();
                ArrayList<String> vern = new ArrayList<String>();
                for (int j = 0; j < ver_code.length; j++) {
                    file = "bibles/" + ver_code[j].toLowerCase() + ".jar";
                    if (new File(file).exists()) {
                        vers.add(ver_code[j]);
                        vern.add(ver_name[j]);
                    }
                }

                String ver_code_strarr = "";
                String ver_name_strarr = "";

                for (int k = 0; k < vers.size(); k++) {
                    ver_code_strarr = ver_code_strarr + "," + vers.get(k);
                    ver_name_strarr = ver_name_strarr + "," + vern.get(k);
                }
                if (vers.size() > 0) {
                    ver_code_strarr = ver_code_strarr.substring(1);
                    ver_name_strarr = ver_name_strarr.substring(1);

                    SelectedLanguageUnicodeProp.remove(_SupportedChurchLanguages[i] + ".Versions");
                    SelectedLanguageUnicodeProp.remove(_SupportedChurchLanguages[i] + ".VersionNames");

                    SelectedLanguageUnicodeProp.setProperty(_SupportedChurchLanguages[i] + ".Versions",
                            ver_code_strarr);
                    SelectedLanguageUnicodeProp.setProperty(_SupportedChurchLanguages[i] + ".VersionNames",
                            ver_name_strarr);
                } else {
                    //System.out.println("\t\tnot supported.");
                    continue;
                }

                //////---

                file = "bibles/" + SelectedLanguageUnicodeProp
                        .getProperty(_SupportedChurchLanguages[i] + ".Versions").split(",")[0].toLowerCase()
                        + ".jar";

                //System.out.println("\tBible = "+file+" >> ");            
                if (new File(file).exists()) {
                    //System.out.println("\t\tsupported.");
                    // if present...
                    lang.add(_SupportedChurchLanguages[i]);
                    disp.add(_DisplayCaptionLanguages[i]);
                }
            }
            SupportedChurchLanguages = new String[lang.size()];
            DisplayCaptionLanguages = new String[disp.size()];

            for (int i = 0; i < lang.size(); i++) {
                SupportedChurchLanguages[i] = lang.get(i);
                DisplayCaptionLanguages[i] = disp.get(i);
            }

            if (!loadFaster) {
                Thread.sleep(10);
                splash.setPercentComplete(84);
                splash.setModuleLoading("Loading language details");
            }
            //
            File stored = new File("bgobj.db");
            if (stored.exists()) {
                ObjectInputStream is = new ObjectInputStream(new FileInputStream(stored));
                Global.biblePersons = (ArrayList<BiblePerson>) is.readObject();
                is.close();
            }
            if (!loadFaster) {
                Thread.sleep(10);
                splash.setPercentComplete(88);
                splash.setModuleLoading("Loading Bible Genealogy details");
            }
        } catch (Exception e) {
            Logger.getLogger(Global.class).error(e, e);
        }

        Global.defaultUnicodeFont = SelectedLanguageUnicodeProp.getProperty("OS.DefaultUnicodeFont",
                "Arial Unicode MS");

        Global.BibleVersionsShort = SelectedLanguageUnicodeProp.getProperty("English.Versions", "ENGLISHKJV")
                .split(",");
        Global.BibleVersionsLong = SelectedLanguageUnicodeProp
                .getProperty("English.VersionNames", "King James Version").split(",");

        //selectedOtherLangVersion = BibleVersionsShort[0];
        //defaultEnglishBibleVersion = BibleVersionsShort[0];

        checkIfDefaultOSFontFound();
        //
        initDefaultUnicodeFont();
        if (!loadFaster) {
            Thread.sleep(10);
            splash.setPercentComplete(90);
            splash.setModuleLoading("Loading default " + System.getProperty("os.name") + " Unicode Font");
        }
        // //
        bibleReadingPlanProp = new Properties();
        try {
            bibleReadingPlanProp.load(new FileInputStream("brp.prop"));
        } catch (Exception e) {
            Logger.getLogger(Global.class).error(e, e);
        }
        if (!loadFaster) {
            Thread.sleep(10);
            splash.setPercentComplete(92);
            splash.setModuleLoading("Loading Bible reading plan");
        }
        // /

        try {
            if (new File("transliteration/transliterate_" + selectedLanguage.toLowerCase() + ".prop").exists())
                transliterateContext.load(new FileInputStream(
                        "transliteration/transliterate_" + selectedLanguage.toLowerCase() + ".prop"));
            else
                transliterateContext.load(new FileInputStream("transliteration/transliterate.prop"));
        } catch (Exception e1) {
            transliterateContext = new Properties();
            Logger.getLogger(Global.class).error(e1, e1);
            JOptionPane.showMessageDialog(null,
                    "Error loading Transliteration Data..\nPlease use manual patch to fix the error.");
        }

        loadTransitionEffects();
        if (!loadFaster) {
            Thread.sleep(10);
            splash.setPercentComplete(94);
            splash.setModuleLoading("Loading available transition effects");
        }
        try {
            loadCelebrationBibleRef();
            if (!loadFaster) {
                Thread.sleep(10);
                splash.setPercentComplete(96);
                splash.setModuleLoading("Loading available Bible ref for Celebrations");
            }
        } catch (Exception e) {
            Logger.getLogger(Global.class).error(e, e);
        }
        //
        try {
            splash.setModuleLoading("Loading Church Members Database...");
            ChurchMemberUtils.refreshMemory();
        } catch (Exception e) {
            Logger.getLogger(Global.class).error(e, e);
        }

    }

    /**
     * Load celebration bible ref.
     * 
     * @throws Exception
     *             the exception
     */
    private static void loadCelebrationBibleRef() throws Exception {
        // celebrationsBibleRef
        BufferedReader br = new BufferedReader(new FileReader("celebrations.ref"));
        String line = "";
        // 0=birthday, 1=marriage
        int celebration = -1;
        birthdayCelebrationsBibleRef = new ArrayList<Integer[]>();
        weddingAnivCelebrationsBibleRef = new ArrayList<Integer[]>();
        while ((line = br.readLine()) != null) {
            if (line.trim().startsWith("#") || line.trim().equalsIgnoreCase(""))
                continue;
            if (line.trim().equalsIgnoreCase("BIRTHDAY")) {
                celebration = 0;
                continue;
            } else if (line.trim().equalsIgnoreCase("WEDDING")) {
                celebration = 1;
                continue;
            }

            try {
                int verseno = Integer.parseInt(line.split("[:]")[1].trim());
                String bookpart = line.split("[:]")[0];
                int chapterno = Integer.parseInt(bookpart.substring(bookpart.lastIndexOf(" ")).trim());
                String book = bookpart.substring(0, bookpart.lastIndexOf(" ")).trim();

                int bookno = BibleUtils.lookupOtherLangBook(Global.selectedLanguage, book);
                Integer[] data = new Integer[] { bookno, chapterno, verseno };
                if (celebration == 0)
                    birthdayCelebrationsBibleRef.add(data);
                else if (celebration == 1)
                    weddingAnivCelebrationsBibleRef.add(data);
            } catch (Exception e) {
                Logger.getRootLogger().error(e, e);
                // Ignore..as it is read for random verse display
            }
        }
        br.close();

    }

    /**
     * Load transition effects.
     */
    private static void loadTransitionEffects() {
        ArrayList<String> display = new ArrayList<String>();
        ArrayList<String> classname = new ArrayList<String>();

        try {
            byte[] xmlbytes = Network.getLocalFile("transitions.xml");
            Document doc = DocumentHelper.parseText(new String(xmlbytes));
            Element root = doc.getRootElement();
            List<Node> nodes = root.selectNodes("transition");
            transitionParameters = new HashMap<String, Object[]>();
            for (Node n : nodes) {
                Element elmt = (Element) n;
                display.add(elmt.selectSingleNode("display").getText());
                classname.add(elmt.selectSingleNode("class").getText());
                List<Node> ps = elmt.selectNodes("parameter");
                if (ps != null) {
                    Object[] arr = new Object[ps.size()];
                    for (int i = 0; i < ps.size(); i++) {
                        Element ep = (Element) ps.get(i);
                        arr[i] = ep.getTextTrim();
                    }
                    transitionParameters.put(elmt.selectSingleNode("display").getText(), arr);
                } else
                    transitionParameters.put(elmt.selectSingleNode("display").getText(), new Object[] {});
            }
        } catch (DocumentException e) {
            Logger.getLogger(Global.class).error(e, e);
        }
        supportedTransitionClasses = new String[classname.size()];
        supportedTransitions = new String[display.size()];
        for (int i = 0; i < classname.size(); i++) {
            supportedTransitionClasses[i] = classname.get(i) + ":" + display.get(i);
            supportedTransitions[i] = display.get(i);
        }
    }

    /**
     * Check if default os font found.
     */
    public static void checkIfDefaultOSFontFound() {
        boolean flag = false;
        String available_fonts[] = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
        for (String font : available_fonts)
            if (Global.defaultUnicodeFont.equalsIgnoreCase(font)) {
                flag = true;
                break;
            }
        if (!flag) {
            JOptionPane.showMessageDialog(null,
                    "The font '" + Global.defaultUnicodeFont + "' set in language.prop as \n"
                            + "property 'OS.DefaultUnicodeFont' is not installed in the system. \n"
                            + "Church software can run without this font but may have unexpected\n"
                            + "rendering with 'square boxes' in certain locations. You can also \n"
                            + "change the property with an existing Unicode Font.\n\n"
                            + "Note: Ignore this message if you had installed CS Minimum version.",
                    "Font Warning!", JOptionPane.WARNING_MESSAGE);
            unicodeFontNotFound = true;
        } else
            unicodeFontNotFound = false;

    }

    /**
     * Gets the all bible versions.
     * 
     * @param isName
     *            the is name
     * @param isDisplayable
     *            the is displayable
     * 
     * @return the all bible versions
     */
    public static ArrayList<String> getAllBibleVersions(boolean isName, boolean isDisplayable) {
        ArrayList<String> langver = new ArrayList<String>();
        String property = ".Versions";
        if (isName)
            property = ".VersionNames";
        for (String lang : Global.SupportedChurchLanguages) {
            String str = Global.SelectedLanguageUnicodeProp.getProperty(lang + property, lang);
            if (str != null) {
                if (str.indexOf(",") != -1) {
                    String v[] = str.split("[,]");
                    for (String _v : v) {
                        if (isDisplayable)
                            langver.add(lang + ": " + _v);
                        else
                            langver.add(_v);
                    }
                } else {
                    if (isDisplayable)
                        langver.add(lang + ": " + str);
                    else
                        langver.add(str);
                }
            }
        }
        return langver;
    }

    public static ArrayList<String> getAllBibleVersions_ALL(boolean isName, boolean isDisplayable) {
        ArrayList<String> langver = new ArrayList<String>();
        String property = ".Versions";
        if (isName)
            property = ".VersionNames";

        Properties SelectedLanguageUnicodeProp_ALL = new Properties();

        try {
            SelectedLanguageUnicodeProp_ALL.load(new FileInputStream("language.prop"));
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        String SupportedChurchLanguages_ALL[] = SelectedLanguageUnicodeProp_ALL.getProperty("Languages", "English")
                .split(",");
        for (String lang : SupportedChurchLanguages_ALL) {
            String str = SelectedLanguageUnicodeProp_ALL.getProperty(lang + property, lang);
            if (str != null) {
                if (str.indexOf(",") != -1) {
                    String v[] = str.split("[,]");
                    for (String _v : v) {
                        if (isDisplayable)
                            langver.add(lang + ": " + _v);
                        else
                            langver.add(_v);
                    }
                } else {
                    if (isDisplayable)
                        langver.add(lang + ": " + str);
                    else
                        langver.add(str);
                }
            }
        }
        return langver;
    }

    /**
     * Gets the english version long name.
     * 
     * @param versionShort
     *            the version short
     * 
     * @return the english version long name
     */
    public static String getEnglishVersionLongName(String versionShort) {
        String bibleVersionLong = versionShort;
        for (int i = 0; i < Global.BibleVersionsShort.length; i++) {
            if (Global.BibleVersionsShort[i].equalsIgnoreCase(versionShort))
                bibleVersionLong = Global.BibleVersionsLong[i];
        }
        return bibleVersionLong;
    }

    /**
     * Gets the english version short name.
     * 
     * @param versionLong
     *            the version long
     * 
     * @return the english version short name
     */
    public static String getEnglishVersionShortName(String versionLong) {
        String bibleVersionShort = versionLong;
        for (int i = 0; i < Global.BibleVersionsLong.length; i++) {
            if (Global.BibleVersionsLong[i].equalsIgnoreCase(versionLong))
                bibleVersionShort = Global.BibleVersionsShort[i];
        }
        return bibleVersionShort;
    }

    /**
     * Gets the other lang version long name.
     * 
     * @param versionShort
     *            the version short
     * 
     * @return the other lang version long name
     */
    public static String getOtherLangVersionLongName(String versionShort) {
        String bibleVersionLong = versionShort;
        for (int i = 0; i < Global.OtherLangVersions.length; i++) {
            if (Global.OtherLangVersions[i].equalsIgnoreCase(versionShort))
                bibleVersionLong = Global.OtherLangVersionNames[i];
        }
        return bibleVersionLong;
    }

    /**
     * Gets the other lang version short name.
     * 
     * @param versionLong
     *            the version long
     * 
     * @return the other lang version short name
     */
    public static String getOtherLangVersionShortName(String versionLong) {
        String bibleVersionShort = versionLong;
        for (int i = 0; i < Global.OtherLangVersionNames.length; i++) {
            if (Global.OtherLangVersionNames[i].trim().equalsIgnoreCase(versionLong.trim()))
                bibleVersionShort = Global.OtherLangVersions[i];
        }
        return bibleVersionShort;
    }

    public static String getOtherLangVersionShortName(String lang, String versionLong) {
        String bibleVersionShort = versionLong;
        String olVnames[] = Global.SelectedLanguageUnicodeProp.getProperty(lang + ".VersionNames", lang).split(",");
        String olVersions[] = Global.SelectedLanguageUnicodeProp.getProperty(lang + ".Versions", lang).split(",");
        for (int i = 0; i < olVnames.length; i++) {
            if (olVnames[i].trim().equalsIgnoreCase(versionLong.trim()))
                bibleVersionShort = olVersions[i];
        }
        return bibleVersionShort;
    }

    /**
     * Load currencies.
     * 
     * @throws Exception
     *             the exception
     */
    private static void loadCurrencies() throws Exception {
        BufferedReader br = new BufferedReader(new StringReader(FileUtils.readUnicodeFile("currencies.txt")));
        String line = null;
        currencySymbols = new ArrayList<String>();
        while ((line = br.readLine()) != null) {
            currencySymbols.add(line);
        }
    }

    /**
     * Gets the bible verse presentation frame.
     * 
     * @return the bible verse presentation frame
     */
    public static JInternalFrame getBibleVersePresentationFrame() {
        JInternalFrame[] frames = DesktopUI._desktop.getAllFrames();
        for (JInternalFrame frame : frames) {
            if (frame.getTitle().startsWith(Global.presentationTitle)) {
                return frame;
            }
        }
        return null;
    }

    public static void loadProjectorMargins() {
        Properties prop = new Properties();
        try {
            prop.load(new FileInputStream("projectormargin.prop"));
        } catch (FileNotFoundException e) {
            Logger.getLogger(Global.class).error(e, e);
            e.printStackTrace();
        } catch (IOException e) {
            Logger.getLogger(Global.class).error(e, e);
            e.printStackTrace();
        }
        Global.PROJECTOR_MARGIN_TOP = Integer.parseInt(prop.getProperty("PROJECTOR_MARGIN_TOP", "0"));
        Global.PROJECTOR_MARGIN_BOTTOM = Integer.parseInt(prop.getProperty("PROJECTOR_MARGIN_BOTTOM", "0"));
        Global.PROJECTOR_MARGIN_LEFT = Integer.parseInt(prop.getProperty("PROJECTOR_MARGIN_LEFT", "0"));
        Global.PROJECTOR_MARGIN_RIGHT = Integer.parseInt(prop.getProperty("PROJECTOR_MARGIN_RIGHT", "0"));
        Global.displayTextHorizontalAlignment = Integer
                .parseInt(prop.getProperty("displayTextHorizontalAlignment", "0"));
        Global.displayTextVerticalAlignment = Integer
                .parseInt(prop.getProperty("displayTextVerticalAlignment", "0"));
    }

    public static void setProjectorMarginAlignments(int PROJ_WIDTH, int PROJ_HEIGHT, ImagePanel background_panel,
            JLabel label_top, JLabel label_bottom) {
        background_panel.removeAll();
        background_panel.setLayout(new GridBagLayout());
        GridBagConstraints c = new GridBagConstraints();

        c.gridx = 0;
        c.gridy = 0;
        c.weightx = 1;
        c.weighty = 1;
        c.insets = new Insets(Global.PROJECTOR_MARGIN_TOP * PROJ_HEIGHT / 100,
                Global.PROJECTOR_MARGIN_LEFT * PROJ_WIDTH / 100, Global.PROJECTOR_MARGIN_BOTTOM * PROJ_HEIGHT / 100,
                Global.PROJECTOR_MARGIN_RIGHT * PROJ_WIDTH / 100);
        c.fill = GridBagConstraints.BOTH;
        c.anchor = GridBagConstraints.CENTER;
        //label_top.setBorder(BorderFactory.createEtchedBorder(Color.WHITE, Color.GRAY));
        label_top.setHorizontalAlignment(displayTextHorizontalAlignment);
        label_top.setVerticalAlignment(displayTextVerticalAlignment);
        background_panel.add(label_top, c);

        c.gridx = 0;
        c.gridy = 1;
        c.weightx = 1;
        c.weighty = 1;
        c.insets = new Insets(Global.PROJECTOR_MARGIN_TOP * PROJ_HEIGHT / 100,
                Global.PROJECTOR_MARGIN_LEFT * PROJ_WIDTH / 100, Global.PROJECTOR_MARGIN_BOTTOM * PROJ_HEIGHT / 100,
                Global.PROJECTOR_MARGIN_RIGHT * PROJ_WIDTH / 100);
        c.fill = GridBagConstraints.BOTH;
        c.anchor = GridBagConstraints.CENTER;
        //label_bottom.setBorder(BorderFactory.createEtchedBorder(Color.WHITE, Color.GRAY));
        label_bottom.setHorizontalAlignment(displayTextHorizontalAlignment);
        label_bottom.setVerticalAlignment(displayTextVerticalAlignment);
        background_panel.add(label_bottom, c);
        ////
    }

    public static void setProjectorMarginAlignments(int PROJ_WIDTH, int PROJ_HEIGHT, ImagePanel background_panel,
            JLabel label) {
        background_panel.removeAll();
        background_panel.setLayout(new GridBagLayout());
        GridBagConstraints c = new GridBagConstraints();

        c.gridx = 0;
        c.gridy = 0;
        c.weightx = 1;
        c.weighty = 1;
        c.insets = new Insets(Global.PROJECTOR_MARGIN_TOP * PROJ_HEIGHT / 100,
                Global.PROJECTOR_MARGIN_LEFT * PROJ_WIDTH / 100, Global.PROJECTOR_MARGIN_BOTTOM * PROJ_HEIGHT / 100,
                Global.PROJECTOR_MARGIN_RIGHT * PROJ_WIDTH / 100);
        c.fill = GridBagConstraints.BOTH;
        c.anchor = GridBagConstraints.CENTER;
        //label.setBorder(BorderFactory.createEtchedBorder(Color.WHITE, Color.GRAY));      
        label.setHorizontalAlignment(displayTextHorizontalAlignment);
        label.setVerticalAlignment(displayTextVerticalAlignment);
        background_panel.add(label, c);
    }
}