• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*******************************************************************************
2  * Copyright 2011 See AUTHORS file.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *   http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  ******************************************************************************/
16 
17 package com.badlogic.gdx.tools.flame;
18 import java.awt.GridBagConstraints;
19 import java.awt.Insets;
20 
21 import javax.swing.JLabel;
22 import javax.swing.JPanel;
23 import javax.swing.JSpinner;
24 import javax.swing.SpinnerNumberModel;
25 import javax.swing.event.ChangeEvent;
26 import javax.swing.event.ChangeListener;
27 
28 import com.badlogic.gdx.graphics.g3d.particles.values.NumericValue;
29 
30 
31 /** @author Inferno */
32 class NumericPanel extends ParticleValuePanel<NumericValue> {
33 	JSpinner valueSpinner;
34 
NumericPanel( FlameMain editor, NumericValue value, String name, String description)35 	public NumericPanel ( FlameMain editor, NumericValue value, String name, String description) {
36 		super(editor, name, description);
37 		setValue(value);
38 	}
39 
40 	@Override
setValue(NumericValue value)41 	public void setValue (NumericValue value) {
42 		super.setValue(value);
43 		if(value == null)return;
44 		setValue(valueSpinner, value.getValue());
45 	}
46 
initializeComponents()47 	protected void initializeComponents () {
48 		super.initializeComponents();
49 		JPanel contentPanel = getContentPanel();
50 		{
51 			JLabel label = new JLabel("Value:");
52 			contentPanel.add(label, new GridBagConstraints(0, 1, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE,
53 				new Insets(0, 0, 0, 6), 0, 0));
54 		}
55 		{
56 			valueSpinner = new JSpinner(new SpinnerNumberModel(new Float(0), new Float(-99999), new Float(99999), new Float(0.1f)));
57 			contentPanel.add(valueSpinner, new GridBagConstraints(1, 1, 1, 1, 1, 0, GridBagConstraints.WEST,
58 				GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
59 		}
60 		valueSpinner.addChangeListener(new ChangeListener() {
61 			public void stateChanged (ChangeEvent event) {
62 				NumericPanel.this.value.setValue((Float)valueSpinner.getValue());
63 			}
64 		});
65 	}
66 }
67