Example usage for javax.swing JButton setToolTipText

List of usage examples for javax.swing JButton setToolTipText

Introduction

In this page you can find the example usage for javax.swing JButton setToolTipText.

Prototype

@BeanProperty(bound = false, preferred = true, description = "The text to display in a tool tip.")
public void setToolTipText(String text) 

Source Link

Document

Registers the text to display in a tool tip.

Usage

From source file:savant.view.swing.BookmarkSheet.java

public BookmarkSheet(Container c) {

    // set the layout of the data sheet
    c.setLayout(new BorderLayout());
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    /**//  w  ww  .java2 s.c o  m
     * Create a toolbar. 
     */
    JMenuBar toolbar = new JMenuBar();
    toolbar.setLayout(new BoxLayout(toolbar, BoxLayout.X_AXIS));
    c.add(toolbar, BorderLayout.NORTH);

    JButton previousButton = new JButton();
    previousButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.UP));
    previousButton.setToolTipText("Go to previous bookmark [ Ctrl+( ]");
    previousButton.putClientProperty("JButton.buttonType", "segmentedRoundRect");
    previousButton.putClientProperty("JButton.segmentPosition", "first");
    previousButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            goToPreviousBookmark();
        }

    });
    toolbar.add(previousButton);

    JButton nextButton = new JButton();
    nextButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.DOWN));
    nextButton.setToolTipText("Go to next bookmark [ Ctrl+) ]");
    nextButton.putClientProperty("JButton.buttonType", "segmentedRoundRect");
    nextButton.putClientProperty("JButton.segmentPosition", "last");
    nextButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            goToNextBookmark();
        }

    });
    toolbar.add(nextButton);

    JButton goButton = new JButton("Go");
    goButton.setToolTipText("Go to selected bookmark");
    goButton.putClientProperty("JButton.buttonType", "segmentedRoundRect");
    goButton.putClientProperty("JButton.segmentPosition", "only");
    goButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            goToSelectedBookmark();
        }

    });
    toolbar.add(goButton);

    toolbar.add(Box.createGlue());

    addButton = new JButton();
    addButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.BKMK_ADD));
    addButton.setToolTipText("Add bookmark for current range");
    addButton.putClientProperty("JButton.buttonType", "segmentedRoundRect");
    addButton.putClientProperty("JButton.segmentPosition", "first");
    addButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            BookmarkController fc = BookmarkController.getInstance();
            fc.addCurrentRangeToBookmarks();
        }
    });
    toolbar.add(addButton);

    JButton deleteButton = new JButton();
    deleteButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.BKMK_RM));
    deleteButton.setToolTipText("Delete selected bookmarks");
    deleteButton.putClientProperty("JButton.buttonType", "segmentedRoundRect");
    deleteButton.putClientProperty("JButton.segmentPosition", "last");
    deleteButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            BookmarkController fc = BookmarkController.getInstance();
            int[] selectedRows = table.getSelectedRows();
            Arrays.sort(selectedRows);
            boolean delete = false;

            if (selectedRows.length > 0 && confirmDelete) {
                Object[] options = { "Yes", "No", "Yes, don't ask again" };
                JLabel message = new JLabel(
                        "Are you sure you want to delete " + selectedRows.length + " item(s)?");
                message.setPreferredSize(new Dimension(300, 20));
                int confirmDeleteDialog = JOptionPane.showOptionDialog(DialogUtils.getMainWindow(), message,
                        "Confirm Delete", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null,
                        options, options[0]);

                if (confirmDeleteDialog == 0) {
                    delete = true;
                } else if (confirmDeleteDialog == 2) {
                    delete = true;
                    confirmDelete = false;
                }
            } else if (selectedRows.length > 0 && !confirmDelete) {
                delete = true;
            }

            if (delete) {
                for (int i = selectedRows.length - 1; i >= 0; i--) {
                    fc.removeBookmark(selectedRows[i]);
                }
            }
        }
    });
    toolbar.add(deleteButton);

    toolbar.add(Box.createGlue());

    JButton loadButton = new JButton();
    loadButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.OPEN));
    loadButton.setToolTipText("Load bookmarks from file");
    loadButton.putClientProperty("JButton.buttonType", "segmentedRoundRect");
    loadButton.putClientProperty("JButton.segmentPosition", "first");
    loadButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            loadBookmarks(table);
        }
    });
    toolbar.add(loadButton);

    JButton saveButton = new JButton();
    saveButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.SAVE));
    saveButton.setToolTipText("Save bookmarks to file");
    saveButton.putClientProperty("JButton.buttonType", "segmentedRoundRect");
    saveButton.putClientProperty("JButton.segmentPosition", "last");
    saveButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            saveBookmarks(table);
        }
    });
    toolbar.add(saveButton);

    // create a table (the most important component)
    table = new JTable(new BookmarksTableModel());
    table.setAutoCreateRowSorter(true);
    table.setFillsViewportHeight(true);
    table.setShowGrid(true);
    table.setGridColor(Color.gray);
    //table.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);

    // add the table and its header to the subpanel
    c.add(table.getTableHeader());

    add(table);

    final JScrollPane sp = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    sp.setWheelScrollingEnabled(false);
    sp.addMouseWheelListener(new MouseWheelListener() {
        @Override
        public void mouseWheelMoved(MouseWheelEvent e) {
            sp.getVerticalScrollBar().setValue(sp.getVerticalScrollBar().getValue() + e.getUnitsToScroll() * 2);
        }
    });

    c.add(sp);

    // add glue to fill the remaining space
    add(Box.createGlue());
}

From source file:savant.view.swing.NavigationBar.java

