Browse Source

Cosmetic fixes: Adding Copyright, formatting, adding @Override

MeFisto94 6 years ago
parent
commit
e85d9abbb5

+ 43 - 11
jme3-materialeditor/src/com/jme3/gde/materials/MaterialProperty.java

@@ -1,13 +1,41 @@
 /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
+ *  Copyright (c) 2009-2018 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.materials;
 
 import com.jme3.material.MatParam;
 
 /**
- *
+ * The MaterialProperty is the SDK representation of a "MatParam". It is unclear
+ * why MatParams themselves aren't used along with their getValueAsString.
  * @author normenhansen
  */
 public class MaterialProperty {
@@ -26,14 +54,7 @@ public class MaterialProperty {
     }
 
     public MaterialProperty(MatParam param) {
-        this.type = param.getVarType().name();
-        this.name = param.getName();
-        if (param.getValue() != null) {
-            try {
-                this.value = param.getValueAsString();
-            } catch (UnsupportedOperationException e) {
-            }
-        }
+        setFromMatParam(param);
     }
 
     /**
@@ -77,4 +98,15 @@ public class MaterialProperty {
     public void setValue(String value) {
         this.value = value;
     }
+    
+    public void setFromMatParam(MatParam param) {
+        this.type = param.getVarType().name();
+        this.name = param.getName();
+        if (param.getValue() != null) {
+            try {
+                this.value = param.getValueAsString();
+            } catch (UnsupportedOperationException e) {
+            }
+        }
+    }
 }

+ 15 - 5
jme3-materialeditor/src/com/jme3/gde/materials/MaterialPropertyEditor.java

@@ -47,7 +47,6 @@ import java.beans.PropertyChangeListener;
 import java.beans.PropertyEditor;
 import java.util.Arrays;
 import java.util.Collections;
-import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.concurrent.Callable;
@@ -69,28 +68,34 @@ public class MaterialPropertyEditor implements PropertyEditor, SceneExplorerProp
     private LinkedList<PropertyChangeListener> listeners = new LinkedList<PropertyChangeListener>();
     private Material material = new Material();
 
+    @Override
     public void setValue(Object value) {
         if (value instanceof Material) {
             material = (Material) value;
         }
     }
 
+    @Override
     public Object getValue() {
         return material;
     }
 
+    @Override
     public boolean isPaintable() {
         return false;
     }
 
+    @Override
     public void paintValue(Graphics gfx, Rectangle box) {
         throw new UnsupportedOperationException("Not supported yet.");
     }
 
+    @Override
     public String getJavaInitializationString() {
         return null;
     }
 
+    @Override
     public String getAsText() {
         String name = material.getAssetName();
         if (name == null) {
@@ -99,6 +104,7 @@ public class MaterialPropertyEditor implements PropertyEditor, SceneExplorerProp
         return name;
     }
 
+    @Override
     public void setAsText(final String text) throws IllegalArgumentException {
         if ("create j3m file".equals(text)) {
             try {
@@ -128,9 +134,7 @@ public class MaterialPropertyEditor implements PropertyEditor, SceneExplorerProp
                 currentFolder.refresh();
                 applyMaterial(material.getAssetName());
             } catch (Exception ex) {
-
                 Exceptions.printStackTrace(ex);
-                return;
             }
         } else {
             applyMaterial(text);
@@ -145,6 +149,7 @@ public class MaterialPropertyEditor implements PropertyEditor, SceneExplorerProp
         try {
             Material old = material;
             SceneApplication.getApplication().enqueue(new Callable<Void>() {
+                @Override
                 public Void call() throws Exception {
                     SceneRequest request = SceneApplication.getApplication().getCurrentSceneRequest();
                     request.getManager().deleteFromCache(new MaterialKey(text));
@@ -163,6 +168,7 @@ public class MaterialPropertyEditor implements PropertyEditor, SceneExplorerProp
         }
     }
 
+    @Override
     public String[] getTags() {
         SceneRequest request = SceneApplication.getApplication().getCurrentSceneRequest();
         if (request == null) {
@@ -188,6 +194,7 @@ public class MaterialPropertyEditor implements PropertyEditor, SceneExplorerProp
         }
     }
 
+    @Override
     public Component getCustomEditor() {
         ProjectAssetManager currentProjectAssetManager = null;
 
@@ -200,26 +207,29 @@ public class MaterialPropertyEditor implements PropertyEditor, SceneExplorerProp
 
     }
 
+    @Override
     public boolean supportsCustomEditor() {
         return true;
     }
 
+    @Override
     public void addPropertyChangeListener(PropertyChangeListener listener) {
         listeners.add(listener);
     }
 
+    @Override
     public void removePropertyChangeListener(PropertyChangeListener listener) {
         listeners.remove(listener);
     }
 
     private void notifyListeners(Material before, Material after) {
-        for (Iterator<PropertyChangeListener> it = listeners.iterator(); it.hasNext();) {
-            PropertyChangeListener propertyChangeListener = it.next();
+        for (PropertyChangeListener propertyChangeListener : listeners) {
             //TODO: check what the "programmatic name" is supposed to be here.. for now its Quaternion
             propertyChangeListener.propertyChange(new PropertyChangeEvent(this, "Material", before, after));
         }
     }
 
+    @Override
     public void setEditor(Class valueType, SceneExplorerProperty prop) {
         if (valueType == Material.class) {
             prop.setPropertyEditorClass(MaterialPropertyEditor.class);

+ 40 - 11
jme3-materialeditor/src/com/jme3/gde/materials/multiview/widgets/MaterialPropertyWidget.java

@@ -1,8 +1,34 @@
 /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
+ *  Copyright (c) 2009-2018 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.materials.multiview.widgets;
 
 import com.jme3.gde.materials.MaterialProperty;
@@ -12,16 +38,19 @@ import javax.swing.JPanel;
  *
  * @author normenhansen
  */
-public abstract class MaterialPropertyWidget extends JPanel{
+public abstract class MaterialPropertyWidget extends JPanel {
+
     protected MaterialProperty property;
     private MaterialWidgetListener listener;
 
-    public void registerChangeListener(MaterialWidgetListener listener){
-        this.listener=listener;
+    public void registerChangeListener(MaterialWidgetListener listener) {
+        this.listener = listener;
     }
 
-    protected void fireChanged(){
-        if(listener==null) return;
+    protected void fireChanged() {
+        if (listener == null) {
+            return;
+        }
         listener.propertyChanged(property);
     }
 
@@ -41,9 +70,9 @@ public abstract class MaterialPropertyWidget extends JPanel{
     }
 
     protected abstract void readProperty();
-    
-    public void cleanUp(){
-        
+
+    public void cleanUp() {
+
     }
 
 }

+ 29 - 3
jme3-materialeditor/src/com/jme3/gde/materials/multiview/widgets/MaterialWidgetListener.java

@@ -1,8 +1,34 @@
 /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
+ *  Copyright (c) 2009-2018 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.materials.multiview.widgets;
 
 import com.jme3.gde.materials.MaterialProperty;