Browse Source

First part of a big refactoring: Refactored the Shader Nodes Material Editor to a more abstract interface for node editors in general and a shader-node-specific implementation. If something in the ShaderNodes Editor breaks it should A) be easier to spot now and B) simplify generating other edditors based on this one.

If you experience new problems after this commit, raise an issue, I tried to be careful but sometimes one messes up the order of initialization or something.
MeFisto94 6 years ago
parent
commit
0e1ba16dee
29 changed files with 1219 additions and 950 deletions
  1. 4 4
      jme3-materialeditor/nbproject/genfiles.properties
  2. 1 0
      jme3-materialeditor/src/com/jme3/gde/materialdefinition/dialog/AddAttributeDialog.form
  3. 33 6
      jme3-materialeditor/src/com/jme3/gde/materialdefinition/dialog/AddAttributeDialog.java
  4. 1 0
      jme3-materialeditor/src/com/jme3/gde/materialdefinition/dialog/AddMaterialParameterDialog.form
  5. 33 5
      jme3-materialeditor/src/com/jme3/gde/materialdefinition/dialog/AddMaterialParameterDialog.java
  6. 33 6
      jme3-materialeditor/src/com/jme3/gde/materialdefinition/dialog/AddNodeDialog.java
  7. 1 0
      jme3-materialeditor/src/com/jme3/gde/materialdefinition/dialog/AddWorldParameterDialog.form
  8. 33 6
      jme3-materialeditor/src/com/jme3/gde/materialdefinition/dialog/AddWorldParameterDialog.java
  9. 6 6
      jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/BackdropPanel.form
  10. 38 5
      jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/BackdropPanel.java
  11. 6 3
      jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/Bundle.properties
  12. 41 6
      jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/Connection.java
  13. 57 27
      jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/ConnectionCurve.java
  14. 67 27
      jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/ConnectionStraight.java
  15. 278 412
      jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/Diagram.java
  16. 46 11
      jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/DraggablePanel.java
  17. 29 2
      jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/InOut.java
  18. 33 6
      jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/MatDefEditorToolBar.java
  19. 1 1
      jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/MatDefEditorlElement.form
  20. 58 40
      jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/MatDefEditorlElement.java
  21. 5 5
      jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/MatPanel.form
  22. 33 5
      jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/MatPanel.java
  23. 160 247
      jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/NodePanel.java
  24. 65 93
      jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/NodeToolBar.java
  25. 31 6
      jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/Selectable.java
  26. 35 8
      jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/ShaderEditPanel.java
  27. 29 4
      jme3-materialeditor/src/com/jme3/gde/materialdefinition/fileStructure/leaves/MappingBlock.java
  28. 33 6
      jme3-materialeditor/src/com/jme3/gde/materialdefinition/icons/Icons.java
  29. 29 3
      jme3-materialeditor/src/com/jme3/gde/materialdefinition/utils/MaterialUtils.java

+ 4 - 4
jme3-materialeditor/nbproject/genfiles.properties

@@ -1,8 +1,8 @@
-build.xml.data.CRC32=ee2a0a5d
+build.xml.data.CRC32=f88d9f31
 build.xml.script.CRC32=f284e28d
[email protected]1.1
[email protected]2.1
 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=ee2a0a5d
+nbproject/build-impl.xml.data.CRC32=f88d9f31
 nbproject/build-impl.xml.script.CRC32=56cee44d
-nbproject/[email protected]1.1
+nbproject/[email protected]2.1

+ 1 - 0
jme3-materialeditor/src/com/jme3/gde/materialdefinition/dialog/AddAttributeDialog.form

@@ -10,6 +10,7 @@
   </Properties>
   <SyntheticProperties>
     <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+    <SyntheticProperty name="generateCenter" type="boolean" value="false"/>
   </SyntheticProperties>
   <AuxValues>
     <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>

+ 33 - 6
jme3-materialeditor/src/com/jme3/gde/materialdefinition/dialog/AddAttributeDialog.java

@@ -1,10 +1,37 @@
 /*
- * 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.materialdefinition.dialog;
 
-import com.jme3.gde.materialdefinition.editor.Diagram;
+import com.jme3.gde.materialdefinition.editor.ShaderNodeDiagram;
 import com.jme3.scene.VertexBuffer;
 import java.awt.Point;
 import javax.swing.DefaultComboBoxModel;
@@ -16,13 +43,13 @@ import javax.swing.DefaultComboBoxModel;
 @SuppressWarnings({"unchecked", "rawtypes"})
 public class AddAttributeDialog extends javax.swing.JDialog {
 
-    private Diagram diagram;
-    private Point clickPosition;
+    private final ShaderNodeDiagram diagram;
+    private final Point clickPosition;
 
     /**
      * Creates new form AddMaterialParameter
      */