NavigationBar() {

    this.setOpaque(false);
    this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));

    String buttonStyle = "segmentedCapsule";

    String shortcutMod = MiscUtils.MAC ? "Cmd" : "Ctrl";

    add(getRigidPadding());/* w  ww .j  a v a2  s . c o  m*/

    JButton loadGenomeButton = (JButton) add(new JButton(""));
    loadGenomeButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.GENOME));
    loadGenomeButton.setToolTipText("Load or change genome");
    loadGenomeButton.setFocusable(false);
    loadGenomeButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Savant.getInstance().showOpenGenomeDialog();
        }
    });
    loadGenomeButton.putClientProperty("JButton.buttonType", buttonStyle);
    loadGenomeButton.putClientProperty("JButton.segmentPosition", "first");
    loadGenomeButton.setPreferredSize(ICON_SIZE);
    loadGenomeButton.setMinimumSize(ICON_SIZE);
    loadGenomeButton.setMaximumSize(ICON_SIZE);

    JButton loadTrackButton = (JButton) add(new JButton(""));
    loadTrackButton.setFocusable(false);
    loadTrackButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.TRACK));
    loadTrackButton.setToolTipText("Load a track");
    loadTrackButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Savant.getInstance().openTrack();
        }
    });
    loadTrackButton.putClientProperty("JButton.buttonType", buttonStyle);
    loadTrackButton.putClientProperty("JButton.segmentPosition", "last");
    loadTrackButton.setPreferredSize(ICON_SIZE);
    loadTrackButton.setMinimumSize(ICON_SIZE);
    loadTrackButton.setMaximumSize(ICON_SIZE);

    if (!Savant.getInstance().isStandalone()) {
        add(loadGenomeButton);
        add(loadTrackButton);
        add(getRigidPadding());
        add(getRigidPadding());
    } else {
        loadGenomeButton.setVisible(false);
        loadTrackButton.setVisible(false);
    }

    JLabel rangeText = new JLabel("Location ");
    add(rangeText);

    String[] a = { " ", " ", " ", " ", " ", " ", " ", " ", " ", " " };
    locationField = new JComboBox(a);
    locationField.setEditable(true);
    locationField.setRenderer(new ReferenceListRenderer());

    // When the item is chosen from the menu, navigate to the given feature/reference.
    locationField.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            if (!currentlyPopulating) {
                if (ae.getActionCommand().equals("comboBoxChanged")) {
                    // Assumes that combo-box items created by populateCombo() are of the form "GENE (chrX:1-1000)".
                    String itemText = locationField.getSelectedItem().toString();
                    int lastBracketPos = itemText.lastIndexOf('(');
                    if (lastBracketPos > 0) {
                        itemText = itemText.substring(lastBracketPos + 1, itemText.length() - 1);
                    }
                    setRangeFromText(itemText);

                }
            }
        }
    });

    // When the combo-box is popped open, we may want to repopulate the menu.
    locationField.addPopupMenuListener(new PopupMenuListener() {
        @Override
        public void popupMenuWillBecomeVisible(PopupMenuEvent pme) {
            String text = (String) locationField.getEditor().getItem();
            if (!text.equals(lastPoppedUp)) {
                try {
                    // Building the menu could take a while.
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    populateCombo();
                } finally {
                    setCursor(Cursor.getDefaultCursor());
                }
            }
        }

        @Override
        public void popupMenuWillBecomeInvisible(PopupMenuEvent pme) {
        }

        @Override
        public void popupMenuCanceled(PopupMenuEvent pme) {
        }
    });

    // Add our special keystroke-handling to the JComboBox' text-field.
    // We have to turn off default tab-handling so that tab can pop up our list.
    Component textField = locationField.getEditor().getEditorComponent();
    textField.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, Collections.EMPTY_SET);
    textField.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent evt) {
            if (evt.getKeyCode() == KeyEvent.VK_TAB) {
                locationField.showPopup();
            } else if (evt.getModifiers() == KeyEvent.SHIFT_MASK) {
                switch (evt.getKeyCode()) {
                case KeyEvent.VK_LEFT:
                    locationController.shiftRangeLeft();
                    evt.consume();
                    break;
                case KeyEvent.VK_RIGHT:
                    locationController.shiftRangeRight();
                    evt.consume();
                    break;
                case KeyEvent.VK_UP:
                    locationController.zoomIn();
                    evt.consume();
                    break;
                case KeyEvent.VK_DOWN:
                    locationController.zoomOut();
                    evt.consume();
                    break;
                case KeyEvent.VK_HOME:
                    locationController.shiftRangeFarLeft();
                    evt.consume();
                    break;
                case KeyEvent.VK_END:
                    locationController.shiftRangeFarRight();
                    evt.consume();
                    break;
                }
            }
        }
    });
    add(locationField);
    locationField.setToolTipText("Current display range");
    locationField.setPreferredSize(LOCATION_SIZE);
    locationField.setMaximumSize(LOCATION_SIZE);
    locationField.setMinimumSize(LOCATION_SIZE);

    add(getRigidPadding());

    JButton goButton = (JButton) add(new JButton("  Go  "));
    goButton.putClientProperty("JButton.buttonType", buttonStyle);
    goButton.putClientProperty("JButton.segmentPosition", "only");
    goButton.setToolTipText("Go to specified range (Enter)");
    goButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setRangeFromText(locationField.getEditor().getItem().toString());
        }
    });

    add(getRigidPadding());

    JLabel l = new JLabel("Length: ");
    add(l);

    lengthLabel = (JLabel) add(new JLabel());
    lengthLabel.setToolTipText("Length of the current range");
    lengthLabel.setPreferredSize(LENGTH_SIZE);
    lengthLabel.setMaximumSize(LENGTH_SIZE);
    lengthLabel.setMinimumSize(LENGTH_SIZE);

    add(Box.createGlue());

    double screenwidth = Toolkit.getDefaultToolkit().getScreenSize().getWidth();

    JButton afterGo = null;
    //if (screenwidth > 800) {
    final JButton undoButton = (JButton) add(new JButton(""));
    afterGo = undoButton;
    undoButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.UNDO));
    undoButton.setToolTipText("Undo range change (" + shortcutMod + "+Z)");
    undoButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            locationController.undoLocationChange();
        }
    });
    undoButton.putClientProperty("JButton.buttonType", buttonStyle);
    undoButton.putClientProperty("JButton.segmentPosition", "first");
    undoButton.setPreferredSize(ICON_SIZE);
    undoButton.setMinimumSize(ICON_SIZE);
    undoButton.setMaximumSize(ICON_SIZE);

    final JButton redo = (JButton) add(new JButton(""));
    redo.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.REDO));
    redo.setToolTipText("Redo range change (" + shortcutMod + "+Y)");
    redo.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            locationController.redoLocationChange();
        }
    });
    redo.putClientProperty("JButton.buttonType", buttonStyle);
    redo.putClientProperty("JButton.segmentPosition", "last");
    redo.setPreferredSize(ICON_SIZE);
    redo.setMinimumSize(ICON_SIZE);
    redo.setMaximumSize(ICON_SIZE);
    //}

    add(getRigidPadding());
    add(getRigidPadding());

    final JButton zoomInButton = (JButton) add(new JButton());
    if (afterGo == null) {
        afterGo = zoomInButton;
    }
    zoomInButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.ZOOMIN));
    zoomInButton.putClientProperty("JButton.buttonType", buttonStyle);
    zoomInButton.putClientProperty("JButton.segmentPosition", "first");
    zoomInButton.setPreferredSize(ICON_SIZE);
    zoomInButton.setMinimumSize(ICON_SIZE);
    zoomInButton.setMaximumSize(ICON_SIZE);
    zoomInButton.setToolTipText("Zoom in (Shift+Up)");
    zoomInButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            locationController.zoomIn();
            AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "zoomed"),
                    new NameValuePair("navigation-direction", "in"),
                    new NameValuePair("navigation-modality", "navbar") });
        }
    });

    final JButton zoomOut = (JButton) add(new JButton(""));
    zoomOut.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.ZOOMOUT));
    zoomOut.setToolTipText("Zoom out (Shift+Down)");
    zoomOut.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            locationController.zoomOut();
            AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "zoomed"),
                    new NameValuePair("navigation-direction", "out"),
                    new NameValuePair("navigation-modality", "navbar") });
        }
    });
    zoomOut.putClientProperty("JButton.buttonType", buttonStyle);
    zoomOut.putClientProperty("JButton.segmentPosition", "last");
    zoomOut.setPreferredSize(ICON_SIZE);
    zoomOut.setMinimumSize(ICON_SIZE);
    zoomOut.setMaximumSize(ICON_SIZE);

    add(getRigidPadding());
    add(getRigidPadding());

    final JButton shiftFarLeft = (JButton) add(new JButton());
    shiftFarLeft.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.SHIFT_FARLEFT));
    shiftFarLeft.putClientProperty("JButton.buttonType", buttonStyle);
    shiftFarLeft.putClientProperty("JButton.segmentPosition", "first");
    shiftFarLeft.setToolTipText("Move to the beginning of the genome (Shift+Home)");
    shiftFarLeft.setPreferredSize(ICON_SIZE);
    shiftFarLeft.setMinimumSize(ICON_SIZE);
    shiftFarLeft.setMaximumSize(ICON_SIZE);
    shiftFarLeft.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            locationController.shiftRangeFarLeft();
            AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "panned"),
                    new NameValuePair("navigation-direction", "left"),
                    new NameValuePair("navigation-modality", "navbar") });
        }
    });

    final JButton shiftLeft = (JButton) add(new JButton());
    shiftLeft.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.SHIFT_LEFT));
    shiftLeft.putClientProperty("JButton.buttonType", buttonStyle);
    shiftLeft.putClientProperty("JButton.segmentPosition", "middle");
    shiftLeft.setToolTipText("Move left (Shift+Left)");
    shiftLeft.setPreferredSize(ICON_SIZE);
    shiftLeft.setMinimumSize(ICON_SIZE);
    shiftLeft.setMaximumSize(ICON_SIZE);
    shiftLeft.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            locationController.shiftRangeLeft();
            AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "panned"),
                    new NameValuePair("navigation-direction", "left"),
                    new NameValuePair("navigation-modality", "navbar") });
        }
    });

    final JButton shiftRight = (JButton) add(new JButton());
    shiftRight.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.SHIFT_RIGHT));
    shiftRight.putClientProperty("JButton.buttonType", buttonStyle);
    shiftRight.putClientProperty("JButton.segmentPosition", "middle");
    shiftRight.setToolTipText("Move right (Shift+Right)");
    shiftRight.setPreferredSize(ICON_SIZE);
    shiftRight.setMinimumSize(ICON_SIZE);
    shiftRight.setMaximumSize(ICON_SIZE);
    shiftRight.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            locationController.shiftRangeRight();
            AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "panned"),
                    new NameValuePair("navigation-direction", "right"),
                    new NameValuePair("navigation-modality", "navbar") });
        }
    });

    final JButton shiftFarRight = (JButton) add(new JButton());
    shiftFarRight
            .setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.SHIFT_FARRIGHT));
    shiftFarRight.putClientProperty("JButton.buttonType", buttonStyle);
    shiftFarRight.putClientProperty("JButton.segmentPosition", "last");
    shiftFarRight.setToolTipText("Move to the end of the genome (Shift+End)");
    shiftFarRight.setPreferredSize(ICON_SIZE);
    shiftFarRight.setMinimumSize(ICON_SIZE);
    shiftFarRight.setMaximumSize(ICON_SIZE);
    shiftFarRight.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            locationController.shiftRangeFarRight();
            AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "panned"),
                    new NameValuePair("navigation-direction", "right"),
                    new NameValuePair("navigation-modality", "navbar") });
        }
    });

    add(getRigidPadding());

    locationController.addListener(new Listener<LocationChangedEvent>() {
        @Override
        public void handleEvent(LocationChangedEvent event) {
            updateLocation(event.getReference(), (Range) event.getRange());
        }
    });

    // When the genome changes, we may need to invalidate our menu.
    GenomeController.getInstance().addListener(new Listener<GenomeChangedEvent>() {
        @Override
        public void handleEvent(GenomeChangedEvent event) {
            lastPoppedUp = "INVALID";
        }
    });

    this.addComponentListener(new ComponentListener() {
        @Override
        public void componentResized(ComponentEvent ce) {
            int width = ce.getComponent().getWidth();

            undoButton.setVisible(true);
            redo.setVisible(true);
            zoomInButton.setVisible(true);
            zoomOut.setVisible(true);
            shiftFarLeft.setVisible(true);
            shiftLeft.setVisible(true);
            shiftRight.setVisible(true);
            shiftFarRight.setVisible(true);

            // hide some components if the window isn't wide enough
            if (width < 1200) {
                undoButton.setVisible(false);
                redo.setVisible(false);
            }
            if (width < 1000) {
                shiftFarLeft.setVisible(false);
                shiftFarRight.setVisible(false);

                shiftRight.putClientProperty("JButton.segmentPosition", "last");
                shiftLeft.putClientProperty("JButton.segmentPosition", "first");
            } else {
                shiftRight.putClientProperty("JButton.segmentPosition", "middle");
                shiftLeft.putClientProperty("JButton.segmentPosition", "middle");
            }
        }

        public void componentMoved(ComponentEvent ce) {
        }

        @Override
        public void componentShown(ComponentEvent ce) {
        }

        @Override
        public void componentHidden(ComponentEvent ce) {
        }
    });
}

From source file:se.llbit.chunky.renderer.ui.RenderControls.java

