Search in sources :

Example 1 with ControllerType

use of com.badlogic.gdx.tools.flame.FlameMain.ControllerType in project libgdx by libgdx.

the class EffectPanel method initializeComponents.

private void initializeComponents() {
    setLayout(new GridBagLayout());
    {
        JScrollPane scroll = new JScrollPane();
        add(scroll, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 6), 0, 0));
        {
            emitterTable = new JTable() {

                public Class getColumnClass(int column) {
                    return column == 1 ? Boolean.class : super.getColumnClass(column);
                }

                @Override
                public Dimension getPreferredScrollableViewportSize() {
                    Dimension dim = super.getPreferredScrollableViewportSize();
                    dim.height = getPreferredSize().height;
                    return dim;
                }
            };
            emitterTable.getTableHeader().setReorderingAllowed(false);
            emitterTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            scroll.setViewportView(emitterTable);
            emitterTableModel = new DefaultTableModel(new String[0][0], new String[] { "Emitter", "" });
            emitterTable.setModel(emitterTableModel);
            emitterTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

                public void valueChanged(ListSelectionEvent event) {
                    if (event.getValueIsAdjusting())
                        return;
                    emitterSelected();
                }
            });
            emitterTableModel.addTableModelListener(new TableModelListener() {

                public void tableChanged(TableModelEvent event) {
                    if (event.getColumn() != 1)
                        return;
                    emitterChecked(event.getFirstRow(), (Boolean) emitterTable.getValueAt(event.getFirstRow(), 1));
                }
            });
        }
    }
    {
        JPanel sideButtons = new JPanel(new GridBagLayout());
        add(sideButtons, new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
        {
            controllerTypeCombo = new JComboBox();
            controllerTypeCombo.setModel(new DefaultComboBoxModel(ControllerType.values()));
            sideButtons.add(controllerTypeCombo, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
        }
        {
            JButton newButton = new JButton("New");
            sideButtons.add(newButton, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
            newButton.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent event) {
                    ControllerType item = (ControllerType) controllerTypeCombo.getSelectedItem();
                    createDefaultEmitter(item, true, true);
                }
            });
        }
        {
            JButton deleteButton = new JButton("Delete");
            sideButtons.add(deleteButton, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
            deleteButton.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent event) {
                    deleteEmitter();
                }
            });
        }
        {
            JButton cloneButton = new JButton("Clone");
            sideButtons.add(cloneButton, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
            cloneButton.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent event) {
                    cloneEmitter();
                }
            });
        }
        {
            sideButtons.add(new JSeparator(JSeparator.HORIZONTAL), new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
        }
        {
            JButton saveButton = new JButton("Save");
            sideButtons.add(saveButton, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
            saveButton.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent event) {
                    saveEffect();
                }
            });
        }
        {
            JButton openButton = new JButton("Open");
            sideButtons.add(openButton, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
            openButton.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent event) {
                    openEffect();
                }
            });
        }
        {
            JButton importButton = new JButton("Import");
            sideButtons.add(importButton, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
            importButton.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent event) {
                    importEffect();
                }
            });
        }
    /*
			{
				JButton importButton = new JButton("Export");
				sideButtons.add(importButton, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER,
					GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
				importButton.addActionListener(new ActionListener() {
					public void actionPerformed (ActionEvent event) {
						exportEffect();
					}
				});
			}
			*/
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) JComboBox(javax.swing.JComboBox) TableModelEvent(javax.swing.event.TableModelEvent) ActionEvent(java.awt.event.ActionEvent) DefaultTableModel(javax.swing.table.DefaultTableModel) ListSelectionEvent(javax.swing.event.ListSelectionEvent) JButton(javax.swing.JButton) Dimension(java.awt.Dimension) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) ControllerType(com.badlogic.gdx.tools.flame.FlameMain.ControllerType) JSeparator(javax.swing.JSeparator) ListSelectionListener(javax.swing.event.ListSelectionListener) ActionListener(java.awt.event.ActionListener) JTable(javax.swing.JTable) TableModelListener(javax.swing.event.TableModelListener)

Aggregations

ControllerType (com.badlogic.gdx.tools.flame.FlameMain.ControllerType)1 Dimension (java.awt.Dimension)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 Insets (java.awt.Insets)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)1 JButton (javax.swing.JButton)1 JComboBox (javax.swing.JComboBox)1 JPanel (javax.swing.JPanel)1 JScrollPane (javax.swing.JScrollPane)1 JSeparator (javax.swing.JSeparator)1 JTable (javax.swing.JTable)1 ListSelectionEvent (javax.swing.event.ListSelectionEvent)1 ListSelectionListener (javax.swing.event.ListSelectionListener)1 TableModelEvent (javax.swing.event.TableModelEvent)1 TableModelListener (javax.swing.event.TableModelListener)1 DefaultTableModel (javax.swing.table.DefaultTableModel)1