Search in sources :

Example 1 with FFXLocale

use of ffx.ui.properties.FFXLocale in project ffx by mjschnie.

the class MainPanel method initialize.

/**
 * <p>
 * initialize</p>
 */
public void initialize() {
    if (init) {
        return;
    }
    init = true;
    String dir = System.getProperty("user.dir", FileSystemView.getFileSystemView().getDefaultDirectory().getAbsolutePath());
    setCWD(new File(dir));
    locale = new FFXLocale("en", "US");
    JDialog splashScreen = null;
    ClassLoader loader = getClass().getClassLoader();
    if (!GraphicsEnvironment.isHeadless()) {
        // Splash Screen
        JFrame.setDefaultLookAndFeelDecorated(true);
        splashScreen = new JDialog(frame, false);
        ImageIcon logo = new ImageIcon(loader.getResource("ffx/ui/icons/splash.png"));
        JLabel ffxLabel = new JLabel(logo);
        ffxLabel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
        Container contentpane = splashScreen.getContentPane();
        contentpane.setLayout(new BorderLayout());
        contentpane.add(ffxLabel, BorderLayout.CENTER);
        splashScreen.setUndecorated(true);
        splashScreen.pack();
        Dimension screenDimension = getToolkit().getScreenSize();
        Dimension splashDimension = splashScreen.getSize();
        splashScreen.setLocation((screenDimension.width - splashDimension.width) / 2, (screenDimension.height - splashDimension.height) / 2);
        splashScreen.setResizable(false);
        splashScreen.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        splashScreen.setVisible(true);
        // Make all pop-up Menus Heavyweight so they play nicely with Java3D
        JPopupMenu.setDefaultLightWeightPopupEnabled(false);
    }
    // Create the Root Node
    dataRoot = new MSRoot();
    Border bb = BorderFactory.createEtchedBorder(EtchedBorder.RAISED);
    statusLabel = new JLabel("  ");
    JLabel stepLabel = new JLabel("  ");
    stepLabel.setHorizontalAlignment(JLabel.RIGHT);
    JLabel energyLabel = new JLabel("  ");
    energyLabel.setHorizontalAlignment(JLabel.RIGHT);
    JPanel statusPanel = new JPanel(new GridLayout(1, 3));
    statusPanel.setBorder(bb);
    statusPanel.add(statusLabel);
    statusPanel.add(stepLabel);
    statusPanel.add(energyLabel);
    if (!GraphicsEnvironment.isHeadless()) {
        GraphicsConfigTemplate3D template3D = new GraphicsConfigTemplate3D();
        // template3D.setDoubleBuffer(GraphicsConfigTemplate.PREFERRED);
        GraphicsConfiguration gc = null;
        try {
            gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getBestConfiguration(template3D);
        // gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
        } catch (Exception e) {
            e.fillInStackTrace();
            e.printStackTrace();
            logger.log(Level.SEVERE, " Exception encountered when trying to get the best GraphicsConfiguration", e);
        }
        try {
            graphicsCanvas = new GraphicsCanvas(gc, this);
        } catch (Exception e) {
            e.fillInStackTrace();
            e.printStackTrace();
            logger.log(Level.SEVERE, " Exception encountered when trying to create the GraphicsCanvas", e);
        }
        graphicsPanel = new GraphicsPanel(graphicsCanvas, statusPanel);
    }
    // Initialize various Panels
    hierarchy = new Hierarchy(this);
    hierarchy.setStatus(statusLabel, stepLabel, energyLabel);
    keywordPanel = new KeywordPanel(this);
    modelingPanel = new ModelingPanel(this);
    JPanel treePane = new JPanel(new BorderLayout());
    JScrollPane scrollPane = new JScrollPane(hierarchy, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    treePane.add(scrollPane, BorderLayout.CENTER);
    tabbedPane = new JTabbedPane();
    ImageIcon graphicsIcon = new ImageIcon(loader.getResource("ffx/ui/icons/monitor.png"));
    ImageIcon keywordIcon = new ImageIcon(loader.getResource("ffx/ui/icons/key.png"));
    ImageIcon modelingIcon = new ImageIcon(loader.getResource("ffx/ui/icons/cog.png"));
    tabbedPane.addTab(locale.getValue("Graphics"), graphicsIcon, graphicsPanel);
    tabbedPane.addTab(locale.getValue("KeywordEditor"), keywordIcon, keywordPanel);
    tabbedPane.addTab(locale.getValue("ModelingCommands"), modelingIcon, modelingPanel);
    tabbedPane.addChangeListener(this);
    splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, false, treePane, tabbedPane);
    /* splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, false,
         treePane, graphicsPanel); */
    splitPane.setResizeWeight(0.25);
    splitPane.setOneTouchExpandable(true);
    setLayout(new BorderLayout());
    add(splitPane, BorderLayout.CENTER);
    if (!GraphicsEnvironment.isHeadless()) {
        mainMenu = new MainMenu(this);
        add(mainMenu.getToolBar(), BorderLayout.NORTH);
        getModelingShell();
        loadPrefs();
        SwingUtilities.updateComponentTreeUI(SwingUtilities.getRoot(this));
        splashScreen.dispose();
    }
}
Also used : ImageIcon(javax.swing.ImageIcon) JPanel(javax.swing.JPanel) JTabbedPane(javax.swing.JTabbedPane) ForceFieldString(ffx.potential.parameters.ForceField.ForceFieldString) GraphicsConfiguration(java.awt.GraphicsConfiguration) Container(java.awt.Container) GridLayout(java.awt.GridLayout) BorderLayout(java.awt.BorderLayout) JScrollPane(javax.swing.JScrollPane) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) GraphicsConfigTemplate3D(javax.media.j3d.GraphicsConfigTemplate3D) UnsupportedLookAndFeelException(javax.swing.UnsupportedLookAndFeelException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) MalformedURLException(java.net.MalformedURLException) FFXLocale(ffx.ui.properties.FFXLocale) MSRoot(ffx.potential.bonded.MSRoot) JSplitPane(javax.swing.JSplitPane) File(java.io.File) Border(javax.swing.border.Border) EtchedBorder(javax.swing.border.EtchedBorder) JDialog(javax.swing.JDialog)

Aggregations

MSRoot (ffx.potential.bonded.MSRoot)1 ForceFieldString (ffx.potential.parameters.ForceField.ForceFieldString)1 FFXLocale (ffx.ui.properties.FFXLocale)1 BorderLayout (java.awt.BorderLayout)1 Container (java.awt.Container)1 Dimension (java.awt.Dimension)1 GraphicsConfiguration (java.awt.GraphicsConfiguration)1 GridLayout (java.awt.GridLayout)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 GraphicsConfigTemplate3D (javax.media.j3d.GraphicsConfigTemplate3D)1 ImageIcon (javax.swing.ImageIcon)1 JDialog (javax.swing.JDialog)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1 JScrollPane (javax.swing.JScrollPane)1 JSplitPane (javax.swing.JSplitPane)1 JTabbedPane (javax.swing.JTabbedPane)1