| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package com.jme3.gde.materialdefinition.dialog;
- import com.jme3.gde.materialdefinition.editor.Diagram;
- import com.jme3.scene.VertexBuffer;
- import java.awt.Point;
- import javax.swing.DefaultComboBoxModel;
- /**
- *
- * @author Nehon
- */
- @SuppressWarnings({"unchecked", "rawtypes"})
- public class AddAttributeDialog extends javax.swing.JDialog {
- private Diagram diagram;
- private Point clickPosition;
- /**
- * Creates new form AddMaterialParameter
- */
- public AddAttributeDialog(java.awt.Frame parent, boolean modal, Diagram diagram, Point clickPosition) {
- super(parent, modal);
- initComponents();
- DefaultComboBoxModel model = new DefaultComboBoxModel();
- for (VertexBuffer.Type attr : VertexBuffer.Type.values()) {
- model.addElement("in" + attr.name());
- }
- this.diagram = diagram;
- this.clickPosition = clickPosition;
- nameField.setModel(model);
- updateType();
- }
- /**
- * 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.
- */
- @SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
- private void initComponents() {
- jButton1 = new javax.swing.JButton();
- jButton2 = new javax.swing.JButton();
- jLabel1 = new javax.swing.JLabel();
- nameField = new javax.swing.JComboBox();
- jLabel2 = new javax.swing.JLabel();
- typeField = new javax.swing.JTextField();
- setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
- setTitle(org.openide.util.NbBundle.getMessage(AddAttributeDialog.class, "AddAttributeDialog.title")); // NOI18N
- setModal(true);
- org.openide.awt.Mnemonics.setLocalizedText(jButton1, org.openide.util.NbBundle.getMessage(AddAttributeDialog.class, "AddAttributeDialog.jButton1.text")); // NOI18N
- jButton1.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton1ActionPerformed(evt);
- }
- });
- org.openide.awt.Mnemonics.setLocalizedText(jButton2, org.openide.util.NbBundle.getMessage(AddAttributeDialog.class, "AddAttributeDialog.jButton2.text")); // NOI18N
- jButton2.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton2ActionPerformed(evt);
- }
- });
- jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
- org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(AddAttributeDialog.class, "AddAttributeDialog.jLabel1.text")); // NOI18N
- nameField.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
- nameField.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- nameFieldActionPerformed(evt);
- }
- });
- org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(AddAttributeDialog.class, "AddAttributeDialog.jLabel2.text")); // NOI18N
- typeField.setText(org.openide.util.NbBundle.getMessage(AddAttributeDialog.class, "AddAttributeDialog.typeField.text")); // NOI18N
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addComponent(jButton2)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(jButton1))
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
- .addComponent(jLabel2)
- .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(nameField, 0, 253, Short.MAX_VALUE)
- .addComponent(typeField))))
- .addContainerGap())
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addContainerGap()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel1)
- .addComponent(nameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel2)
- .addComponent(typeField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jButton1)
- .addComponent(jButton2))
- .addContainerGap())
- );
- pack();
- }// </editor-fold>//GEN-END:initComponents
- private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
- setVisible(false);
- }//GEN-LAST:event_jButton2ActionPerformed
- private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
- diagram.addAttribute((String) nameField.getSelectedItem(), typeField.getText(), clickPosition);
- setVisible(false);
- }//GEN-LAST:event_jButton1ActionPerformed
- private void nameFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nameFieldActionPerformed
- updateType();
- }
- private void updateType() {
- VertexBuffer.Type attr = VertexBuffer.Type.valueOf(((String) nameField.getSelectedItem()).replaceFirst("in", ""));
- switch (attr) {
- case BoneWeight:
- case BindPoseNormal:
- case Binormal:
- case Normal:
- typeField.setText("vec3");
- break;
- case Size:
- typeField.setText("float");
- break;
- case Position:
- case BindPosePosition:
- case BindPoseTangent:
- case Tangent:
- case Color:
- typeField.setText("vec4");
- break;
- case InterleavedData:
- typeField.setText("int");
- break;
- case Index:
- typeField.setText("uint");
- break;
- case BoneIndex:
- typeField.setText("uvec4");
- break;
- case TexCoord:
- case TexCoord2:
- case TexCoord3:
- case TexCoord4:
- case TexCoord5:
- case TexCoord6:
- case TexCoord7:
- case TexCoord8:
- typeField.setText("vec2");
- break;
- }
- }//GEN-LAST:event_nameFieldActionPerformed
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JButton jButton1;
- private javax.swing.JButton jButton2;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JComboBox nameField;
- private javax.swing.JTextField typeField;
- // End of variables declaration//GEN-END:variables
- }
|