⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kbbiapplication.java

📁 一个数据挖掘软件ALPHAMINERR的整个过程的JAVA版源代码
💻 JAVA
字号:
/*
 *    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 Software 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., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

package eti.bi.alphaminer.ui;

import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Image;
import java.awt.Toolkit;
import java.net.MalformedURLException;
import javax.swing.UIManager;

import eti.bi.alphaminer.core.config.ConfigLoader;
import eti.bi.common.ImageLocation;
import eti.bi.common.Locale.Resource;
import eti.bi.common.System.SysLog;
import eti.bi.exception.SysException;
import eti.bi.util.ResourceLoader;

/**
 * KBBIApplication is responsible to show the ApplicationWindow of the KBBI-client.
 */
public class KBBIApplication{
  boolean packFrame = false;
  //String messageFile = "eti.bi.alphaminer.resource.property.ApplicationMessage";

  private static ApplicationWindow m_ApplicationWindow = null;
  
  // Background execution set to true for automated testing.  
  public static boolean BACKGOUND_EXECUTION = false;
  public static boolean m_loaded=false;
  /**
   * Construct the application
 * @throws SysException
   */
  public KBBIApplication() throws SysException {
  	// Load Operator information from definition file 
	  
  	//<<11/12/2005, XJ. Chen 
  	//currentLocale = new Locale(language, country);    
    //messages = ResourceBundle.getBundle(messageFile, currentLocale);
//System.out.println(messages.getString("try"));
    m_ApplicationWindow = new ApplicationWindow();
    m_ApplicationWindow.setIconImage(ResourceLoader.getImage(ImageLocation.APP_ICON));
    //Validate frames that have preset sizes
    //Pack frames that have useful preferred size info, e.g. from their layout

    if (packFrame) {
    	m_ApplicationWindow.pack();
    }
    else {
    	m_ApplicationWindow.validate();
    }
    
    //Center the window
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension frameSize = m_ApplicationWindow.getSize();
    if (frameSize.height > screenSize.height) {
      frameSize.height = screenSize.height;
    }
    if (frameSize.width > screenSize.width) {
      frameSize.width = screenSize.width;
    }
    m_ApplicationWindow.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
    //frame.pack();
    //frame.setExtendedState(Frame.MAXIMIZED_BOTH);
    //m_ApplicationWindow.setVisible(true);

  }
  
  public static ApplicationWindow getApplicationWindow()
  {
  	return m_ApplicationWindow;
  }
  
  /* Main method */
  public static void main(String[] args) {
	
    try {
    	ConfigLoader.loadConfig();
        Thread splashThread = new Thread(new Splash());
        splashThread.start();
		//Change font for ZH
		setUIFont(new javax.swing.plaf.FontUIResource("Dialog",0,12));
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
//        System.setProperty("file.encoding", "UTF8");
        new KBBIApplication();
        m_loaded = true;
    }
    catch(Exception e) {
      e.printStackTrace();
      SysLog.fatal("Alphaminer Exit!", e);
      System.exit(0);
    }
  }
  
  public synchronized static boolean isLoaded()
  {
     return m_loaded;
      
  }
  public static void setUIFont(javax.swing.plaf.FontUIResource f)
  {
	  
      java.util.Enumeration keys = UIManager.getDefaults().keys();
      while(keys.hasMoreElements())
      {
          Object key = keys.nextElement();
          Object value = UIManager.get(key);
          if(value instanceof javax.swing.plaf.FontUIResource)
          {
              UIManager.put(key,f);
          }
      }
  }
}

class Splash extends Thread
{
    /* (non-Javadoc)
     * @see java.lang.Runnable#run()
     */
    public void run() {
        Image splashImage;
        Frame splashFrame=null;
        try {
        	while(Resource.getLocale()==null) {}
            splashImage = ResourceLoader.getsplashImage();
            splashFrame = SplashWindow.splash(splashImage); 
            
            while(!KBBIApplication.isLoaded()){}
	       	splashFrame.setVisible(false);
	       	KBBIApplication.getApplicationWindow().setVisible(true);
            
        } catch (SysException e) {
            e.printStackTrace();
            SysLog.fatal("Splash image not found!");
            System.exit(0);
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			SysLog.fatal("Splash image not found!");
			System.exit(0);
		}
        finally {
        	if (splashFrame!=null) splashFrame.dispose();
        }
    }
    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -