Search in sources :

Example 1 with ImagePanel

use of org.sunflow.system.ImagePanel in project JWildfire by thargor6.

the class EDENInternalFrame method getLeftSplitPanel.

private JPanel getLeftSplitPanel() {
    if (leftSplitPanel == null) {
        leftSplitPanel = new JPanel();
        leftSplitPanel.setLayout(new BorderLayout());
        imagePanel = new ImagePanel();
        leftSplitPanel.add(imagePanel, BorderLayout.CENTER);
    }
    return leftSplitPanel;
}
Also used : JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) ImagePanel(org.sunflow.system.ImagePanel)

Example 2 with ImagePanel

use of org.sunflow.system.ImagePanel in project joons-renderer by joonhyublee.

the class SunflowGUI method initGUI.

private void initGUI() {
    setTitle("Sunflow v" + SunflowAPI.VERSION);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    {
        desktop = new JDesktopPane();
        getContentPane().add(desktop, BorderLayout.CENTER);
        Dimension screenRes = Toolkit.getDefaultToolkit().getScreenSize();
        if (screenRes.getWidth() <= DEFAULT_WIDTH || screenRes.getHeight() <= DEFAULT_HEIGHT) {
            desktop.setPreferredSize(new java.awt.Dimension(640, 480));
        } else {
            desktop.setPreferredSize(new java.awt.Dimension(DEFAULT_WIDTH, DEFAULT_HEIGHT));
        }
        {
            imagePanelFrame = new JInternalFrame();
            desktop.add(imagePanelFrame);
            {
                jPanel1 = new JPanel();
                FlowLayout jPanel1Layout = new FlowLayout();
                jPanel1Layout.setAlignment(FlowLayout.LEFT);
                jPanel1.setLayout(jPanel1Layout);
                imagePanelFrame.getContentPane().add(jPanel1, BorderLayout.NORTH);
                {
                    renderButton = new JButton();
                    jPanel1.add(renderButton);
                    renderButton.setText("Render");
                    renderButton.addActionListener(new ActionListener() {

                        @Override
                        public void actionPerformed(ActionEvent evt) {
                            renderMenuItemActionPerformed(evt);
                        }
                    });
                }
                {
                    iprButton = new JButton();
                    jPanel1.add(iprButton);
                    iprButton.setText("IPR");
                    iprButton.addActionListener(new ActionListener() {

                        @Override
                        public void actionPerformed(ActionEvent evt) {
                            iprMenuItemActionPerformed(evt);
                        }
                    });
                }
            }
            {
                imagePanel = new ImagePanel();
                imagePanelFrame.getContentPane().add(imagePanel, BorderLayout.CENTER);
            }
            imagePanelFrame.pack();
            imagePanelFrame.setResizable(true);
            imagePanelFrame.setMaximizable(true);
            imagePanelFrame.setVisible(true);
            imagePanelFrame.setTitle("Image");
            imagePanelFrame.setIconifiable(true);
        }
        {
            editorFrame = new JInternalFrame();
            desktop.add(editorFrame);
            editorFrame.setTitle("Script Editor");
            editorFrame.setMaximizable(true);
            editorFrame.setResizable(true);
            editorFrame.setIconifiable(true);
            {
                jScrollPane1 = new JScrollPane();
                editorFrame.getContentPane().add(jScrollPane1, BorderLayout.CENTER);
                jScrollPane1.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
                jScrollPane1.setPreferredSize(new java.awt.Dimension(360, 280));
                {
                    editorTextArea = new JTextArea();
                    jScrollPane1.setViewportView(editorTextArea);
                    editorTextArea.setFont(new java.awt.Font("Monospaced", 0, 12));
                    // drag and drop
                    editorTextArea.setTransferHandler(new SceneTransferHandler());
                }
            }
            {
                jPanel3 = new JPanel();
                editorFrame.getContentPane().add(jPanel3, BorderLayout.SOUTH);
                FlowLayout jPanel3Layout = new FlowLayout();
                jPanel3Layout.setAlignment(FlowLayout.RIGHT);
                jPanel3.setLayout(jPanel3Layout);
                {
                    buildButton = new JButton();
                    jPanel3.add(buildButton);
                    buildButton.setText("Build Scene");
                    buildButton.addActionListener(new ActionListener() {

                        @Override
                        public void actionPerformed(ActionEvent evt) {
                            buildMenuItemActionPerformed(evt);
                        }
                    });
                }
            }
            editorFrame.pack();
            editorFrame.setVisible(true);
        }
        {
            consoleFrame = new JInternalFrame();
            desktop.add(consoleFrame);
            consoleFrame.setIconifiable(true);
            consoleFrame.setMaximizable(true);
            consoleFrame.setResizable(true);
            consoleFrame.setTitle("Console");
            {
                jScrollPane2 = new JScrollPane();
                consoleFrame.getContentPane().add(jScrollPane2, BorderLayout.CENTER);
                jScrollPane2.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
                jScrollPane2.setPreferredSize(new java.awt.Dimension(360, 100));
                {
                    consoleTextArea = new JTextArea();
                    jScrollPane2.setViewportView(consoleTextArea);
                    consoleTextArea.setFont(new java.awt.Font("Monospaced", 0, 12));
                    consoleTextArea.setEditable(false);
                }
            }
            {
                jPanel4 = new JPanel();
                consoleFrame.getContentPane().add(jPanel4, BorderLayout.SOUTH);
                BorderLayout jPanel4Layout = new BorderLayout();
                jPanel4.setLayout(jPanel4Layout);
                {
                    jPanel6 = new JPanel();
                    BorderLayout jPanel6Layout = new BorderLayout();
                    jPanel6.setLayout(jPanel6Layout);
                    jPanel4.add(jPanel6, BorderLayout.CENTER);
                    jPanel6.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 0));
                    {
                        taskProgressBar = new JProgressBar();
                        jPanel6.add(taskProgressBar);
                        taskProgressBar.setEnabled(false);
                        taskProgressBar.setString("");
                        taskProgressBar.setStringPainted(true);
                        taskProgressBar.setOpaque(false);
                    }
                }
                {
                    jPanel5 = new JPanel();
                    FlowLayout jPanel5Layout = new FlowLayout();
                    jPanel5Layout.setAlignment(FlowLayout.RIGHT);
                    jPanel5.setLayout(jPanel5Layout);
                    jPanel4.add(jPanel5, BorderLayout.EAST);
                    {
                        taskCancelButton = new JButton();
                        jPanel5.add(taskCancelButton);
                        taskCancelButton.setText("Cancel");
                        taskCancelButton.setEnabled(false);
                        taskCancelButton.addActionListener(new ActionListener() {

                            @Override
                            public void actionPerformed(ActionEvent evt) {
                                UI.taskCancel();
                            }
                        });
                    }
                    {
                        clearConsoleButton = new JButton();
                        jPanel5.add(clearConsoleButton);
                        clearConsoleButton.setText("Clear");
                        clearConsoleButton.addActionListener(new ActionListener() {

                            @Override
                            public void actionPerformed(ActionEvent evt) {
                                clearConsole();
                            }
                        });
                    }
                }
            }
            consoleFrame.pack();
            consoleFrame.setVisible(true);
        }
    }
    {
        jMenuBar1 = new JMenuBar();
        setJMenuBar(jMenuBar1);
        {
            fileMenu = new JMenu();
            jMenuBar1.add(fileMenu);
            fileMenu.setText("File");
            {
                newFileMenuItem = new JMenuItem();
                fileMenu.add(newFileMenuItem);
                newFileMenuItem.setText("New");
                newFileMenuItem.setAccelerator(KeyStroke.getKeyStroke("ctrl N"));
                newFileMenuItem.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        newFileMenuItemActionPerformed(evt);
                    }
                });
            }
            {
                openFileMenuItem = new JMenuItem();
                fileMenu.add(openFileMenuItem);
                openFileMenuItem.setText("Open ...");
                openFileMenuItem.setAccelerator(KeyStroke.getKeyStroke("ctrl O"));
                openFileMenuItem.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        openFileMenuItemActionPerformed(evt);
                    }
                });
            }
            {
                saveMenuItem = new JMenuItem();
                fileMenu.add(saveMenuItem);
                saveMenuItem.setText("Save");
                saveMenuItem.setAccelerator(KeyStroke.getKeyStroke("ctrl S"));
                saveMenuItem.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        saveCurrentFile(currentFile);
                    }
                });
            }
            {
                saveAsMenuItem = new JMenuItem();
                fileMenu.add(saveAsMenuItem);
                saveAsMenuItem.setText("Save As ...");
                saveAsMenuItem.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        saveAsMenuItemActionPerformed(evt);
                    }
                });
            }
            {
                jSeparator2 = new JSeparator();
                fileMenu.add(jSeparator2);
            }
            {
                exitMenuItem = new JMenuItem();
                fileMenu.add(exitMenuItem);
                exitMenuItem.setText("Exit");
                exitMenuItem.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        System.exit(0);
                    }
                });
            }
        }
        {
            sceneMenu = new JMenu();
            jMenuBar1.add(sceneMenu);
            sceneMenu.setText("Scene");
            {
                buildMenuItem = new JMenuItem();
                sceneMenu.add(buildMenuItem);
                buildMenuItem.setText("Build");
                buildMenuItem.setAccelerator(KeyStroke.getKeyStroke("ctrl B"));
                buildMenuItem.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        if (sceneMenu.isEnabled()) {
                            buildMenuItemActionPerformed(evt);
                        }
                    }
                });
            }
            {
                autoBuildMenuItem = new JCheckBoxMenuItem();
                sceneMenu.add(autoBuildMenuItem);
                autoBuildMenuItem.setText("Build on open");
                autoBuildMenuItem.setSelected(true);
            }
            {
                jSeparator3 = new JSeparator();
                sceneMenu.add(jSeparator3);
            }
            {
                renderMenuItem = new JMenuItem();
                sceneMenu.add(renderMenuItem);
                renderMenuItem.setText("Render");
                renderMenuItem.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        renderMenuItemActionPerformed(evt);
                    }
                });
            }
            {
                iprMenuItem = new JMenuItem();
                sceneMenu.add(iprMenuItem);
                iprMenuItem.setText("IPR");
                iprMenuItem.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        iprMenuItemActionPerformed(evt);
                    }
                });
            }
            {
                clearLogMenuItem = new JCheckBoxMenuItem();
                sceneMenu.add(clearLogMenuItem);
                clearLogMenuItem.setText("Auto Clear Log");
                clearLogMenuItem.setToolTipText("Clears the console before building or rendering");
                clearLogMenuItem.setSelected(true);
            }
            {
                jSeparator4 = new JSeparator();
                sceneMenu.add(jSeparator4);
            }
            {
                textureCacheClearMenuItem = new JMenuItem();
                sceneMenu.add(textureCacheClearMenuItem);
                textureCacheClearMenuItem.setText("Clear Texture Cache");
                textureCacheClearMenuItem.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        textureCacheClearMenuItemActionPerformed(evt);
                    }
                });
            }
            {
                smallTrianglesMenuItem = new JCheckBoxMenuItem();
                sceneMenu.add(smallTrianglesMenuItem);
                smallTrianglesMenuItem.setText("Low Mem Triangles");
                smallTrianglesMenuItem.setToolTipText("Load future meshes using a low memory footprint triangle representation");
                smallTrianglesMenuItem.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        smallTrianglesMenuItemActionPerformed(evt);
                    }
                });
            }
        }
        {
            imageMenu = new JMenu();
            jMenuBar1.add(imageMenu);
            imageMenu.setText("Image");
            {
                resetZoomMenuItem = new JMenuItem();
                imageMenu.add(resetZoomMenuItem);
                resetZoomMenuItem.setText("Reset Zoom");
                resetZoomMenuItem.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        imagePanel.reset();
                    }
                });
            }
            {
                fitWindowMenuItem = new JMenuItem();
                imageMenu.add(fitWindowMenuItem);
                fitWindowMenuItem.setText("Fit to Window");
                fitWindowMenuItem.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        imagePanel.fit();
                    }
                });
            }
            {
                jSeparator1 = new JSeparator();
                imageMenu.add(jSeparator1);
            }
            {
                jMenuItem4 = new JMenuItem();
                imageMenu.add(jMenuItem4);
                jMenuItem4.setText("Save Image ...");
                jMenuItem4.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        // imagePanel.image;
                        JFileChooser fc = new JFileChooser(".");
                        fc.setFileFilter(new FileFilter() {

                            @Override
                            public String getDescription() {
                                return "Image File";
                            }

                            @Override
                            public boolean accept(File f) {
                                return (f.isDirectory() || f.getName().endsWith(".png") || f.getName().endsWith(".tga"));
                            }
                        });
                        if (fc.showSaveDialog(SunflowGUI.this) == JFileChooser.APPROVE_OPTION) {
                            String filename = fc.getSelectedFile().getAbsolutePath();
                            imagePanel.save(filename);
                        }
                    }
                });
            }
        }
        {
            windowMenu = new JMenu();
            jMenuBar1.add(windowMenu);
            windowMenu.setText("Window");
        }
        {
            imageWindowMenuItem = new JMenuItem();
            windowMenu.add(imageWindowMenuItem);
            imageWindowMenuItem.setText("Image");
            imageWindowMenuItem.setAccelerator(KeyStroke.getKeyStroke("ctrl 1"));
            imageWindowMenuItem.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent evt) {
                    selectFrame(imagePanelFrame);
                }
            });
        }
        {
            editorWindowMenuItem = new JMenuItem();
            windowMenu.add(editorWindowMenuItem);
            editorWindowMenuItem.setText("Script Editor");
            editorWindowMenuItem.setAccelerator(KeyStroke.getKeyStroke("ctrl 2"));
            editorWindowMenuItem.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent evt) {
                    selectFrame(editorFrame);
                }
            });
        }
        {
            consoleWindowMenuItem = new JMenuItem();
            windowMenu.add(consoleWindowMenuItem);
            consoleWindowMenuItem.setText("Console");
            consoleWindowMenuItem.setAccelerator(KeyStroke.getKeyStroke("ctrl 3"));
            consoleWindowMenuItem.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent evt) {
                    selectFrame(consoleFrame);
                }
            });
        }
        {
            jSeparator5 = new JSeparator();
            windowMenu.add(jSeparator5);
        }
        {
            tileWindowMenuItem = new JMenuItem();
            windowMenu.add(tileWindowMenuItem);
            tileWindowMenuItem.setText("Tile");
            tileWindowMenuItem.setAccelerator(KeyStroke.getKeyStroke("ctrl T"));
            tileWindowMenuItem.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent evt) {
                    tileWindowMenuItemActionPerformed(evt);
                }
            });
        }
    }
}
Also used : JDesktopPane(javax.swing.JDesktopPane) JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) JTextArea(javax.swing.JTextArea) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JProgressBar(javax.swing.JProgressBar) JSeparator(javax.swing.JSeparator) BorderLayout(java.awt.BorderLayout) JMenuItem(javax.swing.JMenuItem) FileFilter(javax.swing.filechooser.FileFilter) JScrollPane(javax.swing.JScrollPane) Dimension(java.awt.Dimension) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) ActionListener(java.awt.event.ActionListener) JFileChooser(javax.swing.JFileChooser) JInternalFrame(javax.swing.JInternalFrame) File(java.io.File) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu) ImagePanel(org.sunflow.system.ImagePanel)

Aggregations

BorderLayout (java.awt.BorderLayout)2 JPanel (javax.swing.JPanel)2 ImagePanel (org.sunflow.system.ImagePanel)2 Dimension (java.awt.Dimension)1 FlowLayout (java.awt.FlowLayout)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 File (java.io.File)1 JButton (javax.swing.JButton)1 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)1 JDesktopPane (javax.swing.JDesktopPane)1 JFileChooser (javax.swing.JFileChooser)1 JInternalFrame (javax.swing.JInternalFrame)1 JMenu (javax.swing.JMenu)1 JMenuBar (javax.swing.JMenuBar)1 JMenuItem (javax.swing.JMenuItem)1 JProgressBar (javax.swing.JProgressBar)1 JScrollPane (javax.swing.JScrollPane)1 JSeparator (javax.swing.JSeparator)1 JTextArea (javax.swing.JTextArea)1