Browse Source

some formatting and documentation

rickard 3 years ago
parent
commit
4804104266

+ 8 - 11
jme3-materialeditor/src/com/jme3/gde/materialdefinition/fileStructure/DefinesBlock.java

@@ -1,7 +1,3 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
 package com.jme3.gde.materialdefinition.fileStructure;
 package com.jme3.gde.materialdefinition.fileStructure;
 
 
 import com.jme3.gde.materialdefinition.fileStructure.leaves.DefineBlock;
 import com.jme3.gde.materialdefinition.fileStructure.leaves.DefineBlock;
@@ -9,30 +5,31 @@ import com.jme3.util.blockparser.Statement;
 import java.util.List;
 import java.util.List;
 
 
 /**
 /**
- *
+ * Handles the surrounding statement of Defines{} in a MaterialDefinition
+ * Each row is a DefineBlock
  * @author rickard
  * @author rickard
  */
  */
-public class DefinesBlock extends UberStatement {
-    
+public final class DefinesBlock extends UberStatement {
+
     protected DefinesBlock(int lineNumber, String line) {
     protected DefinesBlock(int lineNumber, String line) {
         super(lineNumber, line);
         super(lineNumber, line);
     }
     }
-    
+
     public DefinesBlock(Statement sta) {
     public DefinesBlock(Statement sta) {
         this(sta.getLineNumber(), sta.getLine());
         this(sta.getLineNumber(), sta.getLine());
         for (Statement statement : sta.getContents()) {
         for (Statement statement : sta.getContents()) {
             addStatement(new DefineBlock(statement));
             addStatement(new DefineBlock(statement));
         }
         }
     }
     }
-    
+
     public List<DefineBlock> getDefineBlocks() {
     public List<DefineBlock> getDefineBlocks() {
         return getBlocks(DefineBlock.class);
         return getBlocks(DefineBlock.class);
     }
     }
-    
+
     public void addDefineBlock(DefineBlock block) {
     public void addDefineBlock(DefineBlock block) {
         contents.add(block);
         contents.add(block);
     }
     }
-    
+
     public void removeDefineBlock(DefineBlock block) {
     public void removeDefineBlock(DefineBlock block) {
         contents.remove(block);
         contents.remove(block);
     }
     }

+ 62 - 62
jme3-materialeditor/src/com/jme3/gde/materialdefinition/fileStructure/UberStatement.java

@@ -1,62 +1,62 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package com.jme3.gde.materialdefinition.fileStructure;
-
-import com.jme3.util.blockparser.Statement;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- *
- * @author Nehon
- */
-@SuppressWarnings({"unchecked", "rawtypes"})
-public class UberStatement extends Statement {
-
-    private List listeners = Collections.synchronizedList(new LinkedList());
-
-    public void addPropertyChangeListener(PropertyChangeListener pcl) {
-        listeners.add(pcl);
-    }
-
-    public void removePropertyChangeListener(PropertyChangeListener pcl) {
-        listeners.remove(pcl);
-    }
-
-    protected void fire(String propertyName, Object old, Object nue) {
-        //Passing 0 below on purpose, so you only synchronize for one atomic call:
-        PropertyChangeListener[] pcls = (PropertyChangeListener[]) listeners.toArray(new PropertyChangeListener[0]);
-        for (int i = 0; i < pcls.length; i++) {
-            pcls[i].propertyChange(new PropertyChangeEvent(this, propertyName, old, nue));
-        }
-    }
-
-    public UberStatement(int lineNumber, String line) {
-        super(lineNumber, line);
-    }
-
-    protected <T extends Statement> T getBlock(Class<T> blockType) {
-        for (Statement statement : contents) {
-            if (statement.getClass().isAssignableFrom(blockType)) {
-                return (T) statement;
-            }
-        }
-        return null;
-    }
-
-    protected <T extends Statement> List<T> getBlocks(Class<T> blockType) {
-        List<T> blocks = new ArrayList<T>();
-        for (Statement statement : contents) {
-            if (statement.getClass().isAssignableFrom(blockType)) {
-                blocks.add((T) statement);
-            }
-        }
-        return blocks;
-    }
-}
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.jme3.gde.materialdefinition.fileStructure;
+
+import com.jme3.util.blockparser.Statement;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * A statement that will be enclosed with curly braces
+ * @author Nehon
+ */
+@SuppressWarnings({"unchecked", "rawtypes"})
+public class UberStatement extends Statement {
+
+    private List listeners = Collections.synchronizedList(new LinkedList());
+
+    public void addPropertyChangeListener(PropertyChangeListener pcl) {
+        listeners.add(pcl);
+    }
+
+    public void removePropertyChangeListener(PropertyChangeListener pcl) {
+        listeners.remove(pcl);
+    }
+
+    protected void fire(String propertyName, Object old, Object nue) {
+        //Passing 0 below on purpose, so you only synchronize for one atomic call:
+        PropertyChangeListener[] pcls = (PropertyChangeListener[]) listeners.toArray(new PropertyChangeListener[0]);
+        for (int i = 0; i < pcls.length; i++) {
+            pcls[i].propertyChange(new PropertyChangeEvent(this, propertyName, old, nue));
+        }
+    }
+
+    public UberStatement(int lineNumber, String line) {
+        super(lineNumber, line);
+    }
+
+    protected <T extends Statement> T getBlock(Class<T> blockType) {
+        for (Statement statement : contents) {
+            if (statement.getClass().isAssignableFrom(blockType)) {
+                return (T) statement;
+            }
+        }
+        return null;
+    }
+
+    protected <T extends Statement> List<T> getBlocks(Class<T> blockType) {
+        List<T> blocks = new ArrayList<T>();
+        for (Statement statement : contents) {
+            if (statement.getClass().isAssignableFrom(blockType)) {
+                blocks.add((T) statement);
+            }
+        }
+        return blocks;
+    }
+}

+ 9 - 15
jme3-materialeditor/src/com/jme3/gde/materialdefinition/fileStructure/leaves/DefineBlock.java

@@ -1,20 +1,16 @@
-/*
- * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
- * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
- */
 package com.jme3.gde.materialdefinition.fileStructure.leaves;
 package com.jme3.gde.materialdefinition.fileStructure.leaves;
 
 
 import com.jme3.util.blockparser.Statement;
 import com.jme3.util.blockparser.Statement;
 import java.util.Objects;
 import java.util.Objects;
 
 
 /**
 /**
- *
+ * Handles one row of Defines in a MaterialDef, ie ALBEDOMAP : AlbedoMap
  * @author rickard
  * @author rickard
  */
  */
-public class DefineBlock extends LeafStatement{
-    
-    protected String name;
-    protected String define;
+public final class DefineBlock extends LeafStatement {
+
+    private String name;
+    private String define;
 
 
     protected DefineBlock(int lineNumber, String line) {
     protected DefineBlock(int lineNumber, String line) {
         super(lineNumber, line);
         super(lineNumber, line);
@@ -23,7 +19,7 @@ public class DefineBlock extends LeafStatement{
     public DefineBlock(Statement sta) {
     public DefineBlock(Statement sta) {
         this(sta.getLineNumber(), sta.getLine());
         this(sta.getLineNumber(), sta.getLine());
         parse(sta);
         parse(sta);
-         updateLine();
+        updateLine();
     }
     }
 
 
     public DefineBlock(String name, String define) {
     public DefineBlock(String name, String define) {
@@ -54,8 +50,6 @@ public class DefineBlock extends LeafStatement{
         this.define = define;
         this.define = define;
         updateLine();
         updateLine();
     }
     }
-    
-    
 
 
     private void parse(Statement sta) {
     private void parse(Statement sta) {
         String[] values = sta.getLine().split(":");
         String[] values = sta.getLine().split(":");
@@ -73,10 +67,10 @@ public class DefineBlock extends LeafStatement{
 
 
     @Override
     @Override
     public boolean equals(Object obj) {
     public boolean equals(Object obj) {
-        if(!(obj instanceof DefineBlock)){
+        if (!(obj instanceof DefineBlock)) {
             return false;
             return false;
         }
         }
-        return ((DefineBlock)obj).getName().equals(name) && ((DefineBlock)obj).getDefine().equals(define);
+        return ((DefineBlock) obj).getName().equals(name) && ((DefineBlock) obj).getDefine().equals(define);
     }
     }
-    
+
 }
 }

+ 43 - 43
jme3-materialeditor/src/com/jme3/gde/materialdefinition/fileStructure/leaves/LeafStatement.java

@@ -1,43 +1,43 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package com.jme3.gde.materialdefinition.fileStructure.leaves;
-
-import com.jme3.util.blockparser.Statement;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- *
- * @author Nehon
- */
-@SuppressWarnings({"unchecked", "rawtypes"})
-public class LeafStatement extends Statement {
-
-    private List listeners = Collections.synchronizedList(new LinkedList());
-
-    public void addPropertyChangeListener(PropertyChangeListener pcl) {
-        listeners.add(pcl);
-    }
-
-    public void removePropertyChangeListener(PropertyChangeListener pcl) {
-        listeners.remove(pcl);
-    }
-
-    protected void fire(String propertyName, Object old, Object nue) {
-        //Passing 0 below on purpose, so you only synchronize for one atomic call:
-        PropertyChangeListener[] pcls = (PropertyChangeListener[]) listeners.toArray(new PropertyChangeListener[0]);
-        for (int i = 0; i < pcls.length; i++) {
-            pcls[i].propertyChange(new PropertyChangeEvent(this, propertyName, old, nue));
-        }
-    }
-
-    public LeafStatement(int lineNumber, String line) {
-        super(lineNumber, line);
-        contents = null;
-    }
-}
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.jme3.gde.materialdefinition.fileStructure.leaves;
+
+import com.jme3.util.blockparser.Statement;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * A statement that will not be decorated
+ * @author Nehon
+ */
+@SuppressWarnings({"unchecked", "rawtypes"})
+public class LeafStatement extends Statement {
+
+    private List listeners = Collections.synchronizedList(new LinkedList());
+
+    public void addPropertyChangeListener(PropertyChangeListener pcl) {
+        listeners.add(pcl);
+    }
+
+    public void removePropertyChangeListener(PropertyChangeListener pcl) {
+        listeners.remove(pcl);
+    }
+
+    protected void fire(String propertyName, Object old, Object nue) {
+        //Passing 0 below on purpose, so you only synchronize for one atomic call:
+        PropertyChangeListener[] pcls = (PropertyChangeListener[]) listeners.toArray(new PropertyChangeListener[0]);
+        for (int i = 0; i < pcls.length; i++) {
+            pcls[i].propertyChange(new PropertyChangeEvent(this, propertyName, old, nue));
+        }
+    }
+
+    public LeafStatement(int lineNumber, String line) {
+        super(lineNumber, line);
+        contents = null;
+    }
+}