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 17package com.badlogic.gdx.tools.flame; 18import java.awt.GridBagConstraints; 19import java.awt.Insets; 20 21import javax.swing.JLabel; 22import javax.swing.JPanel; 23import javax.swing.JSpinner; 24import javax.swing.SpinnerNumberModel; 25import javax.swing.event.ChangeEvent; 26import javax.swing.event.ChangeListener; 27 28import com.badlogic.gdx.graphics.g3d.particles.values.NumericValue; 29 30 31/** @author Inferno */ 32class NumericPanel extends ParticleValuePanel<NumericValue> { 33 JSpinner valueSpinner; 34 35 public NumericPanel ( FlameMain editor, NumericValue value, String name, String description) { 36 super(editor, name, description); 37 setValue(value); 38 } 39 40 @Override 41 public void setValue (NumericValue value) { 42 super.setValue(value); 43 if(value == null)return; 44 setValue(valueSpinner, value.getValue()); 45 } 46 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