private void buildUI() {
    setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    setModalityType(ModalityType.MODELESS);

    if (!ShutdownAlert.canShutdown()) {
        // disable the computer shutdown checkbox if we can't shutdown
        shutdownWhenDoneCB.setEnabled(false);
    }/* w w w .j a  v  a  2 s .  c  o m*/

    addWindowListener(new WindowListener() {
        @Override
        public void windowOpened(WindowEvent e) {
        }

        @Override
        public void windowIconified(WindowEvent e) {
        }

        @Override
        public void windowDeiconified(WindowEvent e) {
        }

        @Override
        public void windowDeactivated(WindowEvent e) {
        }

        @Override
        public void windowClosing(WindowEvent e) {
            sceneMan.interrupt();
            RenderControls.this.dispose();
        }

        @Override
        public void windowClosed(WindowEvent e) {
            // halt rendering
            renderMan.interrupt();

            // dispose of the 3D view
            view.setVisible(false);
            view.dispose();
        }

        @Override
        public void windowActivated(WindowEvent e) {
        }
    });

    updateTitle();

    addTab("General", Icon.wrench, buildGeneralPane());
    addTab("Lighting", Icon.light, buildLightingPane());
    addTab("Sky", Icon.sky, buildSkyPane());
    addTab("Water", Icon.water, buildWaterPane());
    addTab("Camera", Icon.camera, buildCameraPane());
    addTab("Post-processing", Icon.gear, buildPostProcessingPane());
    addTab("Advanced", Icon.advanced, buildAdvancedPane());
    addTab("Help", Icon.question, buildHelpPane());

    JLabel sppTargetLbl = new JLabel("SPP Target: ");
    sppTargetLbl.setToolTipText("The render will be paused at this SPP count");

    JButton setDefaultBtn = new JButton("Make Default");
    setDefaultBtn.setToolTipText("Make the current SPP target the default");
    setDefaultBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            PersistentSettings.setSppTargetDefault(renderMan.scene().getTargetSPP());
        }
    });

    targetSPP.update();

    JLabel renderLbl = new JLabel("Render: ");

    setViewVisible(false);
    showPreviewBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (view.isViewVisible()) {
                view.hideView();
            } else {
                showPreviewWindow();
            }
        }
    });

    startRenderBtn.setText("START");
    startRenderBtn.setIcon(Icon.play.imageIcon());
    startRenderBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            switch (renderMan.scene().getRenderState()) {
            case PAUSED:
                renderMan.scene().resumeRender();
                break;
            case PREVIEW:
                renderMan.scene().startRender();
                break;
            case RENDERING:
                renderMan.scene().pauseRender();
                break;
            }
            stopRenderBtn.setEnabled(true);
        }
    });

    stopRenderBtn.setText("RESET");
    stopRenderBtn.setIcon(Icon.stop.imageIcon());
    stopRenderBtn.setToolTipText("<html>Warning: this will discard the "
            + "current rendered image!<br>Make sure to save your image " + "before stopping the renderer!");
    stopRenderBtn.setEnabled(false);
    stopRenderBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            renderMan.scene().haltRender();
        }
    });

    saveFrameBtn.setText("Save Current Frame");
    saveFrameBtn.addActionListener(saveFrameListener);

    sppLbl.setToolTipText("SPP = Samples Per Pixel, SPS = Samples Per Second");

    setRenderTime(0);
    setSamplesPerSecond(0);
    setSPP(0);
    setProgress("Progress:", 0, 0, 1);

    progressLbl.setText("Progress:");

    etaLbl.setText("ETA:");

    sceneNameLbl.setText("Scene name: ");
    sceneNameField.setColumns(15);
    AbstractDocument document = (AbstractDocument) sceneNameField.getDocument();
    document.setDocumentFilter(new SceneNameFilter());
    document.addDocumentListener(sceneNameListener);
    sceneNameField.addActionListener(sceneNameActionListener);
    updateSceneNameField();

    saveSceneBtn.setText("Save");
    saveSceneBtn.setIcon(Icon.disk.imageIcon());
    saveSceneBtn.addActionListener(saveSceneListener);

    JPanel panel = new JPanel();
    GroupLayout layout = new GroupLayout(panel);
    panel.setLayout(layout);
    layout.setHorizontalGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout
            .createParallelGroup()
            .addGroup(layout.createSequentialGroup().addComponent(sceneNameLbl).addComponent(sceneNameField)
                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(saveSceneBtn))
            .addComponent(tabbedPane)
            .addGroup(layout.createSequentialGroup().addGroup(targetSPP.horizontalGroup(layout))
                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(setDefaultBtn))
            .addGroup(layout.createSequentialGroup().addComponent(renderLbl)
                    .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(startRenderBtn)
                    .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(stopRenderBtn))
            .addGroup(
                    layout.createSequentialGroup().addComponent(saveFrameBtn)
                            .addPreferredGap(ComponentPlacement.UNRELATED, GroupLayout.PREFERRED_SIZE,
                                    Short.MAX_VALUE)
                            .addComponent(showPreviewBtn))
            .addGroup(
                    layout.createSequentialGroup().addComponent(renderTimeLbl)
                            .addPreferredGap(ComponentPlacement.UNRELATED, GroupLayout.PREFERRED_SIZE,
                                    Short.MAX_VALUE)
                            .addComponent(sppLbl))
            .addGroup(
                    layout.createSequentialGroup().addComponent(progressLbl)
                            .addPreferredGap(ComponentPlacement.UNRELATED, GroupLayout.PREFERRED_SIZE,
                                    Short.MAX_VALUE)
                            .addComponent(etaLbl))
            .addComponent(progressBar)).addContainerGap());
    layout.setVerticalGroup(
            layout.createSequentialGroup().addContainerGap()
                    .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(sceneNameLbl)
                            .addComponent(sceneNameField).addComponent(saveSceneBtn))
                    .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(tabbedPane)
                    .addPreferredGap(ComponentPlacement.UNRELATED)
                    .addGroup(layout.createParallelGroup(Alignment.BASELINE)
                            .addGroup(targetSPP.verticalGroup(layout)).addComponent(setDefaultBtn))
                    .addPreferredGap(ComponentPlacement.UNRELATED)
                    .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(renderLbl)
                            .addComponent(startRenderBtn).addComponent(stopRenderBtn))
                    .addPreferredGap(ComponentPlacement.UNRELATED)
                    .addGroup(layout.createParallelGroup().addComponent(saveFrameBtn)
                            .addComponent(showPreviewBtn))
                    .addPreferredGap(ComponentPlacement.UNRELATED)
                    .addGroup(layout.createParallelGroup().addComponent(renderTimeLbl).addComponent(sppLbl))
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup().addComponent(progressLbl).addComponent(etaLbl))
                    .addComponent(progressBar).addContainerGap());
    final JScrollPane scrollPane = new JScrollPane(panel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    setContentPane(scrollPane);

    scrollPane.getViewport().addChangeListener(new ChangeListener() {
        private boolean resized = false;

        @Override
        public void stateChanged(ChangeEvent e) {
            if (!resized && scrollPane.getVerticalScrollBar().isVisible()) {
                Dimension vsbPrefSize = new JScrollPane().getVerticalScrollBar().getPreferredSize();
                Dimension size = getSize();
                setSize(size.width + vsbPrefSize.width, size.height);
                resized = true;
            }
        }
    });

    pack();

    setLocationRelativeTo(chunky.getFrame());

    setVisible(true);
}

From source file:se.llbit.chunky.renderer.ui.RenderControls.java

