Package jexifviewer

Source Code of jexifviewer.Main

/*
*  Main.java
*
*  Created on 7. April 2006, 19:31
*
*  Copyright (C) 7. April 2006  <Reiner>

*  This program is free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Soloftware Foundation; either version 2 of the License, or
*  (at your option) any later version.
*
*  This program is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with this program; if not, write to the Free Software
*  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
*/

package jexifviewer;


import javax.swing.ImageIcon;
import javax.swing.JFrame;

import java.awt.Frame;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;

import java.net.URL;
import java.text.DateFormatSymbols;
import java.text.SimpleDateFormat;

import java.util.Enumeration;
import java.util.Locale;
import java.util.Properties;
import shared.cvshelper.Cvs;

import shared.files.JPathHelper;

@Cvs
(
    header = "$Header: /home/reiner/cvs/Java/JExifViewer/src/jexifviewer/Main.java,v 1.8 2010/04/03 07:59:53 reiner Exp $"
)

/**
*
* @author reiner
*/
public final class Main
{
    public static final String m_version = "1.8";
    public static final String m_versionString = "Author: Reiner Pr\u00F6ls\nVersion: "+m_version+"\nCopyright \u00A9 2006-2010 by Reiner Pr\u00F6ls\nLicense: GPLv3";
    public static JMainFrame m_mainFrame;
    public static JSettings m_settings;
    public static ImageIcon m_icon16;
    public static ImageIcon m_icon32;
    public static Locale m_sysLocale;
    public static SimpleDateFormat m_shortDayOfWeekFormat = new SimpleDateFormat("E");

    public static URL m_url_map;
 
    /** Creates a new instance of Main */
    public Main()
    {
    }
   
    public static String getMessageBoxCaption()
    {
        String str = null;
        try
        {
            str = m_settings.getResBundle().getString("caption");
        }
        catch(Exception ex)
        {
        }
        if (str == null) str = new String("JExifViewer");
        return str;
    }

    public static String getString(String key, boolean bReplaceLFTAB)
    {
      return m_settings.getResBundleString(key, bReplaceLFTAB);
    }
   
    public static String getString(String key)
    {
        return getString(key, true);
    }

    private static void initGui(String[] args)
    {
        m_icon16 = new ImageIcon(Main.class.getResource("icon16x16.png"));
        m_icon32 = new ImageIcon(Main.class.getResource("icon32x32.png"));
        m_url_map = Main.class.getResource("map.png");

        if (m_settings.isDebug())
        {
            Properties props = System.getProperties();
            Enumeration enumProp = props.propertyNames();
            while (enumProp.hasMoreElements())
            {
                String key = (String)enumProp.nextElement();
                String val = System.getProperty(key);
                System.err.println(key + ": " + val);
            }
        }
        if (!m_settings.init("JExifViewerLang", "JExifViewer"))
            System.exit(1);

        DateFormatSymbols shortDayOfWeekSymbols = new DateFormatSymbols();
        String strArray[] = new String[8];
        strArray[0] = "";
        for (int i=0; i<7; i++)
            strArray[i+1] = getString(String.format("weekday_short_%1$d", i));
        shortDayOfWeekSymbols.setShortWeekdays(strArray);
        m_shortDayOfWeekFormat.setDateFormatSymbols(shortDayOfWeekSymbols);

        m_mainFrame = new JMainFrame();
        m_mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        setSize();
       
        m_mainFrame.setVisible(true);
    }

    public static void setSize()
    {
        Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
        m_mainFrame.setMaximizedBounds(rect);
        m_mainFrame.setPreferredSize(m_settings.getSize());
        m_mainFrame.setLocation(m_settings.getLocation());
        m_mainFrame.setSize(m_settings.getSize());
    }
   
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args)
    {
        final String arguments[] = args.clone();
        // Load settings
        m_settings = new JSettings(true);
        m_settings.load(JPathHelper.addSeparator(System.getProperty("user.home")) + JSettings.SETTINGS_FILE, m_version);
        m_sysLocale = Locale.getDefault();
        if (m_settings.getLocale().length() > 0)
            Locale.setDefault(new Locale(m_settings.getLocale()));
        javax.swing.SwingUtilities.invokeLater(new Runnable()
        {
            public void run()
            {
                initGui(arguments);
            }
        });
    }
}
TOP

Related Classes of jexifviewer.Main

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.