|
@@ -0,0 +1,231 @@
|
|
|
+/*
|
|
|
+ * Copyright (c) 2009-2010 jMonkeyEngine
|
|
|
+ * All rights reserved.
|
|
|
+ *
|
|
|
+ * Redistribution and use in source and binary forms, with or without
|
|
|
+ * modification, are permitted provided that the following conditions are
|
|
|
+ * met:
|
|
|
+ *
|
|
|
+ * * Redistributions of source code must retain the above copyright
|
|
|
+ * notice, this list of conditions and the following disclaimer.
|
|
|
+ *
|
|
|
+ * * Redistributions in binary form must reproduce the above copyright
|
|
|
+ * notice, this list of conditions and the following disclaimer in the
|
|
|
+ * documentation and/or other materials provided with the distribution.
|
|
|
+ *
|
|
|
+ * * Neither the name of 'jMonkeyEngine' nor the names of its contributors
|
|
|
+ * may be used to endorse or promote products derived from this software
|
|
|
+ * without specific prior written permission.
|
|
|
+ *
|
|
|
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
|
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
|
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
|
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
|
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
|
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
+ */
|
|
|
+package com.jme3.gde.core.sceneexplorer.nodes.actions.impl.tracks;
|
|
|
+
|
|
|
+import com.jme3.animation.Animation;
|
|
|
+import com.jme3.effect.ParticleEmitter;
|
|
|
+import com.jme3.gde.core.sceneexplorer.nodes.JmeAnimation;
|
|
|
+import com.jme3.scene.Node;
|
|
|
+import com.jme3.scene.Spatial;
|
|
|
+import java.awt.Component;
|
|
|
+import javax.swing.DefaultComboBoxModel;
|
|
|
+import javax.swing.JLabel;
|
|
|
+import javax.swing.JList;
|
|
|
+import javax.swing.JPanel;
|
|
|
+import javax.swing.ListCellRenderer;
|
|
|
+
|
|
|
+public final class EffectTrackVisualPanel1 extends JPanel {
|
|
|
+
|
|
|
+ Spatial rootNode;
|
|
|
+ JmeAnimation animation;
|
|
|
+
|
|
|
+ /** Creates new form EffectTrackVisualPanel1 */
|
|
|
+ public EffectTrackVisualPanel1(Spatial rootNode, JmeAnimation animation) {
|
|
|
+ this.rootNode = rootNode;
|
|
|
+ this.animation = animation;
|
|
|
+ initComponents();
|
|
|
+ lengthLabel.setText(animation.getLookup().lookup(Animation.class).getLength() + "");
|
|
|
+ DefaultComboBoxModel model = new DefaultComboBoxModel();
|
|
|
+
|
|
|
+ populateModel(rootNode, model);
|
|
|
+ jComboBox1.setModel(model);
|
|
|
+ jComboBox1.setRenderer(new ListCellRenderer() {
|
|
|
+
|
|
|
+ public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
|
|
+ return new JLabel(((Spatial) value).getName());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ jSlider1.setMaximum((int) (animation.getLookup().lookup(Animation.class).getLength() * 100));
|
|
|
+ }
|
|
|
+
|
|
|
+ private void populateModel(Spatial root, DefaultComboBoxModel model) {
|
|
|
+ if (root instanceof Node) {
|
|
|
+ Node n = (Node) root;
|
|
|
+ for (Spatial child : n.getChildren()) {
|
|
|
+ populateModel(child, model);
|
|
|
+ }
|
|
|
+ } else if (root instanceof ParticleEmitter) {
|
|
|
+ model.addElement((ParticleEmitter) root);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String getName() {
|
|
|
+ return "Create a new EffectTrack";
|
|
|
+ }
|
|
|
+
|
|
|
+ public ParticleEmitter getEmitter() {
|
|
|
+ return (ParticleEmitter) jComboBox1.getSelectedItem();
|
|
|
+ }
|
|
|
+
|
|
|
+ public float getStartOffset() {
|
|
|
+ return (float) jSlider1.getValue() / 100f;
|
|
|
+ }
|
|
|
+
|
|
|
+ /** This method is called from within the constructor to
|
|
|
+ * initialize the form.
|
|
|
+ * WARNING: Do NOT modify this code. The content of this method is
|
|
|
+ * always regenerated by the Form Editor.
|
|
|
+ */
|
|
|
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
|
|
+ private void initComponents() {
|
|
|
+
|
|
|
+ jPanel1 = new javax.swing.JPanel();
|
|
|
+ jLabel1 = new javax.swing.JLabel();
|
|
|
+ jSeparator1 = new javax.swing.JSeparator();
|
|
|
+ jLabel2 = new javax.swing.JLabel();
|
|
|
+ jLabel3 = new javax.swing.JLabel();
|
|
|
+ jComboBox1 = new javax.swing.JComboBox();
|
|
|
+ jSlider1 = new javax.swing.JSlider();
|
|
|
+ jLabel4 = new javax.swing.JLabel();
|
|
|
+ jLabel5 = new javax.swing.JLabel();
|
|
|
+ lengthLabel = new javax.swing.JLabel();
|
|
|
+
|
|
|
+ jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
|
|
|
+
|
|
|
+ jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
|
|
|
+ jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jme3/gde/core/sceneexplorer/nodes/icons/effectTrack.png"))); // NOI18N
|
|
|
+ org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(EffectTrackVisualPanel1.class, "EffectTrackVisualPanel1.jLabel1.text")); // NOI18N
|
|
|
+
|
|
|
+ jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
|
|
|
+ org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(EffectTrackVisualPanel1.class, "EffectTrackVisualPanel1.jLabel2.text")); // NOI18N
|
|
|
+
|
|
|
+ jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
|
|
|
+ org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(EffectTrackVisualPanel1.class, "EffectTrackVisualPanel1.jLabel3.text")); // NOI18N
|
|
|
+ jLabel3.setVerticalAlignment(javax.swing.SwingConstants.TOP);
|
|
|
+
|
|
|
+ jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
|
|
|
+
|
|
|
+ jSlider1.setValue(0);
|
|
|
+ jSlider1.addChangeListener(new javax.swing.event.ChangeListener() {
|
|
|
+ public void stateChanged(javax.swing.event.ChangeEvent evt) {
|
|
|
+ jSlider1StateChanged(evt);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ jSlider1.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
|
|
|
+ public void propertyChange(java.beans.PropertyChangeEvent evt) {
|
|
|
+ jSlider1PropertyChange(evt);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
|
|
|
+ org.openide.awt.Mnemonics.setLocalizedText(jLabel4, jSlider1.getValue()+"");
|
|
|
+
|
|
|
+ jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
|
|
|
+ org.openide.awt.Mnemonics.setLocalizedText(jLabel5, org.openide.util.NbBundle.getMessage(EffectTrackVisualPanel1.class, "EffectTrackVisualPanel1.jLabel5.text")); // NOI18N
|
|
|
+
|
|
|
+ org.openide.awt.Mnemonics.setLocalizedText(lengthLabel, org.openide.util.NbBundle.getMessage(EffectTrackVisualPanel1.class, "EffectTrackVisualPanel1.lengthLabel.text")); // NOI18N
|
|
|
+
|
|
|
+ javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
|
|
|
+ jPanel1.setLayout(jPanel1Layout);
|
|
|
+ jPanel1Layout.setHorizontalGroup(
|
|
|
+ jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
+ .addGroup(jPanel1Layout.createSequentialGroup()
|
|
|
+ .addContainerGap()
|
|
|
+ .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
+ .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 390, Short.MAX_VALUE)
|
|
|
+ .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 390, Short.MAX_VALUE)
|
|
|
+ .addGroup(jPanel1Layout.createSequentialGroup()
|
|
|
+ .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
|
|
|
+ .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
+ .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 107, Short.MAX_VALUE)
|
|
|
+ .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
|
+ .addGap(18, 18, 18)
|
|
|
+ .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
|
|
|
+ .addComponent(lengthLabel, javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
+ .addComponent(jComboBox1, javax.swing.GroupLayout.Alignment.LEADING, 0, 157, Short.MAX_VALUE)
|
|
|
+ .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 243, Short.MAX_VALUE)
|
|
|
+ .addComponent(jSlider1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
|
|
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 22, Short.MAX_VALUE)))
|
|
|
+ .addContainerGap())
|
|
|
+ );
|
|
|
+ jPanel1Layout.setVerticalGroup(
|
|
|
+ jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
+ .addGroup(jPanel1Layout.createSequentialGroup()
|
|
|
+ .addContainerGap()
|
|
|
+ .addComponent(jLabel1)
|
|
|
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
|
+ .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
|
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
|
+ .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
|
+ .addComponent(jLabel5)
|
|
|
+ .addComponent(lengthLabel))
|
|
|
+ .addGap(18, 18, 18)
|
|
|
+ .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
|
+ .addComponent(jLabel2)
|
|
|
+ .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
|
+ .addGap(14, 14, 14)
|
|
|
+ .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
+ .addComponent(jLabel3)
|
|
|
+ .addComponent(jSlider1, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
|
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
|
+ .addComponent(jLabel4)
|
|
|
+ .addContainerGap(27, Short.MAX_VALUE))
|
|
|
+ );
|
|
|
+
|
|
|
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
|
|
+ this.setLayout(layout);
|
|
|
+ layout.setHorizontalGroup(
|
|
|
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
+ .addGroup(layout.createSequentialGroup()
|
|
|
+ .addContainerGap()
|
|
|
+ .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
+ .addContainerGap())
|
|
|
+ );
|
|
|
+ layout.setVerticalGroup(
|
|
|
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
|
|
+ .addContainerGap()
|
|
|
+ .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
+ .addContainerGap())
|
|
|
+ );
|
|
|
+ }// </editor-fold>//GEN-END:initComponents
|
|
|
+
|
|
|
+private void jSlider1PropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_jSlider1PropertyChange
|
|
|
+}//GEN-LAST:event_jSlider1PropertyChange
|
|
|
+
|
|
|
+private void jSlider1StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSlider1StateChanged
|
|
|
+ jLabel4.setText(((float) jSlider1.getValue() / 100f) + "");
|
|
|
+}//GEN-LAST:event_jSlider1StateChanged
|
|
|
+ // Variables declaration - do not modify//GEN-BEGIN:variables
|
|
|
+ private javax.swing.JComboBox jComboBox1;
|
|
|
+ private javax.swing.JLabel jLabel1;
|
|
|
+ private javax.swing.JLabel jLabel2;
|
|
|
+ private javax.swing.JLabel jLabel3;
|
|
|
+ private javax.swing.JLabel jLabel4;
|
|
|
+ private javax.swing.JLabel jLabel5;
|
|
|
+ private javax.swing.JPanel jPanel1;
|
|
|
+ private javax.swing.JSeparator jSeparator1;
|
|
|
+ private javax.swing.JSlider jSlider1;
|
|
|
+ private javax.swing.JLabel lengthLabel;
|
|
|
+ // End of variables declaration//GEN-END:variables
|
|
|
+}
|