private JPanel buildWaterPane() {

    JButton storeDefaultsBtn = new JButton("Store as defaults");
    storeDefaultsBtn.setToolTipText("Store the current water settings as new defaults");
    storeDefaultsBtn.addActionListener(new ActionListener() {
        @Override/*from  ww  w .j  av  a2 s .  c  om*/
        public void actionPerformed(ActionEvent e) {
            PersistentSettings.setStillWater(renderMan.scene().stillWaterEnabled());
            PersistentSettings.setWaterOpacity(renderMan.scene().getWaterOpacity());
            PersistentSettings.setWaterVisibility(renderMan.scene().getWaterVisibility());
            PersistentSettings.setWaterHeight(renderMan.scene().getWaterHeight());
            boolean useCustomWaterColor = renderMan.scene().getUseCustomWaterColor();
            PersistentSettings.setUseCustomWaterColor(useCustomWaterColor);
            if (useCustomWaterColor) {
                Vector3d color = renderMan.scene().getWaterColor();
                PersistentSettings.setWaterColorRed(color.x);
                PersistentSettings.setWaterColorGreen(color.y);
                PersistentSettings.setWaterColorBlue(color.z);
            }
        }
    });

    stillWaterCB.setText("still water");
    stillWaterCB.addActionListener(stillWaterListener);
    updateStillWater();

    waterVisibility.update();
    waterOpacity.update();

    JLabel waterWorldLbl = new JLabel(
            "Note: All chunks will be reloaded after changing the water world options!");
    JLabel waterHeightLbl = new JLabel("Water height: ");
    waterHeightField.setColumns(5);
    waterHeightField.setText("" + World.SEA_LEVEL);
    waterHeightField.setEnabled(renderMan.scene().getWaterHeight() != 0);
    waterHeightField.addActionListener(waterHeightListener);

    applyWaterHeightBtn.setToolTipText("Use this water height");
    applyWaterHeightBtn.addActionListener(waterHeightListener);

    waterWorldCB.setText("Water World Mode");
    waterWorldCB.addActionListener(waterWorldListener);
    updateWaterHeight();

    waterColorCB.addActionListener(customWaterColorListener);
    updateWaterColor();

    waterColorBtn.setIcon(Icon.colors.imageIcon());
    waterColorBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            ColorPicker picker = new ColorPicker(waterColorBtn, renderMan.scene().getWaterColor());
            picker.addColorListener(new ColorListener() {
                @Override
                public void onColorPicked(Vector3d color) {
                    renderMan.scene().setWaterColor(color);
                }
            });
        }
    });

    JPanel panel = new JPanel();
    GroupLayout layout = new GroupLayout(panel);
    panel.setLayout(layout);
    layout.setHorizontalGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout
            .createParallelGroup().addComponent(stillWaterCB).addGroup(waterVisibility.horizontalGroup(layout))
            .addGroup(waterOpacity.horizontalGroup(layout)).addComponent(waterWorldLbl)
            .addComponent(waterWorldCB)
            .addGroup(layout.createSequentialGroup().addComponent(waterHeightLbl)
                    .addPreferredGap(ComponentPlacement.UNRELATED, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
                    .addComponent(waterHeightField, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(applyWaterHeightBtn))
            .addGroup(layout.createSequentialGroup().addComponent(waterColorCB)
                    .addPreferredGap(ComponentPlacement.UNRELATED, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
                    .addComponent(waterColorBtn))
            .addGroup(layout.createSequentialGroup()
                    .addPreferredGap(ComponentPlacement.UNRELATED, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
                    .addComponent(storeDefaultsBtn)))
            .addContainerGap());
    layout.setVerticalGroup(layout.createSequentialGroup().addContainerGap().addComponent(stillWaterCB)
            .addPreferredGap(ComponentPlacement.RELATED).addGroup(waterVisibility.verticalGroup(layout))
            .addPreferredGap(ComponentPlacement.RELATED).addGroup(waterOpacity.verticalGroup(layout))
            .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(waterWorldLbl)
            .addPreferredGap(ComponentPlacement.RELATED).addComponent(waterWorldCB)
            .addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(layout.createParallelGroup().addComponent(waterHeightLbl)
                    .addComponent(waterHeightField, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(applyWaterHeightBtn))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(layout.createParallelGroup().addComponent(waterColorCB).addComponent(waterColorBtn))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addPreferredGap(ComponentPlacement.UNRELATED, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
            .addComponent(storeDefaultsBtn).addContainerGap());
    return panel;
}

From source file:se.llbit.chunky.renderer.ui.RenderControls.java

private JPanel buildGeneralPane() {
    JLabel canvasSizeLbl = new JLabel("Canvas size:");
    JLabel canvasSizeAdvisory = new JLabel("Note: Actual image size may not be the same as the window size!");

    canvasSizeCB.setEditable(true);//ww w .j  ava  2  s .c o  m
    canvasSizeCB.addItem("400x400");
    canvasSizeCB.addItem("1024x768");
    canvasSizeCB.addItem("960x540");
    canvasSizeCB.addItem("1920x1080");
    canvasSizeCB.addActionListener(canvasSizeListener);
    final JTextField canvasSizeEditor = (JTextField) canvasSizeCB.getEditor().getEditorComponent();
    canvasSizeEditor.addFocusListener(new FocusListener() {
        @Override
        public void focusLost(FocusEvent e) {
        }

        @Override
        public void focusGained(FocusEvent e) {
            canvasSizeEditor.selectAll();
        }
    });

    updateCanvasSizeField();

    loadSceneBtn.setText("Load Scene");
    loadSceneBtn.setIcon(Icon.load.imageIcon());
    loadSceneBtn.addActionListener(loadSceneListener);

    JButton loadSelectedChunksBtn = new JButton("Load Selected Chunks");
    loadSelectedChunksBtn.setToolTipText("Load the chunks that are currently selected in the map view");
    loadSelectedChunksBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            sceneMan.loadChunks(chunky.getWorld(), chunky.getSelectedChunks());
        }
    });

    JButton reloadChunksBtn = new JButton("Reload Chunks");
    reloadChunksBtn.setIcon(Icon.reload.imageIcon());
    reloadChunksBtn.setToolTipText("Reload all chunks in the scene");
    reloadChunksBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            sceneMan.reloadChunks();
        }
    });

    openSceneDirBtn.setText("Open Scene Directory");
    openSceneDirBtn.setToolTipText("Open the directory where Chunky stores scene descriptions and renders");
    openSceneDirBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            try {
                if (Desktop.isDesktopSupported()) {
                    Desktop.getDesktop().open(context.getSceneDirectory());
                }
            } catch (IOException e) {
                Log.warn("Failed to open scene directory", e);
            }
        }
    });
    openSceneDirBtn.setVisible(Desktop.isDesktopSupported());

    loadSceneBtn.setToolTipText("This replaces the current scene!");
    JButton setCanvasSizeBtn = new JButton("Apply");
    setCanvasSizeBtn.setToolTipText("Set the canvas size to the value in the field");
    setCanvasSizeBtn.addActionListener(canvasSizeListener);

    JButton halveCanvasSizeBtn = new JButton("Halve");
    halveCanvasSizeBtn.setToolTipText("Halve the canvas width and height");
    halveCanvasSizeBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            int width = renderMan.scene().canvasWidth() / 2;
            int height = renderMan.scene().canvasHeight() / 2;
            setCanvasSize(width, height);
        }
    });
    JButton doubleCanvasSizeBtn = new JButton("Double");
    doubleCanvasSizeBtn.setToolTipText("Double the canvas width and height");
    doubleCanvasSizeBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            int width = renderMan.scene().canvasWidth() * 2;
            int height = renderMan.scene().canvasHeight() * 2;
            setCanvasSize(width, height);
        }
    });

    JButton makeDefaultBtn = new JButton("Make Default");
    makeDefaultBtn.setToolTipText("Make the current canvas size the default");
    makeDefaultBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            PersistentSettings.set3DCanvasSize(renderMan.scene().canvasWidth(),
                    renderMan.scene().canvasHeight());
        }
    });

    JSeparator sep1 = new JSeparator();
    JSeparator sep2 = new JSeparator();

    biomeColorsCB.setText("enable biome colors");
    updateBiomeColorsCB();

    saveDumpsCB.setText("save dump once every ");
    saveDumpsCB.addActionListener(saveDumpsListener);
    updateSaveDumpsCheckBox();

    String[] frequencyStrings = new String[dumpFrequencies.length];
    for (int i = 0; i < dumpFrequencies.length; ++i) {
        frequencyStrings[i] = Integer.toString(dumpFrequencies[i]);
    }
    dumpFrequencyCB.setModel(new DefaultComboBoxModel(frequencyStrings));
    dumpFrequencyCB.setEditable(true);
    dumpFrequencyCB.addActionListener(dumpFrequencyListener);
    updateDumpFrequencyField();

    saveSnapshotsCB.addActionListener(saveSnapshotListener);
    updateSaveSnapshotCheckBox();

    yCutoff.update();

    JPanel panel = new JPanel();
    GroupLayout layout = new GroupLayout(panel);
    panel.setLayout(layout);
    layout.setHorizontalGroup(layout.createSequentialGroup().addContainerGap()
            .addGroup(layout.createParallelGroup()
                    .addGroup(layout.createSequentialGroup().addComponent(loadSceneBtn)
                            .addPreferredGap(ComponentPlacement.RELATED).addComponent(openSceneDirBtn))
                    .addGroup(layout.createSequentialGroup().addComponent(loadSelectedChunksBtn)
                            .addPreferredGap(ComponentPlacement.RELATED).addComponent(reloadChunksBtn))
                    .addComponent(sep1)
                    .addGroup(layout.createSequentialGroup().addComponent(canvasSizeLbl)
                            .addPreferredGap(ComponentPlacement.RELATED)
                            .addComponent(canvasSizeCB, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(ComponentPlacement.RELATED).addComponent(setCanvasSizeBtn)
                            .addPreferredGap(ComponentPlacement.RELATED).addComponent(makeDefaultBtn))
                    .addGroup(layout.createSequentialGroup().addComponent(halveCanvasSizeBtn)
                            .addPreferredGap(ComponentPlacement.RELATED).addComponent(doubleCanvasSizeBtn))
                    .addComponent(canvasSizeAdvisory).addComponent(sep2).addComponent(biomeColorsCB)
                    .addGroup(layout.createSequentialGroup().addComponent(saveDumpsCB)
                            .addComponent(dumpFrequencyCB, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
                            .addComponent(dumpFrequencyLbl).addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(saveSnapshotsCB).addGroup(yCutoff.horizontalGroup(layout)))
            .addContainerGap());
    layout.setVerticalGroup(layout.createSequentialGroup().addContainerGap()
            .addGroup(layout.createParallelGroup().addComponent(loadSceneBtn).addComponent(openSceneDirBtn))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(layout
                    .createParallelGroup().addComponent(loadSelectedChunksBtn).addComponent(reloadChunksBtn))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addComponent(
                    sep1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(canvasSizeLbl)
                    .addComponent(canvasSizeCB, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(setCanvasSizeBtn).addComponent(makeDefaultBtn))
            .addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(layout.createParallelGroup().addComponent(halveCanvasSizeBtn)
                    .addComponent(doubleCanvasSizeBtn))
            .addPreferredGap(ComponentPlacement.RELATED).addComponent(canvasSizeAdvisory)
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addComponent(sep2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                    GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(biomeColorsCB)
            .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(saveDumpsCB)
                    .addComponent(dumpFrequencyCB).addComponent(dumpFrequencyLbl))
            .addComponent(saveSnapshotsCB).addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(yCutoff.verticalGroup(layout)).addContainerGap());
    return panel;
}

From source file:se.llbit.chunky.renderer.ui.RenderControls.java

private JPanel buildSkyPane() {

    JLabel skyModeLbl = new JLabel("Sky Mode:");
    skyModeCB.setModel(new DefaultComboBoxModel(Sky.SkyMode.values()));
    skyModeCB.addActionListener(skyModeListener);
    updateSkyMode();/*  w w  w.ja  va2s . c om*/

    JLabel skymapRotationLbl = new JLabel("Skymap rotation:");
    skymapRotationSlider.setMinimum(1);
    skymapRotationSlider.setMaximum(100);
    skymapRotationSlider.addChangeListener(skyRotationListener);
    skymapRotationSlider.setToolTipText("Controls the horizontal rotational offset for the skymap");
    JLabel lightProbeRotationLbl = new JLabel("Skymap rotation:");
    lightProbeRotationSlider.setMinimum(1);
    lightProbeRotationSlider.setMaximum(100);
    lightProbeRotationSlider.addChangeListener(skyRotationListener);
    lightProbeRotationSlider.setToolTipText("Controls the horizontal rotational offset for the skymap");
    JLabel skyboxRotationLbl = new JLabel("Skybox rotation:");
    skyboxRotationSlider.setMinimum(1);
    skyboxRotationSlider.setMaximum(100);
    skyboxRotationSlider.addChangeListener(skyRotationListener);
    skyboxRotationSlider.setToolTipText("Controls the horizontal rotational offset for the skymap");
    updateSkyRotation();

    skyHorizonOffset.update();
    cloudSize.update();
    cloudXOffset.update();
    cloudYOffset.update();
    cloudZOffset.update();

    JLabel verticalResolutionLbl = new JLabel("Vertical resolution (degrees):");
    ButtonGroup verticalResolution = new ButtonGroup();
    v90Btn.setSelected(true);
    v180Btn.setSelected(false);
    verticalResolution.add(v90Btn);
    verticalResolution.add(v180Btn);

    v90Btn.addActionListener(v90Listener);
    v180Btn.addActionListener(v180Listener);
    updateVerticalResolution();

    simulatedSkyPanel.setBorder(BorderFactory.createTitledBorder("Simulated Sky Settings"));
    GroupLayout simulatedSkyLayout = new GroupLayout(simulatedSkyPanel);
    simulatedSkyPanel.setLayout(simulatedSkyLayout);
    simulatedSkyLayout.setAutoCreateContainerGaps(true);
    simulatedSkyLayout.setAutoCreateGaps(true);
    simulatedSkyLayout.setHorizontalGroup(simulatedSkyLayout.createParallelGroup()
            .addGroup(skyHorizonOffset.horizontalGroup(simulatedSkyLayout)));
    simulatedSkyLayout.setVerticalGroup(simulatedSkyLayout.createSequentialGroup()
            .addGroup(skyHorizonOffset.verticalGroup(simulatedSkyLayout)));

    skymapPanel.setBorder(BorderFactory.createTitledBorder("Skymap Settings"));
    GroupLayout skymapLayout = new GroupLayout(skymapPanel);
    skymapPanel.setLayout(skymapLayout);
    skymapLayout.setAutoCreateContainerGaps(true);
    skymapLayout.setAutoCreateGaps(true);
    skymapLayout.setHorizontalGroup(skymapLayout.createParallelGroup().addComponent(loadSkymapBtn)
            .addGroup(skymapLayout.createSequentialGroup().addComponent(skymapRotationLbl)
                    .addComponent(skymapRotationSlider))
            .addGroup(skymapLayout.createSequentialGroup().addComponent(verticalResolutionLbl)
                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(v90Btn)
                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(v180Btn)));
    skymapLayout.setVerticalGroup(skymapLayout.createSequentialGroup().addComponent(loadSkymapBtn)
            .addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(skymapLayout.createParallelGroup(Alignment.BASELINE).addComponent(verticalResolutionLbl)
                    .addComponent(v90Btn).addComponent(v180Btn))
            .addPreferredGap(ComponentPlacement.RELATED).addGroup(skymapLayout.createParallelGroup()
                    .addComponent(skymapRotationLbl).addComponent(skymapRotationSlider)));

    loadSkymapBtn.setText("Load Skymap");
    loadSkymapBtn.setToolTipText("Use a panoramic skymap");
    loadSkymapBtn.addActionListener(new SkymapTextureLoader(renderMan));

    lightProbePanel.setBorder(BorderFactory.createTitledBorder("Spherical Skymap Settings"));
    GroupLayout lightProbeLayout = new GroupLayout(lightProbePanel);
    lightProbePanel.setLayout(lightProbeLayout);
    lightProbeLayout.setAutoCreateContainerGaps(true);
    lightProbeLayout.setAutoCreateGaps(true);
    lightProbeLayout.setHorizontalGroup(lightProbeLayout.createParallelGroup().addComponent(loadLightProbeBtn)
            .addGroup(lightProbeLayout.createSequentialGroup().addComponent(lightProbeRotationLbl)
                    .addComponent(lightProbeRotationSlider)));
    lightProbeLayout.setVerticalGroup(lightProbeLayout.createSequentialGroup().addComponent(loadLightProbeBtn)
            .addPreferredGap(ComponentPlacement.RELATED).addGroup(lightProbeLayout.createParallelGroup()
                    .addComponent(lightProbeRotationLbl).addComponent(lightProbeRotationSlider)));

    loadLightProbeBtn.setText("Load Spherical Skymap");
    loadLightProbeBtn.setToolTipText("Select the spherical skymap to use");
    loadLightProbeBtn.addActionListener(new SkymapTextureLoader(renderMan));

    skyGradientPanel.setBorder(BorderFactory.createTitledBorder("Sky Gradient"));
    gradientEditor = new GradientEditor();
    gradientEditor.addGradientListener(gradientListener);
    updateSkyGradient();
    skyGradientPanel.add(gradientEditor);

    GroupLayout skyboxLayout = new GroupLayout(skyboxPanel);
    skyboxPanel.setLayout(skyboxLayout);
    skyboxPanel.setBorder(BorderFactory.createTitledBorder("Skybox"));

    JLabel skyboxLbl = new JLabel("Load skybox textures:");

    JButton loadUpTexture = new JButton("Up");
    loadUpTexture.setToolTipText("Load up texture");
    loadUpTexture.setIcon(Icon.skyboxUp.imageIcon());
    loadUpTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_UP));

    JButton loadDownTexture = new JButton("Down");
    loadDownTexture.setToolTipText("Load down texture");
    loadDownTexture.setIcon(Icon.skyboxDown.imageIcon());
    loadDownTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_DOWN));

    JButton loadFrontTexture = new JButton("Front");
    loadFrontTexture.setToolTipText("Load front (north) texture");
    loadFrontTexture.setIcon(Icon.skyboxFront.imageIcon());
    loadFrontTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_FRONT));

    JButton loadBackTexture = new JButton("Back");
    loadBackTexture.setToolTipText("Load back (south) texture");
    loadBackTexture.setIcon(Icon.skyboxBack.imageIcon());
    loadBackTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_BACK));

    JButton loadRightTexture = new JButton("Right");
    loadRightTexture.setToolTipText("Load right (east) texture");
    loadRightTexture.setIcon(Icon.skyboxRight.imageIcon());
    loadRightTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_RIGHT));

    JButton loadLeftTexture = new JButton("Left");
    loadLeftTexture.setToolTipText("Load left (west) texture");
    loadLeftTexture.setIcon(Icon.skyboxLeft.imageIcon());
    loadLeftTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_LEFT));

    skyboxLayout.setAutoCreateContainerGaps(true);
    skyboxLayout.setAutoCreateGaps(true);
    skyboxLayout.setHorizontalGroup(skyboxLayout.createParallelGroup()
            .addGroup(skyboxLayout.createSequentialGroup().addComponent(skyboxLbl)
                    .addGroup(skyboxLayout.createParallelGroup().addComponent(loadUpTexture)
                            .addComponent(loadFrontTexture).addComponent(loadRightTexture))
                    .addGroup(skyboxLayout.createParallelGroup().addComponent(loadDownTexture)
                            .addComponent(loadBackTexture).addComponent(loadLeftTexture)))
            .addGroup(skyboxLayout.createSequentialGroup().addComponent(skyboxRotationLbl)
                    .addComponent(skyboxRotationSlider)));
    skyboxLayout.setVerticalGroup(skyboxLayout.createSequentialGroup().addComponent(skyboxLbl)
            .addGroup(skyboxLayout.createParallelGroup().addComponent(loadUpTexture)
                    .addComponent(loadDownTexture))
            .addGroup(skyboxLayout.createParallelGroup().addComponent(loadFrontTexture)
                    .addComponent(loadBackTexture))
            .addGroup(skyboxLayout.createParallelGroup().addComponent(loadRightTexture)
                    .addComponent(loadLeftTexture))
            .addGroup(skyboxLayout.createParallelGroup().addComponent(skyboxRotationLbl)
                    .addComponent(skyboxRotationSlider)));

    atmosphereEnabled.setText("enable atmosphere");
    atmosphereEnabled.addActionListener(atmosphereListener);
    updateAtmosphereCheckBox();

    transparentSky.setText("transparent sky");
    transparentSky.addActionListener(transparentSkyListener);
    updateTransparentSky();

    volumetricFogEnabled.setText("enable volumetric fog");
    volumetricFogEnabled.addActionListener(volumetricFogListener);
    updateVolumetricFogCheckBox();

    cloudsEnabled.setText("enable clouds");
    cloudsEnabled.addActionListener(cloudsEnabledListener);
    updateCloudsEnabledCheckBox();

    JPanel panel = new JPanel();
    GroupLayout layout = new GroupLayout(panel);
    panel.setLayout(layout);
    layout.setHorizontalGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout
            .createParallelGroup()
            .addGroup(layout.createSequentialGroup().addComponent(skyModeLbl)
                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(skyModeCB,
                            GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
            .addComponent(simulatedSkyPanel).addComponent(skymapPanel).addComponent(lightProbePanel)
            .addComponent(skyGradientPanel).addComponent(skyboxPanel).addComponent(atmosphereEnabled)
            .addComponent(transparentSky).addComponent(volumetricFogEnabled).addComponent(cloudsEnabled)
            .addGroup(cloudSize.horizontalGroup(layout)).addGroup(cloudXOffset.horizontalGroup(layout))
            .addGroup(cloudYOffset.horizontalGroup(layout)).addGroup(cloudZOffset.horizontalGroup(layout)))
            .addContainerGap());
    layout.setVerticalGroup(layout.createSequentialGroup().addContainerGap()
            .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(skyModeLbl)
                    .addComponent(skyModeCB))
            .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(simulatedSkyPanel)
            .addComponent(skymapPanel).addComponent(lightProbePanel).addComponent(skyGradientPanel)
            .addComponent(skyboxPanel).addPreferredGap(ComponentPlacement.UNRELATED)
            .addComponent(atmosphereEnabled).addPreferredGap(ComponentPlacement.UNRELATED)
            .addComponent(transparentSky).addPreferredGap(ComponentPlacement.UNRELATED)
            .addComponent(volumetricFogEnabled).addPreferredGap(ComponentPlacement.UNRELATED)
            .addComponent(cloudsEnabled).addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(cloudSize.verticalGroup(layout)).addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(cloudXOffset.verticalGroup(layout)).addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(cloudYOffset.verticalGroup(layout)).addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(cloudZOffset.verticalGroup(layout)).addContainerGap());
    return panel;
}