-    public AddAttributeDialog(java.awt.Frame parent, boolean modal, Diagram diagram, Point clickPosition) {
+    public AddAttributeDialog(java.awt.Frame parent, boolean modal, ShaderNodeDiagram diagram, Point clickPosition) {
         super(parent, modal);
         initComponents();
         DefaultComboBoxModel model = new DefaultComboBoxModel();

+ 1 - 0
jme3-materialeditor/src/com/jme3/gde/materialdefinition/dialog/AddMaterialParameterDialog.form

@@ -10,6 +10,7 @@
   </Properties>
   <SyntheticProperties>
     <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+    <SyntheticProperty name="generateCenter" type="boolean" value="false"/>
   </SyntheticProperties>
   <AuxValues>
     <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>

+ 33 - 5
jme3-materialeditor/src/com/jme3/gde/materialdefinition/dialog/AddMaterialParameterDialog.java

@@ -1,10 +1,38 @@
 /*
- * 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.materialdefinition.dialog;
 
 import com.jme3.gde.materialdefinition.editor.Diagram;
+import com.jme3.gde.materialdefinition.editor.ShaderNodeDiagram;
 import com.jme3.shader.VarType;
 import java.awt.Point;
 import java.awt.event.KeyEvent;
@@ -17,13 +45,13 @@ import javax.swing.DefaultComboBoxModel;
 @SuppressWarnings({"unchecked", "rawtypes"})
 public class AddMaterialParameterDialog extends javax.swing.JDialog {
 
-    private Diagram diagram;
-    private Point clickPosition;
+    private final ShaderNodeDiagram diagram;
+    private final Point clickPosition;
 
     /**
      * Creates new form AddMaterialParameter
      */
-    public AddMaterialParameterDialog(java.awt.Frame parent, boolean modal, Diagram diagram, Point clickPosition) {
+    public AddMaterialParameterDialog(java.awt.Frame parent, boolean modal, ShaderNodeDiagram diagram, Point clickPosition) {
         super(parent, modal);
         initComponents();
         DefaultComboBoxModel model = new DefaultComboBoxModel();

+ 33 - 6
jme3-materialeditor/src/com/jme3/gde/materialdefinition/dialog/AddNodeDialog.java

@@ -1,13 +1,40 @@
 /*
- * 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.materialdefinition.dialog;
 
 import com.jme3.asset.ShaderNodeDefinitionKey;
 import com.jme3.gde.core.assets.ProjectAssetManager;
 import com.jme3.gde.core.util.TreeUtil;
-import com.jme3.gde.materialdefinition.editor.Diagram;
+import com.jme3.gde.materialdefinition.editor.ShaderNodeDiagram;
 import com.jme3.gde.materialdefinition.icons.Icons;
 import com.jme3.gde.materialdefinition.utils.DocFormatter;
 import com.jme3.shader.Shader;
@@ -31,14 +58,14 @@ import javax.swing.tree.TreeSelectionModel;
 public class AddNodeDialog extends javax.swing.JDialog {
 
     private List<ShaderNodeDefinition> defList = new ArrayList<ShaderNodeDefinition>();
-    private Diagram diagram;
-    private Point clickPosition;
+    private final ShaderNodeDiagram diagram;
+    private final Point clickPosition;
     private String path;
 
     /**
      * Creates new form NewJDialog
      */
-    public AddNodeDialog(java.awt.Frame parent, boolean modal, ProjectAssetManager mgr, Diagram diagram, Point clickPosition) {
+    public AddNodeDialog(java.awt.Frame parent, boolean modal, ProjectAssetManager mgr, ShaderNodeDiagram diagram, Point clickPosition) {
         super(parent, modal);
         this.diagram = diagram;
         initComponents();

+ 1 - 0
jme3-materialeditor/src/com/jme3/gde/materialdefinition/dialog/AddWorldParameterDialog.form

@@ -10,6 +10,7 @@
   </Properties>
   <SyntheticProperties>
     <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+    <SyntheticProperty name="generateCenter" type="boolean" value="false"/>
   </SyntheticProperties>
   <AuxValues>
     <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>

+ 33 - 6
jme3-materialeditor/src/com/jme3/gde/materialdefinition/dialog/AddWorldParameterDialog.java

@@ -1,10 +1,37 @@
 /*
- * 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.materialdefinition.dialog;
 
-import com.jme3.gde.materialdefinition.editor.Diagram;
+import com.jme3.gde.materialdefinition.editor.ShaderNodeDiagram;
 import com.jme3.shader.UniformBinding;
 import java.awt.Point;
 import javax.swing.DefaultComboBoxModel;
@@ -16,13 +43,13 @@ import javax.swing.DefaultComboBoxModel;
 @SuppressWarnings({"unchecked", "rawtypes"})
 public class AddWorldParameterDialog extends javax.swing.JDialog {
 
-    private Diagram diagram;
-    private Point clickPosition;
+    private final ShaderNodeDiagram diagram;
+    private final Point clickPosition;
 
     /**
      * Creates new form AddMaterialParameter
      */
-    public AddWorldParameterDialog(java.awt.Frame parent, boolean modal, Diagram diagram, Point clickPosition) {
+    public AddWorldParameterDialog(java.awt.Frame parent, boolean modal, ShaderNodeDiagram diagram, Point clickPosition) {
         super(parent, modal);
         initComponents();
         DefaultComboBoxModel model = new DefaultComboBoxModel();

+ 6 - 6
jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/BackdropPanel.form

@@ -68,7 +68,7 @@
             <Property name="borderPainted" type="boolean" value="false"/>
             <Property name="contentAreaFilled" type="boolean" value="false"/>
             <Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
-              <Color id="Curseur par d&#xe9;faut"/>
+              <Color id="Standardcursor"/>
             </Property>
             <Property name="focusable" type="boolean" value="false"/>
             <Property name="iconTextGap" type="int" value="0"/>
@@ -105,7 +105,7 @@
             <Property name="borderPainted" type="boolean" value="false"/>
             <Property name="contentAreaFilled" type="boolean" value="false"/>
             <Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
-              <Color id="Curseur par d&#xe9;faut"/>
+              <Color id="Standardcursor"/>
             </Property>
             <Property name="focusable" type="boolean" value="false"/>
             <Property name="iconTextGap" type="int" value="0"/>
@@ -142,7 +142,7 @@
             <Property name="borderPainted" type="boolean" value="false"/>
             <Property name="contentAreaFilled" type="boolean" value="false"/>
             <Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
-              <Color id="Curseur par d&#xe9;faut"/>
+              <Color id="Standardcursor"/>
             </Property>
             <Property name="focusable" type="boolean" value="false"/>
             <Property name="iconTextGap" type="int" value="0"/>
@@ -179,7 +179,7 @@
             <Property name="borderPainted" type="boolean" value="false"/>
             <Property name="contentAreaFilled" type="boolean" value="false"/>
             <Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
-              <Color id="Curseur par d&#xe9;faut"/>
+              <Color id="Standardcursor"/>
             </Property>
             <Property name="focusable" type="boolean" value="false"/>
             <Property name="iconTextGap" type="int" value="0"/>
@@ -216,7 +216,7 @@
             <Property name="borderPainted" type="boolean" value="false"/>
             <Property name="contentAreaFilled" type="boolean" value="false"/>
             <Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
-              <Color id="Curseur par d&#xe9;faut"/>
+              <Color id="Standardcursor"/>
             </Property>
             <Property name="focusable" type="boolean" value="false"/>
             <Property name="iconTextGap" type="int" value="0"/>
@@ -253,7 +253,7 @@
             <Property name="borderPainted" type="boolean" value="false"/>
             <Property name="contentAreaFilled" type="boolean" value="false"/>
             <Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
-              <Color id="Curseur par d&#xe9;faut"/>
+              <Color id="Standardcursor"/>
             </Property>
             <Property name="focusable" type="boolean" value="false"/>
             <Property name="iconTextGap" type="int" value="0"/>

+ 38 - 5
jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/BackdropPanel.java

@@ -1,7 +1,33 @@
 /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, 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.materialdefinition.editor;
 
@@ -16,6 +42,7 @@ import java.awt.event.ComponentEvent;
 import java.awt.event.MouseEvent;
 import java.awt.event.MouseListener;
 import java.awt.event.MouseMotionListener;
+import javax.swing.JPanel;
 import javax.swing.JScrollPane;
 import javax.swing.JViewport;
 import javax.swing.SwingUtilities;
@@ -24,10 +51,12 @@ import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;
 
 /**
- *
+ * The ShaderBackdrop Panel is the Material renderer in the background of the
+ * ShaderNodes Editor. It can be placed behind all the out-busses but can also
+ * be toggled to be drawn infront of everything
  * @author Nehon
  */
-public class BackdropPanel extends javax.swing.JPanel implements MouseListener, ChangeListener,MouseMotionListener {
+public class BackdropPanel extends JPanel implements MouseListener, ChangeListener,MouseMotionListener {
 
     private final MaterialPreviewRenderer renderer;
     private Material mat;
@@ -440,6 +469,7 @@ public class BackdropPanel extends javax.swing.JPanel implements MouseListener,
         t.restart();
     }
 
+    @Override
     public void stateChanged(ChangeEvent e) {
         JViewport vp = (JViewport) e.getSource();
         update(vp);
@@ -448,6 +478,7 @@ public class BackdropPanel extends javax.swing.JPanel implements MouseListener,
 
     private final Timer recalculateTimer = new Timer(20, new ActionListener() {
 
+        @Override
         public void actionPerformed(ActionEvent e) {
             refresh();
         }
@@ -481,6 +512,7 @@ public class BackdropPanel extends javax.swing.JPanel implements MouseListener,
         }
     }
 
+    @Override
     public void mouseDragged(MouseEvent e) {
         Container c = getParent();
         if (c != null) {
@@ -488,6 +520,7 @@ public class BackdropPanel extends javax.swing.JPanel implements MouseListener,
         }
     }
 
+    @Override
     public void mouseMoved(MouseEvent e) {
         Container c = getParent();
         if (c != null) {

+ 6 - 3
jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/Bundle.properties

@@ -9,10 +9,13 @@ BackdropPanel.quadButton.toolTipText=Quad
 BackdropPanel.reloadButton.toolTipText=Refresh
 BackdropPanel.boxButton.toolTipText=Cube
 BackdropPanel.bringToFrontButton.toolTipText=Toggle back/front
-NodeToolBar.codeButton.toolTipText=Display code
-NodeToolBar.deleteButton.toolTipText=Delete node
-NodeToolBar.deleteButton.text=
 MatDefEditorToolBar.jLabel1.text=Technique
 MatDefEditorToolBar.jButton1.text=Add
 MatDefEditorToolBar.jButton1.toolTipText=Add a new technique
 MatDefEditorToolBar.jButton2.text=Auto layout
+ShaderNodeToolBar.deleteButton.toolTipText=Delete node
+ShaderNodeToolBar.deleteButton.text=
+ShaderNodeToolBar.codeButton.toolTipText=Display code
+NodeToolBar.deleteButton.toolTipText=Delete node
+NodeToolBar.deleteButton.text=
+NodeToolBar.codeButton.toolTipText=Display code

+ 41 - 6
jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/Connection.java

@@ -1,17 +1,52 @@
 /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, 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.materialdefinition.editor;
 
 /**
- *
+ * Form a Connection between two ConnectionEndpoints
  * @author Nehon
  */
-public class Connection extends ConnectionCurve{
+public class Connection extends ConnectionCurve {
 
-    public Connection(Dot start, Dot end) {
+    /**
+     * Create a new Instance of Connection.
+     * Don't call this from Usercode, call 
+     * {@link Diagram#connect(com.jme3.gde.materialdefinition.editor.ConnectionEndpoint,
+     * com.jme3.gde.materialdefinition.editor.ConnectionEndpoint)  } instead.
+     * 
+     * @param start The Connection Start
+     * @param end The Connection End
+     */
+    public Connection(ConnectionEndpoint start, ConnectionEndpoint end) {
         super(start, end);
     }
     

+ 57 - 27
jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/ConnectionCurve.java

@@ -1,11 +1,36 @@
 /*
- * 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.materialdefinition.editor;
 
-import com.jme3.gde.materialdefinition.fileStructure.leaves.MappingBlock;
-import com.jme3.gde.materialdefinition.utils.MaterialUtils;
 import java.awt.BasicStroke;
 import java.awt.Color;
 import java.awt.Graphics;
@@ -31,16 +56,17 @@ import javax.swing.event.MouseInputListener;
  *
  * @author Nehon
  */
-public class ConnectionCurve extends JPanel implements ComponentListener, MouseInputListener, KeyListener, Selectable, PropertyChangeListener {
-
-    protected Dot start;
-    protected Dot end;
+public class ConnectionCurve extends JPanel implements ComponentListener, 
+        MouseInputListener, KeyListener, Selectable, PropertyChangeListener {
+    
+    protected ConnectionEndpoint start;
+    protected ConnectionEndpoint end;
     private final Point[] points = new Point[7];
     private int pointsSize = 7;
     private int nbCurve = 2;
     private final CubicCurve2D[] curves = new CubicCurve2D[2];    
     private String key = "";
-    protected MappingBlock mapping;
+    protected Object mapping; // used to be "Mapping" but is implementation specific
 
     private MouseEvent convertEvent(MouseEvent e) {
         MouseEvent me = null;
@@ -68,11 +94,10 @@ public class ConnectionCurve extends JPanel implements ComponentListener, MouseI
     }
     
     @SuppressWarnings("LeakingThisInConstructor")
-    public ConnectionCurve(Dot start, Dot end) {
-
-        if (start.getParamType() == Dot.ParamType.Output
-                || (start.getParamType() == Dot.ParamType.Both && end.getParamType() != Dot.ParamType.Output)
-                || (end.getParamType() == Dot.ParamType.Both && start.getParamType() != Dot.ParamType.Input)) {
+    public ConnectionCurve(ConnectionEndpoint start, ConnectionEndpoint end) {
+        if (start.getParamType() == ConnectionEndpoint.ParamType.Output
+                || (start.getParamType() == ConnectionEndpoint.ParamType.Both && end.getParamType() != ConnectionEndpoint.ParamType.Output)
+                || (end.getParamType() == ConnectionEndpoint.ParamType.Both && start.getParamType() != ConnectionEndpoint.ParamType.Input)) {
             this.start = start;
             this.end = end;
         } else {
@@ -109,14 +134,17 @@ public class ConnectionCurve extends JPanel implements ComponentListener, MouseI
         return key;
     }
 
-    protected void makeKey(MappingBlock mapping, String techName) {
-        this.mapping = mapping;
-        key = MaterialUtils.makeKey(mapping, techName);
+    protected void makeKey(Object mapping, String techName) {
+        if (this instanceof Connection) {
+            key = getDiagram().makeKeyForConnection((Connection)this, mapping);
+            this.mapping = mapping;
+        } else {
+            key = "error";
+        }
     }
 
     @Override
     protected void paintComponent(Graphics g) {
-
         Graphics2D g2 = ((Graphics2D) g);
         g2.setRenderingHint(
                 RenderingHints.KEY_ANTIALIASING,
@@ -231,18 +259,18 @@ public class ConnectionCurve extends JPanel implements ComponentListener, MouseI
 
     }
 
-    public final void resize(Dot start, Dot end) {
+    public final void resize(ConnectionEndpoint start, ConnectionEndpoint end) {
         Point startLocation = start.getStartLocation();
         Point endLocation = end.getEndLocation();
 
-        if (start.getParamType() == Dot.ParamType.Both) {
+        if (start.getParamType() == ConnectionEndpoint.ParamType.Both) {
             startLocation.x = endLocation.x - MARGIN * 2;
             pointsSize = 3;
             points[0].setLocation(startLocation);
             points[1].x = startLocation.x;
             points[1].y = endLocation.y;
             points[2].setLocation(endLocation);
-        } else if (end.getParamType() == Dot.ParamType.Both) {
+        } else if (end.getParamType() == ConnectionEndpoint.ParamType.Both) {
             endLocation.x = startLocation.x + MARGIN * 2;
             pointsSize = 3;
             points[0].setLocation(startLocation);
@@ -376,7 +404,6 @@ public class ConnectionCurve extends JPanel implements ComponentListener, MouseI
     }
 
     public void select(MouseEvent e) {
-
         requestFocusInWindow(true);
         int margin = MARGIN / 2;
         boolean selected = false;
@@ -405,7 +432,6 @@ public class ConnectionCurve extends JPanel implements ComponentListener, MouseI
 
     @Override
     public void keyPressed(KeyEvent e) {
-
         if (e.getKeyCode() == KeyEvent.VK_DELETE) {
             Diagram diag = getDiagram();
             diag.removeSelected();
@@ -434,16 +460,20 @@ public class ConnectionCurve extends JPanel implements ComponentListener, MouseI
     }
 
     @Override
+    /**
+     * Specific implementations register this class as propertyChangeListener.
+     * This method is called when the "mapping" changes.
+     */
     public void propertyChange(PropertyChangeEvent evt) {
-        MappingBlock map = (MappingBlock) evt.getSource();
-        key = MaterialUtils.makeKey(map, getDiagram().getCurrentTechniqueName());
+        key = getDiagram().makeKeyForConnection((Connection)this, evt.getSource());
+        this.mapping = evt.getSource(); // The original code did not save the new mapping.
     }
 
-    public Dot getStart() {
+    public ConnectionEndpoint getStart() {
         return start;
     }
 
-    public Dot getEnd() {
+    public ConnectionEndpoint getEnd() {
         return end;
     }
     

+ 67 - 27
jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/ConnectionStraight.java

@@ -1,11 +1,37 @@
 /*
- * 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.materialdefinition.editor;
 
 import com.jme3.gde.materialdefinition.fileStructure.leaves.MappingBlock;
-import com.jme3.gde.materialdefinition.utils.MaterialUtils;
 import java.awt.Color;
 import java.awt.Graphics;
 import java.awt.Point;
@@ -29,15 +55,16 @@ import javax.swing.event.MouseInputListener;
  * @author Nehon
  */
 @Deprecated
-public class ConnectionStraight extends JPanel implements ComponentListener, MouseInputListener, KeyListener, Selectable, PropertyChangeListener {
+public class ConnectionStraight extends JPanel implements ComponentListener, 
+        MouseInputListener, KeyListener, Selectable, PropertyChangeListener {
 
-    protected Dot start;
-    protected Dot end;
-    private Point[] points = new Point[6];
+    protected ConnectionEndpoint start;
+    protected ConnectionEndpoint end;
+    private final Point[] points = new Point[6];
     private int pointsSize = 6;
-    private Corner[] corners = new Corner[6];
+    private final Corner[] corners = new Corner[6];
     private String key = "";
-    protected MappingBlock mapping;
+    protected Object mapping;
 
     private MouseEvent convertEvent(MouseEvent e) {
         MouseEvent me = null;
@@ -78,12 +105,12 @@ public class ConnectionStraight extends JPanel implements ComponentListener, Mou
         Bottom,
         None,}
 
-    public ConnectionStraight(Dot start, Dot end) {
+    public ConnectionStraight(ConnectionEndpoint start, ConnectionEndpoint end) {
 
 
-        if (start.getParamType() == Dot.ParamType.Output
-                || (start.getParamType() == Dot.ParamType.Both && end.getParamType() != Dot.ParamType.Output)
-                || (end.getParamType() == Dot.ParamType.Both && start.getParamType() != Dot.ParamType.Input)) {
+        if (start.getParamType() == ConnectionEndpoint.ParamType.Output
+                || (start.getParamType() == ConnectionEndpoint.ParamType.Both && end.getParamType() != ConnectionEndpoint.ParamType.Output)
+                || (end.getParamType() == ConnectionEndpoint.ParamType.Both && start.getParamType() != ConnectionEndpoint.ParamType.Input)) {
             this.start = start;
             this.end = end;
         } else {
@@ -107,12 +134,12 @@ public class ConnectionStraight extends JPanel implements ComponentListener, Mou
         store.x = p.x - getLocation().x - 1;
         store.y = p.y - getLocation().y - 1;
     }
-    private Point p1 = new Point();
-    private Point p2 = new Point();
-    private Point tp1 = new Point();
-    private Point bp1 = new Point();
-    private Point tp2 = new Point();
-    private Point bp2 = new Point();
+    private final Point p1 = new Point();
+    private final Point p2 = new Point();
+    private final Point tp1 = new Point();
+    private final Point bp1 = new Point();
+    private final Point tp2 = new Point();
+    private final Point bp2 = new Point();
 
     @Override
     protected void paintBorder(Graphics g) {
@@ -130,9 +157,16 @@ public class ConnectionStraight extends JPanel implements ComponentListener, Mou
         return key;
     }
 
-    protected void makeKey(MappingBlock mapping, String techName) {
-        this.mapping = mapping;
-        key = MaterialUtils.makeKey(mapping, techName);
+    protected void makeKey(Object mapping, String techName) {
+        /* Doesn't work as Connection doesnt extend ConnectionStraight. Actually
+         * those classes should've been made the other way round: ConnectionStraight
+         * extending Connection and not the opposite way.
+        if (this instanceof Connection) {
+            key = getDiagram().makeKeyForConnection(this, mapping);
+            this.mapping = mapping;
+        } else { */
+            key = "error";
+        /* } */
     }
 
     private void adjustCorners(Corner corner, Point tp, Point bp) {
@@ -277,11 +311,11 @@ public class ConnectionStraight extends JPanel implements ComponentListener, Mou
 
     }
 
-    public final void resize(Dot start, Dot end) {
+    public final void resize(ConnectionEndpoint start, ConnectionEndpoint end) {
         Point startLocation = start.getStartLocation();
         Point endLocation = end.getEndLocation();
 
-        if (start.getParamType() == Dot.ParamType.Both) {
+        if (start.getParamType() == ConnectionEndpoint.ParamType.Both) {
             startLocation.x = endLocation.x - MARGIN * 2;
             pointsSize = 3;
             points[0].setLocation(startLocation);
@@ -297,7 +331,7 @@ public class ConnectionStraight extends JPanel implements ComponentListener, Mou
                 corners[1] = Corner.TopRight;
                 corners[2] = Corner.None;
             }
-        } else if (end.getParamType() == Dot.ParamType.Both) {
+        } else if (end.getParamType() == ConnectionEndpoint.ParamType.Both) {
             endLocation.x = startLocation.x + MARGIN * 2;
             pointsSize = 3;
             points[0].setLocation(startLocation);
@@ -520,21 +554,27 @@ public class ConnectionStraight extends JPanel implements ComponentListener, Mou
     public void keyReleased(KeyEvent e) {
     }
 
+    @Override
     public void componentResized(ComponentEvent e) {
     }
 
+    @Override
     public void componentMoved(ComponentEvent e) {
         resize(start, end);
     }
 
+    @Override
     public void componentShown(ComponentEvent e) {
     }
 
+    @Override
     public void componentHidden(ComponentEvent e) {
     }
 
+    @Override
     public void propertyChange(PropertyChangeEvent evt) {
-        MappingBlock mapping = (MappingBlock) evt.getSource();
-        key = MaterialUtils.makeKey(mapping, getDiagram().getCurrentTechniqueName());
+        mapping = (MappingBlock) evt.getSource();
+        key = "error";
+        //key = MaterialUtils.makeKey(mapping, getDiagram().getCurrentTechniqueName());
     }
 }

+ 278 - 412
jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/Diagram.java

@@ -1,6 +1,33 @@
 /*
- * 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.materialdefinition.editor;
 
@@ -48,50 +75,60 @@ import javax.swing.border.Border;
 import javax.swing.border.TitledBorder;
 
 /**
- *
+ * The Diagram is the main canvas where all nodes {@link NodePanel} and
+ * their connections {@link ConnectionEndpoint} {@link Connection} are added onto.
  * @author Nehon
  */
-public class Diagram extends JPanel implements MouseListener, MouseMotionListener, ComponentListener {
-
-    protected Dot draggedFrom;
-    protected Dot draggedTo;
+public abstract class Diagram extends JPanel implements MouseListener, 
+        MouseMotionListener, ComponentListener {
+    // Content
     protected List<Selectable> selectedItems = new ArrayList<Selectable>();
     protected List<Connection> connections = new ArrayList<Connection>();
     protected List<NodePanel> nodes = new ArrayList<NodePanel>();
-    protected List<OutBusPanel> outBuses = new ArrayList<OutBusPanel>();
-    private final MyMenu contextMenu = new MyMenu("Add");
-    private MatDefEditorlElement parent;
-    private String currentTechniqueName;
-    private final BackdropPanel backDrop = new BackdropPanel();
+    
+    // UI
+    protected final JPopupMenu contextMenu = new JPopupMenu("Add");
+    protected NodeEditor parent;
+    
+    // drag stuff
+    protected ConnectionEndpoint draggedFrom;
+    protected ConnectionEndpoint draggedTo;  
+    private final Point pp = new Point();
+    protected Point clickLoc = new Point(0, 0);    
+    
+    // dynamic switching between the regular and the move cursor (MMB)
     private final Cursor defCursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
     private final Cursor hndCursor = Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR);
-    private final Point pp = new Point();
+    
+    // filled in from componentResize()
+    protected int minWidth = 0;
+    protected int minHeight = 0;
 
     @SuppressWarnings("LeakingThisInConstructor")
     public Diagram() {
-
         addMouseListener(this);
         addMouseMotionListener(this);
         createPopupMenu();
     }
+    
+    /**
+     * This method is called from within the mousePressed event when the Left 
+     * Mouse Button is pressed. Use this if you need to run before the regular
+     * connection logic. The return value determines whether the event was consumed
+     * 
+     * @param e The Event
+     * @return Whether to continue passing the event (true) or to quit (false) 
+     */
+    protected abstract boolean mouseLMBPrePressedEvent(MouseEvent e);
 
     @Override
-    public void mouseClicked(MouseEvent e) {
-    }
+    public void mouseClicked(MouseEvent e) {}
 
     @Override
     public void mousePressed(MouseEvent e) {
-
-        if (e.getButton() == MouseEvent.BUTTON1) {
-            for (OutBusPanel outBusPanel : outBuses) {
-                Point p = SwingUtilities.convertPoint(this, e.getX(), e.getY(), outBusPanel);
-                if (outBusPanel.contains(p)) {
-                    MouseEvent me = SwingUtilities.convertMouseEvent(this, e, outBusPanel);
-                    outBusPanel.dispatchEvent(me);
-                    if (me.isConsumed()) {
-                        return;
-                    }
-                }
+        if (SwingUtilities.isLeftMouseButton(e)) {
+            if (mouseLMBPrePressedEvent(e)) {
+                return; // event already consumed
             }
 
             for (Connection connection : connections) {
@@ -105,48 +142,16 @@ public class Diagram extends JPanel implements MouseListener, MouseMotionListene
             selectedItems.clear();
             repaint();
         } else if (e.getButton() == MouseEvent.BUTTON2) {
+            // change to "move using mouse wheel button" and set the cursor
             setCursor(hndCursor);
             pp.setLocation(e.getPoint());
-            ((JScrollPane) getParent().getParent()).setWheelScrollingEnabled(false);
+            ((JScrollPane)getParent().getParent()).setWheelScrollingEnabled(false);
         }
     }
 
-    public void refreshPreviews(Material mat, String technique) {
-        for (OutBusPanel outBusPanel : outBuses) {
-            outBusPanel.updatePreview(mat, technique);
-        }
-        if (backDrop.isVisible()) {
-            backDrop.showMaterial(mat, technique);
-        }
-    }
-
-    public void displayBackdrop() {
-        if (backDrop.getParent() == null) {
-            add(backDrop);
-            ((JViewport) getParent()).addChangeListener(backDrop);
-        }
-
-        backDrop.setVisible(true);
-        backDrop.update(((JViewport) getParent()));
-    }
-
-    Point clickLoc = new Point(0, 0);
-
     @Override
     public void mouseReleased(MouseEvent e) {
-
         switch (e.getButton()) {
-            case MouseEvent.BUTTON1:
-                if (draggedFrom != null && draggedFrom.getNode() instanceof OutBusPanel) {
-                    MouseEvent me = SwingUtilities.convertMouseEvent(this, e, draggedFrom.getNode());
-                    draggedFrom.getNode().dispatchEvent(me);
-                    if (me.isConsumed()) {
-                        return;
-                    }
-                }
-
-                dispatchToOutBuses(e);
-                break;
             case MouseEvent.BUTTON2:
                 setCursor(defCursor);
                 ((JScrollPane) getParent().getParent()).setWheelScrollingEnabled(true);
@@ -158,23 +163,65 @@ public class Diagram extends JPanel implements MouseListener, MouseMotionListene
         }
 
     }
+    
+    @Override
+    public void mouseEntered(MouseEvent e) {}
 
-    public MatDefEditorlElement getEditorParent() {
+    @Override
+    public void mouseExited(MouseEvent e) {}
+    
+    @Override
+    public void mouseMoved(MouseEvent e) {}
+    
+    @Override
+    public void mouseDragged(MouseEvent e) {
+        if (SwingUtilities.isLeftMouseButton(e)) {
+        } else if (SwingUtilities.isMiddleMouseButton(e)) {
+            JViewport vport = (JViewport) getParent();
+            Point cp = e.getPoint();
+            Point vp = vport.getViewPosition();
+            vp.translate(pp.x - cp.x, pp.y - cp.y);
+            scrollRectToVisible(new Rectangle(vp, vport.getSize()));
+            //pp.setLocation(cp);
+        }
+    }
+
+    public NodeEditor getEditorParent() {
         return parent;
     }
+    
+    public void setEditorParent(NodeEditor parent) {
+        this.parent = parent;
+    }
+    
+    /**
+     * Create a unique key for this connection based on implementation specifc
+     * data (obj)
+     * @param con the connection
+     * @param obj implementation specific data
+     * @return the key
+     */
+    public abstract String makeKeyForConnection(Connection con, Object obj);
 
+    /**
+     * Add a Connection to this Diagram.
+     * Usecode: Call {@link #connect(com.jme3.gde.materialdefinition.editor.ConnectionEndpoint,
+     * com.jme3.gde.materialdefinition.editor.ConnectionEndpoint) } where
+     * possible instead.
+     * @param conn The connection to add
+     */
     public void addConnection(Connection conn) {
         connections.add(conn);
         add(conn);
-        for (OutBusPanel bus : outBuses) {
-            setComponentZOrder(bus, getComponentCount() - 1);
-        }
         repaint();
     }
 
-    protected void showEdit(NodePanel node) {
-        parent.showShaderEditor(node.getName(), node.getType(), node.filePaths);
-    }
+    /**
+     * This is called when an Editor should be shown for that Node.
+     * Called by {@link NodePanel#edit() }
+     * @param node The node in question
+     */
+    protected abstract void showEdit(NodePanel node);
 
     public void notifyMappingCreation(Connection conn) {
         parent.makeMapping(conn);
@@ -182,103 +229,22 @@ public class Diagram extends JPanel implements MouseListener, MouseMotionListene
 
     public void addNode(NodePanel node) {
         add(node);
-        node.setTechName(currentTechniqueName);
         node.setDiagram(this);
         nodes.add(node);
         setComponentZOrder(node, 0);
         node.addComponentListener(this);
     }
 
-    public void addOutBus(OutBusPanel bus) {
-        outBuses.add(bus);
-        bus.setDiagram(this);
-        add(bus);
-        setComponentZOrder(bus, getComponentCount() - 1);
-        addComponentListener(bus);
-        bus.componentResized(new ComponentEvent(this, ActionEvent.ACTION_PERFORMED));
-        bus.revalidate();
-    }
-
-    @Override
-    public void mouseEntered(MouseEvent e) {
-    }
-
-    @Override
-    public void mouseExited(MouseEvent e) {
-    }
-
     protected void removeSelectedConnection(Selectable selectedItem) {        
         Connection selectedConnection = (Connection) selectedItem;
         removeConnection(selectedConnection);
         parent.notifyRemoveConnection(selectedConnection);
     }
-
-    private String fixNodeName(String name) {
-        return fixNodeName(name, 0);
-    }
-
-    private String fixNodeName(String name, int count) {
-        for (NodePanel nodePanel : nodes) {
-            if ((name + (count == 0 ? "" : count)).equals(nodePanel.getName())) {
-                return fixNodeName(name, count + 1);
-            }
-        }
-        return name + (count == 0 ? "" : count);
-    }
-
-    public void addNodesFromDefs(List<ShaderNodeDefinition> defList, String path, Point clickPosition) {
-        int i = 0;
-        for (ShaderNodeDefinition def : defList) {
-            ShaderNodeBlock sn = new ShaderNodeBlock(def, path);
-            sn.setName(fixNodeName(sn.getName()));
-
-            NodePanel np = new NodePanel(sn, def);
-            addNode(np);
-            np.setLocation(clickPosition.x + i * 150, clickPosition.y);
-            sn.setSpatialOrder(np.getLocation().x);
-            i++;
-            np.revalidate();
-            getEditorParent().notifyAddNode(sn, def);
-        }
-        repaint();
-    }
-
-    public void addMatParam(String type, String name, Point point) {
-        String fixedType = type;
-        if (type.equals("Color")) {
-            fixedType = "Vector4";
-        }
-        ShaderNodeVariable param = new ShaderNodeVariable(VarType.valueOf(fixedType).getGlslType(), name);
-        NodePanel np = new NodePanel(param, NodePanel.NodeType.MatParam);
-        addNode(np);
-        np.setLocation(point.x, point.y);
-        np.revalidate();
-        repaint();
-        getEditorParent().notifyAddMapParam(type, name);
-    }
-
-    public void addWorldParam(UniformBinding binding, Point point) {
-
-        ShaderNodeVariable param = new ShaderNodeVariable(binding.getGlslType(), binding.name());
-        NodePanel np = new NodePanel(param, NodePanel.NodeType.WorldParam);
-        addNode(np);
-        np.setLocation(point.x, point.y);
-        np.revalidate();
-        repaint();
-        getEditorParent().notifyAddWorldParam(binding.name());
-    }
-
-    public void addAttribute(String name, String type, Point point) {
-        ShaderNodeVariable param = new ShaderNodeVariable(type, "Attr", name);
-        NodePanel np = new NodePanel(param, NodePanel.NodeType.Attribute);
-        addNode(np);
-        np.setLocation(point.x, point.y);
-        np.revalidate();
-        repaint();
-    }
     
-    protected void removeSelected(){
-        
+    /**
+     * Called when user pressed delete after having selected something
+     */
+    protected void removeSelected() {
         int result = JOptionPane.showConfirmDialog(null, "Delete all selected items, nodes and mappings?", "Delete Selected", JOptionPane.OK_CANCEL_OPTION);
         
         if (result == JOptionPane.OK_OPTION) {
@@ -294,8 +260,13 @@ public class Diagram extends JPanel implements MouseListener, MouseMotionListene
         }
     }
 
+    /**
+     * Called from {@link #removeSelected() } to also disconnect all the 
+     * connections made to the node in question
+     * 
+     * @param selectedItem The item to remove
+     */
     private void removeSelectedNode(Selectable selectedItem) {
-
         NodePanel selectedNode = (NodePanel) selectedItem;
         nodes.remove(selectedNode);
         for (Iterator<Connection> it = connections.iterator(); it.hasNext();) {
@@ -318,54 +289,34 @@ public class Diagram extends JPanel implements MouseListener, MouseMotionListene
         return selectedItems;
     }
 
-    @Override
-    public void mouseDragged(MouseEvent e) {
-        if (SwingUtilities.isLeftMouseButton(e)) {
-            if (draggedFrom == null) {
-                for (Selectable selectedItem : selectedItems) {
-                    if (selectedItem instanceof OutBusPanel) {
-                        OutBusPanel bus = (OutBusPanel) selectedItem;
-                        MouseEvent me = SwingUtilities.convertMouseEvent(this, e, bus);
-                        bus.dispatchEvent(me);
-                    }
-                }
-            }
-        } else if (SwingUtilities.isMiddleMouseButton(e)) {
-            JViewport vport = (JViewport) getParent();
-            Point cp = e.getPoint();
-            Point vp = vport.getViewPosition();
-            vp.translate(pp.x - cp.x, pp.y - cp.y);
-            scrollRectToVisible(new Rectangle(vp, vport.getSize()));
-            //pp.setLocation(cp);
-
-        }
-    }
-
-    protected void draggingDot(MouseEvent e) {
-        for (OutBusPanel outBusPanel : outBuses) {
-            Point p = SwingUtilities.convertPoint(this, e.getX(), e.getY(), outBusPanel);
-            if (outBusPanel.contains(p)) {
-                MouseEvent me = SwingUtilities.convertMouseEvent(this, e, outBusPanel);
-                outBusPanel.draggingDot(me);
-                if (me.isConsumed()) {
-                    return;
-                }
-            }
-        }
-    }
+    /**
+     * Called by {@link ConnectionEndpoint} when a Curve has been dragged
+     */
+    protected void draggingDot(MouseEvent e) {}
 
-    public Connection connect(Dot start, Dot end) {
+    /**
+     * Connect two Dots to form a Connection
+     * @param start The Start
+     * @param end The End
+     * @return The Connection
+     */
+    public Connection connect(ConnectionEndpoint start, ConnectionEndpoint end) {
         Connection conn = new Connection(start, end);
         start.connect(conn);
         end.connect(conn);
-
         addConnection(conn);
-
         return conn;
     }
 
+    /**
+     * Find a panel which corresponds to the given key (unique id). Use this to
+     * locate nodes on the diagram
+     * 
+     * @param key The key
+     * @return hopefully the correct node
+     */
     public NodePanel getNodePanel(String key) {
-        for (NodePanel nodePanel : nodes) {
+        for (NodePanel nodePanel: nodes) {
             if (nodePanel.getKey().equals(key)) {
                 return nodePanel;
             }
@@ -373,39 +324,38 @@ public class Diagram extends JPanel implements MouseListener, MouseMotionListene
         return null;
     }
 
-    public OutBusPanel getOutBusPanel(String key) {
-        for (OutBusPanel out : outBuses) {
-            if (out.getKey().equals(key)) {
-                return out;
-            }
-        }
-        return null;
-    }
-
     /**
-     * selection from the editor. Select the item and notify the topComponent
-     *
-     * @param selectable
+     * Selection from the editor. Select the item and notify the topComponent
+     * @param selectable the item to select
      */
     public void select(Selectable selectable, boolean multi) {
         parent.selectionChanged(doSelect(selectable, multi));
     }
     
-    public void multiMove(DraggablePanel movedPanel ,int xOffset, int yOffset){
-        
-        for (Selectable selectedItem : selectedItems) {
-            if(selectedItem != movedPanel){
-                if(selectedItem instanceof DraggablePanel){
+    /**
+     * Move one of the selected panels by a given offset
+     * @param movedPanel the panel in question
+     * @param xOffset the movement in x direction
+     * @param yOffset the movement in y direction
+     */
+    public void multiMove(DraggablePanel movedPanel, int xOffset, int yOffset) {
+        for (Selectable selectedItem: selectedItems) {
+            if (selectedItem != movedPanel) {
+                if (selectedItem instanceof DraggablePanel) {
                     ((DraggablePanel)selectedItem).movePanel(xOffset, yOffset);
                 }
             }
         }
     }
 
+    /**
+     * Prepare dragging multiple selected panels
+     * @param movedPanel The Panel which has been moved.
+     */
     public void multiStartDrag(DraggablePanel movedPanel){
-        for (Selectable selectedItem : selectedItems) {
-            if(selectedItem != movedPanel){
-                if(selectedItem instanceof DraggablePanel){
+        for (Selectable selectedItem: selectedItems) {
+            if (selectedItem != movedPanel) {
+                if (selectedItem instanceof DraggablePanel) {
                     ((DraggablePanel)selectedItem).saveLocation();
                 }
             }
@@ -413,79 +363,107 @@ public class Diagram extends JPanel implements MouseListener, MouseMotionListene
     }
     
     /**
-     * do select the item and repaint the diagram
+     * Select the specified item and repaint the window to reflect selection
+     * outlines.
      *
-     * @param selectable
-     * @return
+     * @param selectable The item which shall be selected
+     * @param multi Whether multiple selection is allowed or if this should
+     * clear previous selections
+     * @return The selected item
      */
     private Selectable doSelect(Selectable selectable, boolean multi) {
-        
-
         if (!multi && !selectedItems.contains(selectable)) {
             selectedItems.clear();
         }
-
         if (selectable != null) {
             selectedItems.add(selectable);
         }
-
         if (selectable instanceof Component) {
-            ((Component) selectable).requestFocusInWindow();
+            ((Component)selectable).requestFocusInWindow();
         }
         repaint();
-
         return selectable;
     }
 
+    /**
+     * Subclasses which add selectable items to the Diagram have to lookup 
+     * items by their key and return them here for regular dragging/selecting
+     * to work.<br>
+     * If nothing was found (or you don't add custom elements to the diagram),
+     * return null.
+     * 
+     * @param key the unique key
+     * @return The Selectable item or null
+     */
+    protected abstract Selectable trySelect(String key);
+    
     /**
      * find the item with the given key and select it without notifying the
-     * topComponent
+     * topComponent. Since this iterates over all possible panels, subclasses
+     * have to implement {@link #trySelect(java.lang.String) }
      *
-     * @param key
-     * @return
+     * @param key The unique key
+     * @return The selected item
      */
-    public Selectable select(String key) {
-
-        for (NodePanel nodePanel : nodes) {
+    protected Selectable select(String key) {
+        for (NodePanel nodePanel: nodes) {
             if (nodePanel.getKey().equals(key)) {
                 return doSelect(nodePanel, false);
             }
         }
 
-        for (Connection connection : connections) {
+        for (Connection connection: connections) {
             if (connection.getKey().equals(key)) {
                 return doSelect(connection, false);
             }
         }
-
-        for (OutBusPanel outBusPanel : outBuses) {
-            if (outBusPanel.getKey().equals(key)) {
-                return doSelect(outBusPanel, false);
-            }
+        
+        Selectable s = trySelect(key);
+        if (s != null) {
+            return doSelect(s, false);
         }
 
         return null;
     }
 
-    @Override
-    public void mouseMoved(MouseEvent e) {
-        dispatchToOutBuses(e);
+    public void clear() {
+        removeAll();
+        connections.clear();
+        nodes.clear();
     }
 
-    private JMenuItem createMenuItem(String text, Icon icon) {
+    /**
+     * Creates a horizontal separator with a black background
+     * @return the separator
+     */
+    protected JSeparator createSeparator() {
+        JSeparator jsep = new JSeparator(JSeparator.HORIZONTAL);
+        jsep.setBackground(Color.BLACK);
+        return jsep;
+    }
+    
+    /**
+     * Creates a MenuItem with the given text and icon.<br>
+     * In addition to calling the constructor this sets the font to Tahoma 10px.
+     * 
+     * @param text The text
+     * @param icon The icon
+     * @return The MenuItem with Tahoma as Font
+     */
+    protected JMenuItem createMenuItem(String text, Icon icon) {
         JMenuItem item = new JMenuItem(text, icon);
         item.setFont(new Font("Tahoma", 1, 10)); // NOI18N
         return item;
     }
 
-    public void clear() {
-        removeAll();
-        outBuses.clear();
-        connections.clear();
-        nodes.clear();
-    }
-
-    private void createPopupMenu() {
+    /**
+     * Override this method to fill the popup/context menu available via 
+     * right clicking the diagram.<br>
+     * It's important to call this (super) first. It will setup fonts and borders.<br>
+     * You can use {@link #createMenuItem(java.lang.String, javax.swing.Icon) }
+     * and {@link #createSeparator() } as helper methods.
+     */
+    protected void createPopupMenu() {
         contextMenu.setFont(new Font("Tahoma", 1, 10)); // NOI18N
         contextMenu.setOpaque(true);
         Border titleUnderline = BorderFactory.createMatteBorder(1, 0, 0, 0, Color.BLACK);
@@ -496,81 +474,6 @@ public class Diagram extends JPanel implements MouseListener, MouseMotionListene
         contextMenu.setBorder(BorderFactory.createLineBorder(Color.BLACK));
         contextMenu.setBorder(BorderFactory.createCompoundBorder(contextMenu.getBorder(),
                 labelBorder));
-
-        JMenuItem nodeItem = createMenuItem("Node", Icons.node);
-        nodeItem.addActionListener(new ActionListener() {
-            @Override
-            public void actionPerformed(ActionEvent e) {
-                AddNodeDialog d = new AddNodeDialog(null, true, parent.obj.getLookup().lookup(ProjectAssetManager.class), Diagram.this, clickLoc);
-                d.setLocationRelativeTo(null);
-                d.setVisible(true);
-            }
-        });
-
-        contextMenu.add(nodeItem);
-        contextMenu.add(createSeparator());
-        JMenuItem matParamItem = createMenuItem("Material Parameter", Icons.mat);
-        matParamItem.addActionListener(new ActionListener() {
-            @Override
-            public void actionPerformed(ActionEvent e) {
-                AddMaterialParameterDialog d = new AddMaterialParameterDialog(null, true, Diagram.this, clickLoc);
-                d.setLocationRelativeTo(null);
-                d.setVisible(true);
-            }
-        });
-        contextMenu.add(matParamItem);
-        JMenuItem worldParamItem = createMenuItem("World Parameter", Icons.world);
-        worldParamItem.addActionListener(new ActionListener() {
-            @Override
-            public void actionPerformed(ActionEvent e) {
-                AddWorldParameterDialog d = new AddWorldParameterDialog(null, true, Diagram.this, clickLoc);
-                d.setLocationRelativeTo(null);
-                d.setVisible(true);
-            }
-        });
-        contextMenu.add(worldParamItem);
-        JMenuItem attributeItem = createMenuItem("Attribute", Icons.attrib);
-        attributeItem.addActionListener(new ActionListener() {
-            @Override
-            public void actionPerformed(ActionEvent e) {
-                AddAttributeDialog d = new AddAttributeDialog(null, true, Diagram.this, clickLoc);
-                d.setLocationRelativeTo(null);
-                d.setVisible(true);
-            }
-        });
-        contextMenu.add(attributeItem);
-        contextMenu.add(createSeparator());
-        JMenuItem outputItem = createMenuItem("Output color", Icons.output);
-        contextMenu.add(outputItem);
-        outputItem.addActionListener(new ActionListener() {
-            @Override
-            public void actionPerformed(ActionEvent e) {
-                OutBusPanel p2 = new OutBusPanel("color" + (outBuses.size() - 1), Shader.ShaderType.Fragment);
-                p2.setBounds(0, 350 + 50 * (outBuses.size() - 1), p2.getWidth(), p2.getHeight());
-
-                addOutBus(p2);
-
-            }
-        });
-    }
-
-    private JSeparator createSeparator() {
-        JSeparator jsep = new JSeparator(JSeparator.HORIZONTAL);
-        jsep.setBackground(Color.BLACK);
-        return jsep;
-    }
-
-    private void dispatchToOutBuses(MouseEvent e) {
-        for (OutBusPanel outBusPanel : outBuses) {
-            Point p = SwingUtilities.convertPoint(this, e.getX(), e.getY(), outBusPanel);
-            if (outBusPanel.contains(p)) {
-                MouseEvent me = SwingUtilities.convertMouseEvent(this, e, outBusPanel);
-                outBusPanel.dispatchEvent(me);
-                if (me.isConsumed()) {
-                    return;
-                }
-            }
-        }
     }
 
     private void removeConnection(Connection selectedConnection) {
@@ -580,14 +483,34 @@ public class Diagram extends JPanel implements MouseListener, MouseMotionListene
         remove(selectedConnection);
     }
 
-    private class MyMenu extends JPopupMenu {
-
-        public MyMenu(String label) {
-            super(label);
-        }
-
-    }
-
+    /**
+     * As part of the semi-automatical layout, the maximum height of the diagram
+     * has to be calculated.<br>
+     * That means for each custom panel (no nodes), calculate the location.y
+     * and add the element's height.<br>
+     * Then find the largest value over all the custom panels.
+     * 
+     * @return The maximum height for all custom elements (or 0 if none are
+     * present).
+     */
+    protected abstract int calcMaxHeight();
+    
+    /**
+     * As part of the semi-automatical layout, the maximum width of the diagram
+     * has to be calculated.<br>
+     * That means for each custom panel (no nodes), calculate the location.x
+     * and add the element's width.<br>
+     * Then find the largest value over all the custom panels.
+     * 
+     * @return The maximum width for all custom elements (or 0 if none are
+     * present).
+     */
+    protected abstract int calcMaxWidth();
+    
+    /**
+     * This is called on multiple occassions to ensure that the size of this 
+     * diagram is just large enough.
+     */
     public void fixSize() {
         int maxWidth = minWidth;
         int maxHeight = minHeight;
@@ -602,101 +525,44 @@ public class Diagram extends JPanel implements MouseListener, MouseMotionListene
                 maxHeight = h;
             }
         }
-        for (OutBusPanel outBusPanel : outBuses) {
-            int h = outBusPanel.getLocation().y + outBusPanel.getHeight();
-            if (h > maxHeight) {
-                maxHeight = h;
-            }
+        
+        // Custom Nodes        
+        int w = calcMaxWidth();
+        int h = calcMaxHeight();
+        
+        if (w > maxWidth) {
+            maxWidth = w;
+        }
+        
+        if (h > maxHeight) {
+            maxHeight = h;
         }
+        
         setPreferredSize(new Dimension(maxWidth, maxHeight));
         revalidate();
     }
-    int minWidth = 0;
-    int minHeight = 0;
 
+    /**
+     * Use this method to layout your elements. Have a look at 
+     * {@link ShaderNodeDiagram#autoLayout() } for an example. Maybe you can
+     * come up with a better/easier solution
+     */
+    public abstract void autoLayout();
+    
+    @Override
     public void componentResized(ComponentEvent e) {
         minWidth = e.getComponent().getWidth() - 2;
         minHeight = e.getComponent().getHeight() - 2;
         fixSize();
     }
 
-    public void autoLayout() {
-
-        int offset = 550;
-        for (OutBusPanel outBus : outBuses) {
-            if (outBus.getKey().equalsIgnoreCase("position")) {
-                outBus.setLocation(0, 100);
-                
-            } else {
-                outBus.setLocation(0, offset);
-                offset += 260;
-            }
-            getEditorParent().savePositionToMetaData(outBus.getKey(), outBus.getLocation().x, outBus.getLocation().y);
-        }
-        offset = 0;
-        String keys = "";
-        for (NodePanel node : nodes) {
-
-            if (node.getType() == NodePanel.NodeType.Vertex || node.getType() == NodePanel.NodeType.Fragment) {
-                node.setLocation(offset + 200, getNodeTop(node));
-                getEditorParent().savePositionToMetaData(node.getKey(), node.getLocation().x, node.getLocation().y);
-                int pad = getNodeTop(node);
-                for (Connection connection : connections) {
-                    if (connection.getEnd().getNode() == node) {
-                        if (connection.getStart().getNode() instanceof NodePanel) {
-                            NodePanel startP = (NodePanel) connection.getStart().getNode();
-                            if (startP.getType() != NodePanel.NodeType.Vertex && startP.getType() != NodePanel.NodeType.Fragment) {
-                                startP.setLocation(offset + 30, pad);
-                                getEditorParent().savePositionToMetaData(startP.getKey(), startP.getLocation().x, startP.getLocation().y);
-                                keys += startP.getKey() + "|";
-                                pad += 50;
-                            }
-                        }
-                    }
-                }
-            }
-            offset += 320;
-        }
-        offset = 0;
-        for (NodePanel node : nodes) {
-            if (node.getType() != NodePanel.NodeType.Vertex && node.getType() != NodePanel.NodeType.Fragment && !(keys.contains(node.getKey()))) {
-                node.setLocation(offset + 10, 0);
-                getEditorParent().savePositionToMetaData(node.getKey(), node.getLocation().x, node.getLocation().y);
-                offset += 130;
-            }
-        }
-
-    }
-
-    private int getNodeTop(NodePanel node) {
-        if (node.getType() == NodePanel.NodeType.Vertex) {
-            return 150;
-        }
-        if (node.getType() == NodePanel.NodeType.Fragment) {
-            return 400;
-        }
-        return 0;
-
-    }
-
-    public void componentMoved(ComponentEvent e) {
-    }
-
-    public void componentShown(ComponentEvent e) {
-    }
-
-    public void componentHidden(ComponentEvent e) {
-    }
+    @Override
+    public void componentMoved(ComponentEvent e) {}
 
-    public void setParent(MatDefEditorlElement parent) {
-        this.parent = parent;
-    }
+    @Override
+    public void componentShown(ComponentEvent e) {}
 
-    public void setCurrentTechniqueName(String currentTechniqueName) {
-        this.currentTechniqueName = currentTechniqueName;
-    }
+    @Override
+    public void componentHidden(ComponentEvent e) {}
 
-    public String getCurrentTechniqueName() {
-        return currentTechniqueName;
-    }
 }

+ 46 - 11
jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/DraggablePanel.java

@@ -1,6 +1,33 @@
 /*
- * 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.materialdefinition.editor;
 
@@ -11,11 +38,14 @@ import javax.swing.JPanel;
 import javax.swing.SwingUtilities;
 
 /**
- *
+ * The DraggablePanel Class represents a Panel in a canvas called {@link Diagram}.
+ * This is used to represent the Nodes which contain of multiple input/outputs
+ * represented by {@link ConnectionEndpoint}s and the {@link Connection}s 
+ * connecting them.
+ * 
  * @author Nehon
  */
 public class DraggablePanel extends JPanel implements MouseListener, MouseMotionListener {
-
     protected int svdx, svdy, svdex, svdey;
     private boolean vertical = false;
     protected Diagram diagram;
@@ -31,13 +61,11 @@ public class DraggablePanel extends JPanel implements MouseListener, MouseMotion
     }
 
     @Override
-    public void mouseClicked(MouseEvent e) {
-    }
+    public void mouseClicked(MouseEvent e) {}
 
     @Override
     public void mousePressed(MouseEvent e) {
         if (e.getButton() != MouseEvent.BUTTON2) {
-            
             if (!vertical) {
                 svdex = e.getXOnScreen();
             }
@@ -53,22 +81,20 @@ public class DraggablePanel extends JPanel implements MouseListener, MouseMotion
         svdx = getLocation().x;
     }
 
+    // empty dummy overrides
     @Override
     public void mouseReleased(MouseEvent e) {
     }
-
     @Override
     public void mouseEntered(MouseEvent e) {
     }
-
     @Override
     public void mouseExited(MouseEvent e) {
     }
-
     @Override
     public void mouseMoved(MouseEvent e) {
     }
-
+    
     @Override
     public void mouseDragged(MouseEvent e) {
         if (!SwingUtilities.isMiddleMouseButton(e)) {
@@ -90,11 +116,20 @@ public class DraggablePanel extends JPanel implements MouseListener, MouseMotion
         setLocation(Math.max(0, svdx + xoffset), Math.max(0, svdy + yoffset));
     }
 
+    /** 
+     * Returns the Diagram this Panel belongs to
+     * @return Diagram
+     */
     public Diagram getDiagram() {
         return diagram;
     }
 
+    /**
+     * Sets the Diagram this Panel belongs to
+     * @param diagram Diagram
+     */
     public void setDiagram(Diagram diagram) {
         this.diagram = diagram;
     }
+
 }

+ 29 - 2
jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/InOut.java

@@ -1,6 +1,33 @@
 /*
- * 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.materialdefinition.editor;
 

+ 33 - 6
jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/MatDefEditorToolBar.java

@@ -1,7 +1,33 @@
 /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, 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.materialdefinition.editor;
 
@@ -15,13 +41,14 @@ import javax.swing.DefaultListCellRenderer;
 import javax.swing.JLabel;
 import javax.swing.JList;
 import javax.swing.JOptionPane;
+import javax.swing.JPanel;
 import javax.swing.ListCellRenderer;
 
 /**
- *
+ * This is the Toolbar where one can select a technique, click auto layout etc
  * @author Nehon
  */
-public class MatDefEditorToolBar extends javax.swing.JPanel {
+public class MatDefEditorToolBar extends JPanel {
 
     private MatDefEditorlElement parent;
     private final DefaultComboBoxModel<TechniqueBlock> comboModel = new DefaultComboBoxModel<TechniqueBlock>();
@@ -35,7 +62,7 @@ public class MatDefEditorToolBar extends javax.swing.JPanel {
         techniqueComboBox.setModel(comboModel);
         final DefaultListCellRenderer renderer = new DefaultListCellRenderer();
         techniqueComboBox.setRenderer(new ListCellRenderer<TechniqueBlock>() {
-
+            @Override
             public Component getListCellRendererComponent(JList list, TechniqueBlock value, int index, boolean isSelected, boolean cellHasFocus) {
                 JLabel c = (JLabel) renderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
                 c.setText(value.getName());

+ 1 - 1
jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/MatDefEditorlElement.form

@@ -61,7 +61,7 @@
 
           <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
           <SubComponents>
-            <Container class="com.jme3.gde.materialdefinition.editor.Diagram" name="diagram1">
+            <Container class="com.jme3.gde.materialdefinition.editor.ShaderNodeDiagram" name="diagram1">
               <Properties>
                 <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
                   <Color blue="66" green="66" red="66" type="rgb"/>

+ 58 - 40
jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/MatDefEditorlElement.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009-2010 jMonkeyEngine
+ * Copyright (c) 2009-2018 jMonkeyEngine
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -33,10 +33,10 @@ package com.jme3.gde.materialdefinition.editor;
 
 import com.jme3.asset.ShaderNodeDefinitionKey;
 import com.jme3.gde.core.assets.ProjectAssetManager;
-import com.jme3.gde.core.scene.SceneApplication;
 import com.jme3.gde.materialdefinition.EditableMatDefFile;
 import com.jme3.gde.materialdefinition.MatDefDataObject;
 import com.jme3.gde.materialdefinition.MatDefMetaData;
+import com.jme3.gde.materialdefinition.editor.ShaderNodePanel.NodeType;
 import com.jme3.gde.materialdefinition.fileStructure.MatDefBlock;
 import com.jme3.gde.materialdefinition.fileStructure.ShaderNodeBlock;
 import com.jme3.gde.materialdefinition.fileStructure.TechniqueBlock;
@@ -98,8 +98,8 @@ import org.openide.windows.TopComponent;
         preferredID = "MatDefVisual",
         position = 2000)
 @Messages("LBL_MatDef_EDITOR=Editor")
-public final class MatDefEditorlElement extends JPanel implements MultiViewElement {
-
+public final class MatDefEditorlElement extends JPanel implements 
+        MultiViewElement, NodeEditor {
     protected MatDefDataObject obj;
     private final MatDefEditorToolBar toolbar = new MatDefEditorToolBar();
     private transient MultiViewElementCallback callback;
@@ -125,9 +125,12 @@ public final class MatDefEditorlElement extends JPanel implements MultiViewEleme
     }
 
     private void initDiagram(Lookup lkp) throws NumberFormatException {
-
+        /* Note: I don't know if the following could also be done by calling
+         * {@link ShaderNodeDiagram#addNodesFromDefs()} etc
+         */
+        
         diagram1.clear();
-        diagram1.setParent(this);
+        diagram1.setEditorParent(this);
 
         Material mat = lkp.lookup(Material.class);
 
@@ -146,7 +149,7 @@ public final class MatDefEditorlElement extends JPanel implements MultiViewEleme
         int i = 0;
         for (ShaderNodeBlock sn : technique.getShaderNodes()) {
             ShaderNodeDefinition def = MaterialUtils.loadShaderNodeDefinition(sn, manager);
-            NodePanel np = new NodePanel(sn, def);
+            NodePanel np = new ShaderNodePanel(sn, def);
             diagram1.addNode(np);
             Point position = getPositionFromMetaData(np.getKey(), 150 * i + 20, 190);
             np.setLocation(position);
@@ -155,7 +158,7 @@ public final class MatDefEditorlElement extends JPanel implements MultiViewEleme
         }
         //  TechniqueDef tech = def.getDefaultTechniques().get(0);
         for (ShaderNodeVariable shaderNodeVariable : vertexGlobals) {
-            OutBusPanel out = new OutBusPanel(shaderNodeVariable.getName(), Shader.ShaderType.Vertex);
+            ShaderOutBusPanel out = new ShaderOutBusPanel(shaderNodeVariable.getName(), Shader.ShaderType.Vertex);
             diagram1.addOutBus(out);
             Point position = getPositionFromMetaData(out.getKey(), 0, 125);
             out.setLocation(position);
@@ -163,7 +166,7 @@ public final class MatDefEditorlElement extends JPanel implements MultiViewEleme
 
         i = 2;
         for (ShaderNodeVariable var : fragmentGlobals) {
-            OutBusPanel out2 = new OutBusPanel(var.getName(), Shader.ShaderType.Fragment);
+            ShaderOutBusPanel out2 = new ShaderOutBusPanel(var.getName(), Shader.ShaderType.Fragment);
             diagram1.addOutBus(out2);
             Point position = getPositionFromMetaData(out2.getKey(), 0, 150 * i + 190);
             out2.setLocation(position);
@@ -173,7 +176,7 @@ public final class MatDefEditorlElement extends JPanel implements MultiViewEleme
         for (ShaderNodeVariable shaderNodeVariable : attributes) {
             NodePanel np = diagram1.getNodePanel(shaderNodeVariable.getNameSpace() + "." + shaderNodeVariable.getName());
             if (np == null) {
-                np = new NodePanel(shaderNodeVariable, NodePanel.NodeType.Attribute);
+                np = new ShaderNodePanel(shaderNodeVariable, NodeType.Attribute);
                 diagram1.addNode(np);
                 Point position = getPositionFromMetaData(np.getKey(), 150 * i + 20, 5);
                 np.setLocation(position);
@@ -184,7 +187,7 @@ public final class MatDefEditorlElement extends JPanel implements MultiViewEleme
         for (ShaderNodeVariable shaderNodeVariable : uniforms) {
             NodePanel np = diagram1.getNodePanel(shaderNodeVariable.getNameSpace() + "." + shaderNodeVariable.getName());
             if (np == null) {
-                np = new NodePanel(shaderNodeVariable, shaderNodeVariable.getNameSpace().equals("MatParam") ? NodePanel.NodeType.MatParam : NodePanel.NodeType.WorldParam);
+                np = new ShaderNodePanel(shaderNodeVariable, shaderNodeVariable.getNameSpace().equals("MatParam") ? NodeType.MatParam : NodeType.WorldParam);
                 diagram1.addNode(np);
                 Point position = getPositionFromMetaData(np.getKey(), 150 * i + 20, 65);
                 np.setLocation(position);
@@ -229,6 +232,7 @@ public final class MatDefEditorlElement extends JPanel implements MultiViewEleme
         diagram1.refreshPreviews(mat,obj.getEditableFile().getCurrentTechnique().getName());
         final Lookup.Result<Material> resMat = obj.getLookup().lookupResult(Material.class);
         resMat.addLookupListener(new LookupListener() {
+            @Override
             public void resultChanged(LookupEvent ev) {
                 Collection<? extends Material> col = (Collection<? extends Material>) resMat.allInstances();
                 if (!col.isEmpty()) {
@@ -243,6 +247,7 @@ public final class MatDefEditorlElement extends JPanel implements MultiViewEleme
 
             Lookup.Result<Selectable> res = nav.getLookup().lookupResult(Selectable.class);
             res.addLookupListener(new LookupListener() {
+                @Override
                 public void resultChanged(LookupEvent ev) {
                     Selectable selected = nav.getLookup().lookup(Selectable.class);
                     if (selected != null && (prevNode == null || !(selected.getKey().equals(prevNode.getKey())))) {
@@ -270,7 +275,8 @@ public final class MatDefEditorlElement extends JPanel implements MultiViewEleme
         return "MatDefVisualElement";
     }
 
-    protected void selectionChanged(Selectable selectable) {
+    @Override
+    public void selectionChanged(Selectable selectable) {
         MatDefNavigatorPanel nav = obj.getLookup().lookup(MatDefNavigatorPanel.class);
         //It's possible that the navigator is null if it's collapsed in the ui.
         //In that case we early return to avoid further issues
@@ -314,7 +320,7 @@ public final class MatDefEditorlElement extends JPanel implements MultiViewEleme
         return obj.getLookup().lookup(ProjectAssetManager.class);
     }
 
-    public void showShaderEditor(String nodeName, NodePanel.NodeType type, List<String> pathList) {
+    public void showShaderEditor(String nodeName, ShaderNodePanel.NodeType type, List<String> pathList) {
 
         List<FileObject> fos = new ArrayList<FileObject>();
         Map<String, String> readOnlyFiles = new HashMap<String, String>();
@@ -385,7 +391,7 @@ public final class MatDefEditorlElement extends JPanel implements MultiViewEleme
         jSplitPane = new javax.swing.JSplitPane();
         shaderEditPanel1 = new com.jme3.gde.materialdefinition.editor.ShaderEditPanel();
         jScrollPane1 = new javax.swing.JScrollPane();
-        diagram1 = new com.jme3.gde.materialdefinition.editor.Diagram();
+        diagram1 = new com.jme3.gde.materialdefinition.editor.ShaderNodeDiagram();
 
         jSplitPane.setDividerLocation(1);
         jSplitPane.setDividerSize(6);
@@ -425,7 +431,7 @@ public final class MatDefEditorlElement extends JPanel implements MultiViewEleme
         );
     }// </editor-fold>//GEN-END:initComponents
     // Variables declaration - do not modify//GEN-BEGIN:variables
-    private com.jme3.gde.materialdefinition.editor.Diagram diagram1;
+    private com.jme3.gde.materialdefinition.editor.ShaderNodeDiagram diagram1;
     private javax.swing.JScrollPane jScrollPane1;
     private javax.swing.JSplitPane jSplitPane;
     private com.jme3.gde.materialdefinition.editor.ShaderEditPanel shaderEditPanel1;
@@ -502,7 +508,8 @@ public final class MatDefEditorlElement extends JPanel implements MultiViewEleme
         return CloseOperationState.STATE_OK;
     }
 
-    protected void makeMapping(Connection conn) {
+    @Override
+    public void makeMapping(Connection conn) {
         InOut startNode = (InOut) conn.start.getNode();
         InOut endNode = (InOut) conn.end.getNode();
         String leftVarName = conn.end.getText();
@@ -519,7 +526,7 @@ public final class MatDefEditorlElement extends JPanel implements MultiViewEleme
             leftVarSwizzle = swizzle.substring(0, startCard);
         }
 
-        if (endNode instanceof OutBusPanel) {
+        if (endNode instanceof ShaderOutBusPanel) {
             OutputMappingBlock mapping = new OutputMappingBlock(leftVarName, rightVarName, leftVarSwizzle, rightVarSwizzle, endNode.getName(), startNode.getName(), null);
             startNode.addOutputMapping(mapping);
             conn.makeKey(mapping, diagram1.getCurrentTechniqueName());
@@ -530,10 +537,11 @@ public final class MatDefEditorlElement extends JPanel implements MultiViewEleme
         }
     }
 
-    protected void notifyRemoveConnection(Connection conn) {
+    @Override
+    public void notifyRemoveConnection(Connection conn) {
         InOut startNode = (InOut) conn.start.getNode();
         InOut endNode = (InOut) conn.end.getNode();
-        if (endNode instanceof OutBusPanel) {
+        if (endNode instanceof ShaderOutBusPanel) {
             startNode.removeOutputMapping((OutputMappingBlock) conn.mapping);
         } else {
             endNode.removeInputMapping((InputMappingBlock) conn.mapping);
@@ -550,7 +558,6 @@ public final class MatDefEditorlElement extends JPanel implements MultiViewEleme
     }
 
     public void notifyAddTechnique(TechniqueBlock tech) {
-       
         String path = "Common/MatDefs/ShaderNodes/Common/Unshaded.j3sn";
         ShaderNodeDefinitionKey key =  new ShaderNodeDefinitionKey(path);
         List<ShaderNodeDefinition> defs = getAssetManager().loadAsset(key);
@@ -592,25 +599,36 @@ public final class MatDefEditorlElement extends JPanel implements MultiViewEleme
         getTechnique().addWorldParam(param);
     }
 
+    @Override
     public void notifyRemoveNode(NodePanel node) {
         MatDefBlock matDef = obj.getLookup().lookup(MatDefBlock.class);
-        if (node.getType() == NodePanel.NodeType.Fragment || node.getType() == NodePanel.NodeType.Vertex) {
-            TechniqueBlock technique = getTechnique();
-            for (ShaderNodeBlock shaderNodeBlock : technique.getShaderNodes()) {
-                if (shaderNodeBlock.getName().equals(node.getName())) {
-                    technique.removeShaderNode(shaderNodeBlock);
-                }
+        if (node instanceof ShaderNodePanel && 
+                ((ShaderNodePanel)node).getType() != null) {
+            switch (((ShaderNodePanel)node).getType()) {
+                case Fragment:
+                case Vertex:
+                    TechniqueBlock technique = getTechnique();
+                    for (ShaderNodeBlock shaderNodeBlock : technique.getShaderNodes()) {
+                        if (shaderNodeBlock.getName().equals(node.getName())) {
+                            technique.removeShaderNode(shaderNodeBlock);
+                        }
+                    }   break;
+                case MatParam:
+                    matDef.removeMatParam(new MatParamBlock("", node.getKey().replaceAll("MatParam.", ""), "", ""));
+                    break;
+                case WorldParam:
+                    getTechnique().removeWorldParam(new WorldParamBlock(node.getKey().replaceAll("WorldParam.", "")));
+                    break;
+                case Attribute:
+                    getTechnique().cleanupMappings("Attr", node.getKey().replaceAll("Attr.", ""));
+                    break;
+                default:
+                    break;
             }
-        } else if (node.getType() == NodePanel.NodeType.MatParam) {
-            matDef.removeMatParam(new MatParamBlock("", node.getKey().replaceAll("MatParam.", ""), "", ""));
-        } else if (node.getType() == NodePanel.NodeType.WorldParam) {
-            getTechnique().removeWorldParam(new WorldParamBlock(node.getKey().replaceAll("WorldParam.", "")));
-        } else if (node.getType() == NodePanel.NodeType.Attribute) {
-            getTechnique().cleanupMappings("Attr", node.getKey().replaceAll("Attr.", ""));
         }
     }
 
-    private Dot findConnectPoint(String nameSpace, String name, boolean isInput) {
+    private ConnectionEndpoint findConnectPoint(String nameSpace, String name, boolean isInput) {
 
         if (nameSpace.equals("MatParam")
                 || nameSpace.equals("WorldParam")
@@ -618,7 +636,7 @@ public final class MatDefEditorlElement extends JPanel implements MultiViewEleme
             NodePanel np = diagram1.getNodePanel(nameSpace + "." + name);
             return isInput ? np.getInputConnectPoint(name) : np.getOutputConnectPoint(name);
         } else if (nameSpace.equals("Global")) {
-            OutBusPanel outBus = diagram1.getOutBusPanel(name);
+            ShaderOutBusPanel outBus = diagram1.getOutBusPanel(name);
             return outBus.getConnectPoint();
         } else {
             NodePanel np = diagram1.getNodePanel(diagram1.getCurrentTechniqueName() + "/" + nameSpace);
@@ -627,9 +645,8 @@ public final class MatDefEditorlElement extends JPanel implements MultiViewEleme
     }
 
     private void makeConnection(MappingBlock mapping) {
-
-        Dot leftDot = findConnectPoint(mapping.getLeftNameSpace(), mapping.getLeftVar(), true);
-        Dot rightDot = findConnectPoint(mapping.getRightNameSpace(), mapping.getRightVar(), false);
+        ConnectionEndpoint leftDot = findConnectPoint(mapping.getLeftNameSpace(), mapping.getLeftVar(), true);
+        ConnectionEndpoint rightDot = findConnectPoint(mapping.getRightNameSpace(), mapping.getRightVar(), false);
         Connection conn = diagram1.connect(leftDot, rightDot);
         mapping.addPropertyChangeListener(WeakListeners.propertyChange(conn, mapping));
         conn.makeKey(mapping, diagram1.getCurrentTechniqueName());
@@ -700,7 +717,8 @@ public final class MatDefEditorlElement extends JPanel implements MultiViewEleme
         return technique;
     }
 
-    protected Point getPositionFromMetaData(String key, int defaultx, int defaulty) throws NumberFormatException {
+    @Override
+    public Point getPositionFromMetaData(String key, int defaultx, int defaulty) throws NumberFormatException {
         Point position = new Point();
         String pos = metaData.getProperty(diagram1.getCurrentTechniqueName() + "/" + key, defaultx + "," + defaulty);
 
@@ -712,8 +730,8 @@ public final class MatDefEditorlElement extends JPanel implements MultiViewEleme
         return position;
     }
 
-    protected void savePositionToMetaData(String key, int x, int y) throws NumberFormatException {
-
+    @Override
+    public void savePositionToMetaData(String key, int x, int y) throws NumberFormatException {
         metaData.setProperty(diagram1.getCurrentTechniqueName() + "/" + key, x + "," + y);
 
     }

+ 5 - 5
jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/MatPanel.form

@@ -83,7 +83,7 @@
             <Property name="borderPainted" type="boolean" value="false"/>
             <Property name="contentAreaFilled" type="boolean" value="false"/>
             <Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
-              <Color id="Curseur par d&#xe9;faut"/>
+              <Color id="Standardcursor"/>
             </Property>
             <Property name="focusable" type="boolean" value="false"/>
             <Property name="iconTextGap" type="int" value="0"/>
@@ -118,7 +118,7 @@
             <Property name="borderPainted" type="boolean" value="false"/>
             <Property name="contentAreaFilled" type="boolean" value="false"/>
             <Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
-              <Color id="Curseur par d&#xe9;faut"/>
+              <Color id="Standardcursor"/>
             </Property>
             <Property name="focusable" type="boolean" value="false"/>
             <Property name="iconTextGap" type="int" value="0"/>
@@ -153,7 +153,7 @@
             <Property name="borderPainted" type="boolean" value="false"/>
             <Property name="contentAreaFilled" type="boolean" value="false"/>
             <Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
-              <Color id="Curseur par d&#xe9;faut"/>
+              <Color id="Standardcursor"/>
             </Property>
             <Property name="focusable" type="boolean" value="false"/>
             <Property name="iconTextGap" type="int" value="0"/>
@@ -188,7 +188,7 @@
             <Property name="borderPainted" type="boolean" value="false"/>
             <Property name="contentAreaFilled" type="boolean" value="false"/>
             <Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
-              <Color id="Curseur par d&#xe9;faut"/>
+              <Color id="Standardcursor"/>
             </Property>
             <Property name="focusable" type="boolean" value="false"/>
             <Property name="iconTextGap" type="int" value="0"/>
@@ -223,7 +223,7 @@
             <Property name="borderPainted" type="boolean" value="false"/>
             <Property name="contentAreaFilled" type="boolean" value="false"/>
             <Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
-              <Color id="Curseur par d&#xe9;faut"/>
+              <Color id="Standardcursor"/>
             </Property>
             <Property name="focusable" type="boolean" value="false"/>
             <Property name="iconTextGap" type="int" value="0"/>

+ 33 - 5
jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/MatPanel.java

@@ -1,6 +1,33 @@
 /*
- * 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.materialdefinition.editor;
 
@@ -13,15 +40,16 @@ import java.awt.event.ComponentEvent;
 import java.awt.event.ComponentListener;
 import java.awt.event.MouseEvent;
 import java.awt.event.MouseListener;
+import javax.swing.JPanel;
 import javax.swing.SwingUtilities;
 import javax.swing.Timer;
 
 /**
- *
+ * The Mat Panel displays the current state of the Material and has a toolbar
+ * to change properties.
  * @author Nehon
  */
-public class MatPanel extends javax.swing.JPanel implements MouseListener, ComponentListener {
-    
+public class MatPanel extends JPanel implements MouseListener, ComponentListener {
     private final MaterialPreviewRenderer renderer;
     private Material mat;
     /**

+ 160 - 247
jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/NodePanel.java

@@ -1,6 +1,33 @@
 /*
- * 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.materialdefinition.editor;
 
@@ -9,9 +36,7 @@ import com.jme3.gde.materialdefinition.fileStructure.leaves.DefinitionBlock;
 import com.jme3.gde.materialdefinition.fileStructure.leaves.InputMappingBlock;
 import com.jme3.gde.materialdefinition.fileStructure.leaves.OutputMappingBlock;
 import com.jme3.gde.materialdefinition.icons.Icons;
-import com.jme3.shader.Shader;
 import com.jme3.shader.ShaderNodeDefinition;
-import com.jme3.shader.ShaderNodeVariable;
 import java.awt.Color;
 import java.awt.Font;
 import java.awt.GradientPaint;
@@ -23,136 +48,56 @@ import java.awt.event.KeyEvent;
 import java.awt.event.KeyListener;
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
 import java.util.ArrayList;
 import java.util.List;
 import javax.swing.GroupLayout;
-import javax.swing.ImageIcon;
 import javax.swing.JLabel;
 import javax.swing.JPanel;
 import javax.swing.LayoutStyle;
 import javax.swing.SwingConstants;
 import javax.swing.SwingUtilities;
-import org.openide.util.WeakListeners;
 
 /**
- *
+ * The NodePanel is the actual implementation of a Node.
  * @author Nehon
  */
-public class NodePanel extends DraggablePanel implements Selectable, PropertyChangeListener, InOut, KeyListener {
-
+public abstract class NodePanel extends DraggablePanel implements Selectable, InOut, KeyListener {
     List<JLabel> inputLabels = new ArrayList<JLabel>();
     List<JLabel> outputLabels = new ArrayList<JLabel>();
-    List<Dot> inputDots = new ArrayList<Dot>();
-    List<Dot> outputDots = new ArrayList<Dot>();
-    private NodeType type = NodeType.Vertex;
+    List<ConnectionEndpoint> inputDots = new ArrayList<ConnectionEndpoint>();
+    List<ConnectionEndpoint> outputDots = new ArrayList<ConnectionEndpoint>();
     private JPanel content;
-    private JLabel header;
-    private Color color;
-    private String name;
-    private String techName;
-    private NodeToolBar toolBar;
-    protected List<String> filePaths = new ArrayList<String>();
-    protected Shader.ShaderType shaderType;
-
-    public enum NodeType {
-
-        Vertex(new Color(220, 220, 70)),//yellow
-        Fragment(new Color(114, 200, 255)),//bleue
-        Attribute(Color.WHITE),
-        MatParam(new Color(70, 220, 70)),//green
-        WorldParam(new Color(220, 70, 70)); //red
-        private Color color;
-
-        private NodeType() {
-        }
-
-        private NodeType(Color color) {
-            this.color = color;
-        }
-
-        public Color getColor() {
-            return color;
-        }
-    }
+    protected JLabel header;
+    protected Color color;
+    protected String name;
+    protected NodeToolBar toolBar = null;
 
     /**
      * Creates new form NodePanel
      */
     @SuppressWarnings("LeakingThisInConstructor")
-    public NodePanel(ShaderNodeBlock node, ShaderNodeDefinition def) {
+    public NodePanel() {
         super();
-        shaderType = def.getType();
-        if (def.getType() == Shader.ShaderType.Vertex) {
-            type = NodePanel.NodeType.Vertex;
-        } else {
-            type = NodePanel.NodeType.Fragment;
-        }
-        init(def.getInputs(), def.getOutputs());
-
-        node.addPropertyChangeListener(WeakListeners.propertyChange(this, node));
-        this.addPropertyChangeListener(WeakListeners.propertyChange(node, this));
-        refresh(node);
         addKeyListener(this);
-        this.filePaths.addAll(def.getShadersPath());
-        String defPath = ((DefinitionBlock) node.getContents().get(0)).getPath();
-        this.filePaths.add(defPath);
-        toolBar = new NodeToolBar(this);        
+    }
+    
+    /*
+     * Sets the Toolbar associated with this node (as it was impossible to do
+     * in the constructor). Don't construct a toolbar before this class' AWT
+     * parts have been initialized.
+    */
+    public void setToolbar(NodeToolBar toolBar) {
+        this.toolBar = toolBar;
     }
 
     /**
-     * Creates new form NodePanel
+     * Set this node's name, title and tooltipText
+     * Note: This name is different from AWTs setName()
+     * @param s The Name
      */
-    @SuppressWarnings("LeakingThisInConstructor")
-    public NodePanel(ShaderNodeVariable singleOut, NodePanel.NodeType type) {
-        super();
-        List<ShaderNodeVariable> outputs = new ArrayList<ShaderNodeVariable>();
-        outputs.add(singleOut);
-        this.type = type;
-        init(new ArrayList<ShaderNodeVariable>(), outputs);
-        addKeyListener(this);
-        toolBar = new NodeToolBar(this);
-    }
-
-    public final void refresh(ShaderNodeBlock node) {
-        name = node.getName();
-        header.setText(node.getName());
-        header.setToolTipText(node.getName());
-
-    }
-
-    public void propertyChange(PropertyChangeEvent evt) {
-        if (evt.getPropertyName().equals("name")) {
-            refresh((ShaderNodeBlock) evt.getSource());
-        }
-    }
-
-    private void init(List<ShaderNodeVariable> inputs, List<ShaderNodeVariable> outputs) {
-
-        setBounds(0, 0, 120, 30 + inputs.size() * 20 + outputs.size() * 20);
-
-        for (ShaderNodeVariable input : inputs) {
-
-            JLabel label = createLabel(input.getType(), input.getName(), Dot.ParamType.Input);
-            Dot dot = createDot(input.getType(), Dot.ParamType.Input, input.getName());
-            inputLabels.add(label);
-            inputDots.add(dot);
-        }
-        int index = 0;
-        for (ShaderNodeVariable output : outputs) {
-            String outName = output.getName();
-            JLabel label = createLabel(output.getType(), outName, Dot.ParamType.Output);
-            Dot dot = createDot(output.getType(), Dot.ParamType.Output, outName);
-            dot.setIndex(index++);
-            outputLabels.add(label);
-            outputDots.add(dot);
-        }
-
-        initComponents();
-        updateType();
-        setOpaque(false);
-
+    public void setNameAndTitle(String s) {
+        name = s;
+        setTitle(name);
     }
 
     public void setTitle(String s) {
@@ -160,21 +105,21 @@ public class NodePanel extends DraggablePanel implements Selectable, PropertyCha
         header.setToolTipText(s);
     }
 
-    public Dot getInputConnectPoint(String varName) {
-        return getConnectPoint(inputLabels, varName, inputDots);
+    public ConnectionEndpoint getInputConnectPoint(String name) {
+        return getConnectPoint(inputLabels, name, inputDots);
     }
 
-    public Dot getOutputConnectPoint(String varName) {
-        return getConnectPoint(outputLabels, varName, outputDots);
+    public ConnectionEndpoint getOutputConnectPoint(String name) {
+        return getConnectPoint(outputLabels, name, outputDots);
     }
 
-    private Dot getConnectPoint(List<JLabel> list, String varName, List<Dot> listDot) {
+    private ConnectionEndpoint getConnectPoint(List<JLabel> list, String varName, List<ConnectionEndpoint> listDot) {
         //This has been commented out because it was causing issues when a variable name was explicitely starting with m_ or g_ in the j3md.
         //I can't remember why it was done in the first place, but I can't see any case where the m_ should be stripped out.
         //I'm letting this commented in case this comes to light some day, and something more clever will have to be done.
-//        if (varName.startsWith("m_") || varName.startsWith("g_")) {
-//            varName = varName.substring(2);
-//        }
+        //if (varName.startsWith("m_") || varName.startsWith("g_")) {
+        //   varName = varName.substring(2);
+        //}
         for (int i = 0; i < list.size(); i++) {
             if (list.get(i).getText().equals(varName)) {
                 return listDot.get(i);
@@ -183,62 +128,25 @@ public class NodePanel extends DraggablePanel implements Selectable, PropertyCha
         return null;
     }
 
-    @Override
-    protected void paintComponent(Graphics g1) {
-        Graphics2D g = (Graphics2D) g1;
-        Color boderColor = Color.BLACK;
-        if (getDiagram().getSelectedItems().contains(this)) {
-            boderColor = Color.WHITE;
-        }
-        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, // Anti-alias!
-                RenderingHints.VALUE_ANTIALIAS_ON);
-        // Color[] colors = {new Color(0, 0, 0, 0.7f), new Color(0, 0, 0, 0.15f)};
-        if (getDiagram().getSelectedItems().contains(this)) {
-            Color[] colors = new Color[]{new Color(0.6f, 0.6f, 1.0f, 0.8f), new Color(0.6f, 0.6f, 1.0f, 0.5f)};
-            float[] factors = {0f, 1f};
-            g.setPaint(new RadialGradientPaint(getWidth() / 2, getHeight() / 2, getWidth() / 2, factors, colors));
-            g.fillRoundRect(8, 3, getWidth() - 10, getHeight() - 6, 15, 15);
-        }else{
-            if(toolBar.isVisible()){
-                toolBar.setVisible(false);
-            }
-        }
-
-        g.setColor(new Color(170, 170, 170, 120));
-        g.fillRoundRect(5, 1, getWidth() - 9, getHeight() - 6, 15, 15);
-        g.setColor(boderColor);
-
-        g.drawRoundRect(4, 0, getWidth() - 9, getHeight() - 6, 15, 15);
-        g.setColor(new Color(170, 170, 170, 120));
-        g.fillRect(4, 1, 10, 10);
-        g.setColor(boderColor);
-        g.drawLine(4, 0, 14, 0);
-        g.drawLine(4, 0, 4, 10);
-        g.setColor(Color.BLACK);
-        g.drawLine(5, 15, getWidth() - 6, 15);
-        g.setColor(new Color(190, 190, 190));
-        g.drawLine(5, 16, getWidth() - 6, 16);
-
-        Color c1 = new Color(color.getRed(), color.getGreen(), color.getBlue(), 150);
-        Color c2 = new Color(color.getRed(), color.getGreen(), color.getBlue(), 0);
-        g.setPaint(new GradientPaint(0, 15, c1, getWidth(), 15, c2));
-        g.fillRect(5, 1, getWidth() - 10, 14);
-
-    }
-
-    public String getKey() {
-        switch (type) {
-            case Attribute:
-                return "Attr." + outputLabels.get(0).getText();
-            case WorldParam:
-                return "WorldParam." + outputLabels.get(0).getText();
-            case MatParam:
-                return "MatParam." + outputLabels.get(0).getText();
-            default:
-                return techName + "/" + name;
-        }
+    /**
+     * Create a Label used for TODO.
+     * @param txt The text on the label
+     * @param type The ParameterType (Input, Output, Both)
+     * @return 
+     */
+    protected JLabel createLabel(String txt, ConnectionEndpoint.ParamType type) {
+        JLabel label = new JLabel(txt);
+        label.setForeground(Color.BLACK);
+        label.setOpaque(false);
+        //label.setPreferredSize(new Dimension(50, 15));        
+        label.setHorizontalAlignment(type == ConnectionEndpoint.ParamType.Output ? SwingConstants.RIGHT : SwingConstants.LEFT);
+        label.setFont(new Font("Tahoma", 0, 10));
+        label.addMouseListener(labelMouseMotionListener);
+        label.addMouseMotionListener(labelMouseMotionListener);
+        // label.setBorder(BorderFactory.createLineBorder(Color.BLACK));
+        return label;
     }
-
+    
     @Override
     public String getName() {
         return name;
@@ -252,11 +160,9 @@ public class NodePanel extends DraggablePanel implements Selectable, PropertyCha
     }
     
     private void showToolBar(){
-        toolBar.display();
-    }
-
-    public NodeType getType() {
-        return type;
+        if (toolBar != null) {
+            toolBar.display();
+        }
     }
 
     @Override
@@ -268,45 +174,29 @@ public class NodePanel extends DraggablePanel implements Selectable, PropertyCha
         }
     }
 
-    public final void updateType() {
-
-        switch (type) {
-            case Vertex:
-                header.setIcon(Icons.vert);
-                break;
-            case Fragment:
-                header.setIcon(Icons.frag);
-                break;
-            case Attribute:
-                header.setIcon(Icons.attrib);
-                header.setText("Attribute");
-                header.setToolTipText("Attribute");
-                name = "Attr";
-                break;
-            case WorldParam:
-                header.setIcon(Icons.world);
-                header.setText("WorldParam");
-                header.setToolTipText("WorldParam");
-                name = "WorldParam";
-                break;
-            case MatParam:
-                header.setIcon(Icons.mat);
-                header.setText("MatParam");
-                header.setToolTipText("MatParam");
-                name = "MatParam";
-                break;
-        }
-        color = type.getColor();
-    }
-
+    /**
+     * Try to open an edit dialog for this node (if supported)
+     */
     public void edit() {
-        if (type == NodeType.Fragment || type == NodeType.Vertex) {
-            diagram.showEdit(NodePanel.this);
+        if (canEdit()) {
+            diagram.showEdit(this);
         }
     }
     
+    /**
+     * Whether this node shall trigger an edit dialog in the diagram
+     * @see Diagram#showEdit(com.jme3.gde.materialdefinition.editor.NodePanel) 
+     * @return Whether this Node can be edited
+     */
+    protected abstract boolean canEdit();
+    
+    @Override
+    public abstract String getKey(); // satisfy Selectable interface
+    
     public void cleanup(){
-        toolBar.getParent().remove(toolBar);
+        if (toolBar != null) {
+            toolBar.getParent().remove(toolBar);
+        }
     }
 
     /**
@@ -316,13 +206,8 @@ public class NodePanel extends DraggablePanel implements Selectable, PropertyCha
      */
     @SuppressWarnings("unchecked")
     // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
-    private void initComponents() {
-
-        ImageIcon icon = Icons.vert;
-        if (type == NodeType.Fragment) {
-            icon = Icons.frag;
-        }
-        header = new JLabel(icon);
+    protected void initComponents() {
+        header = new JLabel(Icons.vert);
         header.setForeground(Color.BLACK);
         header.addMouseListener(labelMouseMotionListener);
         header.addMouseMotionListener(labelMouseMotionListener);
@@ -390,54 +275,81 @@ public class NodePanel extends DraggablePanel implements Selectable, PropertyCha
                         .addComponent(content, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                 .addGap(10, 10, 10));
     }
+    
+    @Override
+    protected void paintComponent(Graphics g1) {
+        Graphics2D g = (Graphics2D) g1;
+        Color borderColor = Color.BLACK;
+        if (getDiagram().getSelectedItems().contains(this)) {
+            borderColor = Color.WHITE;
+        }
+        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, // Anti-alias!
+                RenderingHints.VALUE_ANTIALIAS_ON);
+        // Color[] colors = {new Color(0, 0, 0, 0.7f), new Color(0, 0, 0, 0.15f)};
+        if (getDiagram().getSelectedItems().contains(this)) {
+            Color[] colors = new Color[]{ new Color(0.6f, 0.6f, 1.0f, 0.8f),
+                new Color(0.6f, 0.6f, 1.0f, 0.5f) };
+            
+            float[] factors = {0f, 1f};
+            g.setPaint(new RadialGradientPaint(getWidth() / 2,
+                    getHeight() / 2, getWidth() / 2, factors, colors));
+            
+            g.fillRoundRect(8, 3, getWidth() - 10, getHeight() - 6, 15, 15);
+        } else if (toolBar != null) {
+            // Hide the toolBar when we've been unselected
+            if(toolBar.isVisible()){
+                toolBar.setVisible(false);
+            }
+        }
 
-    public JLabel createLabel(String glslType, String txt, Dot.ParamType type) {
-        JLabel label = new JLabel(txt);
-        label.setForeground(Color.BLACK);
-        label.setToolTipText(glslType + " " + txt);
-        label.setOpaque(false);
-        //label.setPreferredSize(new Dimension(50, 15));        
-        label.setHorizontalAlignment(type == Dot.ParamType.Output ? SwingConstants.RIGHT : SwingConstants.LEFT);
-        label.setFont(new Font("Tahoma", 0, 10));
-        label.addMouseListener(labelMouseMotionListener);
-        label.addMouseMotionListener(labelMouseMotionListener);
-        // label.setBorder(BorderFactory.createLineBorder(Color.BLACK));
-        return label;
-    }
+        g.setColor(new Color(170, 170, 170, 120));
+        g.fillRoundRect(5, 1, getWidth() - 9, getHeight() - 6, 15, 15);
+        g.setColor(borderColor);
+
+        g.drawRoundRect(4, 0, getWidth() - 9, getHeight() - 6, 15, 15);
+        g.setColor(new Color(170, 170, 170, 120));
+        g.fillRect(4, 1, 10, 10);
+        g.setColor(borderColor);
+        g.drawLine(4, 0, 14, 0);
+        g.drawLine(4, 0, 4, 10);
+        g.setColor(Color.BLACK);
+        g.drawLine(5, 15, getWidth() - 6, 15);
+        g.setColor(new Color(190, 190, 190));
+        g.drawLine(5, 16, getWidth() - 6, 16);
+
+        Color c1 = new Color(color.getRed(), color.getGreen(), color.getBlue(), 150);
+        Color c2 = new Color(color.getRed(), color.getGreen(), color.getBlue(), 0);
+        g.setPaint(new GradientPaint(0, 15, c1, getWidth(), 15, c2));
+        g.fillRect(5, 1, getWidth() - 10, 14);
 
-    public Dot createDot(String type, Dot.ParamType paramType, String paramName) {
-        Dot dot1 = new Dot();
-        dot1.setShaderType(shaderType);
-        dot1.setNode(this);
-        dot1.setText(paramName);
-        dot1.setParamType(paramType);
-        dot1.setType(type);
-        return dot1;
     }
 
+    public abstract ConnectionEndpoint createConnectionEndpoint(String type, 
+            ConnectionEndpoint.ParamType paramType, String paramName);
+
+    @Override
     public void keyTyped(KeyEvent e) {
     }
 
     @Override
     public void keyPressed(KeyEvent e) {
-
         if (e.getKeyCode() == KeyEvent.VK_DELETE) {
             delete();
         }
     }
 
     public void delete() {
-        Diagram diag = getDiagram();
-        diag.removeSelected();
+        getDiagram().removeSelected();
     }
 
+    @Override
     public void keyReleased(KeyEvent e) {
     }
-    // used to pass press and drag events to the NodePanel when they occur on the label
+    
+// used to pass press and drag events to the NodePanel when they occur on the label
     private LabelMouseMotionListener labelMouseMotionListener = new LabelMouseMotionListener();
 
     private class LabelMouseMotionListener extends MouseAdapter {
-
         @Override
         public void mousePressed(MouseEvent e) {
             MouseEvent me = SwingUtilities.convertMouseEvent(e.getComponent(), e, NodePanel.this);
@@ -457,22 +369,23 @@ public class NodePanel extends DraggablePanel implements Selectable, PropertyCha
         }
     }
 
-    public void setTechName(String techName) {
-        this.techName = techName;
-    }
-
+    //@TODO: Solve the mistery about these methods
+    @Override
     public void addInputMapping(InputMappingBlock block) {
         firePropertyChange(ShaderNodeBlock.INPUT, null, block);
     }
 
+    @Override
     public void removeInputMapping(InputMappingBlock block) {
         firePropertyChange(ShaderNodeBlock.INPUT, block, null);
     }
 
+    @Override
     public void addOutputMapping(OutputMappingBlock block) {
         firePropertyChange(ShaderNodeBlock.OUTPUT, null, block);
     }
 
+    @Override
     public void removeOutputMapping(OutputMappingBlock block) {
         firePropertyChange(ShaderNodeBlock.OUTPUT, block, null);
     }

+ 65 - 93
jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/NodeToolBar.java

@@ -1,7 +1,33 @@
 /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, 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.materialdefinition.editor;
 
@@ -9,101 +35,42 @@ import java.awt.event.ComponentEvent;
 import java.awt.event.ComponentListener;
 import java.awt.event.MouseEvent;
 import java.awt.event.MouseListener;
+import javax.swing.JPanel;
 
 /**
- *
- * @author Nehon
+ * This class displays a small bar where an edit and remove icon is typically
+ * placed
+ * @author MeFisto94
  */
-public class NodeToolBar extends javax.swing.JPanel implements ComponentListener, MouseListener {
+public abstract class NodeToolBar extends JPanel implements ComponentListener, 
+        MouseListener {
 
+    // The node to which we're added to
     private final NodePanel node;
 
     /**
-     * Creates new form NodeToolBar
+     * Creates a new toolbar for the desired node
+     * @param node The node
      */
     @SuppressWarnings("LeakingThisInConstructor")
     public NodeToolBar(NodePanel node) {
         initComponents();
         this.node = node;
-        if (node.getType() != NodePanel.NodeType.Fragment && node.getType() != NodePanel.NodeType.Vertex) {
-            remove(codeButton);
-        }
         node.addComponentListener(this);
     }
 
     /**
-     * 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.
+     * Implement this method (preferably using a form editor) to
+     * generate the AWT Code for your toolbar
      */
-    @SuppressWarnings("unchecked")
-    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
-    private void initComponents() {
-
-        codeButton = new javax.swing.JButton();
-        deleteButton = new javax.swing.JButton();
-
-        setOpaque(false);
-        java.awt.GridBagLayout layout = new java.awt.GridBagLayout();
-        layout.rowHeights = new int[] {16};
-        setLayout(layout);
-
-        codeButton.setBackground(new java.awt.Color(255, 255, 255));
-        codeButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jme3/gde/materialdefinition/icons/code.png"))); // NOI18N
-        codeButton.setToolTipText(org.openide.util.NbBundle.getMessage(NodeToolBar.class, "NodeToolBar.codeButton.toolTipText")); // NOI18N
-        codeButton.setBorder(null);
-        codeButton.setBorderPainted(false);
-        codeButton.setContentAreaFilled(false);
-        codeButton.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
-        codeButton.setFocusable(false);
-        codeButton.setIconTextGap(0);
-        codeButton.setMaximumSize(new java.awt.Dimension(24, 24));
-        codeButton.setMinimumSize(new java.awt.Dimension(24, 24));
-        codeButton.setPreferredSize(new java.awt.Dimension(16, 16));
-        codeButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jme3/gde/materialdefinition/icons/codeHover.png"))); // NOI18N
-        codeButton.addActionListener(new java.awt.event.ActionListener() {
-            public void actionPerformed(java.awt.event.ActionEvent evt) {
-                codeButtonActionPerformed(evt);
-            }
-        });
-        add(codeButton, new java.awt.GridBagConstraints());
-
-        deleteButton.setBackground(new java.awt.Color(255, 255, 255));
-        deleteButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jme3/gde/materialdefinition/icons/deleteNode.png"))); // NOI18N
-        org.openide.awt.Mnemonics.setLocalizedText(deleteButton, org.openide.util.NbBundle.getMessage(NodeToolBar.class, "NodeToolBar.deleteButton.text")); // NOI18N
-        deleteButton.setToolTipText(org.openide.util.NbBundle.getMessage(NodeToolBar.class, "NodeToolBar.deleteButton.toolTipText")); // NOI18N
-        deleteButton.setBorder(null);
-        deleteButton.setBorderPainted(false);
-        deleteButton.setContentAreaFilled(false);
-        deleteButton.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
-        deleteButton.setFocusable(false);
-        deleteButton.setIconTextGap(0);
-        deleteButton.setMaximumSize(new java.awt.Dimension(24, 24));
-        deleteButton.setMinimumSize(new java.awt.Dimension(24, 24));
-        deleteButton.setPreferredSize(new java.awt.Dimension(16, 16));
-        deleteButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jme3/gde/materialdefinition/icons/deleteNodeHover.png"))); // NOI18N
-        deleteButton.addActionListener(new java.awt.event.ActionListener() {
-            public void actionPerformed(java.awt.event.ActionEvent evt) {
-                deleteButtonActionPerformed(evt);
-            }
-        });
-        add(deleteButton, new java.awt.GridBagConstraints());
-    }// </editor-fold>//GEN-END:initComponents
-
-    private void codeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_codeButtonActionPerformed
-        node.edit();
-    }//GEN-LAST:event_codeButtonActionPerformed
-
-    private void deleteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteButtonActionPerformed
-        node.delete();
-    }//GEN-LAST:event_deleteButtonActionPerformed
-
-
-    // Variables declaration - do not modify//GEN-BEGIN:variables
-    private javax.swing.JButton codeButton;
-    private javax.swing.JButton deleteButton;
-    // End of variables declaration//GEN-END:variables
+    protected abstract void initComponents();
 
+    /**
+     * Called by the NodePanel when the user hovers over this node or selects
+     * it or something<br>.
+     * Hint: There is no "remove" call, that happens automatically. Display
+     * is only required to set the Bounds and Visibility
+     */
     public void display() {
         if (getParent() == null) {
             node.getParent().add(this);
@@ -111,40 +78,45 @@ public class NodeToolBar extends javax.swing.JPanel implements ComponentListener
         setBounds(node.getLocation().x + 5, node.getLocation().y - 18, node.getWidth() - 10, 16);
         node.getParent().setComponentZOrder(this, 0);
         setVisible(true);
-
     }
 
-    public void componentResized(ComponentEvent e) {
-    }
+    @Override
+    public void componentResized(ComponentEvent e) {}
 
+    /**
+     * When parent node moves, also move (this should be done by a layout manager
+     * though....
+     */
+    @Override
     public void componentMoved(ComponentEvent e) {
         setLocation(node.getLocation().x + 5, node.getLocation().y - 18);
     }
 
-    public void componentShown(ComponentEvent e) {
-    }
+    @Override
+    public void componentShown(ComponentEvent e) {}
 
-    public void componentHidden(ComponentEvent e) {
-    }
+    @Override
+    public void componentHidden(ComponentEvent e) {}
 
+    @Override
     public void mouseClicked(MouseEvent e) {
         e.consume();
     }
 
+    @Override
     public void mousePressed(MouseEvent e) {
         e.consume();
     }
 
+    @Override
     public void mouseReleased(MouseEvent e) {
         e.consume();
     }
 
-    public void mouseEntered(MouseEvent e) {
-
-    }
-
-    public void mouseExited(MouseEvent e) {
+    @Override
+    public void mouseEntered(MouseEvent e) {}
 
-    }
+    @Override
+    public void mouseExited(MouseEvent e) {}
 
 }

+ 31 - 6
jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/Selectable.java

@@ -1,16 +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.materialdefinition.editor;
 
 /**
- *
+ * A marker interface for selectable items (Nodes and Connections)
  * @author Nehon
  */
 public interface Selectable {
-    
+    //@TODO: Explain and find out what for selecteable needs keys
     public String getKey();    
-   
-    
 }

+ 35 - 8
jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/ShaderEditPanel.java

@@ -1,7 +1,33 @@
 /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, 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.materialdefinition.editor;
 
@@ -16,7 +42,6 @@ import java.util.List;
 import java.util.Map;
 import javax.swing.JPanel;
 import javax.swing.JToggleButton;
-import javax.swing.text.DefaultStyledDocument;
 import javax.swing.text.EditorKit;
 import org.openide.awt.UndoRedo;
 import org.openide.cookies.EditorCookie;
@@ -50,15 +75,18 @@ public class ShaderEditPanel extends JPanel {
 
         shaderEditorPane.addKeyListener(new KeyListener() {
 
+            @Override
             public void keyTyped(KeyEvent e) {
             }
 
+            @Override
             public void keyPressed(KeyEvent e) {
                 if ((e.getKeyCode() == KeyEvent.VK_S) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
                     saveCurrent();
                 }
             }
 
+            @Override
             public void keyReleased(KeyEvent e) {
             }
         });
@@ -69,9 +97,7 @@ public class ShaderEditPanel extends JPanel {
         undoRedoManager = (UndoRedo.Manager) parent.getUndoRedo();
     }
 
-    public void setFiles(String title, NodePanel.NodeType type, List<FileObject> fos, final Map<String, String> readOnlyFiles) {
-
-        
+    public void setFiles(String title, ShaderNodePanel.NodeType type, List<FileObject> fos, final Map<String, String> readOnlyFiles) {       
         headerText.setText(title);
         headerText.setIcon(Icons.getIconForShaderType(type));
         boolean firstItem = true;
@@ -88,6 +114,7 @@ public class ShaderEditPanel extends JPanel {
             try {
                 b.dataObject = DataObject.find(fo);
                 b.addActionListener(new ActionListener() {
+                    @Override
                     public void actionPerformed(ActionEvent e) {
                         saveCurrent();
                         try {
@@ -114,6 +141,7 @@ public class ShaderEditPanel extends JPanel {
             buttonGroup1.add(b);
             final String theKey = key;
             b.addActionListener(new ActionListener() {
+                @Override
                 public void actionPerformed(ActionEvent e) {
                     switchReadOnlyDoc(readOnlyFiles.get(theKey));
                 }
@@ -174,7 +202,6 @@ public class ShaderEditPanel extends JPanel {
     }
 
     private class Tab extends JToggleButton {
-
         DataObject dataObject;
     }
 

+ 29 - 4
jme3-materialeditor/src/com/jme3/gde/materialdefinition/fileStructure/leaves/MappingBlock.java

@@ -1,6 +1,33 @@
 /*
- * 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.materialdefinition.fileStructure.leaves;
 
@@ -106,7 +133,5 @@ public abstract class MappingBlock extends LeafStatement {
         updateLine();
         fire("leftNameSpace", old, leftNameSpace);
     }
-  
-    
     
 }

+ 33 - 6
jme3-materialeditor/src/com/jme3/gde/materialdefinition/icons/Icons.java

@@ -1,14 +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.materialdefinition.icons;
 
-import com.jme3.gde.materialdefinition.editor.NodePanel;
+import com.jme3.gde.materialdefinition.editor.ShaderNodePanel;
 import javax.swing.ImageIcon;
 
 /**
- *
+ * This class is a provider of ImageIcons
  * @author Nehon
  */
 public class Icons {
@@ -30,8 +57,8 @@ public class Icons {
     public final static ImageIcon out = new ImageIcon(Icons.class.getResource("out.png"));
     public final static ImageIcon error = new ImageIcon(Icons.class.getResource("error.png"));
 
-    public static ImageIcon getIconForShaderType(NodePanel.NodeType type) {
-        if (type == NodePanel.NodeType.Fragment) {
+    public static ImageIcon getIconForShaderType(ShaderNodePanel.NodeType type) {
+        if (type == ShaderNodePanel.NodeType.Fragment) {
             return frag;
         } else {
             return vert;

+ 29 - 3
jme3-materialeditor/src/com/jme3/gde/materialdefinition/utils/MaterialUtils.java

@@ -1,6 +1,33 @@
 /*
- * 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.materialdefinition.utils;
 
@@ -24,7 +51,6 @@ import java.util.List;
 public class MaterialUtils {
     
     public static String makeKey(MappingBlock mapping, String techName) {
-        
         String rightName = mapping.getRightVar();
         String leftName = mapping.getLeftVar();
         String leftSwizzle = mapping.getLeftVarSwizzle() != null ? "." + mapping.getLeftVarSwizzle() : "";