Home | History | Annotate | Download | only in flame
      1 package com.badlogic.gdx.tools.flame;
      2 
      3 import java.awt.Dimension;
      4 import java.awt.GridBagConstraints;
      5 import java.awt.Insets;
      6 import java.awt.event.ActionEvent;
      7 import java.awt.event.ActionListener;
      8 
      9 import javax.swing.JCheckBox;
     10 import javax.swing.JLabel;
     11 import javax.swing.JPanel;
     12 
     13 import com.badlogic.gdx.graphics.g3d.particles.influencers.DynamicsModifier;
     14 
     15 /** @author Inferno */
     16 public class StrengthVelocityPanel extends EditorPanel<DynamicsModifier.Strength> {
     17 
     18 	JCheckBox isGlobalCheckBox;
     19 	ScaledNumericPanel magnitudePanel;
     20 
     21 	public StrengthVelocityPanel(FlameMain editor, DynamicsModifier.Strength value, String charTitle, String name, String description) {
     22 		super(editor, name, description);
     23 		initializeComponents(charTitle);
     24 		setValue(value);
     25 	}
     26 
     27 	@Override
     28 	public void setValue (DynamicsModifier.Strength value) {
     29 		super.setValue(value);
     30 		if(value == null) return;
     31 		setValue(isGlobalCheckBox, this.value.isGlobal);
     32 		magnitudePanel.setValue(value.strengthValue);
     33 	}
     34 
     35 	private void initializeComponents(String charTitle)
     36 	{
     37 		JPanel contentPanel = getContentPanel();
     38 		{
     39 			JPanel panel = new JPanel();
     40 			panel.add(new JLabel("Global"), new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE,
     41 				new Insets(0, 0, 0, 0), 0, 0));
     42 			panel.add(isGlobalCheckBox = new JCheckBox(), new GridBagConstraints(1, 0, 1, 1, 0, 0,
     43 				GridBagConstraints.WEST, GridBagConstraints.NONE,
     44 				new Insets(0, 0, 0, 0), 0, 0));
     45 			contentPanel.add(panel,new GridBagConstraints(0, 1, 1, 1, 0, 0,
     46 				GridBagConstraints.WEST, GridBagConstraints.NONE,
     47 				new Insets(0, 0, 0, 0), 0, 0));
     48 		}
     49 		{
     50 			contentPanel.add( magnitudePanel = new ScaledNumericPanel(editor, null, charTitle, "Strength", "In world units per second.", true),
     51 				new GridBagConstraints(0, 2, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE,
     52 					new Insets(0, 0, 0, 6), 0, 0));
     53 		}
     54 		{
     55 			JPanel spacer = new JPanel();
     56 			spacer.setPreferredSize(new Dimension());
     57 			contentPanel.add(spacer, new GridBagConstraints(6, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE,
     58 				new Insets(0, 0, 0, 0), 0, 0));
     59 		}
     60 
     61 		magnitudePanel.setIsAlwayShown(true);
     62 
     63 		isGlobalCheckBox.addActionListener(new ActionListener() {
     64 			@Override
     65 			public void actionPerformed (ActionEvent e) {
     66 				StrengthVelocityPanel.this.value.isGlobal = isGlobalCheckBox.isSelected();
     67 			}
     68 		});
     69 	}
     70 
     71 }
     72