From source file:se.llbit.chunky.renderer.ui.RenderControls.java

private JPanel buildCameraPane() {
    JLabel projectionModeLbl = new JLabel("Projection");

    fov.update();/*from ww  w .  j  a  v a 2  s .c  o m*/

    dof = new DoFAdjuster(renderMan);
    dof.update();

    subjectDistance.update();

    JLabel presetLbl = new JLabel("Preset:");
    CameraPreset[] presets = { CameraPreset.NONE, CameraPreset.ISO_WEST_NORTH, CameraPreset.ISO_NORTH_EAST,
            CameraPreset.ISO_EAST_SOUTH, CameraPreset.ISO_SOUTH_WEST, CameraPreset.SKYBOX_RIGHT,
            CameraPreset.SKYBOX_LEFT, CameraPreset.SKYBOX_UP, CameraPreset.SKYBOX_DOWN,
            CameraPreset.SKYBOX_FRONT, CameraPreset.SKYBOX_BACK, };
    cameraPreset.setModel(new DefaultComboBoxModel(presets));
    cameraPreset.setMaximumRowCount(presets.length);
    final int presetHeight = cameraPreset.getPreferredSize().height;
    final int presetWidth = cameraPreset.getPreferredSize().width;
    cameraPreset.setRenderer(new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
                boolean cellHasFocus) {
            JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected,
                    cellHasFocus);
            label.setPreferredSize(new Dimension(presetWidth, presetHeight));
            CameraPreset preset = (CameraPreset) value;
            label.setIcon(preset.getIcon());
            return label;
        }
    });
    cameraPreset.addActionListener(cameraPresetListener);

    JLabel customPresetLbl = new JLabel("Custom preset:");
    customPreset.setEditable(true);
    updateCustomPresets();
    JButton savePreset = new JButton("save");
    savePreset.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            String name = "";
            int selected = customPreset.getSelectedIndex();
            if (selected == -1) {
                // select name
                name = (String) customPreset.getEditor().getItem();
                name = (name == null) ? "" : name.trim();
                if (name.isEmpty()) {
                    // auto-assign name
                    int nextIndex = customPreset.getItemCount() + 1;
                    outer: while (true) {
                        name = "custom-" + (nextIndex++);
                        for (int i = 0; i < customPreset.getItemCount(); ++i) {
                            String item = (String) customPreset.getItemAt(i);
                            if (name.equals(item)) {
                                continue outer;
                            }
                        }
                        break;
                    }
                } else {
                    for (int i = 0; i < customPreset.getItemCount(); ++i) {
                        String item = (String) customPreset.getItemAt(i);
                        if (name.equals(item)) {
                            selected = i;
                            break;
                        }
                    }
                }
                if (selected == -1) {
                    // add new preset
                    selected = customPreset.getItemCount();
                    customPreset.addItem(name);

                }
                customPreset.setSelectedIndex(selected);
            } else {
                name = (String) customPreset.getSelectedItem();
            }
            renderMan.scene().saveCameraPreset(name);
        }
    });
    JButton loadPreset = new JButton("load");
    loadPreset.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            String name = "";
            int selected = customPreset.getSelectedIndex();
            if (selected == -1) {
                // select name
                name = (String) customPreset.getEditor().getItem();
                name = (name == null) ? "" : name.trim();
            } else {
                name = ((String) customPreset.getSelectedItem()).trim();
            }
            if (!name.isEmpty()) {
                renderMan.scene().loadCameraPreset(name);
            }
        }
    });
    JButton deletePreset = new JButton("delete");
    deletePreset.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            String name = "";
            int selected = customPreset.getSelectedIndex();
            if (selected == -1) {
                // select name
                name = (String) customPreset.getEditor().getItem();
                name = (name == null) ? "" : name.trim();
            } else {
                name = ((String) customPreset.getSelectedItem()).trim();
            }
            if (!name.isEmpty()) {
                renderMan.scene().deleteCameraPreset(name);
                if (selected != -1) {
                    customPreset.removeItemAt(selected);
                } else {
                    for (int i = 0; i < customPreset.getItemCount(); ++i) {
                        if (name.equals(customPreset.getItemAt(i))) {
                            customPreset.removeItemAt(i);
                            break;
                        }
                    }
                }
            }
        }
    });

    ProjectionMode[] projectionModes = ProjectionMode.values();
    projectionMode.setModel(new DefaultComboBoxModel(projectionModes));
    projectionMode.addActionListener(projectionModeListener);
    updateProjectionMode();

    JButton autoFocusBtn = new JButton("Autofocus");
    autoFocusBtn.setToolTipText("Focuses on the object right in the center, under the crosshairs");
    autoFocusBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            renderMan.scene().autoFocus();
            dof.update();
            subjectDistance.update();
        }
    });

    JButton cameraToPlayerBtn = new JButton("Camera to player");
    cameraToPlayerBtn.setToolTipText("Move camera to player position");
    cameraToPlayerBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            renderMan.scene().moveCameraToPlayer();
        }
    });

    JLabel posLbl = new JLabel("Position:");
    cameraX.setColumns(10);
    cameraX.setHorizontalAlignment(JTextField.RIGHT);
    cameraX.addActionListener(cameraPositionListener);
    cameraY.setColumns(10);
    cameraY.setHorizontalAlignment(JTextField.RIGHT);
    cameraY.addActionListener(cameraPositionListener);
    cameraZ.setColumns(10);
    cameraZ.setHorizontalAlignment(JTextField.RIGHT);
    cameraZ.addActionListener(cameraPositionListener);
    updateCameraPosition();

    JLabel dirLbl = new JLabel("Direction:");
    cameraYaw.setColumns(10);
    cameraYaw.setHorizontalAlignment(JTextField.RIGHT);
    cameraYaw.addActionListener(cameraDirectionListener);
    cameraPitch.setColumns(10);
    cameraPitch.setHorizontalAlignment(JTextField.RIGHT);
    cameraPitch.addActionListener(cameraDirectionListener);
    cameraRoll.setColumns(10);
    cameraRoll.setHorizontalAlignment(JTextField.RIGHT);
    cameraRoll.addActionListener(cameraDirectionListener);
    updateCameraDirection();

    JButton centerCameraBtn = new JButton("Center camera");
    centerCameraBtn.setToolTipText("Center camera above loaded chunks");
    centerCameraBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            renderMan.scene().moveCameraToCenter();
        }
    });

    JSeparator sep1 = new JSeparator();

    JPanel panel = new JPanel();
    GroupLayout layout = new GroupLayout(panel);
    panel.setLayout(layout);
    layout.setHorizontalGroup(
            layout.createSequentialGroup().addContainerGap()
                    .addGroup(layout.createParallelGroup().addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup().addComponent(posLbl).addComponent(dirLbl))
                            .addPreferredGap(ComponentPlacement.RELATED)
                            .addGroup(layout.createParallelGroup()
                                    .addComponent(cameraX, GroupLayout.PREFERRED_SIZE,
                                            GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
                                    .addComponent(cameraYaw, GroupLayout.PREFERRED_SIZE,
                                            GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(ComponentPlacement.RELATED)
                            .addGroup(layout.createParallelGroup()
                                    .addComponent(cameraY, GroupLayout.PREFERRED_SIZE,
                                            GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
                                    .addComponent(cameraPitch, GroupLayout.PREFERRED_SIZE,
                                            GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(ComponentPlacement.RELATED)
                            .addGroup(layout.createParallelGroup()
                                    .addComponent(cameraZ, GroupLayout.PREFERRED_SIZE,
                                            GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
                                    .addComponent(cameraRoll, GroupLayout.PREFERRED_SIZE,
                                            GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)))
                            .addGroup(layout.createSequentialGroup().addComponent(presetLbl)
                                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(cameraPreset))
                            .addGroup(layout.createSequentialGroup().addComponent(customPresetLbl)
                                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(customPreset)
                                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(savePreset)
                                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(loadPreset)
                                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(deletePreset))
                            .addGroup(layout.createSequentialGroup().addComponent(cameraToPlayerBtn)
                                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(centerCameraBtn))
                            .addComponent(sep1)
                            .addGroup(layout.createSequentialGroup()
                                    .addGroup(layout.createParallelGroup().addComponent(projectionModeLbl)
                                            .addComponent(fov.getLabel()).addComponent(dof.getLabel())
                                            .addComponent(subjectDistance.getLabel()))
                                    .addGroup(layout.createParallelGroup().addComponent(projectionMode)
                                            .addComponent(fov.getSlider()).addComponent(dof.getSlider())
                                            .addComponent(subjectDistance.getSlider()))
                                    .addGroup(layout.createParallelGroup().addComponent(fov.getField())
                                            .addComponent(dof.getField())
                                            .addComponent(subjectDistance.getField())))
                            .addComponent(autoFocusBtn))
                    .addContainerGap());
    layout.setVerticalGroup(layout.createSequentialGroup().addContainerGap()
            .addGroup(layout
                    .createParallelGroup(Alignment.BASELINE).addComponent(presetLbl).addComponent(cameraPreset))
            .addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(customPresetLbl)
                    .addComponent(customPreset).addComponent(savePreset).addComponent(loadPreset)
                    .addComponent(deletePreset))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(posLbl).addComponent(cameraX)
                    .addComponent(cameraY).addComponent(cameraZ))
            .addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(dirLbl)
                    .addComponent(cameraYaw).addComponent(cameraPitch).addComponent(cameraRoll))
            .addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(
                    layout.createParallelGroup().addComponent(cameraToPlayerBtn).addComponent(centerCameraBtn))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addComponent(
                    sep1, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(projectionModeLbl)
                    .addComponent(projectionMode))
            .addPreferredGap(ComponentPlacement.RELATED).addGroup(fov.verticalGroup(layout))
            .addGroup(dof.verticalGroup(layout)).addGroup(subjectDistance.verticalGroup(layout))
            .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(autoFocusBtn).addContainerGap());
    return panel;
}

From source file:se.llbit.chunky.renderer.ui.tabs.SkyTab.java

public SkyTab(RenderControls renderControls) {
    super(renderControls);

    JLabel skyModeLbl = new JLabel("Sky Mode:");
    skyModeCB.setModel(new DefaultComboBoxModel(Sky.SkyMode.values()));
    skyModeCB.addActionListener(skyModeListener);

    // Need to hide these to not warp the Swing layout:
    simulatedSkyPanel.setVisible(false);
    skymapPanel.setVisible(false);/*from   www  .  j a  v a2 s  .c  o  m*/
    lightProbePanel.setVisible(false);
    skyGradientPanel.setVisible(false);
    skyboxPanel.setVisible(false);

    JLabel skymapRotationLbl = new JLabel("Skymap rotation:");
    skymapRotationSlider.setMinimum(1);
    skymapRotationSlider.setMaximum(100);
    skymapRotationSlider.addChangeListener(skyRotationListener);
    skymapRotationSlider.setToolTipText("Controls the horizontal rotational offset for the skymap");
    JLabel lightProbeRotationLbl = new JLabel("Skymap rotation:");
    lightProbeRotationSlider.setMinimum(1);
    lightProbeRotationSlider.setMaximum(100);
    lightProbeRotationSlider.addChangeListener(skyRotationListener);
    lightProbeRotationSlider.setToolTipText("Controls the horizontal rotational offset for the skymap");
    JLabel skyboxRotationLbl = new JLabel("Skybox rotation:");
    skyboxRotationSlider.setMinimum(1);
    skyboxRotationSlider.setMaximum(100);
    skyboxRotationSlider.addChangeListener(skyRotationListener);
    skyboxRotationSlider.setToolTipText("Controls the horizontal rotational offset for the skymap");

    JLabel verticalResolutionLbl = new JLabel("Vertical resolution (degrees):");
    ButtonGroup verticalResolution = new ButtonGroup();
    v90Btn.setSelected(true);
    v180Btn.setSelected(false);
    verticalResolution.add(v90Btn);
    verticalResolution.add(v180Btn);

    v90Btn.addActionListener(v90Listener);
    v180Btn.addActionListener(v180Listener);

    simulatedSkyPanel.setBorder(BorderFactory.createTitledBorder("Simulated Sky Settings"));
    GroupLayout simulatedSkyLayout = new GroupLayout(simulatedSkyPanel);
    simulatedSkyPanel.setLayout(simulatedSkyLayout);
    simulatedSkyLayout.setAutoCreateContainerGaps(true);
    simulatedSkyLayout.setAutoCreateGaps(true);
    simulatedSkyLayout.setHorizontalGroup(simulatedSkyLayout.createParallelGroup()
            .addGroup(skyHorizonOffset.horizontalGroup(simulatedSkyLayout)));
    simulatedSkyLayout.setVerticalGroup(simulatedSkyLayout.createSequentialGroup()
            .addGroup(skyHorizonOffset.verticalGroup(simulatedSkyLayout)));

    skymapPanel.setBorder(BorderFactory.createTitledBorder("Skymap Settings"));
    GroupLayout skymapLayout = new GroupLayout(skymapPanel);
    skymapPanel.setLayout(skymapLayout);
    skymapLayout.setAutoCreateContainerGaps(true);
    skymapLayout.setAutoCreateGaps(true);
    skymapLayout.setHorizontalGroup(skymapLayout.createParallelGroup().addComponent(loadSkymapBtn)
            .addGroup(skymapLayout.createSequentialGroup().addComponent(skymapRotationLbl)
                    .addComponent(skymapRotationSlider))
            .addGroup(skymapLayout.createSequentialGroup().addComponent(verticalResolutionLbl)
                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(v90Btn)
                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(v180Btn)));
    skymapLayout.setVerticalGroup(skymapLayout.createSequentialGroup().addComponent(loadSkymapBtn)
            .addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(skymapLayout.createParallelGroup(Alignment.BASELINE).addComponent(verticalResolutionLbl)
                    .addComponent(v90Btn).addComponent(v180Btn))
            .addPreferredGap(ComponentPlacement.RELATED).addGroup(skymapLayout.createParallelGroup()
                    .addComponent(skymapRotationLbl).addComponent(skymapRotationSlider)));

    loadSkymapBtn.setText("Load Skymap");
    loadSkymapBtn.setToolTipText("Use a panoramic skymap");
    loadSkymapBtn.addActionListener(new SkymapTextureLoader(renderMan));

    lightProbePanel.setBorder(BorderFactory.createTitledBorder("Spherical Skymap Settings"));
    GroupLayout lightProbeLayout = new GroupLayout(lightProbePanel);
    lightProbePanel.setLayout(lightProbeLayout);
    lightProbeLayout.setAutoCreateContainerGaps(true);
    lightProbeLayout.setAutoCreateGaps(true);
    lightProbeLayout.setHorizontalGroup(lightProbeLayout.createParallelGroup().addComponent(loadLightProbeBtn)
            .addGroup(lightProbeLayout.createSequentialGroup().addComponent(lightProbeRotationLbl)
                    .addComponent(lightProbeRotationSlider)));
    lightProbeLayout.setVerticalGroup(lightProbeLayout.createSequentialGroup().addComponent(loadLightProbeBtn)
            .addPreferredGap(ComponentPlacement.RELATED).addGroup(lightProbeLayout.createParallelGroup()
                    .addComponent(lightProbeRotationLbl).addComponent(lightProbeRotationSlider)));

    loadLightProbeBtn.setText("Load Spherical Skymap");
    loadLightProbeBtn.setToolTipText("Select the spherical skymap to use");
    loadLightProbeBtn.addActionListener(new SkymapTextureLoader(renderMan));

    skyGradientPanel.setBorder(BorderFactory.createTitledBorder("Sky Gradient"));
    gradientEditor = new GradientEditor();
    gradientEditor.addGradientListener(gradientListener);
    skyGradientPanel.add(gradientEditor);

    GroupLayout skyboxLayout = new GroupLayout(skyboxPanel);
    skyboxPanel.setLayout(skyboxLayout);
    skyboxPanel.setBorder(BorderFactory.createTitledBorder("Skybox"));

    JLabel skyboxLbl = new JLabel("Load skybox textures:");

    JButton loadUpTexture = new JButton("Up");
    loadUpTexture.setToolTipText("Load up texture");
    loadUpTexture.setIcon(Icon.skyboxUp.imageIcon());
    loadUpTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_UP));

    JButton loadDownTexture = new JButton("Down");
    loadDownTexture.setToolTipText("Load down texture");
    loadDownTexture.setIcon(Icon.skyboxDown.imageIcon());
    loadDownTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_DOWN));

    JButton loadFrontTexture = new JButton("Front");
    loadFrontTexture.setToolTipText("Load front (north) texture");
    loadFrontTexture.setIcon(Icon.skyboxFront.imageIcon());
    loadFrontTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_FRONT));

    JButton loadBackTexture = new JButton("Back");
    loadBackTexture.setToolTipText("Load back (south) texture");
    loadBackTexture.setIcon(Icon.skyboxBack.imageIcon());
    loadBackTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_BACK));

    JButton loadRightTexture = new JButton("Right");
    loadRightTexture.setToolTipText("Load right (east) texture");
    loadRightTexture.setIcon(Icon.skyboxRight.imageIcon());
    loadRightTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_RIGHT));

    JButton loadLeftTexture = new JButton("Left");
    loadLeftTexture.setToolTipText("Load left (west) texture");
    loadLeftTexture.setIcon(Icon.skyboxLeft.imageIcon());
    loadLeftTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_LEFT));

    skyboxLayout.setAutoCreateContainerGaps(true);
    skyboxLayout.setAutoCreateGaps(true);
    skyboxLayout.setHorizontalGroup(skyboxLayout.createParallelGroup()
            .addGroup(skyboxLayout.createSequentialGroup().addComponent(skyboxLbl)
                    .addGroup(skyboxLayout.createParallelGroup().addComponent(loadUpTexture)
                            .addComponent(loadFrontTexture).addComponent(loadRightTexture))
                    .addGroup(skyboxLayout.createParallelGroup().addComponent(loadDownTexture)
                            .addComponent(loadBackTexture).addComponent(loadLeftTexture)))
            .addGroup(skyboxLayout.createSequentialGroup().addComponent(skyboxRotationLbl)
                    .addComponent(skyboxRotationSlider)));
    skyboxLayout.setVerticalGroup(skyboxLayout.createSequentialGroup().addComponent(skyboxLbl)
            .addGroup(skyboxLayout.createParallelGroup().addComponent(loadUpTexture)
                    .addComponent(loadDownTexture))
            .addGroup(skyboxLayout.createParallelGroup().addComponent(loadFrontTexture)
                    .addComponent(loadBackTexture))
            .addGroup(skyboxLayout.createParallelGroup().addComponent(loadRightTexture)
                    .addComponent(loadLeftTexture))
            .addGroup(skyboxLayout.createParallelGroup().addComponent(skyboxRotationLbl)
                    .addComponent(skyboxRotationSlider)));

    transparentSky.setText("transparent sky");
    transparentSky.setToolTipText("Disables rendering the skybox");
    transparentSky.addActionListener(transparentSkyListener);

    JLabel fogColorLbl = new JLabel(
            "<html>Hint: set fog density &gt; 0.1 for thick fog,<br>set it &lt; 0.1 for haze/atmosphere effect");
    fogColorBtn.setIcon(Icon.colors.imageIcon());
    fogColorBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            ColorPicker picker = new ColorPicker(fogColorBtn, renderMan.scene().getFogColor());
            picker.addColorListener(new ColorListener() {
                @Override
                public void onColorPicked(Vector3d color) {
                    renderMan.scene().setFogColor(color);
                }
            });
        }
    });

    cloudsEnabled.setText("enable clouds");
    cloudsEnabled.addActionListener(cloudsEnabledListener);

    GroupLayout layout = new GroupLayout(this);
    setLayout(layout);
    layout.setHorizontalGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout
            .createParallelGroup()
            .addGroup(layout.createSequentialGroup().addComponent(skyModeLbl)
                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(skyModeCB,
                            GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
            .addComponent(simulatedSkyPanel).addComponent(skymapPanel).addComponent(lightProbePanel)
            .addComponent(skyGradientPanel).addComponent(skyboxPanel).addComponent(transparentSky)
            .addComponent(cloudsEnabled).addGroup(cloudSize.horizontalGroup(layout))
            .addGroup(cloudXOffset.horizontalGroup(layout)).addGroup(cloudYOffset.horizontalGroup(layout))
            .addGroup(cloudZOffset.horizontalGroup(layout)).addGroup(fogDensity.horizontalGroup(layout))
            .addGroup(layout.createSequentialGroup().addComponent(fogColorBtn)
                    .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(fogColorLbl)))
            .addContainerGap());
    layout.setVerticalGroup(layout.createSequentialGroup().addContainerGap()
            .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(skyModeLbl)
                    .addComponent(skyModeCB))
            .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(simulatedSkyPanel)
            .addComponent(skymapPanel).addComponent(lightProbePanel).addComponent(skyGradientPanel)
            .addComponent(skyboxPanel).addPreferredGap(ComponentPlacement.UNRELATED)
            .addComponent(transparentSky).addPreferredGap(ComponentPlacement.UNRELATED)
            .addComponent(cloudsEnabled).addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(cloudSize.verticalGroup(layout)).addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(cloudXOffset.verticalGroup(layout)).addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(cloudYOffset.verticalGroup(layout)).addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(cloudZOffset.verticalGroup(layout)).addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(fogDensity.verticalGroup(layout)).addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(layout.createParallelGroup().addComponent(fogColorBtn).addComponent(fogColorLbl))
            .addContainerGap());
}

