diff --git a/sdk/jme3-materialeditor/src/com/jme3/gde/materials/multiview/widgets/Bundle.properties b/sdk/jme3-materialeditor/src/com/jme3/gde/materials/multiview/widgets/Bundle.properties
index eef43579a..3a0e61c02 100644
--- a/sdk/jme3-materialeditor/src/com/jme3/gde/materials/multiview/widgets/Bundle.properties
+++ b/sdk/jme3-materialeditor/src/com/jme3/gde/materials/multiview/widgets/Bundle.properties
@@ -13,7 +13,6 @@ ColorRGBADialog.alphaLabel.text=Alpha:
# To change this template, choose Tools | Templates
# and open the template in the editor.
ColorPanel.jLabel1.text=jLabel1
-ColorPanel.jTextField1.text=jTextField1
ColorPanel.jButton1.text=select..
TexturePanel.jLabel1.text=jLabel1
TexturePanel.jButton1.text=set..
@@ -38,3 +37,12 @@ MaterialPreviewWidget.sphereButton.toolTipText=Preview material on a sphere
MaterialPreviewWidget.cubeButton.toolTipText=Preview material on a cube
MaterialPreviewWidget.planeButton.toolTipText=Preview material on a plane
MaterialPreviewWidget.previewLabel.text=
+ColorPanel.colorPreview.text=
+ColorPanel.jLabel2.text=\ r :
+ColorPanel.jLabel3.text=\ g :
+ColorPanel.jLabel4.text=\ b :
+ColorPanel.jLabel5.text=\ a :
+ColorPanel.rLabel.text=0.2545
+ColorPanel.gLabel.text=0.2545
+ColorPanel.bLabel.text=0.2545
+ColorPanel.aLabel.text=0.2545
diff --git a/sdk/jme3-materialeditor/src/com/jme3/gde/materials/multiview/widgets/ColorPanel.form b/sdk/jme3-materialeditor/src/com/jme3/gde/materials/multiview/widgets/ColorPanel.form
index 0495e9783..7eee549cf 100644
--- a/sdk/jme3-materialeditor/src/com/jme3/gde/materials/multiview/widgets/ColorPanel.form
+++ b/sdk/jme3-materialeditor/src/com/jme3/gde/materials/multiview/widgets/ColorPanel.form
@@ -5,6 +5,12 @@
+
+
+
+
+
+
@@ -21,93 +27,257 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
-
+
-
-
+
+
-
-
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
+
+
+
+
-
+
+
+
-
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sdk/jme3-materialeditor/src/com/jme3/gde/materials/multiview/widgets/ColorPanel.java b/sdk/jme3-materialeditor/src/com/jme3/gde/materials/multiview/widgets/ColorPanel.java
index 8f97e9e23..19b3b1eba 100644
--- a/sdk/jme3-materialeditor/src/com/jme3/gde/materials/multiview/widgets/ColorPanel.java
+++ b/sdk/jme3-materialeditor/src/com/jme3/gde/materials/multiview/widgets/ColorPanel.java
@@ -8,9 +8,10 @@
*
* Created on 14.06.2010, 16:42:25
*/
-
package com.jme3.gde.materials.multiview.widgets;
+import com.jme3.math.FastMath;
+import java.awt.Color;
import javax.swing.JFrame;
/**
@@ -33,108 +34,337 @@ public class ColorPanel extends MaterialPropertyWidget {
// //GEN-BEGIN:initComponents
private void initComponents() {
- jToolBar1 = new javax.swing.JToolBar();
jLabel1 = new javax.swing.JLabel();
- jPanel1 = new javax.swing.JPanel();
- jTextField1 = new javax.swing.JTextField();
+ jPanel2 = new javax.swing.JPanel();
+ rLabel = new javax.swing.JTextField();
+ gLabel = new javax.swing.JTextField();
+ bLabel = new javax.swing.JTextField();
+ jLabel2 = new javax.swing.JLabel();
+ jLabel3 = new javax.swing.JLabel();
+ jLabel4 = new javax.swing.JLabel();
+ aLabel = new javax.swing.JTextField();
+ jLabel5 = new javax.swing.JLabel();
+ colorPreview = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
+ jSeparator1 = new javax.swing.JSeparator();
setBackground(new java.awt.Color(204, 204, 204));
-
- jToolBar1.setBackground(new java.awt.Color(204, 204, 204));
- jToolBar1.setFloatable(false);
- jToolBar1.setRollover(true);
+ setMaximumSize(new java.awt.Dimension(32767, 35));
+ setPreferredSize(new java.awt.Dimension(430, 35));
jLabel1.setText(org.openide.util.NbBundle.getMessage(ColorPanel.class, "ColorPanel.jLabel1.text")); // NOI18N
jLabel1.setPreferredSize(new java.awt.Dimension(100, 16));
- jToolBar1.add(jLabel1);
- jPanel1.setBackground(new java.awt.Color(204, 204, 204));
- jPanel1.setMinimumSize(new java.awt.Dimension(0, 0));
- jPanel1.setPreferredSize(new java.awt.Dimension(10, 0));
+ jPanel2.setBackground(new java.awt.Color(204, 204, 204));
- javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
- jPanel1.setLayout(jPanel1Layout);
- jPanel1Layout.setHorizontalGroup(
- jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGap(0, 8, Short.MAX_VALUE)
- );
- jPanel1Layout.setVerticalGroup(
- jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGap(0, 28, Short.MAX_VALUE)
- );
+ rLabel.setText(org.openide.util.NbBundle.getMessage(ColorPanel.class, "ColorPanel.rLabel.text")); // NOI18N
+ rLabel.setMaximumSize(new java.awt.Dimension(110, 2147483647));
+ rLabel.setNextFocusableComponent(gLabel);
+ rLabel.setPreferredSize(new java.awt.Dimension(110, 28));
+ rLabel.setVerifyInputWhenFocusTarget(false);
+ rLabel.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ textChanged(evt);
+ }
+ });
+ rLabel.addFocusListener(new java.awt.event.FocusAdapter() {
+ public void focusGained(java.awt.event.FocusEvent evt) {
+ rLabelFocusGained(evt);
+ }
+ public void focusLost(java.awt.event.FocusEvent evt) {
+ rLabelFocusLost(evt);
+ }
+ });
- jToolBar1.add(jPanel1);
+ gLabel.setText(org.openide.util.NbBundle.getMessage(ColorPanel.class, "ColorPanel.gLabel.text")); // NOI18N
+ gLabel.setMaximumSize(new java.awt.Dimension(110, 2147483647));
+ gLabel.setNextFocusableComponent(bLabel);
+ gLabel.setPreferredSize(new java.awt.Dimension(110, 28));
+ gLabel.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ gLabeltextChanged(evt);
+ }
+ });
+ gLabel.addFocusListener(new java.awt.event.FocusAdapter() {
+ public void focusGained(java.awt.event.FocusEvent evt) {
+ gLabelFocusGained(evt);
+ }
+ public void focusLost(java.awt.event.FocusEvent evt) {
+ gLabelFocusLost(evt);
+ }
+ });
- jTextField1.setText(org.openide.util.NbBundle.getMessage(ColorPanel.class, "ColorPanel.jTextField1.text")); // NOI18N
- jTextField1.setMaximumSize(new java.awt.Dimension(110, 2147483647));
- jTextField1.setPreferredSize(new java.awt.Dimension(110, 28));
- jTextField1.addActionListener(new java.awt.event.ActionListener() {
+ bLabel.setText(org.openide.util.NbBundle.getMessage(ColorPanel.class, "ColorPanel.bLabel.text")); // NOI18N
+ bLabel.setMaximumSize(new java.awt.Dimension(110, 2147483647));
+ bLabel.setNextFocusableComponent(aLabel);
+ bLabel.setPreferredSize(new java.awt.Dimension(110, 28));
+ bLabel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
- textChanged(evt);
+ bLabeltextChanged(evt);
+ }
+ });
+ bLabel.addFocusListener(new java.awt.event.FocusAdapter() {
+ public void focusGained(java.awt.event.FocusEvent evt) {
+ bLabelFocusGained(evt);
+ }
+ public void focusLost(java.awt.event.FocusEvent evt) {
+ bLabelFocusLost(evt);
+ }
+ });
+
+ jLabel2.setText(org.openide.util.NbBundle.getMessage(ColorPanel.class, "ColorPanel.jLabel2.text")); // NOI18N
+
+ jLabel3.setText(org.openide.util.NbBundle.getMessage(ColorPanel.class, "ColorPanel.jLabel3.text")); // NOI18N
+
+ jLabel4.setText(org.openide.util.NbBundle.getMessage(ColorPanel.class, "ColorPanel.jLabel4.text")); // NOI18N
+
+ aLabel.setText(org.openide.util.NbBundle.getMessage(ColorPanel.class, "ColorPanel.aLabel.text")); // NOI18N
+ aLabel.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR));
+ aLabel.setMaximumSize(new java.awt.Dimension(110, 2147483647));
+ aLabel.setNextFocusableComponent(jButton1);
+ aLabel.setPreferredSize(new java.awt.Dimension(110, 28));
+ aLabel.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ aLabeltextChanged(evt);
+ }
+ });
+ aLabel.addFocusListener(new java.awt.event.FocusAdapter() {
+ public void focusGained(java.awt.event.FocusEvent evt) {
+ aLabelFocusGained(evt);
+ }
+ public void focusLost(java.awt.event.FocusEvent evt) {
+ aLabelFocusLost(evt);
}
});
- jToolBar1.add(jTextField1);
+ jLabel5.setText(org.openide.util.NbBundle.getMessage(ColorPanel.class, "ColorPanel.jLabel5.text")); // NOI18N
+
+ colorPreview.setBackground(new java.awt.Color(204, 204, 204));
+ colorPreview.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
+ colorPreview.setText(org.openide.util.NbBundle.getMessage(ColorPanel.class, "ColorPanel.colorPreview.text")); // NOI18N
+ colorPreview.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(102, 102, 102)));
+ colorPreview.setOpaque(true);
+
+ javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
+ jPanel2.setLayout(jPanel2Layout);
+ jPanel2Layout.setHorizontalGroup(
+ jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
+ .addContainerGap()
+ .addComponent(colorPreview, javax.swing.GroupLayout.DEFAULT_SIZE, 18, Short.MAX_VALUE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jLabel2)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(rLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jLabel3)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(gLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jLabel4)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(bLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jLabel5)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(aLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE))
+ );
+ jPanel2Layout.setVerticalGroup(
+ jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(gLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 20, Short.MAX_VALUE)
+ .addComponent(bLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 20, Short.MAX_VALUE)
+ .addComponent(aLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 20, Short.MAX_VALUE)
+ .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLabel3)
+ .addComponent(jLabel4)
+ .addComponent(jLabel5)
+ .addComponent(jLabel2)
+ .addComponent(rLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 20, Short.MAX_VALUE))
+ .addComponent(colorPreview, javax.swing.GroupLayout.DEFAULT_SIZE, 20, Short.MAX_VALUE)
+ );
+
+ jButton1.setBackground(new java.awt.Color(204, 204, 204));
jButton1.setText(org.openide.util.NbBundle.getMessage(ColorPanel.class, "ColorPanel.jButton1.text")); // NOI18N
- jButton1.setFocusable(false);
jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+ jButton1.setMaximumSize(new java.awt.Dimension(43, 15));
+ jButton1.setMinimumSize(new java.awt.Dimension(43, 15));
+ jButton1.setPreferredSize(new java.awt.Dimension(43, 15));
jButton1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
- jToolBar1.add(jButton1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 248, Short.MAX_VALUE)
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+ .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 415, Short.MAX_VALUE)
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 65, Short.MAX_VALUE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)))
+ .addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGroup(layout.createSequentialGroup()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
+ .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(jButton1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 4, javax.swing.GroupLayout.PREFERRED_SIZE))
);
}// //GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
- ColorRGBADialog dialog=new ColorRGBADialog(new JFrame(), true);
+ ColorRGBADialog dialog = new ColorRGBADialog(new JFrame(), true);
dialog.setLocationRelativeTo(null);
+ dialog.setColor(getColor(rLabel.getText(), gLabel.getText(), bLabel.getText(), aLabel.getText()));
dialog.setVisible(true);
- if(dialog.getColor()!=null){
- jTextField1.setText(dialog.getColor());
- property.setValue(jTextField1.getText());
+ if (dialog.getColorAsText() != null) {
+ colorPreview.setBackground(dialog.getColor());
+ float[] f = new float[4];
+ dialog.getColor().getRGBComponents(f);
+ dialog.getColor().getAlpha();
+ rLabel.setText(f[0] + "");
+ gLabel.setText(f[1] + "");
+ bLabel.setText(f[2] + "");
+ aLabel.setText(f[3] + "");
+ property.setValue(rLabel.getText() + " " + gLabel.getText() + " " + bLabel.getText() + " " + aLabel.getText());
fireChanged();
}
-
+
}//GEN-LAST:event_jButton1ActionPerformed
-
+
private void textChanged(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_textChanged
- property.setValue(jTextField1.getText());
- fireChanged();
+ updateValue();
}//GEN-LAST:event_textChanged
-
+
+private void gLabeltextChanged(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_gLabeltextChanged
+ updateValue();
+}//GEN-LAST:event_gLabeltextChanged
+
+private void bLabeltextChanged(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bLabeltextChanged
+ updateValue();
+}//GEN-LAST:event_bLabeltextChanged
+
+private void aLabeltextChanged(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aLabeltextChanged
+ updateValue();
+}//GEN-LAST:event_aLabeltextChanged
+
+private void rLabelFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_rLabelFocusGained
+ rLabel.setSelectionStart(0);
+ rLabel.setSelectionEnd(rLabel.getText().length());
+}//GEN-LAST:event_rLabelFocusGained
+
+private void gLabelFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_gLabelFocusGained
+ gLabel.setSelectionStart(0);
+ gLabel.setSelectionEnd(gLabel.getText().length());
+}//GEN-LAST:event_gLabelFocusGained
+
+private void bLabelFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_bLabelFocusGained
+ bLabel.setSelectionStart(0);
+ bLabel.setSelectionEnd(bLabel.getText().length());
+}//GEN-LAST:event_bLabelFocusGained
+
+private void aLabelFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_aLabelFocusGained
+ aLabel.setSelectionStart(0);
+ aLabel.setSelectionEnd(aLabel.getText().length());
+}//GEN-LAST:event_aLabelFocusGained
+
+private void rLabelFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_rLabelFocusLost
+ updateValue();
+}//GEN-LAST:event_rLabelFocusLost
+
+private void gLabelFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_gLabelFocusLost
+ updateValue();
+}//GEN-LAST:event_gLabelFocusLost
+
+private void bLabelFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_bLabelFocusLost
+ updateValue();
+}//GEN-LAST:event_bLabelFocusLost
+
+private void aLabelFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_aLabelFocusLost
+ updateValue();
+}//GEN-LAST:event_aLabelFocusLost
+
+ private void updateValue() {
+ Color c = getColor(rLabel.getText(), gLabel.getText(), bLabel.getText(), aLabel.getText());
+ if (c != null) {
+ colorPreview.setBackground(c);
+ property.setValue(rLabel.getText() + " " + gLabel.getText() + " " + bLabel.getText() + " " + aLabel.getText());
+ fireChanged();
+ } else {
+ colorPreview.setBackground(new Color(204, 204, 204));
+ }
+ }
+
@Override
protected void readProperty() {
java.awt.EventQueue.invokeLater(new Runnable() {
-
+
public void run() {
jLabel1.setText(property.getName());
jLabel1.setToolTipText(property.getName());
- jTextField1.setText(property.getValue());
+ System.out.println(property.getValue());
+ String[] s = property.getValue().split(" ");
+ if (s.length == 4) {
+ try {
+ colorPreview.setBackground(getColor(s[0], s[1], s[2], s[3]));
+ rLabel.setText(s[0]);
+ gLabel.setText(s[1]);
+ bLabel.setText(s[2]);
+ aLabel.setText(s[3]);
+ } catch (NumberFormatException e) {
+ clear();
+ }
+ } else {
+ clear();
+ }
}
});
}
-
+
+ private void clear() {
+ colorPreview.setBackground(new Color(204, 204, 204));
+ rLabel.setText("");
+ gLabel.setText("");
+ bLabel.setText("");
+ aLabel.setText("");
+ }
+
+ private Color getColor(String r, String g, String b, String a) {
+ try {
+ float fr = FastMath.clamp(Float.parseFloat(r), 0, 1);
+ float fg = FastMath.clamp(Float.parseFloat(g), 0, 1);
+ float fb = FastMath.clamp(Float.parseFloat(b), 0, 1);
+ float fa = FastMath.clamp(Float.parseFloat(a), 0, 1);
+ return new Color(fr, fg, fb, fa);
+ } catch (NumberFormatException e) {
+ return null;
+ }
+ }
// Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JTextField aLabel;
+ private javax.swing.JTextField bLabel;
+ private javax.swing.JLabel colorPreview;
+ private javax.swing.JTextField gLabel;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
- private javax.swing.JPanel jPanel1;
- private javax.swing.JTextField jTextField1;
- private javax.swing.JToolBar jToolBar1;
+ private javax.swing.JLabel jLabel2;
+ private javax.swing.JLabel jLabel3;
+ private javax.swing.JLabel jLabel4;
+ private javax.swing.JLabel jLabel5;
+ private javax.swing.JPanel jPanel2;
+ private javax.swing.JSeparator jSeparator1;
+ private javax.swing.JTextField rLabel;
// End of variables declaration//GEN-END:variables
-
}
diff --git a/sdk/jme3-materialeditor/src/com/jme3/gde/materials/multiview/widgets/ColorRGBADialog.form b/sdk/jme3-materialeditor/src/com/jme3/gde/materials/multiview/widgets/ColorRGBADialog.form
index dcf4e8353..0c29c0c75 100644
--- a/sdk/jme3-materialeditor/src/com/jme3/gde/materials/multiview/widgets/ColorRGBADialog.form
+++ b/sdk/jme3-materialeditor/src/com/jme3/gde/materials/multiview/widgets/ColorRGBADialog.form
@@ -23,7 +23,7 @@
-
+
diff --git a/sdk/jme3-materialeditor/src/com/jme3/gde/materials/multiview/widgets/ColorRGBADialog.java b/sdk/jme3-materialeditor/src/com/jme3/gde/materials/multiview/widgets/ColorRGBADialog.java
index 732320ec8..cd11a8cdd 100644
--- a/sdk/jme3-materialeditor/src/com/jme3/gde/materials/multiview/widgets/ColorRGBADialog.java
+++ b/sdk/jme3-materialeditor/src/com/jme3/gde/materials/multiview/widgets/ColorRGBADialog.java
@@ -44,7 +44,9 @@ import java.awt.Color;
* @author normenhansen
*/
public class ColorRGBADialog extends javax.swing.JDialog {
- private String color;
+
+ private String strColor;
+ private Color color;
/** Creates new form ColorRGBADialog */
public ColorRGBADialog(java.awt.Frame parent, boolean modal) {
@@ -54,11 +56,12 @@ public class ColorRGBADialog extends javax.swing.JDialog {
}
private void convertColor() {
- Color cColor = jColorChooser1.getColor();
+
float[] floats = new float[4];
- cColor.getComponents(floats);
- String str=new String(floats[0]+" "+ floats[1]+" "+ floats[2]+" "+ ((float)alphaSlider.getValue())/100.0f);
- color=str;
+ jColorChooser1.getColor().getComponents(floats);
+ color = new Color(floats[0], floats[1], floats[2], ((float) alphaSlider.getValue()) / 100.0f);
+ String str = new String(floats[0] + " " + floats[1] + " " + floats[2] + " " + ((float) alphaSlider.getValue()) / 100.0f);
+ strColor = str;
}
/** This method is called from within the constructor to
@@ -149,11 +152,22 @@ public class ColorRGBADialog extends javax.swing.JDialog {
/**
* @return the color
*/
- public String getColor() {
+ public String getColorAsText() {
+ return strColor;
+ }
+
+ public void setColorAsText(String color) {
+ this.strColor = color;
+ }
+
+ public Color getColor() {
return color;
}
- public void setColor(String color){
- this.color=color;
+ public void setColor(Color color) {
+ this.color = color;
+ jColorChooser1.setColor(color);
+ alphaSlider.setValue((int) ((float) (color.getAlpha() / 255f) * 100));
+
}
}
diff --git a/sdk/jme3-materialeditor/src/com/jme3/gde/materials/multiview/widgets/FloatPanel.form b/sdk/jme3-materialeditor/src/com/jme3/gde/materials/multiview/widgets/FloatPanel.form
index a4d83b357..e5331bfd4 100644
--- a/sdk/jme3-materialeditor/src/com/jme3/gde/materials/multiview/widgets/FloatPanel.form
+++ b/sdk/jme3-materialeditor/src/com/jme3/gde/materials/multiview/widgets/FloatPanel.form
@@ -21,7 +21,7 @@
-
+
@@ -55,29 +55,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/sdk/jme3-materialeditor/src/com/jme3/gde/materials/multiview/widgets/FloatPanel.java b/sdk/jme3-materialeditor/src/com/jme3/gde/materials/multiview/widgets/FloatPanel.java
index 2fc4dd1fa..a8ea621b2 100644
--- a/sdk/jme3-materialeditor/src/com/jme3/gde/materials/multiview/widgets/FloatPanel.java
+++ b/sdk/jme3-materialeditor/src/com/jme3/gde/materials/multiview/widgets/FloatPanel.java
@@ -35,7 +35,6 @@ public class FloatPanel extends MaterialPropertyWidget {
jToolBar1 = new javax.swing.JToolBar();
jLabel1 = new javax.swing.JLabel();
- jPanel1 = new javax.swing.JPanel();
jSpinner1 = new javax.swing.JSpinner();
setBackground(new java.awt.Color(204, 204, 204));
@@ -49,22 +48,6 @@ public class FloatPanel extends MaterialPropertyWidget {
jLabel1.setPreferredSize(new java.awt.Dimension(100, 16));
jToolBar1.add(jLabel1);
- jPanel1.setBackground(new java.awt.Color(204, 204, 204));
- jPanel1.setPreferredSize(new java.awt.Dimension(100, 25));
-
- javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
- jPanel1.setLayout(jPanel1Layout);
- jPanel1Layout.setHorizontalGroup(
- jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGap(0, 255, Short.MAX_VALUE)
- );
- jPanel1Layout.setVerticalGroup(
- jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGap(0, 25, Short.MAX_VALUE)
- );
-
- jToolBar1.add(jPanel1);
-
jSpinner1.setModel(new javax.swing.SpinnerNumberModel(Float.valueOf(0.0f), null, null, Float.valueOf(1.0f)));
jSpinner1.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
@@ -77,7 +60,7 @@ public class FloatPanel extends MaterialPropertyWidget {
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 543, Short.MAX_VALUE)
+ .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -113,7 +96,6 @@ public class FloatPanel extends MaterialPropertyWidget {
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel jLabel1;
- private javax.swing.JPanel jPanel1;
private javax.swing.JSpinner jSpinner1;
private javax.swing.JToolBar jToolBar1;
// End of variables declaration//GEN-END:variables