gdx-studio
git clone https://git.pyrossh.dev/gdx-studio
An IDE for creating Games using libgdx and Java supported on all platforms Android, iOS, Desktop
src_libs/com/badlogic/gdx/tools/particleeditor/NumericPanel.java
| a62d533 | 1 | /******************************************************************************* |
| a62d533 | 2 | * Copyright 2011 See AUTHORS file. |
| a62d533 | 3 | * |
| a62d533 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| a62d533 | 5 | * you may not use this file except in compliance with the License. |
| a62d533 | 6 | * You may obtain a copy of the License at |
| a62d533 | 7 | * |
| a62d533 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| a62d533 | 9 | * |
| a62d533 | 10 | * Unless required by applicable law or agreed to in writing, software |
| a62d533 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| a62d533 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| a62d533 | 13 | * See the License for the specific language governing permissions and |
| a62d533 | 14 | * limitations under the License. |
| a62d533 | 15 | ******************************************************************************/ |
| a62d533 | 16 | |
| a62d533 | 17 | package com.badlogic.gdx.tools.particleeditor; |
| a62d533 | 18 | |
| a62d533 | 19 | import java.awt.GridBagConstraints; |
| a62d533 | 20 | import java.awt.Insets; |
| a62d533 | 21 | |
| a62d533 | 22 | import javax.swing.JLabel; |
| a62d533 | 23 | import javax.swing.JPanel; |
| a62d533 | 24 | import javax.swing.JSpinner; |
| a62d533 | 25 | import javax.swing.SpinnerNumberModel; |
| a62d533 | 26 | import javax.swing.event.ChangeEvent; |
| a62d533 | 27 | import javax.swing.event.ChangeListener; |
| a62d533 | 28 | |
| a62d533 | 29 | import com.badlogic.gdx.graphics.g2d.ParticleEmitter.NumericValue; |
| a62d533 | 30 | |
| a62d533 | 31 | class NumericPanel extends EditorPanel {
|
| a62d533 | 32 | private final NumericValue value; |
| a62d533 | 33 | JSpinner valueSpinner; |
| a62d533 | 34 | |
| a62d533 | 35 | public NumericPanel (final NumericValue value, String name, String description) {
|
| a62d533 | 36 | super(value, name, description); |
| a62d533 | 37 | this.value = value; |
| a62d533 | 38 | |
| a62d533 | 39 | initializeComponents(); |
| a62d533 | 40 | |
| a62d533 | 41 | valueSpinner.setValue(value.getValue()); |
| a62d533 | 42 | |
| a62d533 | 43 | valueSpinner.addChangeListener(new ChangeListener() {
|
| a62d533 | 44 | public void stateChanged (ChangeEvent event) {
|
| a62d533 | 45 | value.setValue((Float)valueSpinner.getValue()); |
| a62d533 | 46 | } |
| a62d533 | 47 | }); |
| a62d533 | 48 | } |
| a62d533 | 49 | |
| a62d533 | 50 | private void initializeComponents () {
|
| a62d533 | 51 | JPanel contentPanel = getContentPanel(); |
| a62d533 | 52 | {
|
| a62d533 | 53 | JLabel label = new JLabel("Value:");
|
| a62d533 | 54 | contentPanel.add(label, new GridBagConstraints(0, 1, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, |
| a62d533 | 55 | new Insets(0, 0, 0, 6), 0, 0)); |
| a62d533 | 56 | } |
| a62d533 | 57 | {
|
| a62d533 | 58 | valueSpinner = new JSpinner(new SpinnerNumberModel(new Float(0), new Float(-99999), new Float(99999), new Float(0.1f))); |
| a62d533 | 59 | contentPanel.add(valueSpinner, new GridBagConstraints(1, 1, 1, 1, 1, 0, GridBagConstraints.WEST, |
| a62d533 | 60 | GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); |
| a62d533 | 61 | } |
| a62d533 | 62 | } |
| a62d533 | 63 | } |