Package com.neptuny.xgrapher.cli.launcher

Source Code of com.neptuny.xgrapher.cli.launcher.Main

/*******************************************************************************
*   Copyright 2007 Neptuny s.r.l. - www.neptuny.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*    http://www.apache.org/licenses/LICENSE-2.0
*
*   Unless required by applicable law or agreed to in writing, software
*   distributed under the License is distributed on an "AS IS" BASIS,
*   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*   See the License for the specific language governing permissions and
*   limitations under the License.
*******************************************************************************/
package com.neptuny.xgrapher.cli.launcher;

import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

import com.l2fprod.common.swing.plaf.LookAndFeelAddons;
import com.l2fprod.common.swing.plaf.windows.WindowsLookAndFeelAddons;
import com.neptuny.xgrapher.cli.XGrapherPanel;
import com.neptuny.xgrapher.cli.controller.Application;


/**
* Wraps the XGrapher UI so that it can be executed as a standalone application.
*
* @author Riccardo Govoni [riccardo.govoni@neptuny.it]
* @since Sep 25, 2007
*
*/
public class Main {

  public static void main(String[] args) {
    new Main().start(args);
  }
       
        private String getParameter(String[] args, String param) {
            for (int i = 0; i < args.length - 1 ; i++) {
                if (param.equals(args[i]))
                    return args[i+1];
            }
            return null;
        }       

  public void start(String[] args) {
    try {
      String osName = System.getProperty("os.name");
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
      UIManager.put("win.xpstyle.name", "luna");
      LookAndFeelAddons.setAddon(WindowsLookAndFeelAddons.class);
    } catch (Exception e) {
      // FIXME: handle exception and notify user
    }

    final Application app = new Application(
                        getParameter(args, "--mapping"),
                        getParameter(args, "--loader"),
                        getParameter(args, "--renderer"));

    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        JFrame f = new JFrame();
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.setSize(800, 600);
        f.add(new XGrapherPanel(app));
        f.setVisible(true);
      }
    });
  }

}
TOP

Related Classes of com.neptuny.xgrapher.cli.launcher.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.