From source file:shuffle.fwk.service.roster.EditRosterService.java

private Component makeUpperPanel() {
    JPanel ret = new JPanel(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;//w w w  .  j  a v  a  2  s . c  o  m
    c.weighty = 0.0;
    c.gridx = 1;
    c.gridy = 1;
    c.gridwidth = 1;
    c.gridheight = 1;

    c.gridx += 1;
    c.weightx = 0.0;
    JPanel typePanel = new JPanel();
    typePanel.add(new JLabel(getString(KEY_TYPE)));
    typeChooser = new TypeChooser(true);
    typePanel.add(typeChooser);
    typePanel.setToolTipText(getString(KEY_TYPE_TOOLTIP));
    typeChooser.setToolTipText(getString(KEY_TYPE_TOOLTIP));
    ret.add(typePanel, c);

    c.gridx += 1;
    c.weightx = 0.0;
    JPanel levelPanel = new JPanel();
    levelPanel.add(new JLabel(getString(KEY_LEVEL)));
    SpinnerNumberModel snm = new SpinnerNumberModel(0, 0, Species.MAX_LEVEL, 1);
    levelSpinner = new JSpinner(snm);
    levelPanel.add(levelSpinner);
    levelPanel.setToolTipText(getString(KEY_LEVEL_TOOLTIP));
    levelSpinner.setToolTipText(getString(KEY_LEVEL_TOOLTIP));
    JButton applyAllButton = new JButton(getString(KEY_SET_FOR_ALL));
    applyAllButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            applyLevelToAll();
        }
    });
    applyAllButton.setToolTipText(getString(KEY_SET_FOR_ALL_TOOLTIP));
    levelPanel.add(applyAllButton);
    ret.add(levelPanel, c);

    c.gridx += 1;
    c.weightx = 1.0;
    JPanel stringPanel = new JPanel(new GridBagLayout());
    GridBagConstraints sc = new GridBagConstraints();
    sc.fill = GridBagConstraints.HORIZONTAL;
    sc.gridx = 1;
    stringPanel.add(new JLabel(getString(KEY_NAME)), sc);
    textField = new JTextField();
    sc.gridx += 1;
    sc.weightx = 1.0;
    sc.insets = new Insets(0, 5, 0, 5);
    stringPanel.add(textField, sc);
    stringPanel.setToolTipText(getString(KEY_NAME_TOOLTIP));
    textField.setToolTipText(getString(KEY_NAME_TOOLTIP));
    ret.add(stringPanel, c);

    c.gridx += 1;
    c.weightx = 0.0;
    megaFilter = new JCheckBox(getString(KEY_MEGA_FILTER));
    megaFilter.setToolTipText(getString(KEY_MEGA_FILTER_TOOLTIP));
    ret.add(megaFilter, c);

    c.gridx += 1;
    c.weightx = 0.0;
    effectFilter = new EffectChooser(false, EffectChooser.DefaultEntry.NO_FILTER);
    effectFilter.setToolTipText(getString(KEY_EFFECT_FILTER_TOOLTIP));
    ret.add(effectFilter, c);

    getMinUpperPanel = new Supplier<Dimension>() {

        @Override
        public Dimension get() {
            Dimension ret = new Dimension(10 + 50, 0);
            for (Component c : new Component[] { typePanel, levelPanel, stringPanel, megaFilter,
                    effectFilter }) {
                Dimension temp = c.getPreferredSize();
                int width = temp.width + ret.width;
                int height = Math.max(temp.height, ret.height);
                ret.setSize(width, height);
            }
            return ret;
        }
    };

    return ret;
}

From source file:shuffle.fwk.service.roster.EditRosterService.java

private Component makeBottomPanel() {
    JPanel ret = new JPanel(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.NONE;
    c.insets = new Insets(0, 10, 0, 10);
    c.weightx = 1.0;/*from  ww w . j  a  v  a  2s. c  o  m*/
    c.weighty = 0.0;
    c.gridx = 1;
    c.gridy = 1;
    c.gridwidth = 1;
    c.gridheight = 1;

    c.anchor = GridBagConstraints.LINE_START;
    c.weightx = 0.0;
    c.gridx++;
    selectedDisplayLabel = new JLabel(getString(KEY_NONE_SELECTED));
    selectedDisplayLabel.setToolTipText(getString(KEY_SELECTED_TOOLTIP));
    ;
    ret.add(selectedDisplayLabel, c);
    c.insets = new Insets(0, 0, 0, 0);

    c.anchor = GridBagConstraints.LINE_END;
    c.weightx = 1.0;
    c.gridx++;
    teamFilter = new JCheckBox(getString(KEY_TEAM));
    JPanel teamFilterPanel = new JPanel(new BorderLayout());
    teamFilterPanel.add(teamFilter, BorderLayout.WEST);
    teamFilter.setToolTipText(getString(KEY_TEAM_TOOLTIP));
    ret.add(teamFilterPanel, c);

    c.anchor = GridBagConstraints.LINE_END;
    c.weightx = 0.0;
    c.gridx++;
    activeEffect = new EffectChooser(false, EffectChooser.DefaultEntry.SPECIES);
    JPanel activeEffectPanel = new JPanel(new BorderLayout());
    activeEffectPanel.add(activeEffect, BorderLayout.WEST);
    activeEffect.setToolTipText(getString(KEY_ACTIVE_EFFECT));
    ret.add(activeEffectPanel, c);

    c.anchor = GridBagConstraints.LINE_END;
    c.weightx = 0.0;
    c.gridx++;
    JPanel skillPanel = new JPanel(new BorderLayout());
    ImageIcon skillBoosterIcon = getUser().getImageManager().getImageFor(KEY_SKILL_BOOSTER);
    JLabel skillBoosterLabel = new JLabel(skillBoosterIcon);
    skillPanel.add(skillBoosterLabel, BorderLayout.EAST);
    skillLevels = new JComboBox<Integer>();
    skillLevels.setEnabled(false);
    skillLevels.addItem(1);
    skillPanel.add(skillLevels, BorderLayout.WEST);
    skillPanel.setToolTipText(getString(KEY_SKILL_BOOSTER_TOOLTIP));
    skillLevels.setToolTipText(getString(KEY_SKILL_BOOSTER_TOOLTIP));
    ret.add(skillPanel, c);

    c.anchor = GridBagConstraints.LINE_END;
    c.weightx = 0.0;
    c.gridx++;
    JPanel speedupPanel = new JPanel(new BorderLayout());
    ImageIcon candyIcon = getUser().getImageManager().getImageFor(KEY_CANDY_ICON);
    JLabel candyLabel = new JLabel(candyIcon);
    speedupPanel.add(candyLabel, BorderLayout.EAST);
    speedups = new JComboBox<Integer>();
    speedups.setEnabled(false);
    speedups.addItem(0);
    speedupPanel.add(speedups, BorderLayout.WEST);
    speedupPanel.setToolTipText(getString(KEY_CANDY_TOOLTIP));
    speedups.setToolTipText(getString(KEY_CANDY_TOOLTIP));
    ret.add(speedupPanel, c);

    c.anchor = GridBagConstraints.LINE_END;
    c.weightx = 0.0;
    c.gridx++;
    JButton okButton = new JButton(getString(KEY_OK));
    okButton.setToolTipText(getString(KEY_OK_TOOLTIP));
    ret.add(okButton, c);
    setDefaultButton(okButton);

    c.anchor = GridBagConstraints.CENTER;
    c.weightx = 0.0;
    c.gridx++;
    JButton applyButton = new JButton(getString(KEY_APPLY));
    applyButton.setToolTipText(getString(KEY_APPLY_TOOLTIP));
    ret.add(applyButton, c);

    c.anchor = GridBagConstraints.LINE_START;
    c.weightx = 0.0;
    c.gridx++;
    JButton cancelButton = new JButton(new DisposeAction(getString(KEY_CANCEL), this));
    cancelButton.setToolTipText(getString(KEY_CANCEL_TOOLTIP));
    ret.add(cancelButton, c);

    okButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            onOK();
        }
    });
    applyButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            onApply();
        }
    });
    addSpeedupsListener();
    return ret;
}